mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-15 04:32:35 +00:00
Improvements to layout recalculating, reduces need to manually force a refresh (F5)
This commit is contained in:
@@ -30,6 +30,8 @@ module CyberarmEngine
|
||||
@y = @style.y
|
||||
@z = @style.z
|
||||
|
||||
@old_width = 0
|
||||
@old_height = 0
|
||||
@width = 0
|
||||
@height = 0
|
||||
|
||||
@@ -342,6 +344,7 @@ module CyberarmEngine
|
||||
end
|
||||
|
||||
def update
|
||||
recalculate_if_size_changed
|
||||
end
|
||||
|
||||
def button_down(id)
|
||||
@@ -558,6 +561,15 @@ module CyberarmEngine
|
||||
@style.background_image_canvas.image = @style.background_image
|
||||
end
|
||||
|
||||
def recalculate_if_size_changed
|
||||
if !is_a?(ToolTip) && (@old_width != width || @old_height != height)
|
||||
root.gui_state.request_recalculate
|
||||
|
||||
@old_width = width
|
||||
@old_height = height
|
||||
end
|
||||
end
|
||||
|
||||
def root
|
||||
return self if is_root?
|
||||
|
||||
|
||||
@@ -246,6 +246,7 @@ module CyberarmEngine
|
||||
end
|
||||
|
||||
root.gui_state.request_repaint if @width != old_width || @height != old_height
|
||||
recalculate_if_size_changed
|
||||
end
|
||||
|
||||
def layout
|
||||
|
||||
@@ -93,6 +93,7 @@ module CyberarmEngine
|
||||
update_background
|
||||
|
||||
root.gui_state.request_repaint if @width != old_width || @height != old_height
|
||||
recalculate_if_size_changed
|
||||
end
|
||||
|
||||
def handle_text_wrapping(max_width)
|
||||
|
||||
@@ -78,15 +78,6 @@ module CyberarmEngine
|
||||
end
|
||||
|
||||
def update
|
||||
if @pending_recalculate_request
|
||||
Stats.frame.start_timing(:gui_recalculate)
|
||||
@root_container.recalculate
|
||||
|
||||
@pending_recalculate_request = false
|
||||
|
||||
Stats.frame.end_timing(:gui_recalculate)
|
||||
end
|
||||
|
||||
Stats.frame.start_timing(:gui_element_recalculate_requests)
|
||||
|
||||
# puts "PENDING REQUESTS: #{@pending_element_recalculate_requests.size}" if @pending_element_recalculate_requests.size.positive?
|
||||
@@ -95,6 +86,16 @@ module CyberarmEngine
|
||||
|
||||
Stats.frame.end_timing(:gui_element_recalculate_requests)
|
||||
|
||||
if @pending_recalculate_request
|
||||
Stats.frame.start_timing(:gui_recalculate)
|
||||
|
||||
@root_container.recalculate
|
||||
|
||||
@pending_recalculate_request = false
|
||||
|
||||
Stats.frame.end_timing(:gui_recalculate)
|
||||
end
|
||||
|
||||
if @pending_focus_request
|
||||
@pending_focus_request = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user