Class: Rabbit::CursorManager

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

Constant Summary collapse

@@cursors =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCursorManager

Returns a new instance of CursorManager.



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

def initialize
  @stocks = {}
  @current = nil
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



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

def current
  @current
end

Class Method Details

.cursorsObject



22
23
24
25
26
27
28
# 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

Instance Method Details

#keep(name) ⇒ Object



37
38
39
40
# File 'lib/rabbit/cursor-manager.rb', line 37

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

#restore(drawable, name) ⇒ Object



42
43
44
45
46
47
48
49
# 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) ⇒ Object



51
52
53
# File 'lib/rabbit/cursor-manager.rb', line 51

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