class Gosuplus::GUI::Toggleable

Attributes

state[R]

Public Class Methods

new(position, image, checkbox, checkmark, input_handler, key_id) click to toggle source
Calls superclass method Gosuplus::GUI::Button::new
# File lib/Gosuplus/gui/toggleable.rb, line 5
def initialize(position, image, checkbox, checkmark, input_handler, key_id)
  super(position, image, input_handler, key_id)

  @checkbox = Icon.new(checkbox, position)
  @checkmark = Icon.new(checkmark, position)
  @checkbox.center(@icon)
  @checkmark.center(@icon)
  @state = :checked
end

Public Instance Methods

draw() click to toggle source
Calls superclass method Gosuplus::GUI::Button#draw
# File lib/Gosuplus/gui/toggleable.rb, line 15
def draw
  super
  ButtonRenderer.draw(@checkbox)
  ButtonRenderer.draw(@checkmark) if @state == :checked
end
next_state() click to toggle source
# File lib/Gosuplus/gui/toggleable.rb, line 26
def next_state; @state = @state == :checked ? :unchecked : :checked; end
set_checkbox(image) click to toggle source
# File lib/Gosuplus/gui/toggleable.rb, line 27
def set_checkbox(image); @checkbox = image; end
set_checker(image) click to toggle source
# File lib/Gosuplus/gui/toggleable.rb, line 28
def set_checker(image); @checker = image; end
update(x, y) click to toggle source
Calls superclass method Gosuplus::GUI::Button#update
# File lib/Gosuplus/gui/toggleable.rb, line 21
def update(x, y)
  super(x, y)
  next_state if @active
end