2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 15:35:51 +00:00

Add rpl::take(count).

This commit is contained in:
John Preston
2017-10-01 12:39:07 +03:00
parent f0ad78d808
commit c4d33f9986
9 changed files with 135 additions and 18 deletions

View File

@@ -76,6 +76,10 @@ public:
virtual rpl::producer<int> desiredHeightValue() const {
return heightValue();
}
auto shownValue() const {
auto &stream = eventStreams().shown;
return stream.events_starting_with(!this->isHidden());
}
auto paintRequest() const {
return eventStreams().paint.events();
@@ -85,6 +89,17 @@ public:
return eventStreams().alive.events();
}
void setVisible(bool visible) final override {
auto wasVisible = !this->isHidden();
Parent::setVisible(visible);
auto nowVisible = !this->isHidden();
if (nowVisible != wasVisible) {
if (auto streams = _eventStreams.get()) {
streams->shown.fire_copy(nowVisible);
}
}
}
template <typename Error, typename Generator>
void showOn(rpl::producer<bool, Error, Generator> &&shown) {
std::move(shown)
@@ -133,6 +148,7 @@ private:
struct EventStreams {
rpl::event_stream<QRect> geometry;
rpl::event_stream<QRect> paint;
rpl::event_stream<bool> shown;
rpl::event_stream<> alive;
};
struct LifetimeHolder {