4 Commits

8 changed files with 66 additions and 4 deletions

View File

@@ -21,6 +21,14 @@ module CyberarmEngine
recalculate
end
def value
@toggle_button.value
end
def value=(bool)
@toggle_button.vlaue = bool
end
def define_label_singletons
@label.define_singleton_method(:_toggle_button) do |button|
@_toggle_button = button

View File

@@ -64,12 +64,17 @@ module CyberarmEngine
end
def recalculate
@current_position = Vector.new(@margin_left, @margin_top)
@current_position = Vector.new(@margin_left + @padding_left, @margin_top + @padding_top)
unless @visible
@width = 0
@height= 0
return
end
layout
@width = @max_width ? @max_width : (@children.map {|c| c.x + c.width + c.margin_right }.max || 0).round
@height = @max_height ? @max_height : (@children.map {|c| c.y + c.height + c.margin_bottom}.max || 0).round
@width = @max_width ? @max_width : (@children.map {|c| c.x + c.outer_width }.max || 0).round
@height = @max_height ? @max_height : (@children.map {|c| c.y + c.outer_height}.max || 0).round
# Move child to parent after positioning
@children.each do |child|

View File

@@ -56,6 +56,9 @@ module CyberarmEngine
end
def leave(sender)
unless @focus
super
end
end
def blur(sender)
@@ -77,6 +80,12 @@ module CyberarmEngine
def recalculate
super
unless @visible
@width = 0
@height= 0
return
end
@width = default(:width)
update_background
end

View File

@@ -53,6 +53,7 @@ module CyberarmEngine
# raise "#{self.class} 'padding' must be a number" unless @padding.is_a?(Numeric)
@enabled = true
@visible = true
default_events
end
@@ -122,7 +123,28 @@ module CyberarmEngine
@enabled
end
def visible?
@visible
end
def toggle
@visible = !@visible
root.recalculate
end
def show
@visible = true
root.recalculate
end
def hide
@visible = false
root.recalculate
end
def draw
return unless @visible
@background_canvas.draw
@border_canvas.draw
render

View File

@@ -31,6 +31,12 @@ module CyberarmEngine
end
def recalculate
unless @visible
@width = 0
@height= 0
return
end
@width = @image.width * @scale_x
@height = @image.height * @scale_y
end

View File

@@ -17,6 +17,12 @@ module CyberarmEngine
end
def recalculate
unless @visible
@width = 0
@height= 0
return
end
@width = @text.width.round
@height= @text.height.round

View File

@@ -38,6 +38,12 @@ module CyberarmEngine
def recalculate
super
unless @visible
@width = 0
@height= 0
return
end
@width = @text.textobject.text_width(@options[:checkmark])
update_background
end

View File

@@ -1,4 +1,4 @@
module CyberarmEngine
NAME = "InDev"
VERSION = "0.6.0"
VERSION = "0.7.1"
end