SceneSwitcher/lib/utils/resizable-widget.hpp
WarmUpTill be8f7bd70f Add ResizableWidget
When manual resizing is enabled, the vertical widget size can be changed
by dragging the widget in the lower right corner.
2025-07-13 18:17:46 +02:00

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