lib/cyberarm_engine/ui/element.rb in cyberarm_engine-0.6.0 vs lib/cyberarm_engine/ui/element.rb in cyberarm_engine-0.7.0

- old
+ new

@@ -51,10 +51,11 @@ raise "#{self.class} 'options' must be a Hash" unless @options.is_a?(Hash) # raise "#{self.class} 'padding' must be a number" unless @padding.is_a?(Numeric) @enabled = true + @visible = true default_events end def set_background(background) @@ -120,10 +121,31 @@ def enabled? @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 end \ No newline at end of file