You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thank you for taking the time to write Cassette!
The on_draw callback (and other callbacks like on_close or on_focus) of the window API takes a cgui_window argument and a delay. Is there a way to access a private pointer that could linked to the program state from within the callback?
static void on_draw(cgui_window *window, unsigned long delay) {
// TODO: find a way to access the animation state from within the callback
update_animation(animation, delay);
draw_animation(animation);
cgui_window_redraw_delayed(window, 20 /* milliseconds */);
}
One option could be to add an extra parameter to the callback (like what was done for #4). Another approach could be to store a private pointer in cgui_window (similar to what cgui_cell_set_data/cgui_cell_get_data does).
The text was updated successfully, but these errors were encountered:
I've now added cgui_window_set_data() modeled after Glib's GObject.Object.set_data().
You can now throw in as many arbitrary pointers as you want with different identifying keys. And retrieve them with that same key:
To stay consistent (and avoid macros for every single callback) I decided to roll back the changes from the previous issue with button callbacks (sry about that), and adopted the same kind of setter and getters:
With a reserved key value for cell internals: CGUI_CELL_IMPLEMENTATION (defined as "_IMPL"). You're free to use any other string values for your own keys.
Hi, thank you for taking the time to write Cassette!
The
on_draw
callback (and other callbacks likeon_close
oron_focus
) of the window API takes acgui_window
argument and a delay. Is there a way to access a private pointer that could linked to the program state from within the callback?Here is an example to illustrate the problem where cairo is used to draw an animation on the window:
One option could be to add an extra parameter to the callback (like what was done for #4). Another approach could be to store a private pointer in cgui_window (similar to what cgui_cell_set_data/cgui_cell_get_data does).
The text was updated successfully, but these errors were encountered: