added experimental new tabs

This commit is contained in:
fourtf 2018-03-30 13:44:01 +02:00
parent ea21aa5dea
commit ec349f5978
3 changed files with 49 additions and 15 deletions

View file

@ -89,6 +89,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
// tabs // tabs
// text, {regular, hover, unfocused} // text, {regular, hover, unfocused}
this->windowBg = "#ccc";
this->tabs.regular = {tabFg, {windowBg, blendColors(windowBg, "#999", 0.5), windowBg}}; this->tabs.regular = {tabFg, {windowBg, blendColors(windowBg, "#999", 0.5), windowBg}};
this->tabs.selected = {"#fff", {themeColor, themeColor, QColor::fromHslF(hue, 0, 0.5)}}; this->tabs.selected = {"#fff", {themeColor, themeColor, QColor::fromHslF(hue, 0, 0.5)}};
@ -103,6 +104,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
tabFg, tabFg,
{blendColors(themeColor, windowBg, 0.7), blendColors(themeColor, windowBg, 0.5), {blendColors(themeColor, windowBg, 0.7), blendColors(themeColor, windowBg, 0.5),
blendColors(themeColorNoSat, windowBg, 0.7)}}; blendColors(themeColorNoSat, windowBg, 0.7)}};
this->windowBg = "#fff";
// Split // Split
bool flat = isLight; bool flat = isLight;

View file

@ -77,13 +77,16 @@ void NotebookTab::themeRefreshEvent()
void NotebookTab::updateSize() void NotebookTab::updateSize()
{ {
float scale = getScale(); float scale = getScale();
QString qTitle(qS(this->title));
if (singletons::SettingManager::getInstance().hideTabX) { this->resize((int)(150 * scale), (int)(24 * scale));
this->resize((int)((fontMetrics().width(qTitle) + 16) * scale), (int)(24 * scale));
} else { // QString qTitle(qS(this->title));
this->resize((int)((fontMetrics().width(qTitle) + 8 + 24) * scale), (int)(24 * scale)); // if (singletons::SettingManager::getInstance().hideTabX) {
} // this->resize((int)((fontMetrics().width(qTitle) + 16) * scale), (int)(24 * scale));
// } else {
// this->resize((int)((fontMetrics().width(qTitle) + 8 + 24) * scale), (int)(24 *
// scale));
// }
if (this->parent() != nullptr) { if (this->parent() != nullptr) {
(static_cast<Notebook *>(this->parent()))->performLayout(true); (static_cast<Notebook *>(this->parent()))->performLayout(true);
@ -168,6 +171,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
{ {
singletons::SettingManager &settingManager = singletons::SettingManager::getInstance(); singletons::SettingManager &settingManager = singletons::SettingManager::getInstance();
QPainter painter(this); QPainter painter(this);
float scale = this->getScale();
// select the right tab colors // select the right tab colors
singletons::ThemeManager::TabColors colors; singletons::ThemeManager::TabColors colors;
@ -186,25 +190,51 @@ void NotebookTab::paintEvent(QPaintEvent *)
bool windowFocused = this->window() == QApplication::activeWindow(); bool windowFocused = this->window() == QApplication::activeWindow();
// || SettingsDialog::getHandle() == QApplication::activeWindow(); // || SettingsDialog::getHandle() == QApplication::activeWindow();
painter.fillRect(rect(), this->mouseOver ? regular.backgrounds.hover if (false) {
: (windowFocused ? regular.backgrounds.regular painter.fillRect(rect(), this->mouseOver ? regular.backgrounds.hover
: regular.backgrounds.unfocused)); : (windowFocused ? regular.backgrounds.regular
: regular.backgrounds.unfocused));
// fill the tab background // fill the tab background
painter.fillRect(rect(), this->mouseOver ? colors.backgrounds.hover painter.fillRect(rect(), this->mouseOver ? colors.backgrounds.hover
: (windowFocused ? colors.backgrounds.regular : (windowFocused ? colors.backgrounds.regular
: colors.backgrounds.unfocused)); : colors.backgrounds.unfocused));
} else {
QPainterPath path(QPointF(0, this->height()));
path.lineTo(8 * scale, 0);
path.lineTo(this->width() - 8 * scale, 0);
path.lineTo(this->width(), this->height());
painter.fillPath(path, this->mouseOver ? regular.backgrounds.hover
: (windowFocused ? regular.backgrounds.regular
: regular.backgrounds.unfocused));
// fill the tab background
painter.fillPath(path, this->mouseOver ? colors.backgrounds.hover
: (windowFocused ? colors.backgrounds.regular
: colors.backgrounds.unfocused));
painter.setPen(QColor("#FFF"));
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPath(path);
// painter.setBrush(QColor("#000"));
}
// set the pen color // set the pen color
painter.setPen(colors.text); painter.setPen(colors.text);
// set area for text // set area for text
float scale = this->getScale();
int rectW = (settingManager.hideTabX ? 0 : static_cast<int>(16) * scale); int rectW = (settingManager.hideTabX ? 0 : static_cast<int>(16) * scale);
QRect rect(0, 0, this->width() - rectW, this->height()); QRect rect(0, 0, this->width() - rectW, this->height());
// draw text // draw text
painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter)); if (false) { // legacy
painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter));
} else {
QTextOption option(Qt::AlignLeft | Qt::AlignVCenter);
option.setWrapMode(QTextOption::NoWrap);
int offset = (int)(scale * 16);
QRect textRect(offset, 0, this->width() - offset - offset, this->height());
painter.drawText(textRect, this->getTitle(), option);
}
// draw close x // draw close x
if (!settingManager.hideTabX && (mouseOver || selected)) { if (!settingManager.hideTabX && (mouseOver || selected)) {

View file

@ -250,6 +250,8 @@ void Notebook::performLayout(bool animated)
x += i->getTab()->width(); x += i->getTab()->width();
} }
x -= (int)(8 * scale);
first = false; first = false;
} }