New sliding handle widget for resizing side panels
This commit is contained in:
@@ -131,6 +131,7 @@ add_executable(Bloom
|
|||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp
|
||||||
|
src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#include "SlidingHandleWidget.hpp"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
using namespace Bloom::Widgets;
|
||||||
|
|
||||||
|
void SlidingHandleWidget::mouseMoveEvent(QMouseEvent* event) {
|
||||||
|
emit this->horizontalSlide(event->pos().x());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SlidingHandleWidget::enterEvent(QEnterEvent* event) {
|
||||||
|
this->setCursor(Qt::SplitHCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SlidingHandleWidget::leaveEvent(QEvent* event) {
|
||||||
|
this->setCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QSize>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QEnterEvent>
|
||||||
|
|
||||||
|
#include "src/Logger/Logger.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::Widgets
|
||||||
|
{
|
||||||
|
class Q_WIDGETS_EXPORT SlidingHandleWidget: public QFrame
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int handleWidth READ getHandleWidth WRITE setHandleWidth DESIGNABLE true)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int handleWidth = 10;
|
||||||
|
|
||||||
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
|
void enterEvent(QEnterEvent* event) override;
|
||||||
|
void leaveEvent(QEvent* event) override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SlidingHandleWidget(QWidget* parent): QFrame(parent) {};
|
||||||
|
|
||||||
|
QSize minimumSizeHint() const override {
|
||||||
|
return QSize(this->handleWidth, this->parentWidget()->height());
|
||||||
|
};
|
||||||
|
|
||||||
|
QSize sizeHint() const override {
|
||||||
|
return QSize(this->handleWidth, this->parentWidget()->height());
|
||||||
|
};
|
||||||
|
|
||||||
|
void setHandleWidth(int handleWidth) {
|
||||||
|
this->handleWidth = handleWidth;
|
||||||
|
this->setFixedWidth(handleWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
int getHandleWidth() {
|
||||||
|
return this->handleWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void horizontalSlide(int position);
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user