summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/labelwidget.c20
-rw-r--r--src/ui/labelwidget.h1
-rw-r--r--src/ui/root.c3
3 files changed, 20 insertions, 4 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index 6847ddf1..e4ab378d 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -39,8 +39,11 @@ struct Impl_LabelWidget {
39 iChar icon; 39 iChar icon;
40 int forceFg; 40 int forceFg;
41 iString command; 41 iString command;
42 iBool alignVisual; /* align according to visible bounds, not font metrics */
43 iClick click; 42 iClick click;
43 struct {
44 uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */
45 uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */
46 } flags;
44}; 47};
45 48
46static iInt2 padding_LabelWidget_(const iLabelWidget *d, int corner) { 49static iInt2 padding_LabelWidget_(const iLabelWidget *d, int corner) {
@@ -339,7 +342,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
339 adjusted_Rect(bounds, 342 adjusted_Rect(bounds,
340 add_I2(zero_I2(), init_I2(iconPad, 0)), 343 add_I2(zero_I2(), init_I2(iconPad, 0)),
341 neg_I2(zero_I2())), 344 neg_I2(zero_I2())),
342 d->alignVisual, 345 d->flags.alignVisual,
343 fg, 346 fg,
344 "%s", 347 "%s",
345 cstr_String(&d->label)); 348 cstr_String(&d->label));
@@ -425,7 +428,8 @@ void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) {
425 d->kmods = 0; 428 d->kmods = 0;
426 init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0); 429 init_Click(&d->click, d, !isEmpty_String(&d->command) ? SDL_BUTTON_LEFT : 0);
427 setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0); 430 setFlags_Widget(w, hover_WidgetFlag, d->click.button != 0);
428 d->alignVisual = iFalse; 431 d->flags.alignVisual = iFalse;
432 d->flags.noAutoMinHeight = iFalse;
429 updateSize_LabelWidget(d); 433 updateSize_LabelWidget(d);
430 updateKey_LabelWidget_(d); /* could be bound to another key */ 434 updateKey_LabelWidget_(d); /* could be bound to another key */
431} 435}
@@ -454,7 +458,15 @@ void setText_LabelWidget(iLabelWidget *d, const iString *text) {
454} 458}
455 459
456void setAlignVisually_LabelWidget(iLabelWidget *d, iBool alignVisual) { 460void setAlignVisually_LabelWidget(iLabelWidget *d, iBool alignVisual) {
457 d->alignVisual = alignVisual; 461 d->flags.alignVisual = alignVisual;
462}
463
464void setNoAutoMinHeight_LabelWidget(iLabelWidget *d, iBool noAutoMinHeight) {
465 /* By default all labels use a minimum height determined by the text dimensions. */
466 d->flags.noAutoMinHeight = noAutoMinHeight;
467 if (noAutoMinHeight) {
468 d->widget.minSize.y = 0;
469 }
458} 470}
459 471
460void updateText_LabelWidget(iLabelWidget *d, const iString *text) { 472void updateText_LabelWidget(iLabelWidget *d, const iString *text) {
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h
index f4c4658c..e38a1dc8 100644
--- a/src/ui/labelwidget.h
+++ b/src/ui/labelwidget.h
@@ -30,6 +30,7 @@ iDeclareWidgetClass(LabelWidget)
30iDeclareObjectConstructionArgs(LabelWidget, const char *label, const char *command) 30iDeclareObjectConstructionArgs(LabelWidget, const char *label, const char *command)
31 31
32void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual); 32void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual);
33void setNoAutoMinHeight_LabelWidget(iLabelWidget *, iBool noAutoMinHeight);
33void setFont_LabelWidget (iLabelWidget *, int fontId); 34void setFont_LabelWidget (iLabelWidget *, int fontId);
34void setTextColor_LabelWidget (iLabelWidget *, int color); 35void setTextColor_LabelWidget (iLabelWidget *, int color);
35void setText_LabelWidget (iLabelWidget *, const iString *text); /* resizes widget */ 36void setText_LabelWidget (iLabelWidget *, const iString *text); /* resizes widget */
diff --git a/src/ui/root.c b/src/ui/root.c
index 3661229e..cd6959c4 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -1020,6 +1020,7 @@ void createUserInterface_Root(iRoot *d) {
1020 setBackgroundColor_Widget(as_Widget(queryInd), uiBackground_ColorId); 1020 setBackgroundColor_Widget(as_Widget(queryInd), uiBackground_ColorId);
1021 setFrameColor_Widget(as_Widget(queryInd), uiTextAction_ColorId); 1021 setFrameColor_Widget(as_Widget(queryInd), uiTextAction_ColorId);
1022 setAlignVisually_LabelWidget(queryInd, iTrue); 1022 setAlignVisually_LabelWidget(queryInd, iTrue);
1023 setNoAutoMinHeight_LabelWidget(queryInd, iTrue);
1023 addChildFlags_Widget(rightEmbed, 1024 addChildFlags_Widget(rightEmbed,
1024 iClob(queryInd), 1025 iClob(queryInd),
1025 collapse_WidgetFlag | hidden_WidgetFlag); 1026 collapse_WidgetFlag | hidden_WidgetFlag);
@@ -1030,6 +1031,7 @@ void createUserInterface_Root(iRoot *d) {
1030 setId_Widget(as_Widget(fprog), "feeds.progress"); 1031 setId_Widget(as_Widget(fprog), "feeds.progress");
1031 setBackgroundColor_Widget(as_Widget(fprog), uiBackground_ColorId); 1032 setBackgroundColor_Widget(as_Widget(fprog), uiBackground_ColorId);
1032 setAlignVisually_LabelWidget(fprog, iTrue); 1033 setAlignVisually_LabelWidget(fprog, iTrue);
1034 setNoAutoMinHeight_LabelWidget(fprog, iTrue);
1033 addChildFlags_Widget(rightEmbed, 1035 addChildFlags_Widget(rightEmbed,
1034 iClob(fprog), 1036 iClob(fprog),
1035 collapse_WidgetFlag | frameless_WidgetFlag | hidden_WidgetFlag); 1037 collapse_WidgetFlag | frameless_WidgetFlag | hidden_WidgetFlag);
@@ -1039,6 +1041,7 @@ void createUserInterface_Root(iRoot *d) {
1039 setId_Widget(as_Widget(progress), "document.progress"); 1041 setId_Widget(as_Widget(progress), "document.progress");
1040 setBackgroundColor_Widget(as_Widget(progress), uiBackground_ColorId); 1042 setBackgroundColor_Widget(as_Widget(progress), uiBackground_ColorId);
1041 setAlignVisually_LabelWidget(progress, iTrue); 1043 setAlignVisually_LabelWidget(progress, iTrue);
1044 setNoAutoMinHeight_LabelWidget(progress, iTrue);
1042 addChildFlags_Widget( 1045 addChildFlags_Widget(
1043 rightEmbed, iClob(progress), collapse_WidgetFlag); 1046 rightEmbed, iClob(progress), collapse_WidgetFlag);
1044 } 1047 }