lib/cyberarm_engine/ui/element.rb in cyberarm_engine-0.24.2 vs lib/cyberarm_engine/ui/element.rb in cyberarm_engine-0.24.3
- old
+ new
@@ -178,13 +178,11 @@
@style_event = event
return if self.is_a?(ToolTip)
- if old_width != width || old_height != height
- root.gui_state.request_recalculate
- end
+ root.gui_state.request_recalculate if old_width != width || old_height != height
stylize
end
def default_events
@@ -195,10 +193,14 @@
event(:"holding_#{button}_mouse_button")
end
event(:mouse_wheel_up)
event(:mouse_wheel_down)
+ event(:scroll_jump_to_top)
+ event(:scroll_jump_to_end)
+ event(:scroll_page_up)
+ event(:scroll_page_down)
event(:enter)
event(:hover)
event(:leave)
@@ -327,12 +329,11 @@
render
end
def debug_draw
- # FIXME
- return# if const_defined?(GUI_DEBUG_ONLY_ELEMENT) && self.class == GUI_DEBUG_ONLY_ELEMENT
+ return if CyberarmEngine.const_defined?("GUI_DEBUG_ONLY_ELEMENT") && self.class == GUI_DEBUG_ONLY_ELEMENT
Gosu.draw_line(
x, y, @debug_color,
x + outer_width, y, @debug_color,
Float::INFINITY
@@ -346,11 +347,11 @@
x + outer_width, y + outer_height, @debug_color,
x, y + outer_height, @debug_color,
Float::INFINITY
)
Gosu.draw_line(
- x, outer_height, @debug_color,
+ x, y + outer_height, @debug_color,
x, y, @debug_color,
Float::INFINITY
)
end
@@ -571,11 +572,11 @@
@style.background_image_canvas.image = @style.background_image
end
def recalculate_if_size_changed
- if !is_a?(ToolTip) && (@old_width != width || @old_height != height)
+ if @parent && !is_a?(ToolTip) && (@old_width != width || @old_height != height)
root.gui_state.request_recalculate
@old_width = width
@old_height = height
end
@@ -622,10 +623,22 @@
:handled
end
def recalculate
- raise "#{self.class}#recalculate was not overridden!"
+ old_width = width
+ old_height = height
+
+ stylize
+ layout
+
+ root.gui_state.request_recalculate if @parent && !is_a?(ToolTip) && (width != old_width || height != old_height)
+ root.gui_state.request_repaint if width != old_width || height != old_height
+
+ root.gui_state.menu.recalculate if root.gui_state.menu && root.gui_state.menu.parent == self
+ end
+
+ def layout
end
def reposition
end