Added ability to customize widget for events in VerticalLayoutReorder.
This commit is contained in:
parent
f450dcf2c5
commit
0c592310af
2 changed files with 12 additions and 1 deletions
|
|
@ -50,7 +50,10 @@ void VerticalLayoutReorder::start() {
|
|||
}
|
||||
for (auto i = 0; i != count; ++i) {
|
||||
const auto widget = _layout->widgetAt(i);
|
||||
widget->events(
|
||||
const auto eventsProducer = _proxyWidgetCallback
|
||||
? _proxyWidgetCallback(i)
|
||||
: widget;
|
||||
eventsProducer->events(
|
||||
) | rpl::start_with_next_done([=](not_null<QEvent*> e) {
|
||||
switch (e->type()) {
|
||||
case QEvent::MouseMove:
|
||||
|
|
@ -83,6 +86,10 @@ void VerticalLayoutReorder::clearPinnedIntervals() {
|
|||
_pinnedIntervals.clear();
|
||||
}
|
||||
|
||||
void VerticalLayoutReorder::setMouseEventProxy(ProxyCallback callback) {
|
||||
_proxyWidgetCallback = std::move(callback);
|
||||
}
|
||||
|
||||
bool VerticalLayoutReorder::Interval::isIn(int index) const {
|
||||
return (index >= from) && (index < (from + length));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class VerticalLayout;
|
|||
|
||||
class VerticalLayoutReorder final {
|
||||
public:
|
||||
using ProxyCallback = Fn<not_null<Ui::RpWidget*>(int)>;
|
||||
enum class State : uchar {
|
||||
Started,
|
||||
Applied,
|
||||
|
|
@ -38,6 +39,7 @@ public:
|
|||
void finishReordering();
|
||||
void addPinnedInterval(int from, int length);
|
||||
void clearPinnedIntervals();
|
||||
void setMouseEventProxy(ProxyCallback callback);
|
||||
[[nodiscard]] rpl::producer<Single> updates() const;
|
||||
|
||||
private:
|
||||
|
|
@ -85,6 +87,8 @@ private:
|
|||
|
||||
std::vector<Interval> _pinnedIntervals;
|
||||
|
||||
ProxyCallback _proxyWidgetCallback = nullptr;
|
||||
|
||||
RpWidget *_currentWidget = nullptr;
|
||||
int _currentStart = 0;
|
||||
int _currentDesiredIndex = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue