Disabled Alpha Icons |
Post Reply |
Author | |
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
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? |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
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 |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
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. |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
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. |
|
Sven
Senior Member Joined: 21 August 2003 Location: Germany Status: Offline Points: 127 |
Post Options
Thanks(0)
|
It would be nice if Codejock can add your code to the library. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |