mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
When manual resizing is enabled, the vertical widget size can be changed by dragging the widget in the lower right corner.
35 lines
818 B
C++
35 lines
818 B
C++
#pragma once
|
|
#include <QMouseEvent>
|
|
#include <QPainter>
|
|
#include <QWidget>
|
|
|
|
namespace advss {
|
|
|
|
class ResizableWidget : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
ResizableWidget(QWidget *parent = nullptr);
|
|
|
|
protected:
|
|
void SetResizingEnabled(bool enable);
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
void paintEvent(QPaintEvent *event) override;
|
|
QSize sizeHint() const override;
|
|
int GetCustomHeight() const { return _customHeight; }
|
|
void SetCustomHeight(int value) { _customHeight = value; }
|
|
|
|
private:
|
|
bool IsInResizeArea(const QPoint &pos) const;
|
|
|
|
bool _resizingEnabled = false;
|
|
bool _resizing = false;
|
|
QPoint _lastMousePos;
|
|
int _customHeight = 0;
|
|
const int _gripSize = 15;
|
|
};
|
|
|
|
} // namespace advss
|