aboutsummaryrefslogtreecommitdiff
path: root/src/draw.c
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-03-16 21:11:51 +0100
committerFederico Angelilli <code@fedang.net>2024-03-16 21:11:51 +0100
commit7d8a85532b8ee97af9568443fd97e9701943b225 (patch)
tree7184361d47d2856be20f21ebb256f97f0f61818f /src/draw.c
parent4794a57face4e6e521c8a60a120ebf00bbc8a94f (diff)
Add min and max button width
Diffstat (limited to 'src/draw.c')
-rw-r--r--src/draw.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/draw.c b/src/draw.c
index 5a43a51..51a8a59 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -187,6 +187,15 @@ static void compute_width(Drawer *draw, Window *win)
log_debug("Draw context width calculated [width=%d]", draw->width);
}
+static void layout_check_width(Layout *layout)
+{
+ if (layout->btn->max_width > 0)
+ layout->width = MIN(layout->btn->max_width, layout->width);
+
+ if (layout->btn->min_width > 0)
+ layout->width = MAX(layout->btn->min_width, layout->width);
+}
+
static GList *compute_group_layout(Drawer *draw, GList *btns, int bx, bool root)
{
GList *layouts = NULL;
@@ -242,6 +251,7 @@ retry:
// NOTE: We add half a line width on both sides
layout->width += layout->line_w;
+ layout_check_width(layout);
// Apply layout_func on the layout
ANIMATION(btn, layout, layout);