New sliding handle widget for resizing side panels

This commit is contained in:
Nav
2021-08-22 20:46:19 +01:00
parent 342384a91c
commit 5e280f9327
3 changed files with 67 additions and 0 deletions

View File

@@ -131,6 +131,7 @@ add_executable(Bloom
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp
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/ExpandingHeightScrollAreaWidget.hpp

View File

@@ -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);
}

View File

@@ -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);
};
}