Skip to content

Instantly share code, notes, and snippets.

@Groogy
Last active November 4, 2017 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Groogy/7f083963727f21b6d26b6874062e3a67 to your computer and use it in GitHub Desktop.
Save Groogy/7f083963727f21b6d26b6874062e3a67 to your computer and use it in GitHub Desktop.
class Boleite::GUI
abstract class Widget
Cute.signal mouse_enter
Cute.signal mouse_leave
Cute.signal mouse_over(x : Float64, y : Float64)
Cute.signal left_click(x : Float64, y : Float64)
Cute.signal right_click(x : Float64, y : Float64)
Cute.signal key_pressed
Cute.signal key_released
Cute.signal text_entered
Cute.signal state_change
Cute.signal pulse
def initialize
state_change.on &->on_state_change
mouse_enter.on &->on_mouse_enter
mouse_leave.on &->on_mouse_leave
@input.register_instance WidgetMouseEnter.new(self), ->{ mouse_enter.emit }
@input.register_instance WidgetMouseLeave.new(self), ->{ mouse_leave.emit }
@input.register_instance WidgetMouseOver.new(self), ->(x : Float64, y : Float64) { mouse_over.emit x, y }
@input.register_instance WidgetMouseClick.new(self, Mouse::Left), ->(x : Float64, y : Float64) { left_click.emit x, y }
@input.register_instance WidgetMouseClick.new(self, Mouse::Right), ->(x : Float64, y : Float64) { right_click.emit x, y }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment