From bc6c1b3fd8d0eb8a07768d4e3f441037420f3dc6 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Thu, 6 Mar 2025 12:04:11 +0100 Subject: [PATCH] ide: Dark theme related fixes --- uppsrc/CodeEditor/Style.cpp | 2 +- uppsrc/Core/Convert.h | 4 +-- uppsrc/Core/CvFlt.cpp | 4 +-- uppsrc/CtrlLib/DateTimeCtrl.cpp | 2 +- uppsrc/Draw/Cham.cpp | 4 ++- .../Draw/srcdoc.tpp/UhdAndDarkTheme_en-us.tpp | 6 ++--- uppsrc/ide/LayDes/LayDes.h | 2 ++ uppsrc/ide/LayDes/laydes.cpp | 20 +++++++++++---- uppsrc/ide/LayDes/laylib.cpp | 2 -- uppsrc/ide/ide.iml | 25 +++++++++++++++---- uppsrc/ide/idewin.cpp | 1 + 11 files changed, 50 insertions(+), 22 deletions(-) diff --git a/uppsrc/CodeEditor/Style.cpp b/uppsrc/CodeEditor/Style.cpp index 8b18ff8af..eca1b54b7 100644 --- a/uppsrc/CodeEditor/Style.cpp +++ b/uppsrc/CodeEditor/Style.cpp @@ -192,7 +192,7 @@ void HighlightSetup::DarkTheme(bool host) SetHlStyle(INK_DIFF_COMMENT, Color(173, 255, 173)); SetHlStyle(PAPER_SELWORD, Color(99, 99, 0)); SetHlStyle(PAPER_ERROR, Color(90, 40, 40)); - SetHlStyle(PAPER_ERROR_FILE, Color(120, 40, 40)); + SetHlStyle(PAPER_ERROR_FILE, Color(170, 40, 40)); // Color(0xE2, 0x55, 0)); ? SetHlStyle(PAPER_WARNING, Color(21, 21, 0)); SetHlStyle(SHOW_LINE, Color(27, 75, 26)); SetHlStyle(SHOW_COLUMN, Color(56, 33, 29)); diff --git a/uppsrc/Core/Convert.h b/uppsrc/Core/Convert.h index 60c63fb01..df64c4a41 100644 --- a/uppsrc/Core/Convert.h +++ b/uppsrc/Core/Convert.h @@ -144,8 +144,8 @@ const ConvertDouble& StdConvertDouble(); const ConvertDouble& StdConvertDoubleNotNull(); struct ConvertFloat : public ConvertDouble { - static double GetDefaultMin() { return -std::numeric_limits::max(); } - static double GetDefaultMax() { return std::numeric_limits::max(); } + static double GetDefaultMin() { return (double)-std::numeric_limits::max(); } + static double GetDefaultMax() { return (double)std::numeric_limits::max(); } ConvertFloat(double minval = GetDefaultMin(), double maxval = GetDefaultMax(), bool notnull = false) : ConvertDouble(minval, maxval, notnull) { Pattern("%.7g"); } diff --git a/uppsrc/Core/CvFlt.cpp b/uppsrc/Core/CvFlt.cpp index 8cabe9d0b..a55992f51 100644 --- a/uppsrc/Core/CvFlt.cpp +++ b/uppsrc/Core/CvFlt.cpp @@ -412,13 +412,13 @@ String FormatDoubleN(double x) String FormatFloat(float x) { char h[512]; - return String(h, FormatDouble_(h, x, 7, FD_TOLERANCE(6)|FD_MINIMAL_EXP|FD_SPECIAL)); + return String(h, FormatDouble_(h, (double)x, 7, FD_TOLERANCE(6)|FD_MINIMAL_EXP|FD_SPECIAL)); } String FormatFloatN(float x) { char h[512]; - return String(h, FormatDouble_(h, x, 7, FD_TOLERANCE(6)|FD_MINIMAL_EXP)); + return String(h, FormatDouble_(h, (double)x, 7, FD_TOLERANCE(6)|FD_MINIMAL_EXP)); } diff --git a/uppsrc/CtrlLib/DateTimeCtrl.cpp b/uppsrc/CtrlLib/DateTimeCtrl.cpp index c8dbd9f8c..4fc98d9aa 100644 --- a/uppsrc/CtrlLib/DateTimeCtrl.cpp +++ b/uppsrc/CtrlLib/DateTimeCtrl.cpp @@ -463,7 +463,7 @@ void Calendar::Paint(Draw &w) if(w.IsPainting(0, hs, sz.cx, rh)) { - int y = (int) (hs + (rowh - fh) / 2.0); + int y = (int) (hs + ((double)rowh - fh) / 2.0); fnt.NoBold().NoUnderline(); tsz = GetTextSize(t_("Wk"), fnt); w.DrawText(bs + (cw - tsz.cx) / 2, y, t_("Wk"), fnt, st.week); diff --git a/uppsrc/Draw/Cham.cpp b/uppsrc/Draw/Cham.cpp index 0ecfb9629..92e71ffd6 100644 --- a/uppsrc/Draw/Cham.cpp +++ b/uppsrc/Draw/Cham.cpp @@ -407,9 +407,11 @@ bool IsDarkColorFace() return sIsDarkColorFace; } +extern bool AColor_dark_mode__; + void ChReset() { - dark_theme__ = false; + AColor_dark_mode__ = dark_theme__ = false; for(int i = 0; i < sChStyle().GetCount(); i++) *sChStyle()[i].status = 0; ChLookFn(StdChLookFn); diff --git a/uppsrc/Draw/srcdoc.tpp/UhdAndDarkTheme_en-us.tpp b/uppsrc/Draw/srcdoc.tpp/UhdAndDarkTheme_en-us.tpp index 1e8decc97..bbe0de862 100644 --- a/uppsrc/Draw/srcdoc.tpp/UhdAndDarkTheme_en-us.tpp +++ b/uppsrc/Draw/srcdoc.tpp/UhdAndDarkTheme_en-us.tpp @@ -145,9 +145,9 @@ macros:&] [s0; &] [s3;:4: Reacting to theme changes&] [s5; Before 2025.1 U`+`+ release, the application skin was loaded -from host platform just once at the start of execution and any -if user changed host platform theme, this was not reflected in -the application. Also changing to user defined or some predefined +from host platform just once at the start of execution and if +user changed host platform theme, this was not reflected in the +running application. Also changing to user defined or some predefined skin required restart of application to work properly.&] [s5; Since 2025.1, application can be made to react to host platform changes and can change skins without restart with a call to Ctrl`::SkinChangeSensi diff --git a/uppsrc/ide/LayDes/LayDes.h b/uppsrc/ide/LayDes/LayDes.h index 1d4cd12f5..3ebf2ffca 100644 --- a/uppsrc/ide/LayDes/LayDes.h +++ b/uppsrc/ide/LayDes/LayDes.h @@ -281,6 +281,7 @@ public: void RightDown(Point p, dword keyflags) override; void Layout() override; bool HotKey(dword key) override; + void Skin() override; private: bool DoKey(dword key, int count); @@ -473,6 +474,7 @@ private: void GotoUsing(); + void InvalidateItems(); void SyncUsc(); void Save(); void CloseDesigner(); diff --git a/uppsrc/ide/LayDes/laydes.cpp b/uppsrc/ide/LayDes/laydes.cpp index 25c183a01..7422a15aa 100644 --- a/uppsrc/ide/LayDes/laydes.cpp +++ b/uppsrc/ide/LayDes/laydes.cpp @@ -1669,20 +1669,30 @@ void LayDes::ItemClick() SyncItems(); } +void LayDes::InvalidateItems() +{ + if(!IsNull(currentlayout)) { + LayoutData& d = CurrentLayout(); + for(int i = 0; i < d.item.GetCount(); i++) + d.item[i].Invalidate(); + } +} + void LayDes::SyncUsc() { type.ClearList(); for(int i = 0; i < LayoutTypes().GetCount(); i++) if(LayoutTypes()[i].kind != LAYOUT_SUBCTRL) type.AddList(LayoutTypes().GetKey(i)); - if(!IsNull(currentlayout)) { - LayoutData& d = CurrentLayout(); - for(int i = 0; i < d.item.GetCount(); i++) - d.item[i].Invalidate(); - } + InvalidateItems(); Refresh(); } +void LayDes::Skin() +{ + InvalidateItems(); +} + void LayDes::TypeEdit() { if(IsNull(currentlayout) || cursor.GetCount() == 0) diff --git a/uppsrc/ide/LayDes/laylib.cpp b/uppsrc/ide/LayDes/laylib.cpp index 415fab742..6b97a393e 100644 --- a/uppsrc/ide/LayDes/laylib.cpp +++ b/uppsrc/ide/LayDes/laylib.cpp @@ -44,8 +44,6 @@ EscValue EscColor(Color c) EscValue v; if(IsNull(c)) return v; - if(c.GetSpecial() >= 0) - c = AColor(RealizeColor(c)); v.MapSet("r", c.GetR()); v.MapSet("g", c.GetG()); v.MapSet("b", c.GetB()); diff --git a/uppsrc/ide/ide.iml b/uppsrc/ide/ide.iml index 272707b54..5ab9a964f 100644 --- a/uppsrc/ide/ide.iml +++ b/uppsrc/ide/ide.iml @@ -78,6 +78,7 @@ IMAGE_ID(help_win) IMAGE_ID(help_win__DARK) IMAGE_ID(help_win_large) IMAGE_ID(help_win__UHD) +IMAGE_ID(help_win__UHD__DARK) IMAGE_ID(book) IMAGE_ID(split) IMAGE_ID(vsplit) @@ -3772,7 +3773,7 @@ IMAGE_DATA(223,84,182,254,3,159,69,193,156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 IMAGE_END_DATA(704, 1) IMAGE_BEGIN_DATA -IMAGE_DATA(120,156,237,155,193,107,211,80,28,199,139,127,193,240,220,195,142,50,244,182,214,50,149,49,97,14,193,117,174,91,117,158) +IMAGE_DATA(120,156,237,155,193,107,211,80,28,199,139,127,193,240,220,195,142,67,244,182,214,50,149,49,97,14,193,117,174,91,117,158) IMAGE_DATA(28,158,60,186,131,130,158,60,232,65,177,66,55,21,153,120,208,139,58,152,30,68,240,48,25,43,163,155,110,202,134,138) IMAGE_DATA(194,240,224,240,96,79,19,193,193,144,190,167,191,148,212,44,54,77,210,36,251,189,36,223,15,124,33,203,203,47,191,215) IMAGE_DATA(207,75,30,165,176,93,109,137,182,68,51,118,39,243,249,76,94,74,99,232,92,211,34,67,221,165,130,148,51,101,41,223) @@ -3784,9 +3785,9 @@ IMAGE_DATA(217,149,250,28,58,179,223,165,121,14,20,114,76,231,205,107,150,234,25 IMAGE_DATA(90,170,105,86,159,206,109,202,207,107,21,173,246,198,237,69,209,121,252,135,180,170,55,206,95,63,215,217,191,166,205,249) IMAGE_DATA(201,179,247,194,120,95,243,252,205,254,234,245,217,111,50,119,102,86,118,15,45,72,115,189,249,57,104,52,135,35,35,37) IMAGE_DATA(173,255,243,151,159,132,85,111,171,231,135,174,235,61,249,175,222,248,28,54,122,126,188,62,191,126,188,63,141,238,227,232) -IMAGE_DATA(253,53,110,6,153,142,59,146,59,203,203,203,45,197,88,239,132,141,141,141,250,177,93,189,62,214,181,119,66,228,142,22) -IMAGE_DATA(197,171,153,249,109,227,78,251,175,174,126,208,174,233,237,42,110,219,96,156,214,143,223,124,164,93,115,172,199,125,253,211) -IMAGE_DATA(233,23,50,189,231,150,56,176,111,66,148,230,22,93,207,255,68,182,40,104,252,254,189,105,89,173,86,93,215,147,59,26) +IMAGE_DATA(253,53,110,6,153,61,119,36,119,150,151,151,91,138,177,222,9,27,27,27,245,99,187,122,125,172,107,239,132,200,29,45) +IMAGE_DATA(138,87,51,243,219,198,157,246,95,93,253,160,93,211,219,85,220,182,193,56,173,31,191,249,72,187,230,88,143,251,250,167) +IMAGE_DATA(211,47,100,186,227,150,56,176,111,66,148,230,22,93,207,255,68,182,40,104,252,254,189,105,89,173,86,93,215,147,59,26) IMAGE_DATA(175,84,42,255,141,181,178,126,110,235,245,113,174,122,55,243,247,242,252,123,73,155,113,51,184,122,97,83,114,167,85,25) IMAGE_DATA(198,122,39,152,55,131,102,245,78,54,3,39,253,155,109,6,78,234,155,109,6,118,245,118,155,129,93,189,221,102,96,87) IMAGE_DATA(111,183,25,184,93,63,183,245,118,47,115,208,245,110,230,239,229,249,247,146,195,237,137,246,250,102,208,119,240,174,68,16) @@ -3805,9 +3806,23 @@ IMAGE_DATA(127,85,221,19,81,247,175,178,123,34,202,254,85,119,79,68,213,127,24,2 IMAGE_DATA(252,135,201,61,17,23,255,170,2,255,188,68,201,127,216,246,30,34,14,254,85,6,254,121,129,127,94,224,159,23,248,231) IMAGE_DATA(37,74,254,195,8,252,243,2,255,188,192,63,47,240,207,75,148,252,227,251,15,47,240,207,11,252,243,2,255,188,192,63) IMAGE_DATA(47,240,15,220,2,255,188,192,63,47,240,207,11,252,243,2,255,188,192,63,47,240,207,11,252,243,2,255,188,192,63,47) -IMAGE_DATA(240,207,139,91,255,8,130,32,8,130,32,81,205,31,104,42,120,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0) +IMAGE_DATA(240,207,139,91,255,8,130,32,8,130,32,81,205,31,72,1,120,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0) IMAGE_END_DATA(1088, 5) +IMAGE_BEGIN_DATA +IMAGE_DATA(120,156,237,216,65,74,3,81,16,69,209,94,151,171,201,42,220,129,91,118,170,212,64,112,160,152,142,253,115,95,213,191) +IMAGE_DATA(23,222,52,13,167,32,52,253,114,59,110,199,87,111,175,239,31,206,57,231,156,115,206,57,231,156,115,206,57,231,220,179) +IMAGE_DATA(102,215,166,63,155,254,108,250,179,233,207,166,63,155,254,108,250,179,233,207,166,63,155,254,108,250,179,233,207,54,193,255) +IMAGE_DATA(56,142,187,150,88,103,255,123,221,147,111,209,209,255,63,238,105,119,232,228,127,165,123,202,13,186,248,175,178,167,111,160) +IMAGE_DATA(63,123,131,14,254,87,248,165,222,32,221,255,106,51,253,207,181,194,42,233,6,201,254,43,157,244,255,187,213,70,9,55) +IMAGE_DATA(232,232,191,250,247,245,127,158,141,254,63,167,127,166,127,215,231,252,86,170,255,247,244,231,191,63,172,74,127,54,253,185) +IMAGE_DATA(104,251,106,87,255,132,119,255,106,71,255,20,251,106,55,255,149,223,148,30,105,39,255,52,251,106,23,255,68,251,106,7) +IMAGE_DATA(255,84,251,106,186,127,178,125,53,217,63,221,190,154,234,223,193,190,154,232,223,197,190,218,205,63,173,105,254,157,236,171) +IMAGE_DATA(93,252,83,211,159,109,146,127,183,255,158,106,7,255,228,244,103,211,159,77,127,54,253,217,38,249,119,76,127,54,253,217) +IMAGE_DATA(244,103,211,159,109,146,191,239,63,108,250,179,233,207,166,63,155,254,108,250,219,217,244,103,211,159,77,127,54,253,217,244) +IMAGE_DATA(103,211,159,77,127,54,253,217,244,103,211,159,77,127,182,179,254,206,57,231,156,115,83,247,9,203,140,71,246,0,0,0) +IMAGE_END_DATA(352, 1) + IMAGE_BEGIN_DATA IMAGE_DATA(120,156,237,154,89,76,84,87,24,199,39,141,47,166,60,52,77,159,250,212,164,77,31,240,169,73,235,138,168,181,171,246) IMAGE_DATA(165,169,168,172,2,238,107,91,227,130,27,131,34,130,182,65,4,20,1,41,82,17,97,0,197,168,85,107,44,96,101,29) diff --git a/uppsrc/ide/idewin.cpp b/uppsrc/ide/idewin.cpp index 1ff6e99dc..058158fff 100644 --- a/uppsrc/ide/idewin.cpp +++ b/uppsrc/ide/idewin.cpp @@ -12,6 +12,7 @@ void Ide::Skin() editor.DefaultHlStyles(); UpdateFormat(); } + SyncUsc(); } void Ide::ToggleVerboseBuild() {