@@ -86,35 +86,35 @@ typedef enum LCUI_WidgetTaskType {
86
86
LCUI_WTASK_SHADOW ,
87
87
LCUI_WTASK_BORDER ,
88
88
LCUI_WTASK_BACKGROUND ,
89
- LCUI_WTASK_LAYOUT ,
90
89
LCUI_WTASK_RESIZE ,
91
90
LCUI_WTASK_POSITION ,
92
91
LCUI_WTASK_ZINDEX ,
93
92
LCUI_WTASK_OPACITY ,
93
+ LCUI_WTASK_REFLOW ,
94
94
LCUI_WTASK_USER ,
95
95
LCUI_WTASK_TOTAL_NUM
96
96
} LCUI_WidgetTaskType ;
97
97
98
+ /** See more: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model */
98
99
typedef struct LCUI_WidgetBoxModelRec_ {
99
- LCUI_RectF content ; /**< 内容框的区域 */
100
- LCUI_RectF padding ; /**< 内边距框的区域 */
101
- LCUI_RectF border ; /**< 边框盒的区域,包括内边距框和内容框区域 */
102
- LCUI_RectF outer ; /**< 外边距框的区域,包括边框盒和外边距框区域 */
103
- LCUI_RectF canvas ; /**< 图层的区域,包括边框盒和阴影区域 */
100
+ LCUI_RectF content ;
101
+ LCUI_RectF padding ;
102
+ LCUI_RectF border ;
103
+ LCUI_RectF canvas ;
104
+ LCUI_RectF outer ;
104
105
} LCUI_WidgetBoxModelRec , * LCUI_WidgetBoxModel ;
105
106
106
107
typedef struct LCUI_WidgetTaskBoxRec_ {
107
- /** update for self */
108
-
108
+ /** Should update for self? */
109
109
LCUI_BOOL for_self ;
110
110
111
- /** update for children */
111
+ /** Should update for children? */
112
112
LCUI_BOOL for_children ;
113
113
114
- /** skip the property synchronization of bound surface */
114
+ /** Should skip the property sync of bound surface? */
115
115
LCUI_BOOL skip_surface_props_sync ;
116
116
117
- /** states of tasks */
117
+ /** States of tasks */
118
118
LCUI_BOOL states [LCUI_WTASK_TOTAL_NUM ];
119
119
} LCUI_WidgetTaskBoxRec ;
120
120
@@ -235,39 +235,81 @@ typedef struct LCUI_WidgetAttributeRec_ {
235
235
} value ;
236
236
} LCUI_WidgetAttributeRec , * LCUI_WidgetAttribute ;
237
237
238
- /** 部件结构 */
239
238
typedef struct LCUI_WidgetRec_ {
240
- unsigned hash ; /**< 哈希值 */
241
- LCUI_WidgetState state ; /**< 状态 */
242
- float x , y ; /**< 当前坐标(由 origin 计算而来) */
243
- float origin_x , origin_y ; /**< 当前布局下计算出的坐标 */
244
- float width , height ; /**< 部件区域大小,包括边框和内边距占用区域 */
245
- size_t index ; /**< 部件索引位置 */
246
- char * id ; /**< ID */
247
- char * type ; /**< 类型 */
248
- strlist_t classes ; /**< 类列表 */
249
- strlist_t status ; /**< 状态列表 */
250
- wchar_t * title ; /**< 标题 */
251
- LCUI_Rect2F padding ; /**< 内边距框 */
252
- LCUI_Rect2F margin ; /**< 外边距框 */
253
- LCUI_WidgetBoxModelRec box ; /**< 部件的各个区域信息 */
254
- LCUI_StyleSheet style ; /**< 当前完整样式表 */
255
- LCUI_StyleList custom_style ; /**< 自定义样式表 */
256
- LCUI_CachedStyleSheet inherited_style ; /**< 通过继承得到的样式表 */
257
- LCUI_WidgetStyle computed_style ; /**< 已经计算的样式数据 */
258
- LCUI_Widget parent ; /**< 父部件 */
259
- LinkedList children ; /**< 子部件 */
260
- LinkedList children_show ; /**< 子部件的堆叠顺序记录,由顶到底 */
261
- LCUI_WidgetData data ; /**< 私有数据 */
262
- Dict * attributes ; /**< 属性记录 */
263
- LCUI_WidgetPrototypeC proto ; /**< 原型 */
264
- LCUI_EventTrigger trigger ; /**< 事件触发器 */
265
- LCUI_WidgetTaskBoxRec task ; /**< 任务记录 */
266
- LCUI_WidgetRules rules ; /**< 更新部件时采用的规则 */
267
- LCUI_BOOL event_blocked ; /**< 是否阻止自己和子级部件的事件处理 */
268
- LCUI_BOOL disabled ; /**< 是否禁用 */
269
- LinkedListNode node ; /**< 在部件链表中的结点 */
270
- LinkedListNode node_show ; /**< 在部件显示链表中的结点 */
239
+ unsigned hash ;
240
+ LCUI_WidgetState state ;
241
+
242
+ char * id ;
243
+ char * type ;
244
+ strlist_t classes ;
245
+ strlist_t status ;
246
+ wchar_t * title ;
247
+ Dict * attributes ;
248
+ LCUI_BOOL disabled ;
249
+ LCUI_BOOL event_blocked ;
250
+
251
+ /**
252
+ * Coordinates calculated by the layout system
253
+ * The position of the rectangular boxes is calculated based on it
254
+ */
255
+ float layout_x , layout_y ;
256
+
257
+ /**
258
+ * Geometric parameters (readonly)
259
+ * their values come from the box.border
260
+ */
261
+ float x , y ;
262
+ float width , height ;
263
+
264
+ LCUI_Rect2F padding ;
265
+ LCUI_Rect2F margin ;
266
+ LCUI_WidgetBoxModelRec box ;
267
+
268
+ LCUI_StyleSheet style ;
269
+ LCUI_StyleList custom_style ;
270
+ LCUI_CachedStyleSheet inherited_style ;
271
+ LCUI_WidgetStyle computed_style ;
272
+
273
+ /** Some data bound to the prototype */
274
+ LCUI_WidgetData data ;
275
+
276
+ /**
277
+ * Prototype chain
278
+ * It is used to implement the inheritance of widgets,
279
+ * Just like prototype chain in JavaScript
280
+ */
281
+ LCUI_WidgetPrototypeC proto ;
282
+
283
+ /**
284
+ * Update task context
285
+ */
286
+ LCUI_WidgetTaskBoxRec task ;
287
+ LCUI_WidgetRules rules ;
288
+ LCUI_EventTrigger trigger ;
289
+
290
+ /** Parent widiget */
291
+ LCUI_Widget parent ;
292
+
293
+ /** List of child widgets */
294
+ LinkedList children ;
295
+
296
+ /** List of child widgets in descending order by z-index */
297
+ LinkedList children_show ;
298
+
299
+ /**
300
+ * Position in the parent->children
301
+ * this == LinkedList_Get(&this->parent->children, this.index)
302
+ */
303
+ size_t index ;
304
+
305
+ /**
306
+ * Node in the parent->children
307
+ * &this->node == LinkedList_GetNode(&this->parent->children, this.index)
308
+ */
309
+ LinkedListNode node ;
310
+
311
+ /** Node in the parent->children_shoa */
312
+ LinkedListNode node_show ;
271
313
} LCUI_WidgetRec ;
272
314
273
315
/* clang-format on */
@@ -383,10 +425,6 @@ LCUI_API float Widget_GetLimitedWidth(LCUI_Widget w, float width);
383
425
384
426
LCUI_API float Widget_GetLimitedHeight (LCUI_Widget w , float height );
385
427
386
- LCUI_API void Widget_AutoSize (LCUI_Widget w );
387
-
388
- LCUI_API void Widget_ComputeSizeStyle (LCUI_Widget w );
389
-
390
428
/** 根据阴影参数获取部件区域的横向偏移距离 */
391
429
LCUI_API float Widget_GetBoxShadowOffsetX (LCUI_Widget w );
392
430
@@ -458,7 +496,13 @@ LCUI_API float Widget_ComputeMaxContentWidth(LCUI_Widget w);
458
496
/** 计算部件的最大可用宽度 */
459
497
LCUI_API float Widget_ComputeMaxAvaliableWidth (LCUI_Widget widget );
460
498
461
- LCUI_API void Widget_ComputeLimitSize (LCUI_Widget w );
499
+ LCUI_API void Widget_UpdateBoxPosition (LCUI_Widget w );
500
+
501
+ LCUI_API void Widget_UpdateCanvasBox (LCUI_Widget w );
502
+
503
+ LCUI_API void Widget_UpdateBoxSize (LCUI_Widget w );
504
+
505
+ LCUI_API void Widget_SetBorderBoxSize (LCUI_Widget w , float width , float height );
462
506
463
507
LCUI_API size_t LCUIWidget_ClearTrash (void );
464
508
0 commit comments