@@ -37,7 +37,10 @@ namespace l::ui {
37
37
38
38
bool UIContainer::Accept (UIVisitor& visitor, const InputState& input, uint32_t flags) {
39
39
ContainerArea current;
40
- return Accept (visitor, input, current, flags);
40
+ if (visitor.Active (input)) {
41
+ return Accept (visitor, input, current, flags);
42
+ }
43
+ return false ;
41
44
}
42
45
43
46
bool UIContainer::Accept (UIVisitor& visitor, const InputState& input, const ContainerArea& parent, uint32_t flags) {
@@ -159,6 +162,9 @@ namespace l::ui {
159
162
}
160
163
161
164
165
+ bool UIZoom::Active (const InputState& input) {
166
+ return input.mScroll != 0 ;
167
+ }
162
168
163
169
bool UIZoom::Visit (UIContainer& container, const InputState& input, const ContainerArea& parent) {
164
170
if (input.mScroll != 0 .0f ) {
@@ -184,6 +190,10 @@ namespace l::ui {
184
190
return false ;
185
191
}
186
192
193
+ bool UIDrag::Active (const InputState& input) {
194
+ return input.mStarted && !mDragging || mDragging ;
195
+ }
196
+
187
197
bool UIDrag::Visit (UIContainer& container, const InputState& input, const ContainerArea& parent) {
188
198
if (input.mStarted && !mDragging ) {
189
199
if (input.GetLocalPos ().x >= 0 .0f && input.GetLocalPos ().y >= 0 .0f ) {
@@ -205,6 +215,10 @@ namespace l::ui {
205
215
return false ;
206
216
}
207
217
218
+ bool UIMove::Active (const InputState& input) {
219
+ return input.mStarted && !mMoving || mMoving ;
220
+ }
221
+
208
222
bool UIMove::Visit (UIContainer& container, const InputState& input, const ContainerArea& parent) {
209
223
if (input.mStarted && !mMoving ) {
210
224
if (Overlap (input.GetLocalPos (), container.GetPosition (), container.GetPositionAtSize (), parent)) {
@@ -270,25 +284,62 @@ namespace l::ui {
270
284
container.DebugLog ();
271
285
}
272
286
287
+ ImU32 color = container.GetRenderData ().mColor ;
273
288
ImVec2 pTopLeft = container.GetPosition ();
289
+ ImVec2 pCenter = container.GetPositionAtCenter ();
274
290
ImVec2 pLowRight = container.GetPositionAtSize ();
275
-
291
+ ImVec2 pSize = container. GetSize ();
276
292
ImVec2 p1 = parent.Transform (pTopLeft, input.mRootPos );
293
+ ImVec2 p12 = parent.Transform (pCenter, input.mRootPos );
277
294
ImVec2 p2 = parent.Transform (pLowRight, input.mRootPos );
278
295
279
- ImVec4 colf = ImVec4 (1 .0f , 0 .4f , 0 .4f , 1 .0f );
280
- const ImU32 col = ImColor (colf);
281
-
282
- mDrawList ->AddRect (p1, p2, col, 2 .0f , ImDrawFlags_RoundCornersAll, 2 .0f );
296
+ switch (container.GetRenderData ().mType ) {
297
+ case l::ui::UIRenderType::Rect:
298
+ mDrawList ->AddRect (p1, p2, color, 2 .0f , ImDrawFlags_RoundCornersAll, 2 .0f );
299
+ break ;
300
+ case l::ui::UIRenderType::RectFilled:
301
+ mDrawList ->AddRectFilled (p1, p2, color, 2 .0f , ImDrawFlags_RoundCornersAll);
302
+ break ;
303
+ case l::ui::UIRenderType::Triangle:
304
+ break ;
305
+ case l::ui::UIRenderType::TriangleFilled:
306
+ break ;
307
+ case l::ui::UIRenderType::Circle:
308
+ mDrawList ->AddCircle (p1, pSize.x , color, 15 , 2 .0f );
309
+ break ;
310
+ case l::ui::UIRenderType::CircleFilled:
311
+ mDrawList ->AddCircleFilled (p1, pSize.x , color, 15 );
312
+ break ;
313
+ case l::ui::UIRenderType::Polygon:
314
+ break ;
315
+ case l::ui::UIRenderType::PolygonFilled:
316
+ break ;
317
+ case l::ui::UIRenderType::Spline:
318
+ break ;
319
+ case l::ui::UIRenderType::Text:
320
+ break ;
321
+ case l::ui::UIRenderType::Texture:
322
+ break ;
323
+ }
283
324
284
- if (container.HasConfigFlag (ui::UIContainer_ResizeFlag)) {
285
- ImVec2 p3 = parent.Transform (pLowRight, ImVec2 (input.mRootPos .x - 3 .0f , input.mRootPos .y - 3 .0f ));
286
- ImVec2 p4 = parent.Transform (pLowRight, ImVec2 (input.mRootPos .x + 3 .0f , input.mRootPos .y + 3 .0f ));
287
- if (container.HasNotification (ui::UIContainer_ResizeFlag)) {
288
- p3 = parent.Transform (pLowRight, ImVec2 (input.mRootPos .x - 5 .0f , input.mRootPos .y - 5 .0f ));
289
- p4 = parent.Transform (pLowRight, ImVec2 (input.mRootPos .x + 5 .0f , input.mRootPos .y + 5 .0f ));
325
+ switch (container.GetRenderData ().mType ) {
326
+ case l::ui::UIRenderType::Rect:
327
+ case l::ui::UIRenderType::RectFilled:
328
+ case l::ui::UIRenderType::Texture:
329
+ mDrawList ->AddRect (p1, p2, color, 2 .0f , ImDrawFlags_RoundCornersAll, 2 .0f );
330
+
331
+ if (container.HasConfigFlag (ui::UIContainer_ResizeFlag)) {
332
+ ImVec2 p3 = parent.Transform (pLowRight, ImVec2 (input.mRootPos .x - 3 .0f , input.mRootPos .y - 3 .0f ));
333
+ ImVec2 p4 = parent.Transform (pLowRight, ImVec2 (input.mRootPos .x + 3 .0f , input.mRootPos .y + 3 .0f ));
334
+ if (container.HasNotification (ui::UIContainer_ResizeFlag)) {
335
+ p3 = parent.Transform (pLowRight, ImVec2 (input.mRootPos .x - 5 .0f , input.mRootPos .y - 5 .0f ));
336
+ p4 = parent.Transform (pLowRight, ImVec2 (input.mRootPos .x + 5 .0f , input.mRootPos .y + 5 .0f ));
337
+ }
338
+ mDrawList ->AddRectFilled (p3, p4, color);
290
339
}
291
- mDrawList ->AddRectFilled (p3, p4, col);
340
+ break ;
341
+ default :
342
+ break ;
292
343
}
293
344
294
345
return false ;
0 commit comments