From f8e4d9a73759f545d06a57b8b2a5e5b26ffc0796 Mon Sep 17 00:00:00 2001 From: fourtf Date: Tue, 19 Dec 2017 02:23:17 +0100 Subject: [PATCH] changes for light theme - fixed light colored text being too bright - fixed the ripple effect being white on grey --- src/colorscheme.cpp | 13 +++++++++++-- src/widgets/helper/rippleeffectbutton.cpp | 12 ++++++++++-- src/widgets/helper/rippleeffectbutton.hpp | 6 ++++-- src/widgets/helper/rippleeffectlabel.cpp | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/colorscheme.cpp b/src/colorscheme.cpp index 21e9915b..a2d7b9c1 100644 --- a/src/colorscheme.cpp +++ b/src/colorscheme.cpp @@ -132,7 +132,16 @@ QColor ColorScheme::blendColors(const QColor &color1, const QColor &color2, qrea void ColorScheme::normalizeColor(QColor &color) { if (this->lightTheme) { - // TODO: write some codes + if (color.lightnessF() > 0.5f) { + color.setHslF(color.hueF(), color.saturationF(), 0.5f); + } + + if (color.lightnessF() > 0.4f && color.hueF() > 0.1 && color.hueF() < 0.33333) { + color.setHslF(color.hueF(), color.saturationF(), + color.lightnessF() - + sin((color.hueF() - 0.1) / (0.3333 - 0.1) * 3.14159) * + color.saturationF() * 0.2); + } } else { if (color.lightnessF() < 0.5f) { color.setHslF(color.hueF(), color.saturationF(), 0.5f); @@ -142,7 +151,7 @@ void ColorScheme::normalizeColor(QColor &color) color.setHslF(color.hueF(), color.saturationF(), color.lightnessF() + sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) * - color.saturationF() * 0.2); + color.saturationF() * 0.4); } } } diff --git a/src/widgets/helper/rippleeffectbutton.cpp b/src/widgets/helper/rippleeffectbutton.cpp index 93d84e86..5b07f2af 100644 --- a/src/widgets/helper/rippleeffectbutton.cpp +++ b/src/widgets/helper/rippleeffectbutton.cpp @@ -3,6 +3,8 @@ #include #include +#include "colorscheme.hpp" + namespace chatterino { namespace widgets { @@ -16,7 +18,7 @@ RippleEffectButton::RippleEffectButton(BaseWidget *parent) this->effectTimer.start(); } -void RippleEffectButton::setMouseEffectColor(QColor color) +void RippleEffectButton::setMouseEffectColor(boost::optional color) { this->mouseEffectColor = color; } @@ -30,7 +32,13 @@ void RippleEffectButton::paintEvent(QPaintEvent *) void RippleEffectButton::fancyPaint(QPainter &painter) { - QColor &c = this->mouseEffectColor; + QColor c; + + if (this->mouseEffectColor) { + c = this->mouseEffectColor.get(); + } else { + c = this->colorScheme.isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255); + } if (this->hoverMultiplier > 0) { QRadialGradient gradient(mousePos.x(), mousePos.y(), 50, mousePos.x(), mousePos.y()); diff --git a/src/widgets/helper/rippleeffectbutton.hpp b/src/widgets/helper/rippleeffectbutton.hpp index 2ce38f9b..cc4bf923 100644 --- a/src/widgets/helper/rippleeffectbutton.hpp +++ b/src/widgets/helper/rippleeffectbutton.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "widgets/basewidget.hpp" #include @@ -28,7 +30,7 @@ class RippleEffectButton : public BaseWidget public: RippleEffectButton(BaseWidget *parent); - void setMouseEffectColor(QColor color); + void setMouseEffectColor(boost::optional color); signals: void clicked(); @@ -52,7 +54,7 @@ private: double hoverMultiplier = 0.0; QTimer effectTimer; std::vector clickEffects; - QColor mouseEffectColor = {255, 255, 255}; + boost::optional mouseEffectColor = boost::none; void onMouseEffectTimeout(); }; diff --git a/src/widgets/helper/rippleeffectlabel.cpp b/src/widgets/helper/rippleeffectlabel.cpp index 45fd1a71..61a182ad 100644 --- a/src/widgets/helper/rippleeffectlabel.cpp +++ b/src/widgets/helper/rippleeffectlabel.cpp @@ -21,7 +21,7 @@ RippleEffectLabel::RippleEffectLabel(BaseWidget *parent, int spacing) this->hbox.addWidget(&this->label); this->hbox.addSpacing(spacing); - this->setMouseEffectColor(QColor(255, 255, 255, 63)); + // this->setMouseEffectColor(QColor(255, 255, 255, 63)); } } // namespace widgets