mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
CtrlLib, ide: Better dark theme support (using DarkTheme for RichTextCtrl)
git-svn-id: svn://ultimatepp.org/upp/trunk@12635 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ccca23f1f2
commit
a1f521e289
7 changed files with 10 additions and 13 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ PaintInfo::PaintInfo()
|
|||
highlight = Yellow();
|
||||
indexentry = LtGreen();
|
||||
indexentrybg = false;
|
||||
coloroverride = false;
|
||||
darktheme = false;
|
||||
context = NULL;
|
||||
showlabels = false;
|
||||
shrink_oversized_objects = false;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ Size SplashCtrl::MakeLogo(Ctrl& parent, Array<Ctrl>& 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<StaticRect>().Color(White).SizePos());
|
||||
parent.Add(l.TopPos(0, isz.cy).LeftPos(0, isz.cx));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue