diff options
Diffstat (limited to 'Userland/Applications')
3 files changed, 69 insertions, 0 deletions
diff --git a/Userland/Applications/Piano/CMakeLists.txt b/Userland/Applications/Piano/CMakeLists.txt index 377b892a49..0fd50c01b1 100644 --- a/Userland/Applications/Piano/CMakeLists.txt +++ b/Userland/Applications/Piano/CMakeLists.txt @@ -17,6 +17,7 @@ set(SOURCES SamplerWidget.cpp WaveWidget.cpp ProcessorParameterWidget/Slider.cpp + ProcessorParameterWidget/ParameterWidget.cpp ) serenity_app(Piano ICON app-piano) diff --git a/Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.cpp b/Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.cpp new file mode 100644 index 0000000000..23ba1105d4 --- /dev/null +++ b/Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include "ParameterWidget.h" +#include "Dropdown.h" +#include "Slider.h" +#include "Toggle.h" +#include <LibDSP/Synthesizers.h> +#include <LibGUI/BoxLayout.h> + +ProcessorParameterWidget::ProcessorParameterWidget(DSP::ProcessorParameter& raw_parameter) + : m_parameter(raw_parameter) +{ + set_layout<GUI::VerticalBoxLayout>(); + m_label = add<GUI::Label>(raw_parameter.name()); + switch (raw_parameter.type()) { + case DSP::ParameterType::Range: { + auto& parameter = static_cast<DSP::ProcessorRangeParameter&>(raw_parameter); + m_value_label = add<GUI::Label>(String::number(static_cast<double>(parameter.value()))); + m_parameter_modifier = add<ProcessorParameterSlider>(Orientation::Vertical, parameter, m_value_label); + break; + } + case DSP::ParameterType::Enum: { + // FIXME: We shouldn't do that, but the only user is the synth right now. + auto& parameter = static_cast<DSP::ProcessorEnumParameter<DSP::Synthesizers::Waveform>&>(raw_parameter); + auto enum_strings = Vector<String> { "Sine", "Triangle", "Square", "Saw", "Noise" }; + m_parameter_modifier = add<ProcessorParameterDropdown<DSP::Synthesizers::Waveform>>(parameter, move(enum_strings)); + break; + } + case DSP::ParameterType::Boolean: { + auto& parameter = static_cast<DSP::ProcessorBooleanParameter&>(raw_parameter); + m_parameter_modifier = add<ProcessorParameterToggle>(parameter); + break; + } + default: + VERIFY_NOT_REACHED(); + } +} diff --git a/Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.h b/Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.h new file mode 100644 index 0000000000..89baf3c24c --- /dev/null +++ b/Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/NonnullRefPtr.h> +#include <AK/StdLibExtraDetails.h> +#include <LibCore/Object.h> +#include <LibDSP/ProcessorParameter.h> +#include <LibGUI/Label.h> +#include <LibGUI/Widget.h> + +class ProcessorParameterWidget : public GUI::Widget { + C_OBJECT(ProcessorParameterWidget) +public: + ProcessorParameterWidget(DSP::ProcessorParameter& parameter); + virtual ~ProcessorParameterWidget() = default; + +private: + DSP::ProcessorParameter& m_parameter; + RefPtr<GUI::Widget> m_parameter_modifier; + RefPtr<GUI::Label> m_label; + RefPtr<GUI::Label> m_value_label; +}; |