Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Disabled Alpha Icons
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Disabled Alpha Icons

 Post Reply Post Reply
Author
Message
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Topic: Disabled Alpha Icons
    Posted: 06 September 2004 at 7:35pm
Currently the disabled alpha icons that are autogenerated are greyscale and alpha blended onto the toolbar, but that is not how Office really does it. Office's icons still resemble the toolbar color when faded out.


Office 2003:


Codejock:

Any plans to fix this?
Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 07 September 2004 at 11:00pm

I started some of this, but I am unsure how to properly make all the changes for this in the library.

First, I added:
COLORREF CXTPImageManager::m_clrDisabledDark = RGB(128, 128, 128);
COLORREF CXTPImageManager::m_clrDisabledLight = RGB(192, 192, 192);
since I couldn't get GetXtremeColor() to work for XPCOLOR_* inside of CXTPImageManagerIcon anyplace, and even if it did work, the proper color ranges for the XP themes don't really exist using any of the colors I would have to pick from.
I also changed CXTPImageManager::m_dDisabledBrightnessFactor to default to 1.0 instead of 0.5;

So in CXTPImageManagerIcon::CreateDisabledIcon()
I changed the first:
int nGray = (BYTE)(pow(dGray / 255.0, CXTPImageManager::m_dDisabledBrightnessFactor) * 255.0);
to:
int nGray = (BYTE)(dGray/CXTPImageManager::m_dDisabledBrightnessFactor);
because it scales much nicer that way, then below that I made some bigger changes:
just before the for (UINT i = 0; i < nSize; i += 4) loop, I added:
COLORREF clrRange = RGB( GetRValue(CXTPImageManager::m_clrDisabledLight) - GetRValue(CXTPImageManager::m_clrDisabledDark),
                        GetGValue(CXTPImageManager::m_clrDisable dLight) - GetGValue(CXTPImageManager::m_clrDisabledDark),
                        GetBValue(CXTPImageManager::m_clrDisable dLight) - GetBValue(CXTPImageManager::m_clrDisabledDark) );
then inside the loop I changed:
double dGray = pBits[i + 0] * 0.299 + pBits[i + 1] * 0.587 + pBits[i + 2] * 0.114;
pBits[i + 0] = pBits[i + 1] = pBits[i + 2] = (BYTE)(pow(dGray / 255.0, CXTPImageManager::m_dDisabledBrightnessFactor) * 255.0);
to:
double dGray = (pBits[i + 0] * 0.299 + pBits[i + 1] * 0.587 + pBits[i + 2] * 0.114) / CXTPImageManager::m_dDisabledBrightnessFactor / 255.0;
pBits[i + 0] = GetBValue(CXTPImageManager::m_clrDisabledDark) + BYTE(dGray * GetBValue(clrRange));
pBits[i + 1] = GetGValue(CXTPImageManager::m_clrDisabledDark) + BYTE(dGray * GetGValue(clrRange));
pBits[i + 2] = GetRValue(CXTPImageManager::m_clrDisabledDark) + BYTE(dGray * GetRValue(clrRange));

I also added a GetImageManager()->RefreshAll(); in CXTPCommandBars::SetPaintManager so that the disabledauto icons would be flushed if the theme is changed just like they are when the system colors change.

So in order to actually use this, I just assumed the XP default blue theme to test, and set:
CXTPImageManager::m_clrDisabledDark = RGB(97, 122, 172);
CXTPImageManager::m_clrDisabledLight = RGB(233, 236, 242);
and the results are very similar to what Office 2003 actually does.

The only problem is hardcoding all these values for all the various themes and changing them manually by resetting those two variables whenever the system colors or theme changes.

My new code:


A good enough approximation would probably be to use XPCOLOR_3DFACE for m_clrDisabledLight and 2/3 of each of the RGB values from that for m_clrDisabledDark, but I can't see any good way to automate this so the user doesn't have to keep setting them...




Edited by Ark42
Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 08 September 2004 at 1:04am

After playing around with it some more, I actually like using XPCOLOR_DISABLED for the dark color and XPCOLOR_3DFACE for the light color. It works very well under all of the color themes under XP and under classic themes.

I still feel it is very hackishly done and would like some input on how to clean it up or if you can include such a feature in the future so I wouldn't have to continuously update the library each time I download a new version.

Right now, I have a function that handles switching themes, and I stuck in:
    CXTPImageManager::m_clrDisabledDark = pPaintMgr->GetXtremeColor(XPCOLOR_DISABLED);
    CXTPImageManager::m_clrDisabledLight = pPaintMgr->GetXtremeColor(XPCOLOR_3DFACE);
which works very nicely..
In my void CMainFrame::OnSysColorChange() I also added
    CXTPImageManager::m_clrDisabledDark = pPaintMgr->GetXtremeColor(XPCOLOR_DISABLED);
    CXTPImageManager::m_clrDisabledLight = pPaintMgr->GetXtremeColor(XPCOLOR_3DFACE);
    GetCommandBars()->GetImageManager()->RefreshAll();
I'm not sure why I needed the RefreshAll there, but I did.

All of this works entirely, but I don't feel its the best design.

Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 08 September 2004 at 4:55pm

Yes, I really like this using XPCOLOR_DISABLED for the dark color and XPCOLOR_3DFACE for the light color.  Is there any way to internally use these colors and not have such a mess of code like I sort of created trying this out?
The results are very nice:
Using this method:   compared to the actual Office 2003   
Its not exactly the same, but its good enough and looks very nice still.

To compare:

This is the 3 XP themes and then the normal Win2000 theme and also Spruce and Lilac.
Each in Office 2003, XP, then 2000 styles.

Back to Top
Sven View Drop Down
Senior Member
Senior Member


Joined: 21 August 2003
Location: Germany
Status: Offline
Points: 127
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sven Quote  Post ReplyReply Direct Link To This Post Posted: 08 September 2004 at 5:00pm

It would be nice if Codejock can add your code to the library.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.