mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-09 18:16:15 -05:00
Improve drag & drop behaviour of macro segments
- Depending on the drop position you can either drop before or after a widget - Added a visual indicator where the macro segment will be dropped
This commit is contained in:
@@ -31,15 +31,22 @@ protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void dragLeaveEvent(QDragLeaveEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dragMoveEvent(QDragMoveEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
|
||||
private:
|
||||
int GetIndex(QPoint);
|
||||
int GetDropIndex(QPoint);
|
||||
int GetDragIndex(const QPoint &);
|
||||
int GetDropIndex(const QPoint &);
|
||||
int GetWidgetIdx(const QPoint &);
|
||||
bool IsInListArea(const QPoint &);
|
||||
QRect GetContentItemRectWithPadding(int idx);
|
||||
void HideLastDropLine();
|
||||
MacroSegmentEdit *WidgetAt(int idx);
|
||||
|
||||
int _dragPosition = -1;
|
||||
int _dropLineIdx = -1;
|
||||
|
||||
QVBoxLayout *_layout;
|
||||
QVBoxLayout *_contentLayout;
|
||||
|
||||
@@ -63,15 +63,38 @@ protected:
|
||||
Section *_section;
|
||||
QLabel *_headerInfo;
|
||||
QWidget *_frame;
|
||||
QFrame *_noBorderframe;
|
||||
QFrame *_borderFrame;
|
||||
QVBoxLayout *_contentLayout;
|
||||
|
||||
private:
|
||||
enum class DropLineState {
|
||||
NONE,
|
||||
ABOVE,
|
||||
BELOW,
|
||||
};
|
||||
|
||||
virtual MacroSegment *Data() = 0;
|
||||
void ShowDropLine(DropLineState);
|
||||
|
||||
// The reason for using two separate frame widget each with their own
|
||||
// stylesheet and changing their visibility vs. using a single frame
|
||||
// and changing the stylesheet at runtime is that the operation of
|
||||
// adjusting the stylesheet is very expensive and can take multiple
|
||||
// hundred milliseconds per widget.
|
||||
// This performance impact would hurt in areas like drag and drop or
|
||||
// emitting the "SelectionChanged" signal.
|
||||
QFrame *_noBorderframe;
|
||||
QFrame *_borderFrame;
|
||||
|
||||
// In most cases the line above the widget will be used.
|
||||
// The lower one will only be used if the segment is the last one in
|
||||
// the list.
|
||||
QFrame *_dropLineAbove;
|
||||
QFrame *_dropLineBelow;
|
||||
|
||||
bool _showHighlight;
|
||||
QTimer _timer;
|
||||
|
||||
friend class MacroSegmentList;
|
||||
};
|
||||
|
||||
class MouseWheelWidgetAdjustmentGuard : public QObject {
|
||||
|
||||
Reference in New Issue
Block a user