Improved debug_draw to be free of element clipping rectangle, fixed up container vertical and horizontal alignment

This commit is contained in:
2026-04-15 22:06:55 -05:00
parent e572679f0b
commit a47505e7fa
2 changed files with 10 additions and 9 deletions

View File

@@ -18,7 +18,7 @@ module CyberarmEngine
@visible = !@options.key?(:visible) ? true : @options[:visible] @visible = !@options.key?(:visible) ? true : @options[:visible]
@tip = @options[:tip] || "" @tip = @options[:tip] || ""
@debug = @options[:debug] @debug = @options[:debug] || false
@debug_color = @options[:debug_color].nil? ? Gosu::Color::RED : @options[:debug_color] @debug_color = @options[:debug_color].nil? ? Gosu::Color::RED : @options[:debug_color]
@style = Style.new(options) @style = Style.new(options)
@@ -325,12 +325,10 @@ module CyberarmEngine
@border_canvas&.draw @border_canvas&.draw
render render
debug_draw if @debug
end end
def debug_draw 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 return if CyberarmEngine.const_defined?("GUI_DEBUG_ONLY_ELEMENT") && self.class == GUI_DEBUG_ONLY_ELEMENT
Gosu.draw_line( 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_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.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 end
def layout def layout

View File

@@ -90,6 +90,9 @@ module CyberarmEngine
@children.each(&:draw) @children.each(&:draw)
end end
end end
@children.each(&:debug_draw)
debug_draw
end end
def debug_draw def debug_draw
@@ -194,9 +197,9 @@ module CyberarmEngine
case styled(:v_align) case styled(:v_align)
when :center when :center
@y = parent.height / 2 - height / 2 @y = parent.y + parent.height / 2 - height / 2
when :bottom when :bottom
@y = parent.height - height @y = parent.y + parent.height - height
end end
end end
@@ -205,9 +208,9 @@ module CyberarmEngine
case styled(:h_align) case styled(:h_align)
when :center when :center
@x = parent.width / 2 - width / 2 @x = parent.x + parent.width / 2 - width / 2
when :right when :right
@x = parent.width - width @x = parent.x + parent.width - width
end end
end end