Skip to content

Commit 0022a41

Browse files
authored
Merge bd4dede into fbcf855
2 parents fbcf855 + bd4dede commit 0022a41

3 files changed

Lines changed: 45 additions & 14 deletions

File tree

Src/StartMenu/StartMenuDLL/ItemManager.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,27 @@ static void CreateMonochromeImage( unsigned int *bits, int stride, int width, in
176176
}
177177
}
178178

179+
HBITMAP ColorizeMonochromeImage(HBITMAP bitmap, DWORD color)
180+
{
181+
{
182+
BITMAP info{};
183+
GetObject(bitmap, sizeof(info), &info);
184+
if (!DetectGrayscaleImage((const unsigned int*)info.bmBits, info.bmWidth, info.bmWidth, info.bmHeight))
185+
return nullptr;
186+
}
187+
188+
HBITMAP bmp = (HBITMAP)CopyImage(bitmap, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
189+
if (bmp)
190+
{
191+
BITMAP info{};
192+
GetObject(bmp, sizeof(info), &info);
193+
194+
CreateMonochromeImage((unsigned int*)info.bmBits, info.bmWidth, info.bmWidth, info.bmHeight, color);
195+
}
196+
197+
return bmp;
198+
}
199+
179200
static HBITMAP BitmapFromMetroIcon( HICON hIcon, int bitmapSize, int iconSize, DWORD metroColor, bool bDestroyIcon=true )
180201
{
181202
ICONINFO info;

Src/StartMenu/StartMenuDLL/ItemManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ bool MenuGetFileTimestamp( const wchar_t *path, FILETIME *pWriteTime, FILETIME *
467467
STDAPI ShGetKnownFolderPath( REFKNOWNFOLDERID rfid, PWSTR *pPath );
468468
STDAPI ShGetKnownFolderIDList(REFKNOWNFOLDERID rfid, PIDLIST_ABSOLUTE *pPidl );
469469
STDAPI ShGetKnownFolderItem(REFKNOWNFOLDERID rfid, IShellItem **ppItem );
470+
HBITMAP ColorizeMonochromeImage(HBITMAP bitmap, DWORD color);
470471

471472
#define TASKBAR_PINNED_ROOT L"%APPDATA%\\Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar"
472473
#define START_MENU_PINNED_ROOT L"%APPDATA%\\OpenShell\\Pinned"

Src/StartMenu/StartMenuDLL/MenuPaint.cpp

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,21 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect )
22002200
else
22012201
iconSize.cx=iconSize.cy=0;
22022202

2203+
COLORREF color, shadowColor;
2204+
{
2205+
bool bHotColor = (bHot && !bSplit) || stateLeft > 0;
2206+
if (item.id == MENU_EMPTY || item.id == MENU_EMPTY_TOP)
2207+
{
2208+
color = settings.textColors[bHotColor ? 3 : 2];
2209+
shadowColor = settings.textShadowColors[bHotColor ? 3 : 2];
2210+
}
2211+
else
2212+
{
2213+
color = settings.textColors[bHotColor ? 1 : 0];
2214+
shadowColor = settings.textShadowColors[bHotColor ? 1 : 0];
2215+
}
2216+
}
2217+
22032218
// draw icon
22042219
if (drawType==MenuSkin::PROGRAMS_BUTTON || drawType==MenuSkin::PROGRAMS_BUTTON_NEW)
22052220
{
@@ -2256,15 +2271,21 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect )
22562271
const CItemManager::IconInfo *pIcon=(settings.iconSize==MenuSkin::ICON_SIZE_LARGE)?item.pItemInfo->largeIcon:item.pItemInfo->smallIcon;
22572272
if (pIcon && pIcon->bitmap)
22582273
{
2274+
HBITMAP temp = ColorizeMonochromeImage(pIcon->bitmap, color);
2275+
HBITMAP bitmap = temp ? temp : pIcon->bitmap;
2276+
22592277
BITMAP info;
2260-
GetObject(pIcon->bitmap,sizeof(info),&info);
2261-
HGDIOBJ bmp0=SelectObject(hdc2,pIcon->bitmap);
2278+
GetObject(bitmap,sizeof(info),&info);
2279+
HGDIOBJ bmp0=SelectObject(hdc2,bitmap);
22622280
if (bmp0)
22632281
{
22642282
BLENDFUNCTION func={AC_SRC_OVER,0,255,AC_SRC_ALPHA};
22652283
AlphaBlend(hdc,iconX,iconY,iconSize.cx,iconSize.cy,hdc2,0,0,info.bmWidth,info.bmHeight,func);
22662284
SelectObject(hdc2,bmp0);
22672285
}
2286+
2287+
if (temp)
2288+
DeleteObject(temp);
22682289
}
22692290
}
22702291
else if (item.id==MENU_SHUTDOWN_BUTTON && s_bHasUpdates && s_Skin.Shutdown_bitmap.GetBitmap())
@@ -2287,18 +2308,6 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect )
22872308

22882309
// draw text
22892310
SelectObject(hdc,settings.font);
2290-
COLORREF color, shadowColor;
2291-
bool bHotColor=(bHot && !bSplit) || stateLeft>0;
2292-
if (item.id==MENU_EMPTY || item.id==MENU_EMPTY_TOP)
2293-
{
2294-
color=settings.textColors[bHotColor?3:2];
2295-
shadowColor=settings.textShadowColors[bHotColor?3:2];
2296-
}
2297-
else
2298-
{
2299-
color=settings.textColors[bHotColor?1:0];
2300-
shadowColor=settings.textShadowColors[bHotColor?1:0];
2301-
}
23022311
RECT rc={itemRect.left+settings.iconPadding.left+settings.iconPadding.right+settings.textPadding.left,itemRect.top+settings.textPadding.top,
23032312
itemRect.right-settings.arrPadding.cx-settings.arrPadding.cy-settings.textPadding.right,itemRect.bottom-settings.textPadding.bottom};
23042313
if (item.id==MENU_SHUTDOWN_BUTTON)

0 commit comments

Comments
 (0)