mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:57:44 +00:00
Piano: Move octave controls into main widget
This is not related to the track controls and it may move into another separate widget in the future. The move also allows to simplify the octave slider callback logic.
This commit is contained in:
parent
376e7243a9
commit
7b3b743f88
4 changed files with 36 additions and 50 deletions
|
@ -13,7 +13,6 @@
|
|||
#include <LibDSP/ProcessorParameter.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/Slider.h>
|
||||
#include <LibGfx/Orientation.h>
|
||||
|
||||
TrackControlsWidget::TrackControlsWidget(TrackManager& track_manager, MainWidget& main_widget)
|
||||
|
@ -21,27 +20,9 @@ TrackControlsWidget::TrackControlsWidget(TrackManager& track_manager, MainWidget
|
|||
, m_main_widget(main_widget)
|
||||
{
|
||||
set_layout<GUI::HorizontalBoxLayout>();
|
||||
set_preferred_width(GUI::SpecialDimension::Grow);
|
||||
set_fill_with_background_color(true);
|
||||
|
||||
m_octave_container = add<GUI::Widget>();
|
||||
m_octave_container->set_layout<GUI::VerticalBoxLayout>();
|
||||
m_octave_container->add<GUI::Label>("Octave");
|
||||
m_octave_value = m_octave_container->add<GUI::Label>(DeprecatedString::number(m_track_manager.keyboard()->virtual_keyboard_octave()));
|
||||
|
||||
// FIXME: Implement vertical flipping in GUI::Slider, not here.
|
||||
m_octave_knob = m_octave_container->add<GUI::VerticalSlider>();
|
||||
m_octave_knob->set_tooltip("Z: octave down, X: octave up");
|
||||
m_octave_knob->set_range(octave_min - 1, octave_max - 1);
|
||||
m_octave_knob->set_value((octave_max - 1) - (m_track_manager.keyboard()->virtual_keyboard_octave() - 1));
|
||||
m_octave_knob->set_step(1);
|
||||
m_octave_knob->on_change = [this](int value) {
|
||||
int new_octave = octave_max - value;
|
||||
if (m_change_underlying)
|
||||
m_main_widget.set_octave_and_ensure_note_change(new_octave);
|
||||
VERIFY(new_octave == m_track_manager.keyboard()->virtual_keyboard_octave());
|
||||
m_octave_value->set_text(DeprecatedString::number(new_octave));
|
||||
};
|
||||
|
||||
for (auto& parameter : m_track_manager.current_track()->track_mastering()->parameters())
|
||||
m_parameter_widgets.append(add<ProcessorParameterWidget>(parameter));
|
||||
|
||||
|
@ -51,15 +32,3 @@ TrackControlsWidget::TrackControlsWidget(TrackManager& track_manager, MainWidget
|
|||
for (auto& parameter : m_track_manager.current_track()->delay()->parameters())
|
||||
m_parameter_widgets.append(add<ProcessorParameterWidget>(parameter));
|
||||
}
|
||||
|
||||
void TrackControlsWidget::update_knobs()
|
||||
{
|
||||
// FIXME: This is needed because when the slider is changed normally, we
|
||||
// need to change the underlying value, but if the keyboard was used, we
|
||||
// need to change the slider without changing the underlying value.
|
||||
m_change_underlying = false;
|
||||
|
||||
m_octave_knob->set_value(octave_max - m_track_manager.keyboard()->virtual_keyboard_octave());
|
||||
|
||||
m_change_underlying = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue