From cb235ef532c5e3b9e9d49016e6b221b9585f9d10 Mon Sep 17 00:00:00 2001 From: fourtf Date: Thu, 9 Aug 2018 16:20:09 +0200 Subject: [PATCH] fixed ocd inducing 1 pixel offsets --- src/widgets/splits/SplitContainer.cpp | 19 +++++++++------ src/widgets/splits/SplitInput.cpp | 34 +++++++++++++-------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index 4d7cc9482..c7ae6c798 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -40,12 +40,12 @@ SplitContainer::SplitContainer(Notebook *parent) this->layout(); if (modifiers == showResizeHandlesModifiers) { - for (std::unique_ptr &handle : this->resizeHandles_) { + for (auto &handle : this->resizeHandles_) { handle->show(); handle->raise(); } } else { - for (std::unique_ptr &handle : this->resizeHandles_) { + for (auto &handle : this->resizeHandles_) { handle->hide(); } } @@ -89,7 +89,7 @@ void SplitContainer::hideResizeHandles() { this->overlay_.hide(); - for (std::unique_ptr &handle : this->resizeHandles_) { + for (auto &handle : this->resizeHandles_) { handle->hide(); } } @@ -311,7 +311,7 @@ void SplitContainer::focusSplitRecursive(Node *node, Direction direction) void SplitContainer::layout() { - this->baseNode_.geometry_ = this->rect(); + this->baseNode_.geometry_ = this->rect().adjusted(0, 0, -1, -1); std::vector _dropRects; std::vector _resizeRects; @@ -904,7 +904,7 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale, case Node::_Split: { QRect rect = this->geometry_.toRect(); this->split_->setGeometry( - rect.marginsRemoved(QMargins(1, 1, 1, 1))); + rect.marginsRemoved(QMargins(1, 1, 0, 0))); } break; case Node::VerticalContainer: case Node::HorizontalContainer: { @@ -968,10 +968,10 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale, } // iterate children - qreal pos = isVertical ? childRect.top() : childRect.left(); + auto pos = int(isVertical ? childRect.top() : childRect.left()); for (std::unique_ptr &child : this->children_) { // set rect - QRectF rect = childRect; + QRect rect = childRect.toRect(); if (isVertical) { rect.setTop(pos); rect.setHeight( @@ -987,6 +987,11 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale, sizeMultiplier); } + if (child == this->children_.back()) { + rect.setRight(childRect.right() - 1); + rect.setBottom(childRect.bottom() - 1); + } + child->geometry_ = rect; child->layout(addSpacing, _scale, dropRects, resizeRects); diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index e524e6317..65bc37e5c 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -78,23 +78,21 @@ void SplitInput::initLayout() })); // open emote popup - QObject::connect( - this->ui_.emoteButton, &EffectLabel::clicked, [this] { - if (!this->emotePopup_) { - this->emotePopup_ = std::make_unique(); - this->emotePopup_->linkClicked.connect( - [this](const Link &link) { - if (link.type == Link::InsertText) { - this->insertText(link.value + " "); - } - }); - } + QObject::connect(this->ui_.emoteButton, &EffectLabel::clicked, [this] { + if (!this->emotePopup_) { + this->emotePopup_ = std::make_unique(); + this->emotePopup_->linkClicked.connect([this](const Link &link) { + if (link.type == Link::InsertText) { + this->insertText(link.value + " "); + } + }); + } - this->emotePopup_->resize(int(300 * this->emotePopup_->getScale()), - int(500 * this->emotePopup_->getScale())); - this->emotePopup_->loadChannel(this->split_->getChannel()); - this->emotePopup_->show(); - }); + this->emotePopup_->resize(int(300 * this->emotePopup_->getScale()), + int(500 * this->emotePopup_->getScale())); + this->emotePopup_->loadChannel(this->split_->getChannel()); + this->emotePopup_->show(); + }); // clear channelview selection when selecting in the input QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable, @@ -346,7 +344,7 @@ void SplitInput::paintEvent(QPaintEvent *) if (this->theme->isLightTheme()) { int s = int(3 * this->getScale()); - QRect rect = this->rect().marginsRemoved(QMargins(s, s, s, s)); + QRect rect = this->rect().marginsRemoved(QMargins(s - 1, s - 1, s, s)); painter.fillRect(rect, this->theme->splits.input.background); @@ -354,7 +352,7 @@ void SplitInput::paintEvent(QPaintEvent *) painter.drawRect(rect); } else { int s = int(1 * this->getScale()); - QRect rect = this->rect().marginsRemoved(QMargins(s, s, s, s)); + QRect rect = this->rect().marginsRemoved(QMargins(s - 1, s - 1, s, s)); painter.fillRect(rect, this->theme->splits.input.background);