From b2bb5f244b148bff544113fe6e8dab57d9e6a741 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Mon, 18 Nov 2024 14:14:26 +0100 Subject: [PATCH] ide skin --- uppsrc/CtrlCore/CtrlKbd.cpp | 3 ++- uppsrc/CtrlLib/ColorPusher.cpp | 2 +- uppsrc/CtrlLib/FileSel.cpp | 5 +++++ uppsrc/CtrlLib/FileSel.h | 1 + uppsrc/CtrlLib/TabCtrl.cpp | 1 + uppsrc/Draw/Cham.cpp | 1 + uppsrc/Draw/Cham.h | 6 +----- uppsrc/Draw/MakeCache.cpp | 1 + uppsrc/TabBar/FileTabs.cpp | 6 +++--- uppsrc/TabBar/TabBar.cpp | 6 +++--- uppsrc/ide/Config.cpp | 4 +++- uppsrc/ide/Setup.cpp | 5 +++++ uppsrc/ide/ide.h | 1 + uppsrc/ide/ide.lay | 11 ++++++----- uppsrc/ide/idewin.cpp | 5 +++++ 15 files changed, 39 insertions(+), 19 deletions(-) diff --git a/uppsrc/CtrlCore/CtrlKbd.cpp b/uppsrc/CtrlCore/CtrlKbd.cpp index 6b5a6101f..a9fe351ee 100644 --- a/uppsrc/CtrlCore/CtrlKbd.cpp +++ b/uppsrc/CtrlCore/CtrlKbd.cpp @@ -49,8 +49,9 @@ bool Ctrl::DispatchKey(dword keycode, int count) << ", " << GetKeyDesc(keycode) << "), count:" << count << " focusCtrl:" << UPP::Name(focusCtrl) << " focusCtrlWnd:" << UPP::Name(focusCtrlWnd)); #if defined(_DEBUG) || defined(flagDEBUGCODE) - if(keycode == (K_SHIFT|K_CTRL|K_SUBTRACT)) { + if(keycode == (K_SHIFT|K_ALT|K_SUBTRACT)) { skini = skini ? 0 : IsDarkTheme() ? 1 : 2; + DLOG("---- reskin"); ReSkin(); } #endif diff --git a/uppsrc/CtrlLib/ColorPusher.cpp b/uppsrc/CtrlLib/ColorPusher.cpp index 4821fa4f6..f276775b5 100644 --- a/uppsrc/CtrlLib/ColorPusher.cpp +++ b/uppsrc/CtrlLib/ColorPusher.cpp @@ -18,7 +18,7 @@ void ColorPusher::Paint(Draw& w) voidtext, StdFont(), SColorText()); else { auto DrawColor = [&](int x, int y, int cx, int cy) { - if(color.GetSpecial() >= 0) { + if(color.GetSpecial() >= 0 && color.GetSpecial() < 18) { Color c = RealizeColor(color); w.DrawRect(x, y, cx / 2, cy, c); w.DrawRect(x + cx / 2, y, cx - cx / 2, cy, DarkTheme(c)); diff --git a/uppsrc/CtrlLib/FileSel.cpp b/uppsrc/CtrlLib/FileSel.cpp index b3fd728b8..92ef56964 100644 --- a/uppsrc/CtrlLib/FileSel.cpp +++ b/uppsrc/CtrlLib/FileSel.cpp @@ -1449,6 +1449,11 @@ void FileSel::Activate() TopWindow::Activate(); } +void FileSel::Skin() +{ + Reload(); +} + bool FileSel::Key(dword key, int count) { switch(key) { case K_F9: diff --git a/uppsrc/CtrlLib/FileSel.h b/uppsrc/CtrlLib/FileSel.h index c76c36420..ac4ae2fe5 100644 --- a/uppsrc/CtrlLib/FileSel.h +++ b/uppsrc/CtrlLib/FileSel.h @@ -175,6 +175,7 @@ class FileSel : public WithFileSelectorLayout { public: virtual bool Key(dword key, int count); virtual void Activate(); + virtual void Skin(); private: SizeGrip sizegrip; diff --git a/uppsrc/CtrlLib/TabCtrl.cpp b/uppsrc/CtrlLib/TabCtrl.cpp index aaadd1af8..2325171d4 100644 --- a/uppsrc/CtrlLib/TabCtrl.cpp +++ b/uppsrc/CtrlLib/TabCtrl.cpp @@ -4,6 +4,7 @@ namespace Upp { CH_STYLE(TabCtrl, Style, StyleDefault) { + DLOG("TabCtrl style"); font = StdFont(); tabheight = font.Info().GetHeight() + 8; margin = 2; diff --git a/uppsrc/Draw/Cham.cpp b/uppsrc/Draw/Cham.cpp index 0ecfb9629..a67d97985 100644 --- a/uppsrc/Draw/Cham.cpp +++ b/uppsrc/Draw/Cham.cpp @@ -417,6 +417,7 @@ void ChReset() void ChFinish() { + DLOG("-- chFinish"); sChInvalid = false; for(int i = 0; i < sChStyle().GetCount(); i++) sChStyle()[i].init(); diff --git a/uppsrc/Draw/Cham.h b/uppsrc/Draw/Cham.h index a3127eb21..0a62eddaf 100644 --- a/uppsrc/Draw/Cham.h +++ b/uppsrc/Draw/Cham.h @@ -65,7 +65,7 @@ void COMBINE5(klass, __, type, __, style)::InitIt() { \ \ const klass::type& klass::style() \ { \ - static COMBINE5(klass, __, type, __, style) b, standard; \ + static COMBINE5(klass, __, type, __, style) b; \ if(b.status == 0) { \ ChRegisterStyle__(b.status, b.registered, COMBINE5(klass, __, type, __, style)::InitIt); \ b.Init(); \ @@ -76,10 +76,6 @@ const klass::type& klass::style() \ \ void COMBINE5(klass, __, type, __, style)::Init() -// standard = b; \ -// standard.standard = b.standard = &standard; \ - - // CH_VAR0 allows inserting action into _Write (missing ending '}') #define CH_VAR0(chtype, type, name, init) \ chtype& COMBINE(ch_var__, name)(); \ diff --git a/uppsrc/Draw/MakeCache.cpp b/uppsrc/Draw/MakeCache.cpp index 659de0c43..9c34bda3a 100644 --- a/uppsrc/Draw/MakeCache.cpp +++ b/uppsrc/Draw/MakeCache.cpp @@ -12,6 +12,7 @@ struct scImageMaker : ValueMaker { StringBuffer s; s.Cat(typeid(*m).name()); RawCat(s, paintonly); + RawCat(s, IsDarkTheme()); s.Cat(m->Key()); return String(s); } diff --git a/uppsrc/TabBar/FileTabs.cpp b/uppsrc/TabBar/FileTabs.cpp index b7aaea889..1da300d97 100644 --- a/uppsrc/TabBar/FileTabs.cpp +++ b/uppsrc/TabBar/FileTabs.cpp @@ -175,10 +175,10 @@ FileTabs& FileTabs::operator<<(const FileTabs &src) FileTabs::FileTabs() : stackedicons(false), greyedicons(true), -filecolor(SColorLabel), -extcolor(IsDark(SColorFace()) ? Blend(White, LtBlue) : LtBlue) +filecolor(SColorLabel) { - + static SColor se([] { return IsDark(SColorFace()) ? Blend(White, LtBlue) : LtBlue; }); + extcolor = se; } } diff --git a/uppsrc/TabBar/TabBar.cpp b/uppsrc/TabBar/TabBar.cpp index f7c7a9587..6c77e261c 100644 --- a/uppsrc/TabBar/TabBar.cpp +++ b/uppsrc/TabBar/TabBar.cpp @@ -1151,7 +1151,7 @@ void TabBar::PaintTab(Draw &w, const Size &sz, int n, bool enable, bool dragsamp bool ac = (n == active && enable); bool hl = (n == highlight && enable) || (stacking && highlight >= 0 && tabs[highlight].stack == t.stack); - int c = align == LEFT ? cnt - n : n; + int c = align == LEFT ? cnt - n : n; int lx = n > 0 ? s.extendleft : 0; int x = t.pos.x - sc.GetPos() - lx + s.margin; @@ -2696,7 +2696,7 @@ TabBar::Style& TabBar::Style::GroupSeparators(Value horz, Value vert) TabBar::Style& TabBar::Style::DefaultGroupSeparators() { - return GroupSeparators(TabBarImg::SEP(), TabBarImg::SEPV()); + return GroupSeparators(TabBarImg::SEP(), TabBarImg::SEPV()); } Vector TabBar::GetKeys() const @@ -2723,7 +2723,7 @@ TabBar& TabBar::CopyBaseSettings(const TabBar& src) crosses_side = src.crosses_side; grouping = src.grouping; contextmenu = src.contextmenu; - autoscrollhide = src.autoscrollhide; + autoscrollhide = src.autoscrollhide; nosel = src.nosel; nohl = src.nohl; inactivedisabled = src.inactivedisabled; diff --git a/uppsrc/ide/Config.cpp b/uppsrc/ide/Config.cpp index 88b3307bd..3c7fa5b8f 100644 --- a/uppsrc/ide/Config.cpp +++ b/uppsrc/ide/Config.cpp @@ -187,7 +187,7 @@ void Sentinel(Stream& s, const char *txt) void Ide::Serialize(Stream& s) { - int version = 30; + int version = 31; Sentinel(s, "before 12341234"); s.Magic(0x12341234); Sentinel(s, "after magic"); @@ -254,6 +254,8 @@ void Ide::Serialize(Stream& s) s % hilite_if_endif; s % hilite_bracket; s % hilite_ifdef; + if(version >= 31) + s % hl_custom; if(version >= 3) s % thousands_separator; if(version >= 5) diff --git a/uppsrc/ide/Setup.cpp b/uppsrc/ide/Setup.cpp index 0dc99d162..8ae8dc78f 100644 --- a/uppsrc/ide/Setup.cpp +++ b/uppsrc/ide/Setup.cpp @@ -381,6 +381,7 @@ void Ide::SetupFormat() { (hlt.thousands_separator, thousands_separator) (hlt.hline, hline) (hlt.vline, vline) + (hlt.hl_custom, hl_custom) (edt.indent_spaces, indent_spaces) (edt.no_parenthesis_indent, no_parenthesis_indent) @@ -457,6 +458,7 @@ void Ide::SetupFormat() { edt.tabsize.WhenAction = rtvr <<= hlt.hlstyle.WhenCtrlsAction = ed.WhenAction = tf.WhenAction = con.WhenAction = f1.WhenAction = f2.WhenAction = dlg.Breaker(222); + hlt.hlstyle.WhenCtrlsAction << [&] { hlt.hl_custom <<= true; }; ide.showtimeafter <<= Nvl((Date)FileGetTime(ConfigFile("version")), GetSysDate() - 1); hlt.hl_restore <<= dlg.Breaker(333); hlt.hl_restore_white <<= dlg.Breaker(334); @@ -532,18 +534,21 @@ void Ide::SetupFormat() { SetupEditor(); ReadHlStyles(hlt.hlstyle); hlstyle_is_default = true; + hlt.hl_custom <<= true; } if(c == 334 && PromptYesNo("Set white theme?")) { editor.WhiteTheme(false); SetupEditor(); ReadHlStyles(hlt.hlstyle); hlstyle_is_default = false; + hlt.hl_custom <<= true; } if(c == 335 && PromptYesNo("Set dark theme?")) { editor.DarkTheme(false); SetupEditor(); ReadHlStyles(hlt.hlstyle); hlstyle_is_default = false; + hlt.hl_custom <<= true; } if(c == 336) { auto v = GetAllChSkins(); diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index dafea4afd..83c00180c 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -673,6 +673,7 @@ public: byte hilite_scope; int hilite_bracket; int hilite_ifdef; + bool hl_custom = false; bool barline; bool qtfsel; diff --git a/uppsrc/ide/ide.lay b/uppsrc/ide/ide.lay index 7004b0634..6b5b9569e 100644 --- a/uppsrc/ide/ide.lay +++ b/uppsrc/ide/ide.lay @@ -538,14 +538,15 @@ LAYOUT(SetupHlLayout, 544, 344) ITEM(Upp::Switch, hilite_bracket, SetLabel(t_("None\nNormal\nFlashing")).LeftPosZ(372, 180).TopPosZ(68, 20)) ITEM(Upp::Label, dv___5, SetLabel(t_("#else/#elif/#endif info")).LeftPosZ(372, 160).TopPosZ(100, 16)) ITEM(Upp::Switch, hilite_ifdef, SetLabel(t_("None\nNormal\nWith line number")).LeftPosZ(372, 196).TopPosZ(120, 60)) - ITEM(Upp::Option, hilite_if_endif, SetLabel(t_("#if/#endif tracing")).LeftPosZ(372, 160).TopPosZ(184, 18)) - ITEM(Upp::Option, thousands_separator, SetLabel(t_("Thousands separator")).LeftPosZ(372, 160).TopPosZ(204, 18)) - ITEM(Upp::Option, hline, SetLabel(t_("Line")).LeftPosZ(432, 160).TopPosZ(228, 18)) - ITEM(Upp::Option, vline, SetLabel(t_("Column")).LeftPosZ(472, 84).TopPosZ(228, 18)) + ITEM(Upp::Option, hilite_if_endif, SetLabel(t_("#if/#endif tracing")).LeftPosZ(372, 160).TopPosZ(180, 18)) + ITEM(Upp::Option, thousands_separator, SetLabel(t_("Thousands separator")).LeftPosZ(372, 160).TopPosZ(200, 18)) + ITEM(Upp::Option, hline, SetLabel(t_("Line")).LeftPosZ(432, 160).TopPosZ(224, 18)) + ITEM(Upp::Option, vline, SetLabel(t_("Column")).LeftPosZ(472, 84).TopPosZ(224, 18)) ITEM(Upp::Button, hl_restore, SetLabel(t_("Restore default colors")).HSizePosZ(368, 4).BottomPosZ(56, 20)) ITEM(Upp::Button, hl_restore_dark, SetLabel(t_("Dark theme")).HSizePosZ(368, 4).BottomPosZ(8, 20)) ITEM(Upp::Button, hl_restore_white, SetLabel(t_("White theme")).HSizePosZ(368, 4).BottomPosZ(32, 20)) - ITEM(Upp::Label, dv___14, SetLabel(t_("Current")).LeftPosZ(372, 40).TopPosZ(228, 18)) + ITEM(Upp::Label, dv___14, SetLabel(t_("Current")).LeftPosZ(372, 40).TopPosZ(224, 18)) + ITEM(Upp::Option, hl_custom, SetLabel(t_("Custom colors")).LeftPosZ(372, 172).TopPosZ(248, 16)) END_LAYOUT LAYOUT(SetupEditorLayout, 544, 344) diff --git a/uppsrc/ide/idewin.cpp b/uppsrc/ide/idewin.cpp index 7a338010c..f9e88d406 100644 --- a/uppsrc/ide/idewin.cpp +++ b/uppsrc/ide/idewin.cpp @@ -7,6 +7,11 @@ void Ide::Skin() { SetToolBar(); + ScanWorkspace(); + if(!hl_custom) { + editor.DefaultHlStyles(); + SetupEditor(); + } } void Ide::ToggleVerboseBuild() {