emote2ss

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

commit 62cca89a2cd03937a6ab058d4740c208e09a9927
parent 8d5afbfa1dc4384bf263e4270285a7f651fc714b
Author: bsandro <email@bsandro.tech>
Date:   Sat, 30 Aug 2025 22:38:41 +0300

Plus and Minus buttons are working now

Diffstat:
Mgui/ui.c | 38++++++++++++++++++++++++++++++++++++--
Mgui/ui.h | 2++
2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/gui/ui.c b/gui/ui.c @@ -49,7 +49,7 @@ UIWindow * MainWindowCreate(const char *wname, int w, int h) { btnsave->e.cp = win; UIButton *btn_exit = UIButtonCreate(&panelh_top->e, 0, "Exit", -1); btn_exit->e.messageUser = ButtonCloseEvent; - lbl_header = UILabelCreate(&panelh_top->e, 0, "webp 2 spritesheet converter", -1); + lbl_header = UILabelCreate(&panelh_top->e, 0, "webp to spritesheet converter", -1); // scroll with dimensions label UIPanel *panelh_bottom = UIPanelCreate(&panelv->e, UI_PANEL_GRAY|UI_PANEL_SMALL_SPACING|UI_PANEL_HORIZONTAL|UI_PANEL_EXPAND|UI_ELEMENT_H_FILL); @@ -58,6 +58,11 @@ UIWindow * MainWindowCreate(const char *wname, int w, int h) { UIButton *btnplus = UIButtonCreate(&panelh_bottom->e, 0, "+", -1); UISlider *slider = UISliderCreate(&panelh_bottom->e, UI_ELEMENT_H_FILL); + btnminus->e.messageUser = ButtonMinusEvent; + btnminus->e.cp = slider; + btnplus->e.messageUser = ButtonPlusEvent; + btnplus->e.cp = slider; + 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; slider->e.messageUser = SliderEvent; @@ -74,6 +79,35 @@ int WinModalEvent(UIElement *element, UIMessage msg, int di, void *dp) { return 0; } +int ButtonMinusEvent(UIElement *element, UIMessage msg, int di, void *dp) { + if (msg==UI_MSG_CLICKED) { + if (img==NULL) return 1; + UISlider *slider = (UISlider *)element->cp; + float step = 1.0f / (float)img->frame_count; + slider->position -= step; + cols--; + if (slider->position<0) slider->position=0; + if (cols<1) cols=1; + UIElementRefresh(&slider->e); + PreviewUpdate(img, img_disp); + } + return 0; +} +int ButtonPlusEvent(UIElement *element, UIMessage msg, int di, void *dp) { + if (msg==UI_MSG_CLICKED) { + if (img==NULL) return 1; + UISlider *slider = (UISlider *)element->cp; + float step = 1.0f / (float)img->frame_count; + slider->position += step; + cols++; + if (slider->position>1) slider->position=1; + if (cols>img->frame_count) cols=img->frame_count; + UIElementRefresh(&slider->e); + PreviewUpdate(img, img_disp); + } + return 0; +} + int ButtonDialogSaveEvent(UIElement *element, UIMessage msg, int di, void *dp) { if (msg==UI_MSG_CLICKED) { // get values of path and filename inputs @@ -286,7 +320,7 @@ int SliderEvent(UIElement *element, UIMessage msg, int di, void *dp) { int WinMainEvent(UIElement *element, UIMessage msg, int di, void *dp) { if (msg==UI_MSG_DESTROY) { - printf("main win bye\n"); + //printf("main win bye\n"); free(img); exit(0); } diff --git a/gui/ui.h b/gui/ui.h @@ -20,6 +20,8 @@ void ShowModalWindow(UIWindow *parent, char *def_dir, const char *def_file, Call int WinMainEvent(UIElement *element, UIMessage msg, int di, void *dp); int WinModalEvent(UIElement *element, UIMessage msg, int di, void *dp); int SliderEvent(UIElement *element, UIMessage msg, int di, void *dp); +int ButtonMinusEvent(UIElement *element, UIMessage msg, int di, void *dp); +int ButtonPlusEvent(UIElement *element, UIMessage msg, int di, void *dp); int ButtonOpenEvent(UIElement *element, UIMessage msg, int di, void *dp); int ButtonSaveEvent(UIElement *element, UIMessage msg, int di, void *dp); int ButtonCloseEvent(UIElement *element, UIMessage msg, int di, void *dp);