mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:47:35 +00:00
Piano: Handle octave slider jumps of greater than 1
The previous slider handler relied on the new value being 1 different than the previous. fixes #1163.
This commit is contained in:
parent
0fd31ef598
commit
b8cf07166f
5 changed files with 20 additions and 1 deletions
|
@ -83,7 +83,7 @@ KnobsWidget::KnobsWidget(TrackManager& track_manager, MainWidget& main_widget)
|
||||||
m_octave_knob->on_value_changed = [this](int value) {
|
m_octave_knob->on_value_changed = [this](int value) {
|
||||||
int new_octave = octave_max - value;
|
int new_octave = octave_max - value;
|
||||||
if (m_change_underlying)
|
if (m_change_underlying)
|
||||||
m_main_widget.set_octave_and_ensure_note_change(new_octave == m_track_manager.octave() + 1 ? Up : Down);
|
m_main_widget.set_octave_and_ensure_note_change(new_octave);
|
||||||
ASSERT(new_octave == m_track_manager.octave());
|
ASSERT(new_octave == m_track_manager.octave());
|
||||||
m_octave_value->set_text(String::number(new_octave));
|
m_octave_value->set_text(String::number(new_octave));
|
||||||
};
|
};
|
||||||
|
|
|
@ -160,6 +160,16 @@ void MainWidget::turn_on_pressed_keys()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWidget::set_octave_and_ensure_note_change(int octave)
|
||||||
|
{
|
||||||
|
turn_off_pressed_keys();
|
||||||
|
m_track_manager.set_octave(octave);
|
||||||
|
turn_on_pressed_keys();
|
||||||
|
|
||||||
|
m_knobs_widget->update_knobs();
|
||||||
|
m_keys_widget->update();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::set_octave_and_ensure_note_change(Direction direction)
|
void MainWidget::set_octave_and_ensure_note_change(Direction direction)
|
||||||
{
|
{
|
||||||
turn_off_pressed_keys();
|
turn_off_pressed_keys();
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
void add_actions(GUI::Menu&);
|
void add_actions(GUI::Menu&);
|
||||||
|
|
||||||
void set_octave_and_ensure_note_change(Direction);
|
void set_octave_and_ensure_note_change(Direction);
|
||||||
|
void set_octave_and_ensure_note_change(int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit MainWidget(TrackManager&);
|
explicit MainWidget(TrackManager&);
|
||||||
|
|
|
@ -85,6 +85,13 @@ void TrackManager::set_octave(Direction direction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackManager::set_octave(int octave)
|
||||||
|
{
|
||||||
|
if (octave <= octave_max && octave >= octave_min) {
|
||||||
|
m_octave = octave;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TrackManager::add_track()
|
void TrackManager::add_track()
|
||||||
{
|
{
|
||||||
m_tracks.append(make<Track>(m_time));
|
m_tracks.append(make<Track>(m_time));
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
void set_should_loop(bool b) { m_should_loop = b; }
|
void set_should_loop(bool b) { m_should_loop = b; }
|
||||||
void set_note_current_octave(int note, Switch);
|
void set_note_current_octave(int note, Switch);
|
||||||
void set_octave(Direction);
|
void set_octave(Direction);
|
||||||
|
void set_octave(int octave);
|
||||||
void add_track();
|
void add_track();
|
||||||
void next_track();
|
void next_track();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue