fixed ocd inducing 1 pixel offsets

This commit is contained in:
fourtf 2018-08-09 16:20:09 +02:00
parent 81f2f8781a
commit cb235ef532
2 changed files with 28 additions and 25 deletions

View file

@ -40,12 +40,12 @@ SplitContainer::SplitContainer(Notebook *parent)
this->layout(); this->layout();
if (modifiers == showResizeHandlesModifiers) { if (modifiers == showResizeHandlesModifiers) {
for (std::unique_ptr<ResizeHandle> &handle : this->resizeHandles_) { for (auto &handle : this->resizeHandles_) {
handle->show(); handle->show();
handle->raise(); handle->raise();
} }
} else { } else {
for (std::unique_ptr<ResizeHandle> &handle : this->resizeHandles_) { for (auto &handle : this->resizeHandles_) {
handle->hide(); handle->hide();
} }
} }
@ -89,7 +89,7 @@ void SplitContainer::hideResizeHandles()
{ {
this->overlay_.hide(); this->overlay_.hide();
for (std::unique_ptr<ResizeHandle> &handle : this->resizeHandles_) { for (auto &handle : this->resizeHandles_) {
handle->hide(); handle->hide();
} }
} }
@ -311,7 +311,7 @@ void SplitContainer::focusSplitRecursive(Node *node, Direction direction)
void SplitContainer::layout() void SplitContainer::layout()
{ {
this->baseNode_.geometry_ = this->rect(); this->baseNode_.geometry_ = this->rect().adjusted(0, 0, -1, -1);
std::vector<DropRect> _dropRects; std::vector<DropRect> _dropRects;
std::vector<ResizeRect> _resizeRects; std::vector<ResizeRect> _resizeRects;
@ -904,7 +904,7 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
case Node::_Split: { case Node::_Split: {
QRect rect = this->geometry_.toRect(); QRect rect = this->geometry_.toRect();
this->split_->setGeometry( this->split_->setGeometry(
rect.marginsRemoved(QMargins(1, 1, 1, 1))); rect.marginsRemoved(QMargins(1, 1, 0, 0)));
} break; } break;
case Node::VerticalContainer: case Node::VerticalContainer:
case Node::HorizontalContainer: { case Node::HorizontalContainer: {
@ -968,10 +968,10 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
} }
// iterate children // iterate children
qreal pos = isVertical ? childRect.top() : childRect.left(); auto pos = int(isVertical ? childRect.top() : childRect.left());
for (std::unique_ptr<Node> &child : this->children_) { for (std::unique_ptr<Node> &child : this->children_) {
// set rect // set rect
QRectF rect = childRect; QRect rect = childRect.toRect();
if (isVertical) { if (isVertical) {
rect.setTop(pos); rect.setTop(pos);
rect.setHeight( rect.setHeight(
@ -987,6 +987,11 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
sizeMultiplier); sizeMultiplier);
} }
if (child == this->children_.back()) {
rect.setRight(childRect.right() - 1);
rect.setBottom(childRect.bottom() - 1);
}
child->geometry_ = rect; child->geometry_ = rect;
child->layout(addSpacing, _scale, dropRects, resizeRects); child->layout(addSpacing, _scale, dropRects, resizeRects);

View file

@ -78,23 +78,21 @@ void SplitInput::initLayout()
})); }));
// open emote popup // open emote popup
QObject::connect( QObject::connect(this->ui_.emoteButton, &EffectLabel::clicked, [this] {
this->ui_.emoteButton, &EffectLabel::clicked, [this] { if (!this->emotePopup_) {
if (!this->emotePopup_) { this->emotePopup_ = std::make_unique<EmotePopup>();
this->emotePopup_ = std::make_unique<EmotePopup>(); this->emotePopup_->linkClicked.connect([this](const Link &link) {
this->emotePopup_->linkClicked.connect( if (link.type == Link::InsertText) {
[this](const Link &link) { this->insertText(link.value + " ");
if (link.type == Link::InsertText) { }
this->insertText(link.value + " "); });
} }
});
}
this->emotePopup_->resize(int(300 * this->emotePopup_->getScale()), this->emotePopup_->resize(int(300 * this->emotePopup_->getScale()),
int(500 * this->emotePopup_->getScale())); int(500 * this->emotePopup_->getScale()));
this->emotePopup_->loadChannel(this->split_->getChannel()); this->emotePopup_->loadChannel(this->split_->getChannel());
this->emotePopup_->show(); this->emotePopup_->show();
}); });
// clear channelview selection when selecting in the input // clear channelview selection when selecting in the input
QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable, QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable,
@ -346,7 +344,7 @@ void SplitInput::paintEvent(QPaintEvent *)
if (this->theme->isLightTheme()) { if (this->theme->isLightTheme()) {
int s = int(3 * this->getScale()); 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); painter.fillRect(rect, this->theme->splits.input.background);
@ -354,7 +352,7 @@ void SplitInput::paintEvent(QPaintEvent *)
painter.drawRect(rect); painter.drawRect(rect);
} else { } else {
int s = int(1 * this->getScale()); 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); painter.fillRect(rect, this->theme->splits.input.background);