diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b09a92b..9846e559 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.cpp new file mode 100644 index 00000000..88ad2ed8 --- /dev/null +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.cpp @@ -0,0 +1,17 @@ +#include "SlidingHandleWidget.hpp" + +#include + +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); +} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.hpp new file mode 100644 index 00000000..65963254 --- /dev/null +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/SlidingHandleWidget.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include +#include +#include +#include +#include + +#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); + + }; +}