commit 928e98bc0458e5e329888a3f950f1867859f4206
parent 648b4ae6c6df73174bbf59ef96cad056ae92ddcc
Author: bsandro <[email protected]>
Date: Sun, 30 Jul 2023 16:36:38 +0300
gui tiny fix
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/gui/main.c b/gui/main.c
@@ -247,7 +247,9 @@ void update_preview(UIImageDisplay *img_disp) {
frame0[i] = UI_COLOR_FROM_RGBA(ss.data[i*4+0], ss.data[i*4+1], ss.data[i*4+2], ss.data[i*4+3]);
}
UIImageDisplaySetContent(img_disp, frame0, ss.width, ss.height, ss.stride);
- img_disp->zoom = 1.0f;
+ //img_disp->zoom = 1.0f;
+ UIElementRefresh(img_disp->e.parent);
+ UIElementRefresh(&img_disp->e);
/*for (int i=0; i<16; ++i) {
printf("b 8[%2d] = %x\n", i, ss.data[i]);
@@ -261,7 +263,7 @@ void update_preview(UIImageDisplay *img_disp) {
UILabel *label = (UILabel *)img_disp->e.cp;
char label_text[256] = {0};
- snprintf(&label_text, 255, "slider changed: %d", cols);
+ snprintf(&label_text, 255, "spritesheet width: %d", cols);
UILabelSetContent(label, label_text, strlen(label_text));
UIElementRefresh(label->e.parent);
}
@@ -273,8 +275,8 @@ int SliderEvent(UIElement *element, UIMessage msg, int di, void *dp) {
int new_cols = (int)(slider_pos / step);
if (new_cols > 0 && cols != new_cols) {
printf("new_cols: %d\n", new_cols);
- update_preview(element->cp);
cols = new_cols;
+ update_preview(element->cp);
}
}
@@ -289,7 +291,7 @@ int main(int argc, const char **argv) {
UIPanel *panel = UIPanelCreate(&win->e, UI_PANEL_GRAY|UI_PANEL_MEDIUM_SPACING);
UILabel *label = UILabelCreate(&panel->e, 0, "webp to spritesheet converter", -1);
UISlider *slider = UISliderCreate(&panel->e, 0);
- UIImageDisplay *img_disp = UIImageDisplayCreate(&panel->e, UI_ELEMENT_V_FILL|UI_ELEMENT_H_FILL|UI_IMAGE_DISPLAY_INTERACTIVE, NULL, 0, 0, 0);
+ UIImageDisplay *img_disp = UIImageDisplayCreate(&panel->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;
slider->e.cp = img_disp;