StOneDOes Posted February 3, 2023 Share Posted February 3, 2023 Is there a way to reorder the depth of UI widgets such that I can choose what should appear at the frontmost of the view? At the moment it seems that widgets render in the order they were created. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted February 3, 2023 Share Posted February 3, 2023 I don't think there is as Josh has said that the depth value can change overtime. You can read the depth value of a widget with Widget::z but this is a temporary member so I wouldn't rely on it. Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted February 3, 2023 Solution Share Posted February 3, 2023 WIdget::SetParent has an optional position parameter for this purpose: https://www.ultraengine.com/learn/Widget_SetParent?lang=cpp "Position" here means position in the child list, not the sprite depth value. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
StOneDOes Posted February 3, 2023 Author Share Posted February 3, 2023 Perfect, thank you. Can you please add a function that returns the element count of Widget::m_kids ? Because that member is protected. There is a Widget::CountChildren() but it is commented out. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 3, 2023 Share Posted February 3, 2023 widget->kids.size() 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
StOneDOes Posted February 3, 2023 Author Share Posted February 3, 2023 Oh what!? I swear my visual studio is broken. Ctrl+F found once occurrence of "kids" the first time ... but now I can see it lol. Thanks. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted February 4, 2023 Share Posted February 4, 2023 The kids / m_kids thing is a trick that allows me to make read-only class members in C++: class foo { private: int m_value; public: const int& value; foo(int n) : value(m_value) { m_value = n; } } foo f(3); int a = f.value;// this is okay f.value = 2;// this won't compile 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
StOneDOes Posted February 4, 2023 Author Share Posted February 4, 2023 Interesting. But it seems like more work than just a simple const accessor function? 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.