Containers that need to be recalculated but will not affect their current size can request to have themselves directly recalculated on the next update (fixes scrolling triggering many unneed recalculations), list_box now excludes the currently selected item from the menu, probably fixed list_box callback being called twice instead of the correct once.

This commit is contained in:
2021-11-15 10:17:49 -06:00
parent d2bf406d29
commit 0aa9b59316
3 changed files with 21 additions and 3 deletions

View File

@@ -25,6 +25,7 @@ module CyberarmEngine
@last_mouse_pos = nil
@dragging_element = nil
@pending_recalculate_request = false
@pending_element_recalculate_requests = []
@menu = nil
@min_drag_distance = 0
@@ -56,6 +57,7 @@ module CyberarmEngine
if @tip.value.length.positive?
Gosu.flush
@tip.draw
end
@@ -73,8 +75,11 @@ module CyberarmEngine
@root_container.recalculate
@pending_recalculate_request = false
@pending_element_recalculate_requests.clear # GUI has already been recalculated
end
@pending_element_recalculate_requests.each(&:recalculate)
if @pending_focus_request
@pending_focus_request = false
@@ -231,6 +236,13 @@ module CyberarmEngine
@pending_recalculate_request = true
end
def request_recalculate_for(element)
# element is already queued
return if @pending_element_recalculate_requests.detect { |e| e == element }
@pending_element_recalculate_requests << element
end
def request_focus(element)
@pending_focus_request = true
@pending_focus_element = element