Class: SwingController
- Includes:
- Observable
- Defined in:
- lib/ext/projector/projector.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize ⇒ SwingController
constructor
A new instance of SwingController.
- #motion(event) ⇒ Object
- #press(event) ⇒ Object
- #region(allocation) ⇒ Object
- #release(event) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize ⇒ SwingController
Returns a new instance of SwingController.
251 252 253 254 255 256 257 258 |
# File 'lib/ext/projector/projector.rb', line 251 def initialize @content = nil @drag = false @ratio_x = 0.01 @ratio_y = 0.01 @start_x = 0 @start_y = 0 end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
249 250 251 |
# File 'lib/ext/projector/projector.rb', line 249 def content @content end |
Instance Method Details
#motion(event) ⇒ Object
285 286 287 288 289 |
# File 'lib/ext/projector/projector.rb', line 285 def motion(event) @drag or return self swing_to(event.x, event.y) self end |
#press(event) ⇒ Object
278 279 280 281 282 283 |
# File 'lib/ext/projector/projector.rb', line 278 def press(event) @drag = true @start_x, @start_y = event.x, event.y content.begin_work self end |
#region(allocation) ⇒ Object
272 273 274 275 276 |
# File 'lib/ext/projector/projector.rb', line 272 def region(allocation) @ratio_x = 1.0 / allocation.width.to_f @ratio_y = 1.0 / allocation.height.to_f self end |
#release(event) ⇒ Object
291 292 293 294 295 296 |
# File 'lib/ext/projector/projector.rb', line 291 def release(event) swing_to(event.x, event.y) content.commit @drag = false self end |
#update ⇒ Object
266 267 268 269 270 |
# File 'lib/ext/projector/projector.rb', line 266 def update changed notify_observers self end |