diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-30 12:16:29 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-30 12:16:29 +0200 |
commit | bc88dca176cef6b8943ded58c68a60f7c127baea (patch) | |
tree | fc50148cfbb8ef5c80ee714e38dc0d0366084968 | |
parent | 56b13b6865475c7a42ddd5337402552b60476513 (diff) | |
parent | 749db002276d49c472fb48fab17aac72483f15ab (diff) | |
download | redot-engine-bc88dca176cef6b8943ded58c68a60f7c127baea.tar.gz |
Merge pull request #81155 from garychia/separator_priority
ItemList: Draw separators before selected style boxes
-rw-r--r-- | scene/gui/item_list.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index cff07c6e1c..23b516192e 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1092,6 +1092,32 @@ void ItemList::_notification(int p_what) { // Define a visible frame to check against and optimize drawing. const Rect2 clip(-base_ofs, size); + // Do a binary search to find the first separator that is below clip_position.y. + int first_visible_separator = 0; + { + int lo = 0; + int hi = separators.size(); + while (lo < hi) { + const int mid = (lo + hi) / 2; + if (separators[mid] < clip.position.y) { + lo = mid + 1; + } else { + hi = mid; + } + } + first_visible_separator = lo; + } + + // Draw visible separators. + for (int i = first_visible_separator; i < separators.size(); i++) { + if (separators[i] > clip.position.y + clip.size.y) { + break; // done + } + + const int y = base_ofs.y + separators[i]; + draw_line(Vector2(theme_cache.panel_style->get_margin(SIDE_LEFT), y), Vector2(width, y), theme_cache.guide_color); + } + // Do a binary search to find the first item whose rect reaches below clip.position.y. int first_item_visible; { @@ -1310,32 +1336,6 @@ void ItemList::_notification(int p_what) { draw_style_box(cursor, r); } } - - // Do a binary search to find the first separator that is below clip_position.y. - int first_visible_separator = 0; - { - int lo = 0; - int hi = separators.size(); - while (lo < hi) { - const int mid = (lo + hi) / 2; - if (separators[mid] < clip.position.y) { - lo = mid + 1; - } else { - hi = mid; - } - } - first_visible_separator = lo; - } - - // Draw visible separators. - for (int i = first_visible_separator; i < separators.size(); i++) { - if (separators[i] > clip.position.y + clip.size.y) { - break; // done - } - - const int y = base_ofs.y + separators[i]; - draw_line(Vector2(theme_cache.panel_style->get_margin(SIDE_LEFT), y), Vector2(width, y), theme_cache.guide_color); - } } break; } } |