# File gtk2/sample/misc/mouse-gesture.rb, line 25 def initialize(threshold=nil, skew_threshold_angle=nil) @threshold = threshold || DEFAULT_THRESHOLD @skew_threshold_angle = skew_threshold_angle @skew_threshold_angle ||= DEFAULT_SKEW_THRESHOLD_ANGLE reset end
# File gtk2/sample/misc/mouse-gesture.rb, line 38 def available_motion?(motion) MOTIONS.include?(motion) end
# File gtk2/sample/misc/mouse-gesture.rb, line 78 def position [@x, @y] end
# File gtk2/sample/misc/mouse-gesture.rb, line 68 def reset @started = false @x = @y = -1 @motions = [] end
# File gtk2/sample/misc/mouse-gesture.rb, line 42 def start(x, y) @prev_x = @x = x @prev_y = @y = y @started = true @motions = [] end
# File gtk2/sample/misc/mouse-gesture.rb, line 32 def started? @started end
# File gtk2/sample/misc/mouse-gesture.rb, line 74 def to_a @motions end
# File gtk2/sample/misc/mouse-gesture.rb, line 49 def update_position(x, y) mx = x - @prev_x my = y - @prev_y motion = judge_motion(mx, my) if motion @prev_x = @x = x @prev_y = @y = y if @motions.last == motion false else @motions << motion true end else false end end