Added ability to ignore clicks for toggle in Ui::SettingsButton.
This commit is contained in:
parent
bc85f7baf3
commit
62002f034b
2 changed files with 11 additions and 5 deletions
|
|
@ -701,16 +701,20 @@ SettingsButton::SettingsButton(
|
|||
|
||||
SettingsButton::~SettingsButton() = default;
|
||||
|
||||
SettingsButton *SettingsButton::toggleOn(rpl::producer<bool> &&toggled) {
|
||||
SettingsButton *SettingsButton::toggleOn(
|
||||
rpl::producer<bool> &&toggled,
|
||||
bool ignoreClick) {
|
||||
Expects(_toggle == nullptr);
|
||||
|
||||
_toggle = std::make_unique<Ui::ToggleView>(
|
||||
isOver() ? _st.toggleOver : _st.toggle,
|
||||
false,
|
||||
[this] { rtlupdate(toggleRect()); });
|
||||
addClickHandler([this] {
|
||||
_toggle->setChecked(!_toggle->checked(), anim::type::normal);
|
||||
});
|
||||
if (!ignoreClick) {
|
||||
addClickHandler([this] {
|
||||
_toggle->setChecked(!_toggle->checked(), anim::type::normal);
|
||||
});
|
||||
}
|
||||
std::move(
|
||||
toggled
|
||||
) | rpl::start_with_next([this](bool toggled) {
|
||||
|
|
|
|||
|
|
@ -261,7 +261,9 @@ public:
|
|||
const style::SettingsButton &st);
|
||||
~SettingsButton();
|
||||
|
||||
SettingsButton *toggleOn(rpl::producer<bool> &&toggled);
|
||||
SettingsButton *toggleOn(
|
||||
rpl::producer<bool> &&toggled,
|
||||
bool ignoreClick = false);
|
||||
bool toggled() const;
|
||||
rpl::producer<bool> toggledChanges() const;
|
||||
rpl::producer<bool> toggledValue() const;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue