|
1 | | -/* |
| 1 | +/* |
2 | 2 | * widget_base.c -- The widget base operation set. |
3 | 3 | * |
4 | 4 | * Copyright (c) 2018, Liu chao <lc-soft@live.cn> All rights reserved. |
|
39 | 39 | #include <LCUI/gui/metrics.h> |
40 | 40 |
|
41 | 41 | static struct LCUI_WidgetModule { |
42 | | - LCUI_Widget root; /**< 根级部件 */ |
43 | | - LinkedList trash; /**< 待删除的部件列表 */ |
| 42 | + LCUI_Widget root; /**< 根级部件 */ |
| 43 | + LinkedList trash; /**< 待删除的部件列表 */ |
44 | 44 | } LCUIWidget; |
45 | 45 |
|
46 | 46 | static inline float ToBorderBoxWidth(LCUI_Widget w, float content_width) |
@@ -399,7 +399,6 @@ void Widget_UpdateOpacity(LCUI_Widget w) |
399 | 399 | } |
400 | 400 | w->computed_style.opacity = opacity; |
401 | 401 | Widget_InvalidateArea(w, NULL, SV_GRAPH_BOX); |
402 | | - DEBUG_MSG("opacity: %0.2f\n", opacity); |
403 | 402 | } |
404 | 403 |
|
405 | 404 | void Widget_UpdateZIndex(LCUI_Widget w) |
@@ -690,7 +689,6 @@ static void Widget_ComputeStaticContentSize(LCUI_Widget w, float *out_width, |
690 | 689 | *out_height = content_height; |
691 | 690 | } |
692 | 691 | } |
693 | | - |
694 | 692 | LCUI_BOOL Widget_HasAutoStyle(LCUI_Widget w, int key) |
695 | 693 | { |
696 | 694 | return !Widget_CheckStyleValid(w, key) || |
@@ -1149,16 +1147,20 @@ void Widget_UpdateProps(LCUI_Widget w) |
1149 | 1147 | float Widget_ComputeMaxAvaliableWidth(LCUI_Widget widget) |
1150 | 1148 | { |
1151 | 1149 | LCUI_Widget w; |
1152 | | - float width = 0, padding = 0; |
| 1150 | + float width = 0, padding = 0, margin = 0; |
| 1151 | + |
1153 | 1152 | for (w = widget->parent; w; w = w->parent) { |
1154 | 1153 | if (!Widget_HasAutoStyle(w, key_width) || |
1155 | 1154 | w->computed_style.max_width >= 0) { |
1156 | 1155 | width = w->box.content.width; |
1157 | 1156 | break; |
1158 | 1157 | } |
| 1158 | + if (Widget_HasFillAvailableWidth(w)) { |
| 1159 | + margin += w->box.outer.width - w->box.border.width; |
| 1160 | + } |
1159 | 1161 | padding += w->box.border.width - w->box.content.width; |
1160 | 1162 | } |
1161 | | - width -= padding; |
| 1163 | + width -= padding + margin; |
1162 | 1164 | if (Widget_HasAbsolutePosition(widget)) { |
1163 | 1165 | width += widget->padding.left + widget->padding.right; |
1164 | 1166 | } |
|
0 commit comments