Class: Crimson::Resizer

Inherits:
Object show all
Defined in:
lib/crimson/widgets/resizer.rb

Direct Known Subclasses

BottomResizer, LeftResizer, RightResizer, TopResizer

Instance Attribute Summary collapse

Attributes inherited from Object

#added_children, #event_handlers, #id, #node, #removed_children, #tag

Attributes inherited from Model

#local, #observers, #revision_number, #revisions

Instance Method Summary collapse

Methods inherited from Object

#==, #add, #breadth_each, #children, #commit_tree!, #eql?, #find_descendant, #hash, #hidden?, #hide, #inspect, #move, #on, #on_event, #parent, #parent=, #postordered_each, #preordered_each, #remove, #root, #show, #shown?, #siblings, #to_s, #un

Methods inherited from Model

#add_observer, #apply_changes!, #changed?, #changes, #commit!, #master, #modify, #new_changes, #notify_observers, #reload!, #remove_observer, #rollback!

Constructor Details

#initialize(cursor) ⇒ Resizer

Returns a new instance of Resizer.



9
10
11
12
13
14
15
16
# File 'lib/crimson/widgets/resizer.rb', line 9

def initialize(cursor)
  super(:div)

  @cursor = cursor
  self.style = {}

  enable
end

Instance Attribute Details

#cursorObject (readonly)

Returns the value of attribute cursor.



7
8
9
# File 'lib/crimson/widgets/resizer.rb', line 7

def cursor
  @cursor
end

Instance Method Details

#disableObject



23
24
25
26
# File 'lib/crimson/widgets/resizer.rb', line 23

def disable
  style.cursor = "auto"
  un(:mousedown, method(:on_mousedown))
end

#enableObject



18
19
20
21
# File 'lib/crimson/widgets/resizer.rb', line 18

def enable
  style.cursor = cursor
  on(:mousedown, method(:on_mousedown))
end

#on_mousedown(_data) ⇒ Object



28
29
30
31
# File 'lib/crimson/widgets/resizer.rb', line 28

def on_mousedown(_data)
  parent.parent.on(:mousemove, method(:on_mousemove))
  parent.parent.on(:mouseup, method(:on_mouseup))
end

#on_mouseup(_data) ⇒ Object



33
34
35
36
# File 'lib/crimson/widgets/resizer.rb', line 33

def on_mouseup(_data)
  parent.parent.un(:mousemove, method(:on_mousemove))
  parent.parent.un(:mouseup, method(:on_mouseup))
end