Class: SwingController
- Inherits:
-
Object
- Object
- SwingController
- Includes:
- Observable
- Defined in:
- lib/ext/projector/projector.rb
Instance Attribute Summary (collapse)
-
- (Object) content
Returns the value of attribute content.
Instance Method Summary (collapse)
-
- (SwingController) initialize
constructor
A new instance of SwingController.
- - (Object) motion(event)
- - (Object) press(event)
- - (Object) region(allocation)
- - (Object) release(event)
- - (Object) update
Constructor Details
- (SwingController) initialize
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
- (Object) content
Returns the value of attribute content
249 250 251 |
# File 'lib/ext/projector/projector.rb', line 249 def content @content end |
Instance Method Details
- (Object) motion(event)
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 |
- (Object) press(event)
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 |
- (Object) region(allocation)
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 |
- (Object) release(event)
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 |
- (Object) update
266 267 268 269 270 |
# File 'lib/ext/projector/projector.rb', line 266 def update changed notify_observers self end |