Class: Rabbit::CursorManager

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbit/cursor-manager.rb

Constant Summary collapse

@@blank_cursor =
nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCursorManager

Returns a new instance of CursorManager.



10
11
12
13
14
15
16
# File 'lib/rabbit/cursor-manager.rb', line 10

def initialize
  @stocks = {}
  @current = nil
  @blank_cursor = blank_cursor
  @pencil_cursor = Gdk::Cursor.new(Gdk::Cursor::PENCIL)
  @hand_cursor = Gdk::Cursor.new(Gdk::Cursor::HAND1)
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



9
10
11
# File 'lib/rabbit/cursor-manager.rb', line 9

def current
  @current
end

Instance Method Details

#keep(name) ⇒ Object



18
19
20
21
# File 'lib/rabbit/cursor-manager.rb', line 18

def keep(name)
  @stocks[name] ||= []
  @stocks[name].push(@current)
end

#restore(drawable, name) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/rabbit/cursor-manager.rb', line 23

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) ⇒ Object



32
33
34
# File 'lib/rabbit/cursor-manager.rb', line 32

def update(drawable, type)
  drawable.cursor = type_to_cursor(type)
end