Class: Reight::SoundEditor
- Inherits:
-
App
- Object
- App
- Reight::SoundEditor
show all
- Defined in:
- lib/reight/app/sound/editor.rb
Defined Under Namespace
Classes: Brush, Canvas, Eraser, Tool
Constant Summary
Constants inherited
from App
App::BUTTON_SIZE, App::CHIPS_WIDTH, App::INDEX_SIZE, App::NAVIGATOR_HEIGHT, App::PALETTE_COLORS, App::SCREEN_HEIGHT, App::SCREEN_WIDTH, App::SPACE
Instance Attribute Summary
Attributes inherited from App
#project
Instance Method Summary
collapse
Methods inherited from App
#activated, #active?, #control_change, #deactivated, #double_clicked, #flash, #group, #history, #icon, #initialize, #inspect, #key_released, #key_typed, #label, #mouse_clicked, #mouse_dragged, #mouse_moved, #mouse_pressed, #mouse_released, #mouse_wheel, #note_pressed, #note_released, #pressing?, #touch_ended, #touch_moved, #touch_started, #window_moved
Constructor Details
This class inherits a constructor from Reight::App
Instance Method Details
#canvas ⇒ Object
6
7
8
|
# File 'lib/reight/app/sound/editor.rb', line 6
def canvas()
@canvas ||= Canvas.new self
end
|
#draw ⇒ Object
18
19
20
21
22
|
# File 'lib/reight/app/sound/editor.rb', line 18
def draw()
background 200
sprite(*sprites)
super
end
|
#key_pressed ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/reight/app/sound/editor.rb', line 24
def key_pressed()
super
case key_code
when ENTER then play_or_stop.click
when :b then brush.click
when :e then eraser.click
when /^[#{(1..Reight::Sound::Note::TONES.size).to_a.join}]$/
tones[key_code.to_s.to_i - 1].click
end
end
|
#redo(flash: true) ⇒ Object
85
86
87
88
89
90
91
92
93
|
# File 'lib/reight/app/sound/editor.rb', line 85
def redo(flash: true)
history.redo do |action|
case action
in [:put_note, ti, ni, tone] then canvas.sound.add ti, ni, tone
in [:delete_note, ti, ni, _] then canvas.sound.remove ti, ni
end
self.flash 'Redo!' if flash
end
end
|
#setup ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/reight/app/sound/editor.rb', line 10
def setup()
super
history.disable do
tones[0].click
tools[0].click
end
end
|
#undo(flash: true) ⇒ Object
75
76
77
78
79
80
81
82
83
|
# File 'lib/reight/app/sound/editor.rb', line 75
def undo(flash: true)
history.undo do |action|
case action
in [:put_note, ti, ni, _] then canvas.sound.remove ti, ni
in [:delete_note, ti, ni, tone] then canvas.sound.add ti, ni, tone
end
self.flash 'Undo!' if flash
end
end
|
#window_resized ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/reight/app/sound/editor.rb', line 35
def window_resized()
super
index.sprite.tap do |sp|
sp.w, sp.h = 32, BUTTON_SIZE
sp.x = SPACE
sp.y = NAVIGATOR_HEIGHT + SPACE
end
bpm.sprite.tap do |sp|
sp.w, sp.h = 40, BUTTON_SIZE
sp.x = index.sprite.right + SPACE
sp.y = index.sprite.y
end
edits.map(&:sprite).each.with_index do |sp, i|
sp.w, sp.h = 32, BUTTON_SIZE
sp.x = bpm.sprite.right + SPACE + (sp.w + 1) * i
sp.y = bpm.sprite.y
end
controls.map(&:sprite).each.with_index do |sp, i|
sp.w, sp.h = 32, BUTTON_SIZE
sp.x = SPACE + (sp.w + 1) * i
sp.y = height - (SPACE + sp.h)
end
tools.map(&:sprite).each.with_index do |sp, i|
sp.w = sp.h = BUTTON_SIZE
sp.x = controls.last.sprite.right + SPACE * 2 + (sp.w + 1) * i
sp.y = controls.last.sprite.y
end
tones.map(&:sprite).each.with_index do |sp, i|
sp.w = sp.h = BUTTON_SIZE
sp.x = tools.last.sprite.right + SPACE * 2 + (sp.w + 1) * i
sp.y = tools.last.sprite.y
end
canvas.sprite.tap do |sp|
sp.x = SPACE
sp.y = index.sprite.bottom + SPACE
sp.right = width - SPACE
sp.bottom = tools.first.sprite.y - SPACE
end
end
|