summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkleines Filmröllchen <filmroellchen@serenityos.org>2022-07-23 15:37:22 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-25 15:25:13 +0200
commit6389384882db8e72f1f77fd0430bde233224b642 (patch)
tree56604b88eaef4650673998583179ef10b099300f
parentd5166ddbcf30d13a2af60b98e77c2322eb8cbc08 (diff)
downloadserenity-6389384882db8e72f1f77fd0430bde233224b642.zip
Piano: Add Toggle parameter widget
This is for enum widgets; though positioning is not correct as checkboxes need more options for text-less layout.
-rw-r--r--Userland/Applications/Piano/ProcessorParameterWidget/Toggle.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/Userland/Applications/Piano/ProcessorParameterWidget/Toggle.h b/Userland/Applications/Piano/ProcessorParameterWidget/Toggle.h
new file mode 100644
index 0000000000..0ca2eaa5f4
--- /dev/null
+++ b/Userland/Applications/Piano/ProcessorParameterWidget/Toggle.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibCore/Object.h>
+#include <LibDSP/ProcessorParameter.h>
+#include <LibGUI/CheckBox.h>
+#include <LibGUI/Widget.h>
+
+class ProcessorParameterToggle : public GUI::CheckBox {
+ C_OBJECT(ProcessorParameterToggle)
+
+public:
+ ProcessorParameterToggle(DSP::ProcessorBooleanParameter& parameter)
+ : CheckBox("")
+ , m_parameter(parameter)
+ {
+ on_checked = [this](auto checked) {
+ if (m_currently_setting_from_ui)
+ return;
+ m_currently_setting_from_ui = true;
+ m_parameter.set_value(checked);
+ m_currently_setting_from_ui = false;
+ };
+ m_parameter.register_change_listener([this](auto muted) {
+ set_checked(muted, GUI::AllowCallback::No);
+ });
+
+ set_checked(parameter.value());
+ }
+
+private:
+ DSP::ProcessorBooleanParameter& m_parameter;
+ bool m_currently_setting_from_ui { false };
+};