mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 13:12:34 +00:00
More adjustments to scrolling and scroll_top, added debug_draw to elements that draws a box around the element that is atop all rendered things
This commit is contained in:
@@ -18,6 +18,8 @@ module CyberarmEngine
|
||||
@visible = @options[:visible].nil? ? true : @options[:visible]
|
||||
@tip = @options[:tip] || ""
|
||||
|
||||
@debug_color = @options[:debug_color].nil? ? Gosu::Color::RED : @options[:debug_color]
|
||||
|
||||
@style = Style.new(options)
|
||||
|
||||
@root ||= nil
|
||||
@@ -160,6 +162,31 @@ module CyberarmEngine
|
||||
end
|
||||
end
|
||||
|
||||
def debug_draw
|
||||
return if 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
|
||||
)
|
||||
Gosu.draw_line(
|
||||
x + outer_width, y, @debug_color,
|
||||
x + outer_width, y + outer_height, @debug_color,
|
||||
Float::INFINITY
|
||||
)
|
||||
Gosu.draw_line(
|
||||
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, @debug_color,
|
||||
Float::INFINITY
|
||||
)
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
|
||||
@@ -60,30 +60,13 @@ module CyberarmEngine
|
||||
Gosu.clip_to(@x, @y, width, height) do
|
||||
@children.each(&:draw)
|
||||
end
|
||||
end
|
||||
|
||||
if false # DEBUG
|
||||
Gosu.flush
|
||||
def debug_draw
|
||||
super
|
||||
|
||||
Gosu.draw_line(
|
||||
x, y, Gosu::Color::RED,
|
||||
x + outer_width, y, Gosu::Color::RED,
|
||||
Float::INFINITY
|
||||
)
|
||||
Gosu.draw_line(
|
||||
x + outer_width, y, Gosu::Color::RED,
|
||||
x + outer_width, y + outer_height, Gosu::Color::RED,
|
||||
Float::INFINITY
|
||||
)
|
||||
Gosu.draw_line(
|
||||
x + outer_width, y + outer_height, Gosu::Color::RED,
|
||||
x, y + outer_height, Gosu::Color::RED,
|
||||
Float::INFINITY
|
||||
)
|
||||
Gosu.draw_line(
|
||||
x, outer_height, Gosu::Color::RED,
|
||||
x, y, Gosu::Color::RED,
|
||||
Float::INFINITY
|
||||
)
|
||||
@children.each do |child|
|
||||
child.debug_draw
|
||||
end
|
||||
end
|
||||
|
||||
@@ -206,8 +189,6 @@ module CyberarmEngine
|
||||
def mouse_wheel_up(sender, x, y)
|
||||
return unless @style.scroll
|
||||
|
||||
return unless height < scroll_height
|
||||
|
||||
if @scroll_position.y < 0
|
||||
@scroll_position.y += @scroll_speed
|
||||
@scroll_position.y = 0 if @scroll_position.y > 0
|
||||
@@ -238,7 +219,12 @@ module CyberarmEngine
|
||||
def scroll_top=(n)
|
||||
n = 0 if n <= 0
|
||||
@scroll_position.y = -n
|
||||
|
||||
if max_scroll_height.positive?
|
||||
@scroll_position.y = -max_scroll_height if @scroll_position.y.abs > max_scroll_height
|
||||
else
|
||||
@scroll_position.y = 0
|
||||
end
|
||||
end
|
||||
|
||||
def value
|
||||
|
||||
@@ -55,6 +55,12 @@ module CyberarmEngine
|
||||
Gosu.flush
|
||||
@tip.draw
|
||||
end
|
||||
|
||||
if defined?(GUI_DEBUG)
|
||||
Gosu.flush
|
||||
|
||||
@root_container.debug_draw
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@@ -64,6 +64,10 @@ module CyberarmEngine
|
||||
border_radius: 0
|
||||
},
|
||||
|
||||
Container: { # < Element (Base class for Stack and Flow)
|
||||
debug_color: Gosu::Color::YELLOW
|
||||
},
|
||||
|
||||
Button: { # < Label
|
||||
margin: 1,
|
||||
padding: 4,
|
||||
|
||||
Reference in New Issue
Block a user