From a1f521e28903bfe18927b4f892318d643260b7b2 Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 21 Dec 2018 07:43:53 +0000 Subject: [PATCH] CtrlLib, ide: Better dark theme support (using DarkTheme for RichTextCtrl) git-svn-id: svn://ultimatepp.org/upp/trunk@12635 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Color.cpp | 4 +++- uppsrc/CtrlLib/RichTextView.cpp | 4 +--- uppsrc/RichText/ParaData.cpp | 2 +- uppsrc/RichText/ParaPaint.cpp | 6 +++--- uppsrc/RichText/RichText.h | 2 +- uppsrc/RichText/TableCell.cpp | 4 ---- uppsrc/ide/About.cpp | 1 + 7 files changed, 10 insertions(+), 13 deletions(-) diff --git a/uppsrc/Core/Color.cpp b/uppsrc/Core/Color.cpp index 25d7837d8..d058c3f6e 100644 --- a/uppsrc/Core/Color.cpp +++ b/uppsrc/Core/Color.cpp @@ -216,10 +216,12 @@ bool IsLight(Color c) Color DarkTheme(Color c) { + if(IsNull(c)) + return Null; double h, s, v; const double m = 1/255.0; RGBtoHSV(m * c.GetR(), m * c.GetG(), m * c.GetB(), h, s, v); - return HsvColorf(h, s, (1 + s * 0.3) - v); + return HsvColorf(h, s, (1 + s * 0.5) - v); } Color DarkThemeCached(Color c) diff --git a/uppsrc/CtrlLib/RichTextView.cpp b/uppsrc/CtrlLib/RichTextView.cpp index 2e09ad1b4..fd06473a3 100644 --- a/uppsrc/CtrlLib/RichTextView.cpp +++ b/uppsrc/CtrlLib/RichTextView.cpp @@ -36,9 +36,7 @@ void RichTextView::Paint(Draw& w) pi.usecache = true; pi.sizetracking = sizetracking; pi.shrink_oversized_objects = shrink_oversized_objects; - Color c = SColorPaper(); - if(Grayscale(c) < 100) - pi.coloroverride = true; + pi.darktheme = Grayscale(SColorPaper()) < 100; Rect pg = GetPage(); if(vcenter && sb.GetTotal() < sb.GetPage()) pg.top = (sb.GetPage() - sb.GetTotal()) / 2; diff --git a/uppsrc/RichText/ParaData.cpp b/uppsrc/RichText/ParaData.cpp index cc2509c72..b1503df2b 100644 --- a/uppsrc/RichText/ParaData.cpp +++ b/uppsrc/RichText/ParaData.cpp @@ -56,7 +56,7 @@ PaintInfo::PaintInfo() highlight = Yellow(); indexentry = LtGreen(); indexentrybg = false; - coloroverride = false; + darktheme = false; context = NULL; showlabels = false; shrink_oversized_objects = false; diff --git a/uppsrc/RichText/ParaPaint.cpp b/uppsrc/RichText/ParaPaint.cpp index e75e40039..493c6df4f 100644 --- a/uppsrc/RichText/ParaPaint.cpp +++ b/uppsrc/RichText/ParaPaint.cpp @@ -8,12 +8,12 @@ namespace Upp { Color PaintInfo::ResolveInk(Color ink) const { - return Nvl(textcolor, coloroverride ? SColorText() : Nvl(ink, SColorText())); + return Nvl(textcolor, darktheme ? Nvl(DarkThemeCached(ink), SColorText()) : Nvl(ink, SColorText())); } Color PaintInfo::ResolvePaper(Color paper) const { - return coloroverride ? SColorPaper() : Nvl(paper, SColorPaper()); + return darktheme ? Nvl(DarkThemeCached(paper), SColorPaper()) : Nvl(paper, SColorPaper()); } RichPara::Lines RichPara::Begin(RichContext& rc) const @@ -65,7 +65,7 @@ void RichPara::Flush(Draw& draw, const PaintInfo& pi, wchar *text, } if(!IsNull(f.link) && !IsNull(pi.hyperlink) && !(fnt.IsUnderline() || f.dashed)) { fnt.Underline(); - if(!pi.coloroverride && IsNull(pi.textcolor)) + if(!pi.darktheme && IsNull(pi.textcolor)) ink = pi.hyperlink; } x = zx0; diff --git a/uppsrc/RichText/RichText.h b/uppsrc/RichText/RichText.h index 3ff53e906..0bc8ef022 100644 --- a/uppsrc/RichText/RichText.h +++ b/uppsrc/RichText/RichText.h @@ -284,7 +284,7 @@ struct PaintInfo { Bits (*spellingchecker)(const RichPara& para); int highlightpara; Color highlight; - bool coloroverride; + bool darktheme; void *context; bool showlabels; bool shrink_oversized_objects; diff --git a/uppsrc/RichText/TableCell.cpp b/uppsrc/RichText/TableCell.cpp index fc0699268..0af23ddf3 100644 --- a/uppsrc/RichText/TableCell.cpp +++ b/uppsrc/RichText/TableCell.cpp @@ -147,10 +147,6 @@ void RichCell::DrawCell(Draw& w, int l, int r, int y, int yy, const Rect& border r - l - border.left - border.right, yy - y - border.top - border.bottom, pi.ResolvePaper(format.color)); DrawCellBorder(w, Rect(l, y, r, yy), border, margin, pi.ResolveInk(format.bordercolor), format.round); -// w.DrawRect(l, y, r - l, border.top, format.bordercolor); -// w.DrawRect(l, y, border.left, yy - y, format.bordercolor); -// w.DrawRect(r - border.right, y, border.right, yy - y, format.bordercolor); -// w.DrawRect(l, yy - border.bottom, r - l, border.bottom, format.bordercolor); } PageY RichCell::Align(const RichContext& rc, PageY npy) const diff --git a/uppsrc/ide/About.cpp b/uppsrc/ide/About.cpp index ed6216928..8d5b6a914 100644 --- a/uppsrc/ide/About.cpp +++ b/uppsrc/ide/About.cpp @@ -79,6 +79,7 @@ Size SplashCtrl::MakeLogo(Ctrl& parent, Array& ctrl) v1 = h; v1.HSizePos(DPI(220), DPI(10)).BottomPos(DPI(20), Arial(DPI(20)).GetHeight() * 5); v1.SetFont(Arial(DPI(10))); + v1.SetInk(Black()); l.Add(v1); parent.Add(ctrl.Create().Color(White).SizePos()); parent.Add(l.TopPos(0, isz.cy).LeftPos(0, isz.cx));