mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-15 12:42:34 +00:00
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:
@@ -194,7 +194,9 @@ module CyberarmEngine
|
||||
if @scroll_position.y < 0
|
||||
@scroll_position.y += @scroll_speed
|
||||
@scroll_position.y = 0 if @scroll_position.y > 0
|
||||
recalculate
|
||||
# recalculate
|
||||
root.gui_state.request_recalculate_for(self)
|
||||
|
||||
|
||||
return :handled
|
||||
end
|
||||
@@ -208,7 +210,9 @@ module CyberarmEngine
|
||||
if @scroll_position.y.abs < max_scroll_height
|
||||
@scroll_position.y -= @scroll_speed
|
||||
@scroll_position.y = -max_scroll_height if @scroll_position.y.abs > max_scroll_height
|
||||
recalculate
|
||||
# recalculate
|
||||
root.gui_state.request_recalculate_for(self)
|
||||
|
||||
|
||||
return :handled
|
||||
end
|
||||
|
||||
@@ -47,7 +47,7 @@ module CyberarmEngine
|
||||
end
|
||||
|
||||
def clicked_left_mouse_button(_sender, _x, _y)
|
||||
@block&.call(self.value) if @enabled
|
||||
# @block&.call(self.value) if @enabled
|
||||
|
||||
:handled
|
||||
end
|
||||
@@ -56,6 +56,8 @@ module CyberarmEngine
|
||||
@menu.clear
|
||||
|
||||
@items.each do |item|
|
||||
next if item == self.value
|
||||
|
||||
btn = Button.new(
|
||||
item,
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user