From c25b802a768227afa10138d8bcea8a1c64b5783c Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 28 Feb 2015 19:10:50 +0000 Subject: [PATCH] CtrlLib: Another transparent menu fix... git-svn-id: svn://ultimatepp.org/upp/trunk@8222 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlLib/MenuItem.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/uppsrc/CtrlLib/MenuItem.cpp b/uppsrc/CtrlLib/MenuItem.cpp index b07973a65..a7a6ead0b 100644 --- a/uppsrc/CtrlLib/MenuItem.cpp +++ b/uppsrc/CtrlLib/MenuItem.cpp @@ -181,12 +181,14 @@ void MenuItemBase::PaintTopItem(Draw& w, int state) { Size isz = GetTextSize(text, StdFont()); Color txt = opaque ? style->topitemtext[0] : GetLabelTextColor(this); Color hltxt = opaque2 ? style->topitemtext[state] : GetLabelTextColor(this); - if(!opaque && state != 2) { // Fix issues when text color is not compatible with transparent background (e.g. Ubuntu Ambience) - int g = Grayscale(bg); + if(!opaque && state != 2) { // Fix issues when text color is not compatible with transparent background (e.g. Ubuntu Ambience)] + Color c = state == 1 ? SColorHighlight() : bg; + int g = Grayscale(c); + bool dark = IsDark(c); if(abs(g - Grayscale(txt)) < 70) - txt = IsDark(bg) ? White() : Black(); + txt = dark ? White() : Black(); if(abs(g - Grayscale(hltxt)) < 70) - hltxt = IsDark(bg) ? White() : Black(); + hltxt = dark ? White() : Black(); } DrawMenuText(w, 6, (sz.cy - isz.cy) / 2, text, GetFont(), IsItemEnabled(), state, txt, hltxt);