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) {
|
for (auto i = 0; i != count; ++i) {
|
||||||
const auto widget = _layout->widgetAt(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) {
|
) | rpl::start_with_next_done([=](not_null<QEvent*> e) {
|
||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
case QEvent::MouseMove:
|
case QEvent::MouseMove:
|
||||||
|
|
@ -83,6 +86,10 @@ void VerticalLayoutReorder::clearPinnedIntervals() {
|
||||||
_pinnedIntervals.clear();
|
_pinnedIntervals.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VerticalLayoutReorder::setMouseEventProxy(ProxyCallback callback) {
|
||||||
|
_proxyWidgetCallback = std::move(callback);
|
||||||
|
}
|
||||||
|
|
||||||
bool VerticalLayoutReorder::Interval::isIn(int index) const {
|
bool VerticalLayoutReorder::Interval::isIn(int index) const {
|
||||||
return (index >= from) && (index < (from + length));
|
return (index >= from) && (index < (from + length));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class VerticalLayout;
|
||||||
|
|
||||||
class VerticalLayoutReorder final {
|
class VerticalLayoutReorder final {
|
||||||
public:
|
public:
|
||||||
|
using ProxyCallback = Fn<not_null<Ui::RpWidget*>(int)>;
|
||||||
enum class State : uchar {
|
enum class State : uchar {
|
||||||
Started,
|
Started,
|
||||||
Applied,
|
Applied,
|
||||||
|
|
@ -38,6 +39,7 @@ public:
|
||||||
void finishReordering();
|
void finishReordering();
|
||||||
void addPinnedInterval(int from, int length);
|
void addPinnedInterval(int from, int length);
|
||||||
void clearPinnedIntervals();
|
void clearPinnedIntervals();
|
||||||
|
void setMouseEventProxy(ProxyCallback callback);
|
||||||
[[nodiscard]] rpl::producer<Single> updates() const;
|
[[nodiscard]] rpl::producer<Single> updates() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -85,6 +87,8 @@ private:
|
||||||
|
|
||||||
std::vector<Interval> _pinnedIntervals;
|
std::vector<Interval> _pinnedIntervals;
|
||||||
|
|
||||||
|
ProxyCallback _proxyWidgetCallback = nullptr;
|
||||||
|
|
||||||
RpWidget *_currentWidget = nullptr;
|
RpWidget *_currentWidget = nullptr;
|
||||||
int _currentStart = 0;
|
int _currentStart = 0;
|
||||||
int _currentDesiredIndex = 0;
|
int _currentDesiredIndex = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue