2017-01-18 01:04:54 +01:00
|
|
|
#define LOOKUP_COLOR_COUNT 360
|
|
|
|
|
2018-07-15 14:03:41 +02:00
|
|
|
#include "singletons/Theme.hpp"
|
2018-11-25 15:02:48 +01:00
|
|
|
#include "Application.hpp"
|
2017-01-18 04:52:47 +01:00
|
|
|
|
|
|
|
#include <QColor>
|
2016-12-30 19:16:48 +01:00
|
|
|
|
2018-04-03 02:55:32 +02:00
|
|
|
#include <cmath>
|
2017-08-05 23:38:49 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2017-01-18 21:30:23 +01:00
|
|
|
|
2018-06-28 20:03:04 +02:00
|
|
|
Theme::Theme()
|
2017-06-26 16:41:20 +02:00
|
|
|
{
|
|
|
|
this->update();
|
2017-06-13 21:13:58 +02:00
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
this->themeName.connectSimple([this](auto) { this->update(); }, false);
|
|
|
|
this->themeHue.connectSimple([this](auto) { this->update(); }, false);
|
2017-02-02 01:23:26 +01:00
|
|
|
}
|
|
|
|
|
2016-12-30 19:20:04 +01:00
|
|
|
// hue: theme color (0 - 1)
|
2017-06-26 16:41:20 +02:00
|
|
|
// multiplier: 1 = white, 0.8 = light, -0.8 dark, -1 black
|
2018-06-28 20:03:04 +02:00
|
|
|
void Theme::actuallyUpdate(double hue, double multiplier)
|
2016-12-30 19:16:48 +01:00
|
|
|
{
|
2018-12-02 19:20:14 +01:00
|
|
|
BaseTheme::actuallyUpdate(hue, multiplier);
|
2018-01-27 21:13:22 +01:00
|
|
|
|
|
|
|
auto getColor = [multiplier](double h, double s, double l, double a = 1.0) {
|
|
|
|
return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a);
|
|
|
|
};
|
|
|
|
|
2018-11-25 15:02:48 +01:00
|
|
|
auto sat = qreal(0);
|
|
|
|
auto isLight_ = this->isLightTheme();
|
|
|
|
auto flat = isLight_;
|
2018-05-26 17:11:09 +02:00
|
|
|
|
2018-11-25 15:02:48 +01:00
|
|
|
if (this->isLightTheme())
|
2018-10-21 13:43:02 +02:00
|
|
|
{
|
2018-06-07 17:43:21 +02:00
|
|
|
this->splits.dropTargetRect = QColor(255, 255, 255, 0x00);
|
|
|
|
this->splits.dropTargetRectBorder = QColor(0, 148, 255, 0x00);
|
|
|
|
|
|
|
|
this->splits.resizeHandle = QColor(0, 148, 255, 0xff);
|
|
|
|
this->splits.resizeHandleBackground = QColor(0, 148, 255, 0x50);
|
2019-04-22 18:32:58 +02:00
|
|
|
|
|
|
|
// Highlighted Messages: theme support quick-fix
|
|
|
|
this->messages.backgrounds.highlighted =
|
|
|
|
QColor("#BD8489");
|
2018-10-21 13:43:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-07 17:43:21 +02:00
|
|
|
this->splits.dropTargetRect = QColor(0, 148, 255, 0x00);
|
|
|
|
this->splits.dropTargetRectBorder = QColor(0, 148, 255, 0x00);
|
|
|
|
|
|
|
|
this->splits.resizeHandle = QColor(0, 148, 255, 0x70);
|
|
|
|
this->splits.resizeHandleBackground = QColor(0, 148, 255, 0x20);
|
2019-04-22 18:32:58 +02:00
|
|
|
|
|
|
|
// Highlighted Messages: theme support quick-fix
|
|
|
|
this->messages.backgrounds.highlighted =
|
|
|
|
QColor("#4B282C");
|
|
|
|
|
2018-06-07 17:43:21 +02:00
|
|
|
}
|
2018-01-02 02:15:11 +01:00
|
|
|
|
|
|
|
this->splits.header.background = getColor(0, sat, flat ? 1 : 0.9);
|
|
|
|
this->splits.header.border = getColor(0, sat, flat ? 1 : 0.85);
|
|
|
|
this->splits.header.text = this->messages.textColors.regular;
|
2018-08-06 21:17:03 +02:00
|
|
|
this->splits.header.focusedText =
|
|
|
|
isLight_ ? QColor("#198CFF") : QColor("#84C1FF");
|
2018-01-02 02:15:11 +01:00
|
|
|
|
|
|
|
this->splits.input.background = getColor(0, sat, flat ? 0.95 : 0.95);
|
|
|
|
this->splits.input.border = getColor(0, sat, flat ? 1 : 1);
|
|
|
|
this->splits.input.text = this->messages.textColors.regular;
|
|
|
|
this->splits.input.styleSheet =
|
|
|
|
"background:" + this->splits.input.background.name() + ";" +
|
2018-08-06 21:17:03 +02:00
|
|
|
"border:" + this->tabs.selected.backgrounds.regular.color().name() +
|
|
|
|
";" + "color:" + this->messages.textColors.regular.name() + ";" + //
|
2018-06-07 17:43:21 +02:00
|
|
|
"selection-background-color:" +
|
2018-08-06 21:17:03 +02:00
|
|
|
(isLight_ ? "#68B1FF"
|
|
|
|
: this->tabs.selected.backgrounds.regular.color().name());
|
2018-01-02 02:15:11 +01:00
|
|
|
|
2018-11-25 15:02:48 +01:00
|
|
|
this->splits.input.focusedLine = this->tabs.highlighted.line.regular;
|
2017-09-12 19:06:16 +02:00
|
|
|
|
2018-11-25 15:02:48 +01:00
|
|
|
this->splits.messageSeperator =
|
|
|
|
isLight_ ? QColor(127, 127, 127) : QColor(60, 60, 60);
|
|
|
|
this->splits.background = getColor(0, sat, 1);
|
|
|
|
this->splits.dropPreview = QColor(0, 148, 255, 0x30);
|
|
|
|
this->splits.dropPreviewBorder = QColor(0, 148, 255, 0xff);
|
2018-12-09 12:44:37 +01:00
|
|
|
|
|
|
|
// Highlighted Messages
|
2019-04-22 18:32:58 +02:00
|
|
|
// hidden setting from PR #744 - if set it will overwrite theme color (for now!)
|
|
|
|
//TODO: implement full theme support
|
|
|
|
if (getSettings()->highlightColor != "") {
|
|
|
|
this->messages.backgrounds.highlighted =
|
|
|
|
QColor(getSettings()->highlightColor);
|
|
|
|
}
|
|
|
|
|
2017-09-12 19:06:16 +02:00
|
|
|
}
|
|
|
|
|
2018-06-28 20:03:04 +02:00
|
|
|
void Theme::normalizeColor(QColor &color)
|
2017-01-18 01:04:54 +01:00
|
|
|
{
|
2018-11-25 15:02:48 +01:00
|
|
|
if (this->isLightTheme())
|
2018-10-21 13:43:02 +02:00
|
|
|
{
|
|
|
|
if (color.lightnessF() > 0.5)
|
|
|
|
{
|
2018-06-01 14:20:46 +02:00
|
|
|
color.setHslF(color.hueF(), color.saturationF(), 0.5);
|
2017-12-19 02:23:17 +01:00
|
|
|
}
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
if (color.lightnessF() > 0.4 && color.hueF() > 0.1 &&
|
2018-10-21 13:43:02 +02:00
|
|
|
color.hueF() < 0.33333)
|
|
|
|
{
|
2018-08-06 21:17:03 +02:00
|
|
|
color.setHslF(color.hueF(), color.saturationF(),
|
|
|
|
color.lightnessF() - sin((color.hueF() - 0.1) /
|
|
|
|
(0.3333 - 0.1) * 3.14159) *
|
|
|
|
color.saturationF() * 0.4);
|
2017-12-19 02:23:17 +01:00
|
|
|
}
|
2018-10-21 13:43:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (color.lightnessF() < 0.5)
|
|
|
|
{
|
2018-06-01 14:20:46 +02:00
|
|
|
color.setHslF(color.hueF(), color.saturationF(), 0.5);
|
2017-08-12 12:09:26 +02:00
|
|
|
}
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
if (color.lightnessF() < 0.6 && color.hueF() > 0.54444 &&
|
2018-10-21 13:43:02 +02:00
|
|
|
color.hueF() < 0.83333)
|
|
|
|
{
|
2018-01-12 23:09:05 +01:00
|
|
|
color.setHslF(
|
|
|
|
color.hueF(), color.saturationF(),
|
2018-08-06 21:17:03 +02:00
|
|
|
color.lightnessF() + sin((color.hueF() - 0.54444) /
|
|
|
|
(0.8333 - 0.54444) * 3.14159) *
|
2018-01-12 23:09:05 +01:00
|
|
|
color.saturationF() * 0.4);
|
2017-08-12 12:09:26 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-30 19:16:48 +01:00
|
|
|
}
|
2017-06-07 10:09:24 +02:00
|
|
|
|
2018-11-25 15:02:48 +01:00
|
|
|
Theme *getTheme()
|
|
|
|
{
|
|
|
|
return getApp()->themes;
|
|
|
|
}
|
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace chatterino
|