Allow to change overscroll from outside.
This commit is contained in:
parent
80308cea4f
commit
763b3a37c3
2 changed files with 14 additions and 4 deletions
|
|
@ -1118,9 +1118,19 @@ void ElasticScroll::setOverscrollTypes(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElasticScroll::setOverscrollDefaults(int from, int till) {
|
void ElasticScroll::setOverscrollDefaults(int from, int till, bool shift) {
|
||||||
Expects(from <= 0 && till >= 0);
|
Expects(from <= 0 && till >= 0);
|
||||||
|
|
||||||
|
if (_state.visibleFrom > 0
|
||||||
|
|| (!_state.visibleFrom
|
||||||
|
&& _overscrollTypeFrom != OverscrollType::Virtual)) {
|
||||||
|
from = 0;
|
||||||
|
}
|
||||||
|
if (_state.visibleTill < _state.fullSize
|
||||||
|
|| (_state.visibleTill == _state.fullSize
|
||||||
|
&& _overscrollTypeTill != OverscrollType::Virtual)) {
|
||||||
|
till = 0;
|
||||||
|
}
|
||||||
const auto fromChanged = (_overscrollDefaultFrom != from);
|
const auto fromChanged = (_overscrollDefaultFrom != from);
|
||||||
const auto tillChanged = (_overscrollDefaultTill != till);
|
const auto tillChanged = (_overscrollDefaultTill != till);
|
||||||
const auto changed = (fromChanged && _overscroll < 0)
|
const auto changed = (fromChanged && _overscroll < 0)
|
||||||
|
|
@ -1133,8 +1143,8 @@ void ElasticScroll::setOverscrollDefaults(int from, int till) {
|
||||||
_overscrollDefaultTill = till;
|
_overscrollDefaultTill = till;
|
||||||
if (changed) {
|
if (changed) {
|
||||||
const auto delta = (_overscroll < 0)
|
const auto delta = (_overscroll < 0)
|
||||||
? (_overscroll - _overscrollDefaultFrom)
|
? (_overscroll - (shift ? 0 : _overscrollDefaultFrom))
|
||||||
: (_overscroll - _overscrollDefaultTill);
|
: (_overscroll - (shift ? 0 : _overscrollDefaultTill));
|
||||||
_overscrollAccumulated = currentOverscrollDefaultAccumulated()
|
_overscrollAccumulated = currentOverscrollDefaultAccumulated()
|
||||||
+ OverscrollToAccumulated(delta);
|
+ OverscrollToAccumulated(delta);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ public:
|
||||||
Real,
|
Real,
|
||||||
};
|
};
|
||||||
void setOverscrollTypes(OverscrollType from, OverscrollType till);
|
void setOverscrollTypes(OverscrollType from, OverscrollType till);
|
||||||
void setOverscrollDefaults(int from, int till);
|
void setOverscrollDefaults(int from, int till, bool shift = false);
|
||||||
void setOverscrollBg(QColor bg);
|
void setOverscrollBg(QColor bg);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<> scrolls() const;
|
[[nodiscard]] rpl::producer<> scrolls() const;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue