mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
Piano: Add Toggle parameter widget
This is for enum widgets; though positioning is not correct as checkboxes need more options for text-less layout.
This commit is contained in:
parent
d5166ddbcf
commit
6389384882
Notes:
sideshowbarker
2024-07-17 08:35:52 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/6389384882 Pull-request: https://github.com/SerenityOS/serenity/pull/14664
1 changed files with 39 additions and 0 deletions
|
@ -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 };
|
||||
};
|
Loading…
Reference in a new issue