emote2ss

Animated webp to spritesheets converting tool
git clone git://bsandro.tech/emote2ss
Log | Files | Refs | README | LICENSE

commit b9b7dc673617ae52eeb81b267f085b1c39e2c519
parent 7e78b8981dd573cacf145e1c91f38bae9583d7ea
Author: bsandro <email@bsandro.tech>
Date:   Mon, 14 Aug 2023 02:38:13 +0300

basic events layout - save, exit

Diffstat:
Mgui/main.c | 41++++++++++++++++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/gui/main.c b/gui/main.c @@ -227,13 +227,31 @@ spritesheet_t gen_spritesheet(animation_t *img, int cols) { return ss; } +int ButtonDialogSaveEvent(UIElement *element, UIMessage msg, int di, void *dp) { + if (msg == UI_MSG_CLICKED) { + printf("save window close\n"); + + UIWindow *win_save = (UIWindow *)element->cp; + printf("win_save: %p\n", win_save); + UIElementDestroy(win_save); + } + return 0; +} + int ButtonSaveEvent(UIElement *element, UIMessage msg, int di, void *dp) { (void)di; (void)dp; if (msg == UI_MSG_CLICKED) { printf("save\n"); - } + UIWindow *win_save = UIWindowCreate(0, 0, "Save File", 0, 0); + printf("win_save: %p\n", win_save); + UIPanel *panel_out = UIPanelCreate(&win_save->e, UI_PANEL_GRAY|UI_PANEL_MEDIUM_SPACING); + UILabel *lbl_title = UILabelCreate(&panel_out->e, 0, "Save File Title", -1); + UIButton *btn_save = UIButtonCreate(&panel_out->e, 0, "Save", -1); + btn_save->e.messageUser = ButtonDialogSaveEvent; + btn_save->e.cp = win_save; + } return 0; } @@ -241,9 +259,11 @@ int ButtonCloseEvent(UIElement *element, UIMessage msg, int di, void *dp) { (void)di; (void)dp; if (msg == UI_MSG_CLICKED) { - printf("bye\n"); free(img); - exit(0); + UIWindow *win_main = (UIWindow *)element->cp; + assert(win_main!=NULL); + UIElementDestroy(win_main); + //exit(0); } return 0; @@ -292,11 +312,21 @@ int SliderEvent(UIElement *element, UIMessage msg, int di, void *dp) { return 0; } +int WinMainEvent(UIElement *element, UIMessage msg, int di, void *dp) { + if (msg == UI_MSG_DESTROY) { + printf("bye\n"); + exit(0); + } + return 0; +} + int main(int argc, const char **argv) { atexit(print_webp_version); UIInitialise(); + UIWindow *win = UIWindowCreate(0, 0, "emote2ss gui", 0, 0); + win->e.messageUser = WinMainEvent; UIPanel *panelv = UIPanelCreate(&win->e, UI_PANEL_GRAY|UI_PANEL_MEDIUM_SPACING); UILabel *lbl_title = UILabelCreate(&panelv->e, 0, "filename", -1); @@ -307,8 +337,9 @@ int main(int argc, const char **argv) { //btnopen->e.messageUser = ButtonOpenEvent; UIButton *btnsave = UIButtonCreate(&panelh->e, 0, "Save", -1); btnsave->e.messageUser = ButtonSaveEvent; - UIButton *btnexit = UIButtonCreate(&panelh->e, 0, "Close", -1); - btnexit->e.messageUser = ButtonCloseEvent; + UIButton *btn_exit = UIButtonCreate(&panelh->e, 0, "Close", -1); + btn_exit->e.messageUser = ButtonCloseEvent; + btn_exit->e.cp = win; UIImageDisplay *img_disp = UIImageDisplayCreate(&panelv->e, UI_ELEMENT_V_FILL|UI_ELEMENT_H_FILL|UI_IMAGE_DISPLAY_INTERACTIVE|_UI_IMAGE_DISPLAY_ZOOM_FIT, NULL, 0, 0, 0); img_disp->e.cp = label;