mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 01:44:49 -05:00
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
#pragma once
|
|
#include "macro-segment.hpp"
|
|
|
|
#include <QWidget>
|
|
#include <QScrollArea>
|
|
#include <QVBoxLayout>
|
|
#include <QLabel>
|
|
#include <thread>
|
|
|
|
namespace advss {
|
|
|
|
class MacroSegmentList : public QScrollArea {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
MacroSegmentList(QWidget *parent = nullptr);
|
|
virtual ~MacroSegmentList();
|
|
void SetHelpMsg(const QString &msg);
|
|
void SetHelpMsgVisible(bool visible);
|
|
MacroSegmentEdit *WidgetAt(int idx);
|
|
MacroSegmentEdit *WidgetAt(const QPoint &);
|
|
void Insert(int idx, MacroSegmentEdit *widget);
|
|
void Add(QWidget *widget);
|
|
void Remove(int idx);
|
|
void Clear(int idx = 0); // Clear all elements >= idx
|
|
void Highlight(int idx, QColor color = QColor(Qt::green));
|
|
void SetCollapsed(bool);
|
|
void SetSelection(int idx);
|
|
QVBoxLayout *ContentLayout() { return _contentLayout; }
|
|
|
|
signals:
|
|
void SelectionChanged(int idx);
|
|
void Reorder(int source, int target);
|
|
|
|
protected:
|
|
bool eventFilter(QObject *object, QEvent *event);
|
|
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 GetDragIndex(const QPoint &);
|
|
int GetDropIndex(const QPoint &);
|
|
int GetSegmentIndexFromPos(const QPoint &);
|
|
void CheckScroll();
|
|
void CheckDropLine(const QPoint &);
|
|
bool IsInListArea(const QPoint &);
|
|
QRect GetContentItemRectWithPadding(int idx);
|
|
void HideLastDropLine();
|
|
|
|
int _dragPosition = -1;
|
|
int _dropLineIdx = -1;
|
|
QPoint _dragCursorPos;
|
|
std::thread _autoScrollThread;
|
|
std::atomic_bool _autoScroll{false};
|
|
|
|
QVBoxLayout *_layout;
|
|
QVBoxLayout *_contentLayout;
|
|
QLabel *_helpMsg;
|
|
};
|
|
|
|
} // namespace advss
|