summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-12 14:08:45 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-12 14:08:45 +0300
commitbe76ad93ea6218f6f3b019a07ddc074e84d86969 (patch)
tree3e03e0d93bcc564beec4772b4f448b99799c2537
parentac3dca8a97fabc5b41695d5020e1e4f035335236 (diff)
Keep labels aligned with expanding inputs
A widget may copy its height from another widget.
-rw-r--r--src/app.c4
-rw-r--r--src/ui/util.c9
-rw-r--r--src/ui/widget.c8
-rw-r--r--src/ui/widget.h1
4 files changed, 20 insertions, 2 deletions
diff --git a/src/app.c b/src/app.c
index 1a4112ff..6d172c02 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1578,6 +1578,10 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) {
1578 setToggle_Widget(findChild_Widget(d, "prefs.ostheme"), iFalse); 1578 setToggle_Widget(findChild_Widget(d, "prefs.ostheme"), iFalse);
1579 } 1579 }
1580 } 1580 }
1581 else if (equalWidget_Command(cmd, d, "input.resized")) {
1582 updatePreferencesLayout_Widget(d);
1583 return iFalse;
1584 }
1581 return iFalse; 1585 return iFalse;
1582} 1586}
1583 1587
diff --git a/src/ui/util.c b/src/ui/util.c
index ece527e1..04cdf27f 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -2198,6 +2198,10 @@ static void addDialogInputWithHeading_(iWidget *headings, iWidget *values, const
2198 setPadding_Widget(as_Widget(head), 0, gap_UI, 0, 0); 2198 setPadding_Widget(as_Widget(head), 0, gap_UI, 0, 0);
2199#endif 2199#endif
2200 setId_Widget(addChild_Widget(values, input), inputId); 2200 setId_Widget(addChild_Widget(values, input), inputId);
2201 if (deviceType_App() != phone_AppDeviceType) {
2202 /* Ensure that the label has the same height as the input widget. */
2203 as_Widget(head)->sizeRef = as_Widget(input);
2204 }
2201} 2205}
2202 2206
2203iInputWidget *addTwoColumnDialogInputField_Widget(iWidget *headings, iWidget *values, 2207iInputWidget *addTwoColumnDialogInputField_Widget(iWidget *headings, iWidget *values,
@@ -2225,8 +2229,9 @@ iWidget *makePreferences_Widget(void) {
2225 /* General preferences. */ { 2229 /* General preferences. */ {
2226 appendTwoColumnPage_(tabs, "${heading.prefs.general}", '1', &headings, &values); 2230 appendTwoColumnPage_(tabs, "${heading.prefs.general}", '1', &headings, &values);
2227#if defined (LAGRANGE_ENABLE_DOWNLOAD_EDIT) 2231#if defined (LAGRANGE_ENABLE_DOWNLOAD_EDIT)
2228 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.downloads}"))); 2232 //addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.downloads}")));
2229 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.downloads"); 2233 //setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.downloads");
2234 addPrefsInputWithHeading_(headings, values, "prefs.downloads", iClob(new_InputWidget(0)));
2230#endif 2235#endif
2231 iInputWidget *searchUrl; 2236 iInputWidget *searchUrl;
2232 addPrefsInputWithHeading_(headings, values, "prefs.searchurl", iClob(searchUrl = new_InputWidget(0))); 2237 addPrefsInputWithHeading_(headings, values, "prefs.searchurl", iClob(searchUrl = new_InputWidget(0)));
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 6412481b..c1c920d2 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -54,6 +54,7 @@ void init_Widget(iWidget *d) {
54 d->flags = 0; 54 d->flags = 0;
55 d->rect = zero_Rect(); 55 d->rect = zero_Rect();
56 d->minSize = zero_I2(); 56 d->minSize = zero_I2();
57 d->sizeRef = NULL;
57 d->bgColor = none_ColorId; 58 d->bgColor = none_ColorId;
58 d->frameColor = none_ColorId; 59 d->frameColor = none_ColorId;
59 init_Anim(&d->visualOffset, 0.0f); 60 init_Anim(&d->visualOffset, 0.0f);
@@ -329,6 +330,9 @@ static void setWidth_Widget_(iWidget *d, int width) {
329 330
330static void setHeight_Widget_(iWidget *d, int height) { 331static void setHeight_Widget_(iWidget *d, int height) {
331 iAssert(height >= 0); 332 iAssert(height >= 0);
333 if (d->sizeRef) {
334 return; /* height defined by another widget */
335 }
332 TRACE(d, "attempt to set height to %d (current: %d, min height: %d)", height, d->rect.size.y, d->minSize.y); 336 TRACE(d, "attempt to set height to %d (current: %d, min height: %d)", height, d->rect.size.y, d->minSize.y);
333 height = iMax(height, d->minSize.y); 337 height = iMax(height, d->minSize.y);
334 if (~d->flags & fixedHeight_WidgetFlag) { //} || d->flags & collapse_WidgetFlag) { 338 if (~d->flags & fixedHeight_WidgetFlag) { //} || d->flags & collapse_WidgetFlag) {
@@ -415,6 +419,10 @@ static void boundsOfChildren_Widget_(const iWidget *d, iRect *bounds_out) {
415 419
416static void arrange_Widget_(iWidget *d) { 420static void arrange_Widget_(iWidget *d) {
417 TRACE(d, "arranging..."); 421 TRACE(d, "arranging...");
422 if (d->sizeRef) {
423 d->rect.size.y = height_Widget(d->sizeRef);
424 TRACE(d, "use referenced height: %d", d->rect.size.y);
425 }
418 if (d->flags & moveToParentLeftEdge_WidgetFlag) { 426 if (d->flags & moveToParentLeftEdge_WidgetFlag) {
419 d->rect.pos.x = d->padding[0]; /* FIXME: Shouldn't this be d->parent->padding[0]? */ 427 d->rect.pos.x = d->padding[0]; /* FIXME: Shouldn't this be d->parent->padding[0]? */
420 TRACE(d, "move to parent left edge: %d", d->rect.pos.x); 428 TRACE(d, "move to parent left edge: %d", d->rect.pos.x);
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 5b6b18e1..5c05e917 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -134,6 +134,7 @@ struct Impl_Widget {
134 int64_t flags; 134 int64_t flags;
135 iRect rect; 135 iRect rect;
136 iInt2 minSize; 136 iInt2 minSize;
137 iWidget * sizeRef;
137 int padding[4]; /* left, top, right, bottom */ 138 int padding[4]; /* left, top, right, bottom */
138 iAnim visualOffset; 139 iAnim visualOffset;
139 int bgColor; 140 int bgColor;