Class: Reight::SoundEditor::Brush

Inherits:
Tool show all
Defined in:
lib/reight/app/sound/brush.rb

Instance Attribute Summary

Attributes inherited from Tool

#app

Attributes inherited from Button

#icon, #label, #name

Instance Method Summary collapse

Methods inherited from Tool

#canvas, #canvas_moved, #history, #name, #pick_tone

Methods inherited from Button

#click, #disabled?, #disabled_icon, #draw, #enabled?, #hover, #pressed, #pressing?, #released, #sprite

Methods included from HasHelp

#help, #name, #set_help

Methods included from Hookable

#hook

Methods included from Activatable

#activated, #activated!, #active=, #active?

Constructor Details

#initialize(app, &block) ⇒ Brush

Returns a new instance of Brush.



3
4
5
6
# File 'lib/reight/app/sound/brush.rb', line 3

def initialize(app, &block)
  super app, icon: app.icon(1, 2, 8), &block
  set_help left: name, right: 'Pick Tone'
end

Instance Method Details

#brush(x, y, button) ⇒ Object



8
9
10
# File 'lib/reight/app/sound/brush.rb', line 8

def brush(x, y, button)
  canvas.put x, y
end

#canvas_clicked(x, y, button) ⇒ Object



28
29
30
# File 'lib/reight/app/sound/brush.rb', line 28

def canvas_clicked(x, y, button)
  pick_tone x, y if button == RIGHT
end

#canvas_dragged(x, y, button) ⇒ Object



23
24
25
26
# File 'lib/reight/app/sound/brush.rb', line 23

def canvas_dragged(x, y, button)
  return unless button == LEFT
  brush x, y, button
end

#canvas_pressed(x, y, button) ⇒ Object



12
13
14
15
16
# File 'lib/reight/app/sound/brush.rb', line 12

def canvas_pressed(x, y, button)
  return unless button == LEFT
  canvas.begin_editing
  brush x, y, button
end

#canvas_released(x, y, button) ⇒ Object



18
19
20
21
# File 'lib/reight/app/sound/brush.rb', line 18

def canvas_released(x, y, button)
  return unless button == LEFT
  canvas.end_editing
end