CtrlLib: Issue with transparent MenuBars #994

git-svn-id: svn://ultimatepp.org/upp/trunk@8216 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-02-28 12:40:45 +00:00
parent 84c95b9e0f
commit 118eddccfc
3 changed files with 14 additions and 9 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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