mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2026-05-06 16:08:16 +00:00
Improved debug_draw to be free of element clipping rectangle, fixed up container vertical and horizontal alignment
This commit is contained in:
@@ -18,7 +18,7 @@ module CyberarmEngine
|
||||
@visible = !@options.key?(:visible) ? true : @options[:visible]
|
||||
@tip = @options[:tip] || ""
|
||||
|
||||
@debug = @options[:debug]
|
||||
@debug = @options[:debug] || false
|
||||
@debug_color = @options[:debug_color].nil? ? Gosu::Color::RED : @options[:debug_color]
|
||||
|
||||
@style = Style.new(options)
|
||||
@@ -325,12 +325,10 @@ module CyberarmEngine
|
||||
@border_canvas&.draw
|
||||
|
||||
render
|
||||
|
||||
debug_draw if @debug
|
||||
end
|
||||
|
||||
def debug_draw
|
||||
return if @debug == false # allow elements to opt out of debug drawing, makes debugging some things easier.
|
||||
return unless @debug # allow elements to opt out of debug drawing, makes debugging some things easier.
|
||||
return if CyberarmEngine.const_defined?("GUI_DEBUG_ONLY_ELEMENT") && self.class == GUI_DEBUG_ONLY_ELEMENT
|
||||
|
||||
Gosu.draw_line(
|
||||
@@ -622,7 +620,7 @@ module CyberarmEngine
|
||||
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
|
||||
root.gui_state.active_menu.recalculate if root.gui_state.active_menu && root.gui_state.active_menu.parent == self
|
||||
end
|
||||
|
||||
def layout
|
||||
|
||||
@@ -90,6 +90,9 @@ module CyberarmEngine
|
||||
@children.each(&:draw)
|
||||
end
|
||||
end
|
||||
|
||||
@children.each(&:debug_draw)
|
||||
debug_draw
|
||||
end
|
||||
|
||||
def debug_draw
|
||||
@@ -194,9 +197,9 @@ module CyberarmEngine
|
||||
|
||||
case styled(:v_align)
|
||||
when :center
|
||||
@y = parent.height / 2 - height / 2
|
||||
@y = parent.y + parent.height / 2 - height / 2
|
||||
when :bottom
|
||||
@y = parent.height - height
|
||||
@y = parent.y + parent.height - height
|
||||
end
|
||||
end
|
||||
|
||||
@@ -205,9 +208,9 @@ module CyberarmEngine
|
||||
|
||||
case styled(:h_align)
|
||||
when :center
|
||||
@x = parent.width / 2 - width / 2
|
||||
@x = parent.x + parent.width / 2 - width / 2
|
||||
when :right
|
||||
@x = parent.width - width
|
||||
@x = parent.x + parent.width - width
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user