Broke container layout some more

This commit is contained in:
2019-03-01 22:22:44 -06:00
parent 478c8498f3
commit cfad5eafab
7 changed files with 26 additions and 16 deletions

View File

@@ -11,9 +11,18 @@ module CyberarmEngine
def enter(sender) def enter(sender)
@background = @options[:interactive_hover_background] @background = @options[:interactive_hover_background]
@text.color = @options[:interactive_stroke]
end
def holding_left_mouse_button(sender, x, y)
@background = @options[:interactive_active_background]
@text.color = @options[:interactive_active_stroke] @text.color = @options[:interactive_active_stroke]
end end
def released_left_mouse_button(sender,x, y)
enter(sender)
end
def leave(sender) def leave(sender)
@background = @options[:interactive_background] @background = @options[:interactive_background]
@text.color = @options[:interactive_stroke] @text.color = @options[:interactive_stroke]

View File

@@ -82,6 +82,9 @@ module CyberarmEngine
@current_position = Vector.new(@margin_left + @x, @margin_top + @y) @current_position = Vector.new(@margin_left + @x, @margin_top + @y)
layout layout
@width = @max_width ? @max_width : (@children.map {|c| c.x + c.width }.max + @margin_right || 0)
@height = @max_height ? @max_height : (@children.map {|c| c.y + c.height}.max + @margin_bottom || 0)
end end
def layout def layout
@@ -101,7 +104,7 @@ module CyberarmEngine
element.y = @current_position.y element.y = @current_position.y
@current_position.x += element.width + element.margin_right @current_position.x += element.width + element.margin_right
@current_position.x = @x if @current_position.x >= max_width @current_position.x = @margin_left + @x if @current_position.x >= max_width
end end
def move_to_next_line(element) def move_to_next_line(element)

View File

@@ -4,17 +4,16 @@ module CyberarmEngine
def layout def layout
@children.each do |child| @children.each do |child|
child.recalculate
if fits_on_line?(child) if fits_on_line?(child)
position_on_current_line(child) position_on_current_line(child)
else else
@current_position.x = @margin_left + @x
move_to_next_line(child) move_to_next_line(child)
end end
child.recalculate
end end
@width = @max_width ? @max_width : (@children.map {|c| c.x + c.width }.max || 0)
@height = @max_height ? @max_height : (@children.map {|c| c.y + c.height}.max || 0)
end end
end end
end end

View File

@@ -90,8 +90,10 @@ module CyberarmEngine
end end
def redirect_released_mouse_button(button) def redirect_released_mouse_button(button)
@mouse_over.publish(:"released_#{button}_mouse_button", window.mouse_x, window.mouse_y) if @mouse_over if @mouse_over
@mouse_over.publish(:"clicked_#{button}_mouse_button", window.mouse_x, window.mouse_y) if @mouse_over == @mouse_down_on[button] @mouse_over.publish(:"released_#{button}_mouse_button", window.mouse_x, window.mouse_y)
@mouse_over.publish(:"clicked_#{button}_mouse_button", window.mouse_x, window.mouse_y) if @mouse_over == @mouse_down_on[button]
end
@mouse_down_position[button] = nil @mouse_down_position[button] = nil
@mouse_down_on[button] = nil @mouse_down_on[button] = nil

View File

@@ -27,8 +27,8 @@ module CyberarmEngine
@width = @text.width @width = @text.width
@height= @text.height @height= @text.height
@text.x = @x + @padding_left @text.x = @padding_left + @x
@text.y = @y + @padding_top @text.y = @padding_top + @y
@text.z = @z + 3 @text.z = @z + 3
end end

View File

@@ -4,13 +4,10 @@ module CyberarmEngine
def layout def layout
@children.each do |child| @children.each do |child|
move_to_next_line(child)
child.recalculate child.recalculate
end
@width = @max_width ? @max_width : (@children.map {|c| c.x + c.width }.max || 0) move_to_next_line(child)
@height = @max_height ? @max_height : (@children.map {|c| c.y + c.height}.max || 0) end
end end
end end
end end

View File

@@ -15,7 +15,7 @@ module CyberarmEngine
background: Gosu::Color::NONE, background: Gosu::Color::NONE,
checkmark: "", # √ checkmark: "", # √
margin: 0, margin: 10,
padding: 5, padding: 5,
element_background: Gosu::Color.rgb(12,12,12), element_background: Gosu::Color.rgb(12,12,12),