Cockatrice 2026-01-14-Development-2.11.0-beta.46
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
resizable_panel.h
Go to the documentation of this file.
1#ifndef COCKATRICE_RESIZABLE_PANEL_H
2#define COCKATRICE_RESIZABLE_PANEL_H
3
5
6#include <QApplication>
7#include <QDrag>
8#include <QFrame>
9#include <QMimeData>
10#include <QMouseEvent>
11#include <QPushButton>
12#include <QScrollArea>
13#include <QScrollBar>
14#include <QTimer>
15#include <QVBoxLayout>
16#include <QWidget>
17
18class ResizablePanel : public QWidget
19{
20 Q_OBJECT
21public:
22 explicit ResizablePanel(const QString &typeId,
23 AbstractAnalyticsPanelWidget *analyticsPanel,
24 QWidget *parent = nullptr);
25
26 void setSelected(bool selected);
27 void setHeightFromSaved(int h);
28 int getCurrentHeight() const;
29
30 QSize sizeHint() const override;
31 QSize minimumSizeHint() const override;
32
33 QString getTypeId() const
34 {
35 return typeId;
36 }
37
39
40signals:
42 void dropRequested(ResizablePanel *dragged, ResizablePanel *target, bool insertBefore);
43
44protected:
45 bool eventFilter(QObject *obj, QEvent *event) override;
46 void dragEnterEvent(QDragEnterEvent *event) override;
47 void dragMoveEvent(QDragMoveEvent *event) override;
48 void dragLeaveEvent(QDragLeaveEvent *event) override;
49 void dropEvent(QDropEvent *event) override;
50 void resizeEvent(QResizeEvent *event) override;
51
52private:
53 int getMinimumAllowedHeight() const;
55 void startDrag();
56 void performAutoScroll();
57 void showDropIndicator(double y);
58 void hideDropIndicator();
59
60 QString typeId;
61
62 QFrame *frame;
65 QPushButton *dragButton;
66 QWidget *resizeHandle;
67
69 bool isResizing = false;
70 bool isDraggingPanel = false;
71 double resizeStartY = 0;
73
77};
78
79#endif // COCKATRICE_RESIZABLE_PANEL_H
Definition abstract_analytics_panel_widget.h:14
QPushButton * dragButton
Definition resizable_panel.h:65
QPoint dragStartPos
Definition resizable_panel.h:74
QFrame * dropIndicator
Definition resizable_panel.h:64
QPoint lastDragPos
Definition resizable_panel.h:75
bool isResizing
Definition resizable_panel.h:69
void startDrag()
Definition resizable_panel.cpp:296
void setSelected(bool selected)
Definition resizable_panel.cpp:93
ResizablePanel(const QString &typeId, AbstractAnalyticsPanelWidget *analyticsPanel, QWidget *parent=nullptr)
Definition resizable_panel.cpp:10
void hideDropIndicator()
Definition resizable_panel.cpp:364
AbstractAnalyticsPanelWidget * panel
Definition resizable_panel.h:38
int resizeStartHeight
Definition resizable_panel.h:72
void resizeEvent(QResizeEvent *event) override
Definition resizable_panel.cpp:265
void dragEnterEvent(QDragEnterEvent *event) override
Definition resizable_panel.cpp:206
QTimer * autoScrollTimer
Definition resizable_panel.h:76
void dragMoveEvent(QDragMoveEvent *event) override
Definition resizable_panel.cpp:218
QSize minimumSizeHint() const override
Definition resizable_panel.cpp:121
QWidget * resizeHandle
Definition resizable_panel.h:66
void updateSizeConstraints()
Definition resizable_panel.cpp:289
void dragLeaveEvent(QDragLeaveEvent *event) override
Definition resizable_panel.cpp:236
double resizeStartY
Definition resizable_panel.h:71
void dropEvent(QDropEvent *event) override
Definition resizable_panel.cpp:243
QString typeId
Definition resizable_panel.h:60
int currentHeight
Definition resizable_panel.h:68
QSize sizeHint() const override
Definition resizable_panel.cpp:116
int getMinimumAllowedHeight() const
Definition resizable_panel.cpp:282
QString getTypeId() const
Definition resizable_panel.h:33
QFrame * frame
Definition resizable_panel.h:62
QFrame * selectionOverlay
Definition resizable_panel.h:63
void setHeightFromSaved(int h)
Definition resizable_panel.cpp:103
void dragStarted(ResizablePanel *panel)
int getCurrentHeight() const
Definition resizable_panel.cpp:111
void showDropIndicator(double y)
Definition resizable_panel.cpp:357
void performAutoScroll()
Definition resizable_panel.cpp:324
bool isDraggingPanel
Definition resizable_panel.h:70
bool eventFilter(QObject *obj, QEvent *event) override
Definition resizable_panel.cpp:130
void dropRequested(ResizablePanel *dragged, ResizablePanel *target, bool insertBefore)