diff --git a/src/messages/layouts/messagelayout.cpp b/src/messages/layouts/messagelayout.cpp index ee38aef12..4ac17008a 100644 --- a/src/messages/layouts/messagelayout.cpp +++ b/src/messages/layouts/messagelayout.cpp @@ -117,7 +117,7 @@ void MessageLayout::actuallyLayout(int width, MessageElement::Flags flags) this->deleteBuffer(); } - this->container.finish(); + this->container.end(); this->height = this->container.getHeight(); } diff --git a/src/messages/layouts/messagelayoutcontainer.cpp b/src/messages/layouts/messagelayoutcontainer.cpp index 7a236615a..1913e7b7f 100644 --- a/src/messages/layouts/messagelayoutcontainer.cpp +++ b/src/messages/layouts/messagelayoutcontainer.cpp @@ -142,7 +142,7 @@ void MessageLayoutContainer::breakLine() } this->lineStart = this->elements.size(); - this->currentX = 0; + this->currentX = (int)(this->scale * 8); this->currentY += this->lineHeight; this->height = this->currentY + (this->margin.bottom * this->scale); this->lineHeight = 0; @@ -158,7 +158,7 @@ bool MessageLayoutContainer::fitsInLine(int _width) return this->currentX + _width <= this->width - this->margin.left - this->margin.right; } -void MessageLayoutContainer::finish() +void MessageLayoutContainer::end() { if (!this->atStartOfLine()) { this->breakLine(); diff --git a/src/messages/layouts/messagelayoutcontainer.hpp b/src/messages/layouts/messagelayoutcontainer.hpp index 9656b9b45..d8469ad7a 100644 --- a/src/messages/layouts/messagelayoutcontainer.hpp +++ b/src/messages/layouts/messagelayoutcontainer.hpp @@ -56,7 +56,7 @@ public: // methods void begin(int width, float scale, Message::MessageFlags flags); - void finish(); + void end(); void clear(); void addElement(MessageLayoutElement *element); diff --git a/src/singletons/thememanager.cpp b/src/singletons/thememanager.cpp index 5c228a26d..a088a0b89 100644 --- a/src/singletons/thememanager.cpp +++ b/src/singletons/thememanager.cpp @@ -89,7 +89,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier) // tabs // text, {regular, hover, unfocused} - this->windowBg = "#ccc"; + // this->windowBg = "#ccc"; this->tabs.border = "#999"; this->tabs.regular = {tabFg, {windowBg, blendColors(windowBg, "#999", 0.5), windowBg}}; @@ -107,7 +107,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier) {blendColors(themeColor, windowBg, 0.7), blendColors(themeColor, windowBg, 0.5), blendColors(themeColorNoSat, windowBg, 0.7)}}; - this->windowBg = "#fff"; + // this->windowBg = "#fff"; // Split bool flat = isLight; diff --git a/src/widgets/helper/notebooktab.cpp b/src/widgets/helper/notebooktab.cpp index 9f3d8e9e6..ad2f481db 100644 --- a/src/widgets/helper/notebooktab.cpp +++ b/src/widgets/helper/notebooktab.cpp @@ -83,12 +83,12 @@ void NotebookTab::updateSize() QString qTitle(qS(this->title)); if (singletons::SettingManager::getInstance().hideTabX) { - width = (int)((fontMetrics().width(qTitle) + 16 + 16) * scale); + width = (int)((fontMetrics().width(qTitle) + 16 /*+ 16*/) * scale); } else { - width = (int)((fontMetrics().width(qTitle) + 8 + 24 + 16) * scale); + width = (int)((fontMetrics().width(qTitle) + 8 + 24 /*+ 16*/) * scale); } - this->resize(std::min((int)(150 * scale), width), (int)(48 * scale)); + this->resize(std::min((int)(150 * scale), width), (int)(24 * scale)); if (this->parent() != nullptr) { (static_cast(this->parent()))->performLayout(true); @@ -176,7 +176,7 @@ void NotebookTab::paintEvent(QPaintEvent *) float scale = this->getScale(); int height = (int)(scale * 24); - int fullHeight = (int)(scale * 48); + // int fullHeight = (int)(scale * 48); // select the right tab colors singletons::ThemeManager::TabColors colors; @@ -199,35 +199,47 @@ void NotebookTab::paintEvent(QPaintEvent *) : (windowFocused ? colors.backgrounds.regular : colors.backgrounds.unfocused); - if (false) { + if (true) { painter.fillRect(rect(), this->mouseOver ? regular.backgrounds.hover : (windowFocused ? regular.backgrounds.regular : regular.backgrounds.unfocused)); // fill the tab background painter.fillRect(rect(), tabBackground); - } else { + + // draw border + painter.setPen(QPen("#ccc")); QPainterPath path(QPointF(0, height)); - path.lineTo(8 * scale, 0); - path.lineTo(this->width() - 8 * scale, 0); - path.lineTo(this->width(), height); - painter.fillPath(path, this->mouseOver ? regular.backgrounds.hover - : (windowFocused ? regular.backgrounds.regular - : regular.backgrounds.unfocused)); - - // fill the tab background - painter.fillPath(path, tabBackground); - painter.setPen(QColor("#FFF")); - painter.setRenderHint(QPainter::Antialiasing); + path.lineTo(0, 0); + path.lineTo(this->width() - 1, 0); + path.lineTo(this->width() - 1, this->height() - 1); + path.lineTo(0, this->height() - 1); painter.drawPath(path); - // painter.setBrush(QColor("#000")); + } else { + // QPainterPath path(QPointF(0, height)); + // path.lineTo(8 * scale, 0); + // path.lineTo(this->width() - 8 * scale, 0); + // path.lineTo(this->width(), height); + // painter.fillPath(path, this->mouseOver ? regular.backgrounds.hover + // : (windowFocused ? + // regular.backgrounds.regular + // : + // regular.backgrounds.unfocused)); - QLinearGradient gradient(0, height, 0, fullHeight); - gradient.setColorAt(0, tabBackground.color()); - gradient.setColorAt(1, "#fff"); + // // fill the tab background + // painter.fillPath(path, tabBackground); + // painter.setPen(QColor("#FFF")); + // painter.setRenderHint(QPainter::Antialiasing); + // painter.drawPath(path); + // // painter.setBrush(QColor("#000")); - QBrush brush(gradient); - painter.fillRect(0, height, this->width(), fullHeight - height, brush); + // QLinearGradient gradient(0, height, 0, fullHeight); + // gradient.setColorAt(0, tabBackground.color()); + // gradient.setColorAt(1, "#fff"); + + // QBrush brush(gradient); + // painter.fillRect(0, height, this->width(), fullHeight - height, + // brush); } // set the pen color @@ -238,14 +250,20 @@ void NotebookTab::paintEvent(QPaintEvent *) QRect rect(0, 0, this->width() - rectW, height); // draw text - if (false) { // legacy - painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter)); - } else { + if (true) { // legacy + // painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter)); + int offset = (int)(scale * 8); + QRect textRect(offset, 0, this->width() - offset - offset, height); + QTextOption option(Qt::AlignLeft | Qt::AlignVCenter); option.setWrapMode(QTextOption::NoWrap); - int offset = (int)(scale * 16); - QRect textRect(offset, 0, this->width() - offset - offset, height); painter.drawText(textRect, this->getTitle(), option); + } else { + // QTextOption option(Qt::AlignLeft | Qt::AlignVCenter); + // option.setWrapMode(QTextOption::NoWrap); + // int offset = (int)(scale * 16); + // QRect textRect(offset, 0, this->width() - offset - offset, height); + // painter.drawText(textRect, this->getTitle(), option); } // draw close x @@ -264,7 +282,7 @@ void NotebookTab::paintEvent(QPaintEvent *) painter.drawLine(xRect.topLeft() + QPoint(a, a), xRect.bottomRight() + QPoint(-a, -a)); painter.drawLine(xRect.topRight() + QPoint(-a, a), xRect.bottomLeft() + QPoint(a, -a)); } -} +} // namespace widgets void NotebookTab::mousePressEvent(QMouseEvent *event) { diff --git a/src/widgets/notebook.cpp b/src/widgets/notebook.cpp index ae19ad9a7..fd73921ae 100644 --- a/src/widgets/notebook.cpp +++ b/src/widgets/notebook.cpp @@ -162,7 +162,7 @@ SplitContainer *Notebook::tabAt(QPoint point, int &index, int maxWidth) for (auto *page : this->pages) { QRect rect = page->getTab()->getDesiredRect(); - rect.setHeight((int)(this->getScale() * 22)); + rect.setHeight((int)(this->getScale() * 24)); rect.setWidth(std::min(maxWidth, rect.width())); @@ -244,8 +244,8 @@ void Notebook::performLayout(bool animated) for (auto &i : this->pages) { if (!first && (i == this->pages.last() ? tabHeight : 0) + x + i->getTab()->width() > width()) { - // y += i->getTab()->height(); - y += 20; + y += i->getTab()->height() - 1; + // y += 20; i->getTab()->moveAnimated(QPoint(0, y), animated); x = i->getTab()->width(); } else { @@ -253,15 +253,19 @@ void Notebook::performLayout(bool animated) x += i->getTab()->width(); } - x -= (int)(8 * scale); + // x -= (int)(8 * scale); + x += 1; first = false; } - x += (int)(8 * scale); + // x += (int)(8 * scale); + // x += 1; this->addButton.move(x, y); + y -= 1; + for (auto &i : this->pages) { i->getTab()->raise(); }