mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-10 18:46:11 -05:00
Add ResizableWidget
When manual resizing is enabled, the vertical widget size can be changed by dragging the widget in the lower right corner.
This commit is contained in:
34
lib/utils/resizable-widget.hpp
Normal file
34
lib/utils/resizable-widget.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user