class Rabbit::CursorManager

Attributes

current[RW]

Public Class Methods

cursors() click to toggle source
# File lib/rabbit/cursor-manager.rb, line 22
def cursors
  @@cursors ||= {
    :blank  => Gdk::Cursor.new(:blank_cursor),
    :pencil => Gdk::Cursor.new(:pencil),
    :hand   => Gdk::Cursor.new(:hand1),
  }
end
new() click to toggle source
# File lib/rabbit/cursor-manager.rb, line 32
def initialize
  @stocks = {}
  @current = nil
end

Public Instance Methods

keep(name) click to toggle source
# File lib/rabbit/cursor-manager.rb, line 37
def keep(name)
  @stocks[name] ||= []
  @stocks[name].push(@current)
end
restore(drawable, name) click to toggle source
# File lib/rabbit/cursor-manager.rb, line 42
def restore(drawable, name)
  if name.nil?
    type = @current
  else
    type = @stocks[name].pop
  end
  drawable.cursor = type_to_cursor(type)
end
update(drawable, type) click to toggle source
# File lib/rabbit/cursor-manager.rb, line 51
def update(drawable, type)
  drawable.cursor = type_to_cursor(type)
end

Private Instance Methods

type_to_cursor(type) click to toggle source
# File lib/rabbit/cursor-manager.rb, line 56
def type_to_cursor(type)
  if type.nil?
    nil
  else
    cursor = self.class.cursors[type]
    if cursor.nil?
      raise UnknownCursorTypeError.new(type)
    end
    cursor
  end
end