diff --git a/Telegram/SourceFiles/boxes/edit_color_box.cpp b/Telegram/SourceFiles/boxes/edit_color_box.cpp index 19a2fc3e8..3c78af799 100644 --- a/Telegram/SourceFiles/boxes/edit_color_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_color_box.cpp @@ -27,8 +27,8 @@ public: return _y; } - base::Observable &changed() { - return _changed; + rpl::producer<> changed() const { + return _changed.events(); } void setHSB(HSB hsb); void setRGB(int red, int green, int blue); @@ -61,7 +61,7 @@ private: float64 _y = 0.; bool _choosing = false; - base::Observable _changed; + rpl::event_stream<> _changed; }; @@ -234,7 +234,7 @@ void EditColorBox::Picker::updateCurrentPoint(QPoint localPosition) { _x = x; _y = y; update(); - _changed.notify(); + _changed.fire({}); } } @@ -284,8 +284,8 @@ public: }; Slider(QWidget *parent, Direction direction, Type type, QColor color); - base::Observable &changed() { - return _changed; + rpl::producer<> changed() const { + return _changed.events(); } float64 value() const { return _value; @@ -335,7 +335,7 @@ private: QBrush _transparent; bool _choosing = false; - base::Observable _changed; + rpl::event_stream<> _changed; }; @@ -540,7 +540,7 @@ void EditColorBox::Slider::updateCurrentPoint(QPoint localPosition) { if (_value != value) { _value = value; update(); - _changed.notify(); + _changed.fire({}); } } @@ -826,16 +826,14 @@ void EditColorBox::prepare() { auto height = st::colorEditSkip + st::colorPickerSize + st::colorEditSkip + st::colorSliderWidth + st::colorEditSkip; setDimensions(st::colorEditWidth, height); - subscribe(_picker->changed(), [=] { updateFromControls(); }); - if (_hueSlider) { - subscribe(_hueSlider->changed(), [=] { updateFromControls(); }); - } - if (_opacitySlider) { - subscribe(_opacitySlider->changed(), [=] { updateFromControls(); }); - } - if (_lightnessSlider) { - subscribe(_lightnessSlider->changed(), [=] { updateFromControls(); }); - } + rpl::merge( + _picker->changed(), + (_hueSlider ? _hueSlider->changed() : rpl::never<>()), + (_opacitySlider ? _opacitySlider->changed() : rpl::never<>()), + (_lightnessSlider ? _lightnessSlider->changed() : rpl::never<>()) + ) | rpl::start_with_next([=] { + updateFromControls(); + }, lifetime()); boxClosing() | rpl::start_with_next([=] { if (_cancelCallback) { diff --git a/Telegram/SourceFiles/boxes/edit_color_box.h b/Telegram/SourceFiles/boxes/edit_color_box.h index 5c2e7170a..c77616f5a 100644 --- a/Telegram/SourceFiles/boxes/edit_color_box.h +++ b/Telegram/SourceFiles/boxes/edit_color_box.h @@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" -class EditColorBox : public Ui::BoxContent, private base::Subscriber { +class EditColorBox : public Ui::BoxContent { public: enum class Mode { RGBA,