emote2ss

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

commit 013c05d3fd44635daa9acf74e9ad64cb7ca48bb2
parent 98ad24380832ffffe3dcf82103e6845a4995982c
Author: bsandro <email@bsandro.tech>
Date:   Wed, 16 Aug 2023 16:49:56 +0300

Save (modal) window appearance basic logic

Diffstat:
Mgui/Makefile | 2+-
Mgui/main.c | 38+++++++++++++++++++++++++++++++-------
2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/gui/Makefile b/gui/Makefile @@ -3,7 +3,7 @@ SRC:=$(wildcard *.c) DEPS:=$(wildcard ../include/*.h) OBJ:=$(SRC:.c=.o) LIBS:=libwebp libwebpdemux x11 -CFLAGS=-O0 -g -std=c99 -Wall -Wextra -ffast-math -I. -I../include/ ${shell pkg-config --cflags $(LIBS)} +CFLAGS=-O0 -g -std=c99 -ffast-math -I. -I../include/ ${shell pkg-config --cflags $(LIBS)} LDFLAGS=-lc -lm ${shell pkg-config --libs $(LIBS)} all: $(NAME) diff --git a/gui/main.c b/gui/main.c @@ -61,6 +61,7 @@ typedef struct { // let it be global variable for now static Animation *img = NULL; static int cols = 1; +static volatile UIWindow *modal_win = NULL; void alloc_image(Animation *img, uint32_t frame_count) { assert(frame_count > 0); @@ -227,11 +228,21 @@ Spritesheet gen_spritesheet(Animation *img, int cols) { return ss; } +int WinModalEvent(UIElement *element, UIMessage msg, int di, void *dp) { + if (msg == UI_MSG_DESTROY) { + printf("modal bye\n"); + assert(element==modal_win); + modal_win = NULL; + } + return 0; +} + int ButtonDialogSaveEvent(UIElement *element, UIMessage msg, int di, void *dp) { if (msg == UI_MSG_CLICKED) { printf("save dialog window close\n"); - // + assert(element->window==modal_win); UIElementDestroy(element->window); + //modal_win = NULL; } return 0; } @@ -256,12 +267,12 @@ int TableEvent(UIElement *element, UIMessage msg, int di, void *dp) { return 0; } -int ButtonSaveEvent(UIElement *element, UIMessage msg, int di, void *dp) { - if (msg == UI_MSG_CLICKED) { - printf("save dialog window open\n"); - - UIWindow *win_save = UIWindowCreate((UIWindow *)element->cp, UI_WINDOW_INSPECTOR, "Save File", 0, 0); - UIPanel *panel_out = UIPanelCreate(&win_save->e, UI_PANEL_GRAY|UI_PANEL_EXPAND); +void ShowSaveWindow(UIWindow *parent) { + if (modal_win == NULL) { + printf("create save window\n"); + modal_win = UIWindowCreate(parent, NULL, "Save File", 0, 0); + modal_win->e.messageUser = WinModalEvent; + UIPanel *panel_out = UIPanelCreate(&modal_win->e, UI_PANEL_GRAY|UI_PANEL_EXPAND); UILabel *lbl_title = UILabelCreate(&panel_out->e, 0, "Save File", -1); @@ -279,6 +290,15 @@ int ButtonSaveEvent(UIElement *element, UIMessage msg, int di, void *dp) { table->itemCount = 100; table->e.messageUser = TableEvent; UITableResizeColumns(table); + } else { + UIElementFocus(modal_win); + } +} + +int ButtonSaveEvent(UIElement *element, UIMessage msg, int di, void *dp) { + if (msg == UI_MSG_CLICKED) { + printf("save dialog window open\n"); + ShowSaveWindow(element->window); } return 0; } @@ -343,7 +363,11 @@ int WinMainEvent(UIElement *element, UIMessage msg, int di, void *dp) { return 0; } +#ifdef UI_LINUX int main(int argc, const char **argv) { +#else +int WinMain(HINSTANCE instance, HINSTANCE previousInstance, LPSTR commandLine, int showCommand) { +#endif atexit(print_webp_version); UIInitialise();