From 28fb877020382430eb2d7e61676e02edaaa0c3e8 Mon Sep 17 00:00:00 2001 From: fourtf Date: Fri, 11 May 2018 13:55:10 +0200 Subject: [PATCH] updated splitheader --- chatterino.pro | 8 ++++++-- src/widgets/helper/splitheader.cpp | 14 +++++++------- src/widgets/helper/splitoverlay.cpp | 6 +++--- src/widgets/splitcontainer.hpp | 19 ++++--------------- 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/chatterino.pro b/chatterino.pro index 980bb2c52..5317d757f 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -197,7 +197,9 @@ SOURCES += \ src/controllers/accounts/accountcontroller.cpp \ src/controllers/accounts/accountmodel.cpp \ src/controllers/accounts/account.cpp \ - src/widgets/helper/splitoverlay.cpp + src/widgets/helper/splitoverlay.cpp \ + src/widgets/helper/dropoverlay.cpp \ + src/widgets/helper/splitnode.cpp HEADERS += \ src/precompiled_header.hpp \ @@ -343,7 +345,9 @@ HEADERS += \ src/controllers/accounts/accountmodel.hpp \ src/controllers/accounts/account.hpp \ src/util/sharedptrelementless.hpp \ - src/widgets/helper/splitoverlay.hpp + src/widgets/helper/splitoverlay.hpp \ + src/widgets/helper/dropoverlay.hpp \ + src/widgets/helper/splitnode.hpp RESOURCES += \ resources/resources.qrc diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp index 2b278dea0..42fef1c01 100644 --- a/src/widgets/helper/splitheader.cpp +++ b/src/widgets/helper/splitheader.cpp @@ -241,13 +241,13 @@ void SplitHeader::mouseMoveEvent(QMouseEvent *event) tooltipWidget->show(); } - // if (this->dragging) { - // if (std::abs(this->dragStart.x() - event->pos().x()) > 12 || - // std::abs(this->dragStart.y() - event->pos().y()) > 12) { - // this->split->drag(); - // this->dragging = false; - // } - // } + if (this->dragging) { + if (std::abs(this->dragStart.x() - event->pos().x()) > 12 || + std::abs(this->dragStart.y() - event->pos().y()) > 12) { + this->split->drag(); + this->dragging = false; + } + } } void SplitHeader::leaveEvent(QEvent *event) diff --git a/src/widgets/helper/splitoverlay.cpp b/src/widgets/helper/splitoverlay.cpp index a43ac9567..27ac05a0c 100644 --- a/src/widgets/helper/splitoverlay.cpp +++ b/src/widgets/helper/splitoverlay.cpp @@ -112,9 +112,9 @@ void SplitOverlay::paintEvent(QPaintEvent *event) void SplitOverlay::resizeEvent(QResizeEvent *event) { - float scale = this->getScale(); - bool wideEnough = event->size().width() > 150 * scale; - bool highEnough = event->size().height() > 150 * scale; + float _scale = this->getScale(); + bool wideEnough = event->size().width() > 150 * _scale; + bool highEnough = event->size().height() > 150 * _scale; this->_left->setVisible(wideEnough); this->_right->setVisible(wideEnough); diff --git a/src/widgets/splitcontainer.hpp b/src/widgets/splitcontainer.hpp index 1fb3043af..8feb137a3 100644 --- a/src/widgets/splitcontainer.hpp +++ b/src/widgets/splitcontainer.hpp @@ -189,22 +189,11 @@ public: { auto &siblings = this->parent->children; - qreal size = - // std::accumulate(this->parent->children.begin(), - // this->parent->children.end(), 0, - // [_direction](qreal val, Node *node) { - // if (toContainerType(_direction) == - // Type::VerticalContainer) { - // return val + node->geometry.height(); - // } else { - // return val + node->geometry.width(); - // } - // }); - - this->parent->geometry.width() / siblings.size(); + qreal width = this->parent->geometry.width() / siblings.size(); + qreal height = this->parent->geometry.height() / siblings.size(); if (siblings.size() == 1) { - this->geometry = QRect(0, 0, size, size); + this->geometry = QRect(0, 0, width, height); } auto it = std::find_if(siblings.begin(), siblings.end(), @@ -216,7 +205,7 @@ public: } Node *node = new Node(_split, this->parent); - node->geometry = QRectF(0, 0, size, size); + node->geometry = QRectF(0, 0, width, height); siblings.insert(it, std::unique_ptr(node)); }