@@ -103,6 +103,13 @@ namespace ui
103
103
margin = rf32 (0 .0f , 0 .0f , 0 .0f , 0 .0f );
104
104
padding = rf32 (0 .0f , 0 .0f , 0 .0f , 0 .0f );
105
105
106
+ gap = v2f32 (0 .0f , 0 .0f );
107
+ weight = 0 .0f ;
108
+ span = v2s32 (1 , 1 );
109
+
110
+ hspacing = Spacing::AFTER;
111
+ vspacing = Spacing::AFTER;
112
+
106
113
bg.reset ();
107
114
fg.reset ();
108
115
@@ -141,6 +148,19 @@ namespace ui
141
148
padding.LowerRightCorner = readV2F32 (is);
142
149
}
143
150
151
+ if (testShift (set_mask))
152
+ gap = clamp_vec (readV2F32 (is));
153
+ if (testShift (set_mask))
154
+ weight = std::max (readF32 (is), 0 .0f );
155
+ if (testShift (set_mask)) {
156
+ span = clamp_vec (readV2S32 (is), v2s32 (1 , 1 ));
157
+ }
158
+
159
+ if (testShift (set_mask))
160
+ hspacing = toSpacing (readU8 (is));
161
+ if (testShift (set_mask))
162
+ vspacing = toSpacing (readU8 (is));
163
+
144
164
if (testShift (set_mask))
145
165
bg.read (is);
146
166
if (testShift (set_mask))
@@ -189,25 +209,42 @@ namespace ui
189
209
}
190
210
}
191
211
192
- void Box::layout (const rf32 &parent_rect, const rf32 &parent_clip)
212
+ void Box::layout (const rf32 &parent_rect, const rf32 &parent_clip, bool sizer )
193
213
{
194
214
// First, calculate the size of the element in absolute coordinates
195
215
// based on the normalized size.
196
216
d2f32 origin_size (
197
- (m_style.rel_size .Width * parent_rect.getWidth ()) + m_style. size . Width ,
198
- (m_style.rel_size .Height * parent_rect.getHeight ()) + m_style. size . Height
217
+ (m_style.rel_size .Width * parent_rect.getWidth ()),
218
+ (m_style.rel_size .Height * parent_rect.getHeight ())
199
219
);
200
220
221
+ if (!sizer) {
222
+ // If this box is not in a sizer, then the "pos" and "size"
223
+ // attributes are absolute pixel amounts to offset the rect by.
224
+ origin_size.Width += m_style.size .Width ;
225
+ origin_size.Height += m_style.size .Height ;
226
+ } else {
227
+ // Otherwise, the "size" attribute is the minimum size of the box
228
+ // and the "pos" attribute is reserved for the sizer's use.
229
+ origin_size.Width = std::max (origin_size.Width , m_style.size .Width );
230
+ origin_size.Height = std::max (origin_size.Height , m_style.size .Height );
231
+ }
232
+
201
233
// Then, create the rect of the element relative to the origin by
202
234
// converting the normalized position absolute coordinates, while
203
235
// accounting for the anchor based on the previously calculated size.
204
236
v2f32 origin_pos (
205
- (m_style.rel_pos .X * parent_rect.getWidth ()) + m_style. pos . X -
237
+ (m_style.rel_pos .X * parent_rect.getWidth ()) -
206
238
(m_style.rel_anchor .X * origin_size.Width ),
207
- (m_style.rel_pos .Y * parent_rect.getHeight ()) + m_style. pos . Y -
239
+ (m_style.rel_pos .Y * parent_rect.getHeight ()) -
208
240
(m_style.rel_anchor .Y * origin_size.Height )
209
241
);
210
242
243
+ if (!sizer) {
244
+ origin_pos.X += m_style.pos .X ;
245
+ origin_pos.Y += m_style.pos .Y ;
246
+ }
247
+
211
248
rf32 origin_rect (origin_pos, origin_size);
212
249
213
250
// The absolute rect of the element is made by shifting the origin to
0 commit comments