Performance optimization & bugfix

Only depth sort if we need to.
Fixed a bug where if you left the highest ancestor of a slider and re-entered it would still be sliding.
This commit is contained in:
2025-05-30 22:22:09 -04:00
parent c4ada58e0c
commit 7ac0436a1f
3 changed files with 35 additions and 3 deletions

View File

@@ -81,6 +81,9 @@ namespace JUI {
std::vector<Widget*> GetDescendants();
/// Returns a flat list of all nodes that are higher in the hierarchy list.
std::vector<Widget*> GetAncestors();
/// @returns the highest ancestor which is not the scene root.
Widget* GetHighestNonRootAncestor();
/// Returns the nodes directly descendant to this widget.
std::vector<Widget*> GetChildren();
@@ -123,7 +126,7 @@ namespace JUI {
/// @note The range of valid values is -MAX_INT to MAX_INT.
/// @note This does not manipulate the OpenGL Z buffer, rather, when rendering,
/// we sort the direct children of a widget widget and render.
int ZIndex() const;
[[nodiscard]] int ZIndex() const;
/// Sets this widgets z-index.
/// @see ZIndex().
@@ -384,6 +387,7 @@ namespace JUI {
Widget* next = nullptr;
Widget* prev = nullptr;
int zindex = 0;
bool z_dirty = false;
int layout_order = 0;
Vector2 viewport_size{0,0};