summaryrefslogtreecommitdiffstats
path: root/source/widgets/box.c
diff options
context:
space:
mode:
authorDave Davenport <DaveDavenport@users.noreply.github.com>2021-09-07 19:40:07 +0200
committerGitHub <noreply@github.com>2021-09-07 19:40:07 +0200
commitc10ee955bd81d369034af47335a8ce7a7d1de52b (patch)
tree0eb90326d6733a34654ca0f56b5efaa7b0dd52a0 /source/widgets/box.c
parentf4e5fd328ac0cf8510af735cfc175afbd3a18751 (diff)
#1437 - Fix sizing logic for widgets and textboxes. (#1444)
* [I1437] Textbox make get_desired_width depend on width. Should fix some weird sizing issues on creation of widgest. * [i1437] [View] Do the sizing based on the desired window width. issue: #1437 * [i1437] Fix header documentation.
Diffstat (limited to 'source/widgets/box.c')
-rw-r--r--source/widgets/box.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/source/widgets/box.c b/source/widgets/box.c
index d1d05ab8..1b5e2933 100644
--- a/source/widgets/box.c
+++ b/source/widgets/box.c
@@ -49,7 +49,7 @@ struct _box {
static void box_update(widget *wid);
-static int box_get_desired_width(widget *wid) {
+static int box_get_desired_width(widget *wid, const int height) {
box *b = (box *)wid;
int spacing = distance_get_pixel(b->spacing, b->type);
int width = 0;
@@ -71,10 +71,10 @@ static int box_get_desired_width(widget *wid) {
}
active_widgets++;
if (child->expand == TRUE) {
- width += widget_get_desired_width(child);
+ width += widget_get_desired_width(child, height);
continue;
}
- width += widget_get_desired_width(child);
+ width += widget_get_desired_width(child, height);
}
if (active_widgets > 0) {
width += (active_widgets - 1) * spacing;
@@ -86,13 +86,13 @@ static int box_get_desired_width(widget *wid) {
if (!child->enabled) {
continue;
}
- width = MAX(widget_get_desired_width(child), width);
+ width = MAX(widget_get_desired_width(child, height), width);
}
}
width += widget_padding_get_padding_width(wid);
return width;
}
-static int box_get_desired_height(widget *wid) {
+static int box_get_desired_height(widget *wid, const int width) {
box *b = (box *)wid;
int spacing = distance_get_pixel(b->spacing, b->type);
int height = 0;
@@ -105,7 +105,7 @@ static int box_get_desired_height(widget *wid) {
continue;
}
active_widgets++;
- height += widget_get_desired_height(child);
+ height += widget_get_desired_height(child, width);
}
if (active_widgets > 0) {
height += (active_widgets - 1) * spacing;
@@ -117,7 +117,7 @@ static int box_get_desired_height(widget *wid) {
if (!child->enabled) {
continue;
}
- height = MAX(widget_get_desired_height(child), height);
+ height = MAX(widget_get_desired_height(child, width), height);
}
}
height += widget_padding_get_padding_height(wid);
@@ -134,7 +134,8 @@ static void vert_calculate_size(box *b) {
iter = g_list_next(iter)) {
widget *child = (widget *)iter->data;
if (child->enabled && child->expand == FALSE) {
- widget_resize(child, rem_width, widget_get_desired_height(child));
+ widget_resize(child, rem_width,
+ widget_get_desired_height(child, rem_width));
}
}
b->max_size = 0;
@@ -201,7 +202,7 @@ static void hori_calculate_size(box *b) {
widget *child = (widget *)iter->data;
if (child->enabled && child->expand == FALSE) {
widget_resize(child,
- widget_get_desired_width(child), // child->w,
+ widget_get_desired_width(child, rem_height), // child->w,
rem_height);
}
}