class Gesture

Constants

DEFAULT_BACK_RGBA
DEFAULT_CURRENT_RGBA
DEFAULT_LINE_RGBA
DEFAULT_NEXT_RGBA

Public Class Methods

new(conf={}) click to toggle source
Calls superclass method
# File gtk2/sample/misc/mouse-gesture.rb, line 139
def initialize(conf={})
  super()
  set_visible_window(false)
  conf ||= {}
  @back_rgba = conf[:back_rgba] || DEFAULT_BACK_RGBA
  @line_rgba = conf[:line_rgba] || DEFAULT_LINE_RGBA
  @next_rgba = conf[:next_rgba] || DEFAULT_NEXT_RGBA
  @current_rgba = conf[:current_rgba] || DEFAULT_CURRENT_RGBA
  @processor = GestureProcessor.new(conf[:threshold],
                                    conf[:skew_threshold_angle])
  @actions = []
  set_expose_event
  set_motion_notify_event
  set_button_release_event
end

Public Instance Methods

add_action(sequence, action=Proc.new) click to toggle source
# File gtk2/sample/misc/mouse-gesture.rb, line 155
def add_action(sequence, action=Proc.new)
  invalid_motion = sequence.find do |motion|
    not @processor.available_motion?(motion)
  end
  raise "invalid motion: #{invalid_motion}" if invalid_motion
  @actions << [sequence, action]
end
start(widget, button, x, y, base_x, base_y) click to toggle source
# File gtk2/sample/misc/mouse-gesture.rb, line 163
def start(widget, button, x, y, base_x, base_y)
  Gtk.grab_add(self)
  @widget = widget
  @button = button
  @processor.start(x, y)
  @base_x = base_x
  @base_y = base_y
  @cr = window.create_cairo_context
  @cr.set_source_rgba(@line_rgba)
  @cr.move_to(x, y)
end