From 118eddccfc414ffa76bca48482820196b33306b4 Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 28 Feb 2015 12:40:45 +0000 Subject: [PATCH] CtrlLib: Issue with transparent MenuBars #994 git-svn-id: svn://ultimatepp.org/upp/trunk@8216 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlLib/ChGtk.cpp | 2 -- uppsrc/CtrlLib/MenuItem.cpp | 19 +++++++++++++------ uppsrc/CtrlLib/init | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/uppsrc/CtrlLib/ChGtk.cpp b/uppsrc/CtrlLib/ChGtk.cpp index c3f48ba03..319d8a03a 100644 --- a/uppsrc/CtrlLib/ChGtk.cpp +++ b/uppsrc/CtrlLib/ChGtk.cpp @@ -606,8 +606,6 @@ void ChHostSkin() else s.topitemtext[1] = ChGtkColor(0, top_item); s.topitemtext[2] = ChGtkColor(2, top_item); - if(engine == "Ambiance") - s.topitemtext[1] = Black(); SColorMenuText_Write(s.topitemtext[1]); if(Qt) GtkCh(s.topitem[1], sw, GTK_STATE_PRELIGHT); diff --git a/uppsrc/CtrlLib/MenuItem.cpp b/uppsrc/CtrlLib/MenuItem.cpp index c1b6f8a1d..a2cd673c4 100644 --- a/uppsrc/CtrlLib/MenuItem.cpp +++ b/uppsrc/CtrlLib/MenuItem.cpp @@ -170,19 +170,26 @@ void MenuItemBase::PaintTopItem(Draw& w, int state) { Size sz = GetSize(); if(GUI_GlobalStyle() >= GUISTYLE_XP) { bool opaque = InOpaqueBar(); -// bool opaque2 = opaque || state == 2; - bool opaque2 = opaque || state; //TODO: This would probably cause problems in linux dark themes - check! - // But fixes issues in ide / Win + bool opaque2 = opaque || state; + Color bg = SColorFace(); if(opaque2) ChPaint(w, 0, 0, sz.cx, sz.cy, style->topitem[state]); else if(opaque) - w.DrawRect(0, 0, sz.cx, sz.cy, SColorFace()); + w.DrawRect(0, 0, sz.cx, sz.cy, bg); String text = GetText(); Size isz = GetTextSize(text, StdFont()); + Color txt = opaque ? style->topitemtext[0] : GetLabelTextColor(this); + Color hltxt = opaque2 ? style->topitemtext[state] : GetLabelTextColor(this); + if(!opaque) { // Fix issues when text color is not compatible with transparent background (e.g. Ubuntu Ambience) + int g = Grayscale(bg); + if(abs(g - Grayscale(txt)) < 70) + txt = IsDark(bg) ? White() : Black(); + if(abs(g - Grayscale(hltxt)) < 70) + hltxt = IsDark(bg) ? White() : Black(); + } DrawMenuText(w, 6, (sz.cy - isz.cy) / 2, text, GetFont(), IsItemEnabled(), state, - opaque ? style->topitemtext[0] : GetLabelTextColor(this), - opaque2 ? style->topitemtext[state] : GetLabelTextColor(this)); + txt, hltxt); } else { w.DrawRect(sz, SColorFace); diff --git a/uppsrc/CtrlLib/init b/uppsrc/CtrlLib/init index 3c90182ca..045155554 100644 --- a/uppsrc/CtrlLib/init +++ b/uppsrc/CtrlLib/init @@ -2,7 +2,7 @@ #define _CtrlLib_icpp_init_stub #include "CtrlCore/init" #include "PdfDraw/init" -#define BLITZ_INDEX__ Fa588a2a7bb40a3ed36760f6c2bef5026 +#define BLITZ_INDEX__ F73a88dfc92373ef6f2379fafa069fdce #include "CtrlLib.icpp" #undef BLITZ_INDEX__ #endif