summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-30 12:37:57 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-30 12:37:57 +0300
commitade0ed91adfaad12a51d3ee19e0077151457670f (patch)
tree707c1c5e306cadf52e7658b76d991228db8b8fad
parent1495d08163a4bfcd5db5f6c3b06f031032c5461f (diff)
LabelWidget: Implicit minimum size
-rw-r--r--src/ui/labelwidget.c8
-rw-r--r--src/ui/root.c1
-rw-r--r--src/ui/util.c3
3 files changed, 7 insertions, 5 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index 45c02827..6847ddf1 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -391,6 +391,7 @@ void updateSize_LabelWidget(iLabelWidget *d) {
391 iWidget *w = as_Widget(d); 391 iWidget *w = as_Widget(d);
392 const int64_t flags = flags_Widget(w); 392 const int64_t flags = flags_Widget(w);
393 const iInt2 size = defaultSize_LabelWidget(d); 393 const iInt2 size = defaultSize_LabelWidget(d);
394 w->minSize.y = size.y; /* vertically text must remain visible */
394 /* Wrapped text implies that width must be defined by arrangement. */ 395 /* Wrapped text implies that width must be defined by arrangement. */
395 if (!(flags & (fixedWidth_WidgetFlag | wrapText_WidgetFlag))) { 396 if (!(flags & (fixedWidth_WidgetFlag | wrapText_WidgetFlag))) {
396 w->rect.size.x = size.x; 397 w->rect.size.x = size.x;
@@ -405,7 +406,8 @@ static void replaceVariables_LabelWidget_(iLabelWidget *d) {
405} 406}
406 407
407void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { 408void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) {
408 init_Widget(&d->widget); 409 iWidget *w = &d->widget;
410 init_Widget(w);
409 d->font = uiLabel_FontId; 411 d->font = uiLabel_FontId;
410 d->forceFg = none_ColorId; 412 d->forceFg = none_ColorId;
411 d->icon = 0; 413 d->icon = 0;
@@ -416,13 +418,13 @@ void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) {
416 initCStr_String(&d->command, cmd); 418 initCStr_String(&d->command, cmd);
417 } 419 }
418 else { 420 else {
419 setFrameColor_Widget(&d->widget, uiFrame_ColorId); 421 setFrameColor_Widget(w, uiFrame_ColorId);
420 init_String(&d->command); 422 init_String(&d->command);
421 } 423 }
422 d->key = 0; 424 d->key = 0;
423 d->kmods = 0; 425 d->kmods = 0;
424 init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); 426 init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0);
425 setFlags_Widget(&d->widget, hover_WidgetFlag, d->click.button != 0); 427 setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0);
426 d->alignVisual = iFalse; 428 d->alignVisual = iFalse;
427 updateSize_LabelWidget(d); 429 updateSize_LabelWidget(d);
428 updateKey_LabelWidget_(d); /* could be bound to another key */ 430 updateKey_LabelWidget_(d); /* could be bound to another key */
diff --git a/src/ui/root.c b/src/ui/root.c
index 287b641e..35eb84ef 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -305,6 +305,7 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) {
305 return iTrue; 305 return iTrue;
306 } 306 }
307 else if (equal_Command(cmd, "splitmenu.open")) { 307 else if (equal_Command(cmd, "splitmenu.open")) {
308 setFocus_Widget(NULL);
308 iWidget *menu = findWidget_Root("splitmenu"); 309 iWidget *menu = findWidget_Root("splitmenu");
309 openMenu_Widget(menu, zero_I2()); 310 openMenu_Widget(menu, zero_I2());
310 setPos_Widget(menu, sub_I2(divi_I2(size_Root(get_Root()), 2), divi_I2(menu->rect.size, 2))); 311 setPos_Widget(menu, sub_I2(divi_I2(size_Root(get_Root()), 2), divi_I2(menu->rect.size, 2)));
diff --git a/src/ui/util.c b/src/ui/util.c
index 7bc611e0..9927b79f 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -2061,7 +2061,6 @@ static iWidget *appendTwoColumnPage_(iWidget *tabs, const char *title, int short
2061 iWidget **values) { 2061 iWidget **values) {
2062 /* TODO: Use `makeTwoColumnWidget_()`, see above. */ 2062 /* TODO: Use `makeTwoColumnWidget_()`, see above. */
2063 iWidget *page = new_Widget(); 2063 iWidget *page = new_Widget();
2064 setBackgroundColor_Widget(page, red_ColorId);
2065 setFlags_Widget(page, arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 2064 setFlags_Widget(page, arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
2066 addChildFlags_Widget(page, iClob(new_Widget()), expand_WidgetFlag); 2065 addChildFlags_Widget(page, iClob(new_Widget()), expand_WidgetFlag);
2067 setPadding_Widget(page, 0, gap_UI, 0, gap_UI); 2066 setPadding_Widget(page, 0, gap_UI, 0, gap_UI);
@@ -2438,7 +2437,7 @@ iWidget *makePreferences_Widget(void) {
2438 (iMenuItem[]){ { "${dismiss}", SDLK_ESCAPE, 0, "prefs.dismiss" } }, 1))); 2437 (iMenuItem[]){ { "${dismiss}", SDLK_ESCAPE, 0, "prefs.dismiss" } }, 1)));
2439 addChild_Widget(dlg->root->widget, iClob(dlg)); 2438 addChild_Widget(dlg->root->widget, iClob(dlg));
2440 finalizeSheet_Widget(dlg); 2439 finalizeSheet_Widget(dlg);
2441 //printTree_Widget(dlg); 2440// printTree_Widget(dlg);
2442 return dlg; 2441 return dlg;
2443} 2442}
2444 2443