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() = default;
|
||||||
|
|
||||||
SettingsButton *SettingsButton::toggleOn(rpl::producer<bool> &&toggled) {
|
SettingsButton *SettingsButton::toggleOn(
|
||||||
|
rpl::producer<bool> &&toggled,
|
||||||
|
bool ignoreClick) {
|
||||||
Expects(_toggle == nullptr);
|
Expects(_toggle == nullptr);
|
||||||
|
|
||||||
_toggle = std::make_unique<Ui::ToggleView>(
|
_toggle = std::make_unique<Ui::ToggleView>(
|
||||||
isOver() ? _st.toggleOver : _st.toggle,
|
isOver() ? _st.toggleOver : _st.toggle,
|
||||||
false,
|
false,
|
||||||
[this] { rtlupdate(toggleRect()); });
|
[this] { rtlupdate(toggleRect()); });
|
||||||
addClickHandler([this] {
|
if (!ignoreClick) {
|
||||||
_toggle->setChecked(!_toggle->checked(), anim::type::normal);
|
addClickHandler([this] {
|
||||||
});
|
_toggle->setChecked(!_toggle->checked(), anim::type::normal);
|
||||||
|
});
|
||||||
|
}
|
||||||
std::move(
|
std::move(
|
||||||
toggled
|
toggled
|
||||||
) | rpl::start_with_next([this](bool toggled) {
|
) | rpl::start_with_next([this](bool toggled) {
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,9 @@ public:
|
||||||
const style::SettingsButton &st);
|
const style::SettingsButton &st);
|
||||||
~SettingsButton();
|
~SettingsButton();
|
||||||
|
|
||||||
SettingsButton *toggleOn(rpl::producer<bool> &&toggled);
|
SettingsButton *toggleOn(
|
||||||
|
rpl::producer<bool> &&toggled,
|
||||||
|
bool ignoreClick = false);
|
||||||
bool toggled() const;
|
bool toggled() const;
|
||||||
rpl::producer<bool> toggledChanges() const;
|
rpl::producer<bool> toggledChanges() const;
|
||||||
rpl::producer<bool> toggledValue() const;
|
rpl::producer<bool> toggledValue() const;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue