mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
CtrlLib: ChGtk fixes
This commit is contained in:
parent
d602d81c41
commit
6c61776b41
4 changed files with 28 additions and 51 deletions
|
|
@ -9,9 +9,11 @@ Color SColorEvenRow()
|
|||
static SColor s([] {
|
||||
Color c;
|
||||
Color hl = SColorHighlight();
|
||||
for(Color c : { Blend(SColorMark, SColorPaper, 220), AdjustIfDark(GrayColor(245)),
|
||||
AdjustIfDark(GrayColor(245)), AdjustIfDark(Color(250, 255, 250)),
|
||||
AdjustIfDark(Color(250, 255, 255)) })
|
||||
for(Color c : { Blend(SColorMark, SColorPaper, 220),
|
||||
AdjustIfDark(Color(220, 255, 220)),
|
||||
AdjustIfDark(Color(220, 220, 255)),
|
||||
AdjustIfDark(GrayColor(240))
|
||||
}) // Make sure there is enough contrast between cursor and even lines
|
||||
if(Difference(c, hl) > 80)
|
||||
return c;
|
||||
return SColorPaper();
|
||||
|
|
|
|||
|
|
@ -452,6 +452,22 @@ int GetRoundness(const Image& m)
|
|||
return max(di - hi, 0);
|
||||
}
|
||||
|
||||
void FixButton(Image& button)
|
||||
{
|
||||
Size isz = button.GetSize();
|
||||
Image m = CreateImage(isz, SColorFace());
|
||||
Over(m, button);
|
||||
int g1 = Grayscale(SColorFace());
|
||||
int n = 0;
|
||||
int r = GetRoundness(button);
|
||||
for(RGBA c : m) {
|
||||
if(abs(Grayscale(c) - g1) > 30)
|
||||
n++;
|
||||
}
|
||||
if(n < 2 * isz.cx)
|
||||
button = MakeButton(2, AvgColor(button, 10), 1, Gray());
|
||||
}
|
||||
|
||||
static Value sSample;
|
||||
|
||||
void SetChameleonSample(const Value& m, bool once)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ Color AvgColor(const Image& m, RGBA bg, int margin = 0);
|
|||
|
||||
Color GetInk(const Image& m); // the color that is most different from AvgColor
|
||||
int GetRoundness(const Image& m);
|
||||
void FixButton(Image& button); // fix button if it is too close to face color
|
||||
|
||||
Image WithRect(Image m, int x, int y, int cx, int cy, Color c);
|
||||
Image WithLeftLine(const Image& m, Color c, int w = DPI(1));
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ Color GetInkColor(GtkStyleContext *ctx, dword flags)
|
|||
rgba.g = int(255 * color.green);
|
||||
rgba.b = int(255 * color.blue);
|
||||
rgba.a = int(255 * color.alpha);
|
||||
rgba = Premultiply(rgba);
|
||||
RGBA t = SColorPaper();
|
||||
AlphaBlend(&t, &rgba, 1);
|
||||
return t;
|
||||
|
|
@ -336,52 +337,6 @@ void ChHostSkin()
|
|||
SOImages(CtrlsImg::I_O2, GTK_STATE_FLAG_INCONSISTENT);
|
||||
|
||||
CtrlImg::Set(CtrlImg::I_MenuCheck0, CtrlsImg::O0());
|
||||
/*
|
||||
{
|
||||
MenuBar::Style& s = MenuBar::StyleDefault().Write();
|
||||
s.pullshift.y = 0;
|
||||
|
||||
Gtk_New("menu");
|
||||
Image m = CairoImage(128, 64);
|
||||
s.pullshift.y = 0;
|
||||
int mg = DPI(2);
|
||||
s.popupframe = WithHotSpot(m, mg, mg);
|
||||
Size sz = m.GetSize();
|
||||
s.popupbody = Crop(m, mg, mg, sz.cx - 2 * mg, sz.cy - 2 * mg);
|
||||
s.leftgap = DPI(16) + Zx(6);
|
||||
SColorMenu_Write(GetBackgroundColor());
|
||||
SColorMenuText_Write(s.menutext);
|
||||
|
||||
Gtk_New("menu menuitem");
|
||||
s.menutext = GetInkColor();
|
||||
Gtk_State(CTRL_HOT);
|
||||
s.itemtext = GetInkColor();
|
||||
Color c = AvgColor(m);
|
||||
if(Diff(c, s.menutext) < 100) // menutext color too close to background color, fix it
|
||||
s.menutext = IsDark(c) ? White() : Black();
|
||||
s.item = Hot3(CairoImage(32, 16));
|
||||
|
||||
m = CreateImage(Size(DPI(32), DPI(16)), SColorFace());
|
||||
Gtk_New("frame");
|
||||
Over(m, CairoImage(DPI(32), DPI(16)));
|
||||
Gtk_New("frame border");
|
||||
Over(m, CairoImage(DPI(32), DPI(16)));
|
||||
Gtk_New("menubar");
|
||||
Over(m, CairoImage(DPI(32), DPI(16)));
|
||||
s.look = Hot3(m);
|
||||
Color dk = SColorText();
|
||||
Color wh = SColorPaper();
|
||||
if(IsDark(wh))
|
||||
Swap(dk, wh);
|
||||
s.topitemtext[0] = IsDark(AvgColor(m)) ? wh : dk;
|
||||
s.topitem[1] = s.topitem[0] = Null;
|
||||
s.topitemtext[1] = s.topitemtext[0];
|
||||
Gtk_New("menubar menuitem", CTRL_HOT);
|
||||
s.topitem[0] = Null;
|
||||
s.topitem[2] = Hot3(CairoImage(32, 16));
|
||||
s.topitemtext[2] = GetInkColor();
|
||||
}
|
||||
*/
|
||||
CtrlImg::Set(CtrlImg::I_MenuCheck1, CtrlsImg::O1());
|
||||
CtrlImg::Set(CtrlImg::I_MenuRadio0, CtrlsImg::S0());
|
||||
CtrlImg::Set(CtrlImg::I_MenuRadio1, CtrlsImg::S1());
|
||||
|
|
@ -399,13 +354,16 @@ void ChHostSkin()
|
|||
s.focusmargin = DPI(4);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
Gtk_State(i);
|
||||
s.look[i] = Hot3(CairoImage());
|
||||
Image m = Hot3(CairoImage());
|
||||
FixButton(m);
|
||||
s.look[i] = m;
|
||||
Color ink = i == CTRL_DISABLED ? GetInkColor() : GetInkColorBk();
|
||||
s.monocolor[i] = s.textcolor[i] = ink;
|
||||
if(pass == 0) {
|
||||
button[i] = WithHotSpots(CairoImage(100, 100), DPI(4), DPI(4), 0, 0);
|
||||
text[i] = ink;
|
||||
}
|
||||
FixButton(button[i]);
|
||||
}
|
||||
s.ok = Gtk_IconAdjusted("gtk-ok", DPI(16));
|
||||
s.cancel = Gtk_IconAdjusted("gtk-cancel", DPI(16));
|
||||
|
|
@ -419,7 +377,7 @@ void ChHostSkin()
|
|||
auto& s = ToolButton::StyleDefault().Write();
|
||||
s.look[CTRL_NORMAL] = Image();
|
||||
s.look[CTRL_HOT] = button[CTRL_HOT];
|
||||
s.look[CTRL_PRESSED] = button[CTRL_PRESSED];
|
||||
s.look[CTRL_PRESSED] = button[CTRL_PRESSED];
|
||||
s.look[CTRL_DISABLED] = Image();
|
||||
s.look[CTRL_CHECKED] = button[CTRL_PRESSED];
|
||||
s.look[CTRL_HOTCHECKED] = button[CTRL_HOT];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue