ide: Customizatble GUI font, several more skins

git-svn-id: svn://ultimatepp.org/upp/trunk@14142 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-03-09 14:03:29 +00:00
parent aaf8f0bd83
commit 3cd69d7d3a
9 changed files with 180 additions and 113 deletions

View file

@ -107,6 +107,9 @@ void ChClassicSkin()
CtrlsImg::Set(CtrlsImg::I_EFE, edge);
CtrlsImg::Set(CtrlsImg::I_VE, edge);
for(int i = 0; i < 6; i++)
CtrlsImg::Set(CtrlsImg::I_DA + i, CtrlsImg::Get(CtrlsImg::I_kDA + i));
Color wg = Blend(SColorFace(), WhiteGray());
{
Button::Style& s = Button::StyleNormal().Write();
@ -185,13 +188,14 @@ void ChClassicSkin()
s.extendleft = DPI(2);
s.text_color[i] = SColorText();
}
static int adj[] = { 10, 80, -5, -10 };
Color f = FaceColor(adj[i]);
// static int adj[] = { 10, 80, -5, -10 };
// Color f = FaceColor(adj[i]);
Color f = decode(i, 0, SColorPaper(), 1, Blend(SColorPaper(), SColorFace()), 2, SColorFace(), SColorFace());
{
for(int opt = 0; opt < 2; opt++) {
ImagePainter p(c, c);
p.Clear(RGBAZero());
p.Circle(DPI(7), DPI(7), DPI(6)).Fill(f).Stroke(2, Pointf(DPI(2), DPI(2)), SGray(), Pointf(DPI(14), DPI(14)), White());
p.Circle(DPI(7), DPI(7), DPI(6)).Fill(f).Stroke(2, Pointf(DPI(2), DPI(2)), SGray(), Pointf(DPI(14), DPI(14)), SWhite());
p.Circle(DPI(7), DPI(7), DPI(6) - 1).Fill(f).Stroke(1, Pointf(DPI(2) + 1, DPI(2) + 1), SBlack(), Pointf(DPI(14) - 2, DPI(14) - 2), SColorFace());
if(opt)
p.Circle(DPI(7), DPI(7), DPI(4)).Fill(SColorText());
@ -202,7 +206,7 @@ void ChClassicSkin()
for(int chk = 0; chk < 3; chk++) {
ImagePainter p(c, c);
p.Clear(RGBAZero());
DrawClassicButton(p, Size(c, c), SGray(), White(), SBlack(), LtGray(), f);
DrawClassicButton(p, Size(c, c), SGray(), SWhite(), SBlack(), SLtGray(), f);
p.Scale(DPI(1));
if(chk == 1)
p.Move(3, 7).Line(7, 10).Line(11, 4).Stroke(2, SColorText());
@ -584,8 +588,10 @@ void ChBaseSkin()
ColoredOverride(CtrlsImg::Iml(), CtrlsImg::Iml());
}
void ChStdSkin()
void ChMakeSkin(int roundness, Color button_face, Color thumb, int *adj)
{
GUI_GlobalStyle_Write(GUISTYLE_XP);
ColoredOverride(CtrlsImg::Iml(), CtrlsImg::Iml());
for(int i = 0; i < 6; i++)
@ -598,20 +604,21 @@ void ChStdSkin()
Color border = Gray();
roundness = DPI(roundness);
{
for(int pass = 0; pass < 2; pass++) {
Button::Style& s = pass ? Button::StyleOk().Write() : Button::StyleNormal().Write();
int roundness = DPI(3);
s.focusmargin = DPI(4);
for(int i = 0; i < 4; i++) {
static int adj[] = { 10, 80, -5, -10 };
Color f = FaceColor(adj[i]);
Color f = AdjustColor(button_face, adj[i]);
Color ink = i == CTRL_DISABLED ? SColorDisabled() : SColorText();
s.look[i] = MakeButton(roundness, f, DPI(1 + pass), border);
text[i] = s.monocolor[i] = s.textcolor[i] = ink;
if(pass == 0) {
sbutton[i] = MakeButton(DPI(3), f, DPI(1), border);
button[i] = MakeButton(DPI(1), f, DPI(1), border);
sbutton[i] = MakeButton(roundness, f, DPI(1), border);
button[i] = MakeButton(roundness ? DPI(1) : 0, f, DPI(1), border);
Color f = decode(i, 0, SColorPaper(), 1, Blend(SColorPaper(), SColorFace()), 2, SColorFace(), SColorFace());
{
for(int opt = 0; opt < 2; opt++) {
ImagePainter p(c, c);
@ -661,14 +668,14 @@ void ChStdSkin()
{
ScrollBar::Style& s = ScrollBar::StyleDefault().Write();
ImagePainter p(c, c);
p.Rectangle(0, 0, c, c).Fill(0, 0, SColorFace(), c, 0, SColorPaper());
p.Rectangle(0, 0, c, c).Fill(0, 0, IsDarkTheme() ? SColorFace() : AdjustColor(thumb, 40), c, 0, IsDarkTheme() ? LtGray() : SColorPaper());
Image vtrough = p;
for(int status = CTRL_NORMAL; status <= CTRL_DISABLED; status++) {
s.hupper[status] = s.hlower[status] = ChHot(RotateClockwise(vtrough));
s.vupper[status] = s.vlower[status] = ChHot(vtrough); // we have problems getting this right for vertical
static int adj[] = { 70, 80, 60, -10 };
s.hthumb[status] = s.vthumb[status] = AdjustColor(border, adj[status]);
s.vupper[status] = s.vlower[status] = ChHot(vtrough);
static int adj[] = { 0, 10, -10, -20 };
s.hthumb[status] = s.vthumb[status] = AdjustColor(thumb, adj[status]);
}
}
@ -681,6 +688,62 @@ void ChStdSkin()
MakeDialogIcons();
}
void ChStdSkin()
{
ChReset();
static int adj[] = { 10, 80, -5, -10 };
SColorFace_Write(Color(240, 240, 240));
SColorMenu_Write(Color(240, 240, 240));
SColorHighlight_Write(Color(50, 50, 250));
ChMakeSkin(3, SColorFace(), SLtGray(), adj);
}
void ChGraySkin()
{
ChReset();
static int adj[] = { 0, 70, -15, -20 };
SColorHighlight_Write(Gray());
ChMakeSkin(3, SWhiteGray(), SLtGray(), adj);
}
void ChDarkSkin()
{
ChReset();
static int adj[] = { 10, 80, -5, -10 };
SColorPaper_Write(Black());
SColorHighlight_Write(Gray());
SColorHighlightText_Write(White());
ChMakeSkin(3, SWhiteGray(), SWhiteGray(), adj);
}
void ChFlatSkin()
{
ChReset();
static int adj[] = { 10, 80, -5, -10 };
SColorFace_Write(Color(240, 240, 240));
SColorMenu_Write(Color(240, 240, 240));
SColorHighlight_Write(Color(50, 50, 250));
ChMakeSkin(0, SColorFace(), SLtGray(), adj);
}
void ChFlatGraySkin()
{
ChReset();
static int adj[] = { 0, 70, -15, -20 };
SColorHighlight_Write(Gray());
ChMakeSkin(0, SWhiteGray(), SLtGray(), adj);
}
void ChFlatDarkSkin()
{
ChReset();
static int adj[] = { 10, 80, -5, -10 };
SColorPaper_Write(Black());
SColorHighlight_Write(Gray());
SColorHighlightText_Write(White());
ChMakeSkin(0, SWhiteGray(), SWhiteGray(), adj);
}
#ifdef GUI_X11
void ChHostSkin()
@ -696,4 +759,18 @@ void ChHostSkin()
#endif
Vector<Tuple<void (*)(), String>> GetAllChSkins()
{
return Vector<Tuple<void (*)(), String>> {
{ ChHostSkin, "Host platform" },
{ ChClassicSkin, "Classic" },
{ ChStdSkin, "Standard" },
{ ChGraySkin, "Gray" },
{ ChDarkSkin, "Dark" },
{ ChFlatSkin, "Flat" },
{ ChFlatGraySkin, "Flat Gray" },
{ ChFlatDarkSkin, "Flat Dark" }
};
}
}

View file

@ -1,7 +1,15 @@
void ChBaseSkin();
void ChStdSkin();
void ChClassicSkin();
void ChHostSkin();
void ChClassicSkin();
void ChStdSkin();
void ChDarkSkin();
void ChGraySkin();
void ChFlatSkin();
void ChFlatDarkSkin();
void ChFlatGraySkin();
Vector<Tuple<void (*)(), String>> GetAllChSkins();
enum {
CORNER_TOP_LEFT = 0x01,

View file

@ -523,7 +523,6 @@ void ChHostSkin()
GtkStyleContext *ctx = gtk_widget_get_style_context((GtkWidget *)gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
gtk_style_context_set_state(ctx, GTK_STATE_FLAG_NORMAL);
paper = AvgColor(CairoImage(ctx));
SetChameleonSample(CairoImage(ctx));
}
if(IsDark(paper)) {
SColorText_Write(White());

View file

@ -338,11 +338,69 @@ String XpThemeInfo(LPCWSTR pszPropertyName)
return FromUnicode(h);
}
struct sysColor {
void (*set)(Color c);
int syscolor;
};
static sysColor sSysColor[] = {
{ SColorFace_Write, COLOR_3DFACE },
{ SColorPaper_Write, COLOR_WINDOW },
{ SColorText_Write, COLOR_WINDOWTEXT },
{ SColorHighlight_Write, COLOR_HIGHLIGHT },
{ SColorHighlightText_Write, COLOR_HIGHLIGHTTEXT },
{ SColorMenu_Write, COLOR_MENU },
{ SColorMenuText_Write, COLOR_MENUTEXT },
{ SColorInfo_Write, COLOR_INFOBK },
{ SColorInfoText_Write, COLOR_INFOTEXT },
{ SColorLight_Write, COLOR_3DHILIGHT },
{ SColorShadow_Write, COLOR_3DSHADOW },
};
bool IsSysFlag(dword flag)
{
BOOL b;
return SystemParametersInfo(flag, 0, &b, 0) && b;
}
void ChHostSkin()
{
XpClear();
for(sysColor *s = sSysColor; s < sSysColor + __countof(sSysColor); s++) // this also resets all imls via SColorPaper_Write!!!
(*s->set)(sAdjust(Color::FromCR(GetSysColor(s->syscolor))));
GUI_GlobalStyle_Write(IsWinXP() && !ScreenInPaletteMode() && IsSysFlag(0x1022 /*SPI_GETFLATMENU*/)
? GUISTYLE_XP : GUISTYLE_CLASSIC);
#ifndef PLATFORM_WINCE
GUI_DragFullWindow_Write(IsSysFlag(SPI_GETDRAGFULLWINDOWS));
#endif
GUI_PopUpEffect_Write(IsSysFlag(0x1002 /*SPI_GETMENUANIMATION*/) ?
IsSysFlag(0x1012 /*SPI_GETMENUFADE*/) ? GUIEFFECT_FADE
: GUIEFFECT_SLIDE
: GUIEFFECT_NONE);
GUI_DropShadows_Write(IsSysFlag(0x1024 /*SPI_GETDROPSHADOW*/));
GUI_AltAccessKeys_Write(!IsSysFlag(0x100A /*SPI_GETKEYBOARDCUES*/));
GUI_AKD_Conservative_Write(0);
GUI_DragDistance_Write(GetSystemMetrics(SM_CXDRAG));
GUI_DblClickTime_Write(GetDoubleClickTime());
int slines;
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &slines, 0);
GUI_WheelScrollLines_Write(slines);
CtrlImg::Set(CtrlImg::I_information, Win32Icon(IDI_INFORMATION));
CtrlImg::Set(CtrlImg::I_question, Win32Icon(IDI_QUESTION));
CtrlImg::Set(CtrlImg::I_exclamation, Win32Icon(IDI_EXCLAMATION));
CtrlImg::Set(CtrlImg::I_error, Win32Icon(IDI_ERROR));
FrameButtonWidth_Write(GetSystemMetrics(SM_CYHSCROLL));
ScrollBarArrowSize_Write(GetSystemMetrics(SM_CXHSCROLL));
dword x = GetSysColor(COLOR_GRAYTEXT);
SColorDisabled_Write(sAdjust(x ? Color::FromCR(x) : Color::FromCR(GetSysColor(COLOR_3DSHADOW))));
if(XpWidget(XP_BUTTON)) {
LLOG("XP theme !");
ChSysInit();
GUI_GlobalStyle_Write(GUISTYLE_XP);
EditFieldIsThin_Write(1);
@ -607,31 +665,6 @@ void ChHostSkin()
ChClassicSkin();
}
struct sysColor {
void (*set)(Color c);
int syscolor;
};
static sysColor sSysColor[] = {
{ SColorFace_Write, COLOR_3DFACE },
{ SColorPaper_Write, COLOR_WINDOW },
{ SColorText_Write, COLOR_WINDOWTEXT },
{ SColorHighlight_Write, COLOR_HIGHLIGHT },
{ SColorHighlightText_Write, COLOR_HIGHLIGHTTEXT },
{ SColorMenu_Write, COLOR_MENU },
{ SColorMenuText_Write, COLOR_MENUTEXT },
{ SColorInfo_Write, COLOR_INFOBK },
{ SColorInfoText_Write, COLOR_INFOTEXT },
{ SColorLight_Write, COLOR_3DHILIGHT },
{ SColorShadow_Write, COLOR_3DSHADOW },
};
bool IsSysFlag(dword flag)
{
BOOL b;
return SystemParametersInfo(flag, 0, &b, 0) && b;
}
bool IsSystemThemeDark()
{
String s = GetWinRegString("AppsUseLightTheme", "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", HKEY_CURRENT_USER);
@ -658,10 +691,6 @@ void ChSysInit()
CtrlImg::Reset();
CtrlsImg::Reset();
ChReset();
XpClear();
for(sysColor *s = sSysColor; s < sSysColor + __countof(sSysColor); s++) // this also resets all imls via SColorPaper_Write!!!
(*s->set)(sAdjust(Color::FromCR(GetSysColor(s->syscolor))));
NONCLIENTMETRICS ncm;
#if (WINVER >= 0x0600 && !defined(__MINGW32_VERSION))
@ -676,36 +705,6 @@ void ChSysInit()
int q = Font::FindFaceNameIndex(name);
if(height > 0 && height < 200) // sanity..
Font::SetDefaultFont(Font(q >= 0 ? q : Font::SANSSERIF, height));
GUI_GlobalStyle_Write(IsWinXP() && !ScreenInPaletteMode() && IsSysFlag(0x1022 /*SPI_GETFLATMENU*/)
? GUISTYLE_XP : GUISTYLE_CLASSIC);
#ifndef PLATFORM_WINCE
GUI_DragFullWindow_Write(IsSysFlag(SPI_GETDRAGFULLWINDOWS));
#endif
GUI_PopUpEffect_Write(IsSysFlag(0x1002 /*SPI_GETMENUANIMATION*/) ?
IsSysFlag(0x1012 /*SPI_GETMENUFADE*/) ? GUIEFFECT_FADE
: GUIEFFECT_SLIDE
: GUIEFFECT_NONE);
GUI_DropShadows_Write(IsSysFlag(0x1024 /*SPI_GETDROPSHADOW*/));
GUI_AltAccessKeys_Write(!IsSysFlag(0x100A /*SPI_GETKEYBOARDCUES*/));
GUI_AKD_Conservative_Write(0);
GUI_DragDistance_Write(GetSystemMetrics(SM_CXDRAG));
GUI_DblClickTime_Write(GetDoubleClickTime());
int slines;
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &slines, 0);
GUI_WheelScrollLines_Write(slines);
CtrlImg::Set(CtrlImg::I_information, Win32Icon(IDI_INFORMATION));
CtrlImg::Set(CtrlImg::I_question, Win32Icon(IDI_QUESTION));
CtrlImg::Set(CtrlImg::I_exclamation, Win32Icon(IDI_EXCLAMATION));
CtrlImg::Set(CtrlImg::I_error, Win32Icon(IDI_ERROR));
FrameButtonWidth_Write(GetSystemMetrics(SM_CYHSCROLL));
ScrollBarArrowSize_Write(GetSystemMetrics(SM_CXHSCROLL));
dword x = GetSysColor(COLOR_GRAYTEXT);
SColorDisabled_Write(sAdjust(x ? Color::FromCR(x) : Color::FromCR(GetSysColor(COLOR_3DSHADOW))));
}
#endif

View file

@ -108,7 +108,7 @@ file
Lang readonly separator,
Lang.h,
LNGCtrl.cpp,
Ch readonly separator,
Chameleon readonly separator,
Ch.h,
Ch.cpp,
Ctrls.iml,

View file

@ -417,6 +417,7 @@ bool IsDarkColorFace()
void ChReset()
{
dark_theme__ = false;
for(int i = 0; i < sChStyle().GetCount(); i++)
*sChStyle()[i].status = 0;
ChLookFn(StdChLookFn);

View file

@ -30,22 +30,22 @@ CH_VAR0(ChColor, Color, SColorPaper, White())
Iml::ResetAll();
CH_END
CH_COLOR(SColorFace, LtGray());
CH_COLOR(SColorText, Black());
CH_COLOR(SColorHighlight, Blue());
CH_COLOR(SColorHighlightText, White());
CH_COLOR(SColorMenu, LtGray());
CH_COLOR(SColorMenuText, Black());
CH_COLOR(SColorInfo, LtYellow());
CH_COLOR(SColorInfoText, Black());
CH_COLOR(SColorDisabled, Gray());
CH_COLOR(SColorLight, White());
CH_COLOR(SColorShadow, Gray());
CH_COLOR(SColorFace, SLtGray());
CH_COLOR(SColorText, SBlack());
CH_COLOR(SColorHighlight, SBlue());
CH_COLOR(SColorHighlightText, SWhite());
CH_COLOR(SColorMenu, SLtGray());
CH_COLOR(SColorMenuText, SBlack());
CH_COLOR(SColorInfo, SLtYellow());
CH_COLOR(SColorInfoText, SBlack());
CH_COLOR(SColorDisabled, SGray());
CH_COLOR(SColorLight, SWhite());
CH_COLOR(SColorShadow, SGray());
CH_COLOR(SColorMark, IsDark(SColorPaper()) ? DarkTheme(LtBlue()) : LtBlue());
CH_COLOR(SColorMenuMark, IsDark(SColorMenu()) ? DarkTheme(LtBlue()) : LtBlue());
CH_COLOR(SColorLtFace, Blend(SColorFace, SColorLight));
CH_COLOR(SColorDkShadow, Blend(SColorShadow, Black));
CH_COLOR(SColorDkShadow, Blend(SColorShadow, SBlack));
CH_COLOR(SColorLabel, SColorText());
}

View file

@ -544,11 +544,9 @@ void Ide::SetupFormat() {
hlt.hl_restore <<= dlg.Breaker(333);
hlt.hl_restore_white <<= dlg.Breaker(334);
hlt.hl_restore_dark <<= dlg.Breaker(335);
ide.chstyle.Add(0, "Host platform");
ide.chstyle.Add(1, "Standard");
ide.chstyle.Add(2, "Classic");
ide.chstyle.Add(3, "Host platform, blue bars");
ide.chstyle.Add(4, "Standard, blue bars");
for(auto sk : GetAllChSkins())
ide.chstyle.Add(ide.chstyle.GetCount(), sk.b);
FrameRight<Button> uscBrowse;
uscBrowse.SetImage(CtrlImg::right_arrow());

View file

@ -27,23 +27,8 @@ void ChClassicSkinBlue()
void Ide::SyncCh()
{
switch(chstyle) {
case 0:
SetSkin(ChHostSkin);
break;
case 1:
SetSkin(ChStdSkin);
break;
case 2:
SetSkin(ChClassicSkin);
break;
case 3:
SetSkin(ChHostSkinBlue);
break;
case 4:
SetSkin(ChStdSkinBlue);
break;
}
auto v = GetAllChSkins();
SetSkin(v[clamp(chstyle, 0, v.GetCount() - 1)].a);
}
void Ide::ToggleVerboseBuild() {