Use more convenient format for color settings

We are storing color settings in BBGGRR format (for historical reasons).
This may be confusing for people that are used to (more widely used) RRGGBB format.

Thus we will present color settings in RRGGBB format when editing.

We will still use BBGGRR format for those settings internally. To
maintain backward compatibility with existing settings stored in
registry/xml.

Also setting descriptions now contain hint about expected color format.
This way it should be more clear what values `Open-Shell` expects.

Fixes #82, #1141.
This commit is contained in:
ge0rdi
2022-11-27 15:45:01 +01:00
parent f7334882c3
commit cef27bdfa0
5 changed files with 70 additions and 31 deletions

View File

@@ -135,17 +135,17 @@ BEGIN
IDS_LANGUAGE_SETTINGS "Language" IDS_LANGUAGE_SETTINGS "Language"
IDS_CAPTION_FONT "Caption font" IDS_CAPTION_FONT "Caption font"
IDS_CAPTION_FONT_TIP "Select the font and text size to use for the caption" IDS_CAPTION_FONT_TIP "Select the font and text size to use for the caption"
IDS_TEXT_COLOR "Text color" IDS_TEXT_COLOR "Text color (RRGGBB)"
IDS_TEXT_COLOR_TIP "Select the color for the caption text" IDS_TEXT_COLOR_TIP "Select the color for the caption text"
IDS_MAXTEXT_COLOR "Text color (maximized)" IDS_MAXTEXT_COLOR "Text color (maximized) (RRGGBB)"
IDS_MAXTEXT_COLOR_TIP "Select the color for the caption text when the window is maximized" IDS_MAXTEXT_COLOR_TIP "Select the color for the caption text when the window is maximized"
IDS_INTEXT_COLOR "Text color (inactive)" IDS_INTEXT_COLOR "Text color (inactive) (RRGGBB)"
IDS_INTEXT_COLOR_TIP "Select the color for the caption text when the window is inactive" IDS_INTEXT_COLOR_TIP "Select the color for the caption text when the window is inactive"
IDS_MAXINTEXT_COLOR "Text color (maximized, inactive)" IDS_MAXINTEXT_COLOR "Text color (maximized, inactive) (RRGGBB)"
IDS_MAXINTEXT_COLOR_TIP "Select the color for the caption text when the window is maximized and inactive" IDS_MAXINTEXT_COLOR_TIP "Select the color for the caption text when the window is maximized and inactive"
IDS_GLOW "Text glow" IDS_GLOW "Text glow"
IDS_GLOW_TIP "When this is checked, the text will have a glow around it" IDS_GLOW_TIP "When this is checked, the text will have a glow around it"
IDS_GLOW_COLOR "Glow color" IDS_GLOW_COLOR "Glow color (RRGGBB)"
IDS_GLOW_COLOR_TIP "Select the color for the caption glow" IDS_GLOW_COLOR_TIP "Select the color for the caption glow"
END END
@@ -153,7 +153,7 @@ STRINGTABLE
BEGIN BEGIN
IDS_MAXGLOW "Text glow (maximized)" IDS_MAXGLOW "Text glow (maximized)"
IDS_MAXGLOW_TIP "When this is checked, the text in the maximized window will have a glow around it" IDS_MAXGLOW_TIP "When this is checked, the text in the maximized window will have a glow around it"
IDS_MAXGLOW_COLOR "Glow color (maximized)" IDS_MAXGLOW_COLOR "Glow color (maximized) (RRGGBB)"
IDS_MAXGLOW_COLOR_TIP "Select the color for the caption glow when the window is maximized" IDS_MAXGLOW_COLOR_TIP "Select the color for the caption glow when the window is maximized"
IDS_STATUS_SETTINGS "Status Bar" IDS_STATUS_SETTINGS "Status Bar"
IDS_SHOW_PROGRESS "Show progress" IDS_SHOW_PROGRESS "Show progress"

View File

@@ -2651,15 +2651,14 @@ LRESULT CTreeSettingsDlg::OnBrowse( WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
CString str; CString str;
m_EditBox.GetWindowText(str); m_EditBox.GetWindowText(str);
str.TrimLeft(); str.TrimRight(); str.TrimLeft(); str.TrimRight();
wchar_t *end; COLORREF val=RgbToBgr(ParseColor(str));
COLORREF val=wcstol(str,&end,16)&0xFFFFFF;
static COLORREF customColors[16]; static COLORREF customColors[16];
CHOOSECOLOR choose={sizeof(choose),m_hWnd,NULL,val,customColors}; CHOOSECOLOR choose={sizeof(choose),m_hWnd,NULL,val,customColors};
choose.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT; choose.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
if (ChooseColor(&choose)) if (ChooseColor(&choose))
{ {
wchar_t text[100]; wchar_t text[100];
Sprintf(text,_countof(text),L"%06X",choose.rgbResult); Sprintf(text,_countof(text),L"%06X",BgrToRgb(choose.rgbResult));
m_EditBox.SetWindowText(text); m_EditBox.SetWindowText(text);
ApplyEditBox(); ApplyEditBox();
UpdateGroup(m_pEditSetting); UpdateGroup(m_pEditSetting);
@@ -3048,8 +3047,7 @@ void CTreeSettingsDlg::ApplyEditBox( void )
} }
else if (pSetting->type==CSetting::TYPE_COLOR) else if (pSetting->type==CSetting::TYPE_COLOR)
{ {
wchar_t *end; int val=RgbToBgr(ParseColor(str));
int val=wcstol(str,&end,16)&0xFFFFFF;
if (pSetting->value.vt!=VT_I4 || pSetting->value.intVal!=val) if (pSetting->value.vt!=VT_I4 || pSetting->value.intVal!=val)
{ {
pSetting->value=CComVariant(val); pSetting->value=CComVariant(val);
@@ -3156,7 +3154,7 @@ void CTreeSettingsDlg::ItemSelected( HTREEITEM hItem, CSetting *pSetting, bool b
mode=EDIT_COLOR; mode=EDIT_COLOR;
int val=0; int val=0;
if (valVar.vt==VT_I4) if (valVar.vt==VT_I4)
val=valVar.intVal; val=BgrToRgb(valVar.intVal);
Sprintf(text,_countof(text),L"%06X",val); Sprintf(text,_countof(text),L"%06X",val);
} }
} }
@@ -3462,7 +3460,7 @@ void CTreeSettingsDlg::UpdateGroup( const CSetting *pModified )
CString str=LoadStringEx(pSetting->nameID); CString str=LoadStringEx(pSetting->nameID);
int val=0; int val=0;
if (valVar.vt==VT_I4) if (valVar.vt==VT_I4)
val=valVar.intVal; val=BgrToRgb(valVar.intVal);
Sprintf(text,_countof(text),L"%s: %06X",str,val); Sprintf(text,_countof(text),L"%s: %06X",str,val);
item.mask|=TVIF_TEXT; item.mask|=TVIF_TEXT;
} }
@@ -3616,3 +3614,19 @@ bool CDefaultSettingsPanel::Validate( HWND parent )
s_Dialog.Validate(); s_Dialog.Validate();
return true; return true;
} }
DWORD RgbToBgr(DWORD val)
{
return ((val & 0xFF) << 16) | (val & 0xFF00) | ((val >> 16) & 0xFF);
}
DWORD BgrToRgb(DWORD val)
{
return RgbToBgr(val);
}
DWORD ParseColor(const wchar_t* str)
{
wchar_t* end;
return wcstoul(str, &end, 16) & 0xFFFFFF;
}

View File

@@ -387,3 +387,11 @@ extern const GUID FOLDERID_DesktopRoot;
bool BrowseCommandHelper( HWND parent, wchar_t *text ); bool BrowseCommandHelper( HWND parent, wchar_t *text );
bool BrowseLinkHelper( HWND parent, wchar_t *text, bool bFoldersOnly ); bool BrowseLinkHelper( HWND parent, wchar_t *text, bool bFoldersOnly );
bool BrowseIconHelper( HWND parent, wchar_t *text ); bool BrowseIconHelper( HWND parent, wchar_t *text );
// convert color in RRGGBB format to BBGGRR
DWORD RgbToBgr(DWORD val);
// convert color in BBGGRR format to RRGGBB
DWORD BgrToRgb(DWORD val);
// parse color from hexadecimal string
DWORD ParseColor(const wchar_t* str);

View File

@@ -30,6 +30,19 @@ const int DEFAULT_TASK_OPACITY10=85; // 85%
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
CString RgbToBgr(const wchar_t* str)
{
CString retval;
retval.Format(L"%06X", RgbToBgr(ParseColor(str)));
return retval;
}
CString BgrToRgb(const wchar_t* str)
{
return RgbToBgr(str);
}
class CSkinSettingsDlg: public CResizeableDlg<CSkinSettingsDlg> class CSkinSettingsDlg: public CResizeableDlg<CSkinSettingsDlg>
{ {
public: public:
@@ -422,7 +435,7 @@ void CSkinSettingsDlg::UpdateSkinSettings( void )
if (!option.bEnabled || bLocked) if (!option.bEnabled || bLocked)
image|=SETTING_STATE_DISABLED; image|=SETTING_STATE_DISABLED;
if (option.bValue && option.type>SKIN_OPTION_BOOL) if (option.bValue && option.type>SKIN_OPTION_BOOL)
Sprintf(text,_countof(text),L"%s: %s",option.label,option.sValue); Sprintf(text,_countof(text),L"%s: %s",option.label,(option.type==SKIN_OPTION_COLOR)?BgrToRgb(option.sValue):option.sValue);
else else
Sprintf(text,_countof(text),L"%s",option.label); Sprintf(text,_countof(text),L"%s",option.label);
@@ -482,9 +495,7 @@ LRESULT CSkinSettingsDlg::OnCustomDraw( int idCtrl, LPNMHDR pnmh, BOOL& bHandled
if (TreeView_GetItemRect(m_Tree,(HTREEITEM)pDraw->nmcd.dwItemSpec,&rc,TRUE)) if (TreeView_GetItemRect(m_Tree,(HTREEITEM)pDraw->nmcd.dwItemSpec,&rc,TRUE))
{ {
const wchar_t *str=m_CurrentSkin.Options[pDraw->nmcd.lItemlParam].sValue; const wchar_t *str=m_CurrentSkin.Options[pDraw->nmcd.lItemlParam].sValue;
wchar_t *end; SetDCBrushColor(pDraw->nmcd.hdc,ParseColor(str));
COLORREF color=wcstoul(str,&end,16);
SetDCBrushColor(pDraw->nmcd.hdc,color&0xFFFFFF);
SelectObject(pDraw->nmcd.hdc,GetStockObject(DC_BRUSH)); SelectObject(pDraw->nmcd.hdc,GetStockObject(DC_BRUSH));
SelectObject(pDraw->nmcd.hdc,GetStockObject(BLACK_PEN)); SelectObject(pDraw->nmcd.hdc,GetStockObject(BLACK_PEN));
Rectangle(pDraw->nmcd.hdc,rc.right,rc.top,rc.right+rc.bottom-rc.top,rc.bottom-1); Rectangle(pDraw->nmcd.hdc,rc.right,rc.top,rc.right+rc.bottom-rc.top,rc.bottom-1);
@@ -690,15 +701,14 @@ LRESULT CSkinSettingsDlg::OnBrowse( WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
CString str; CString str;
m_EditBox.GetWindowText(str); m_EditBox.GetWindowText(str);
str.TrimLeft(); str.TrimRight(); str.TrimLeft(); str.TrimRight();
wchar_t *end; COLORREF val=RgbToBgr(ParseColor(str));
COLORREF val=wcstol(str,&end,16)&0xFFFFFF;
static COLORREF customColors[16]; static COLORREF customColors[16];
CHOOSECOLOR choose={sizeof(choose),m_hWnd,NULL,val,customColors}; CHOOSECOLOR choose={sizeof(choose),m_hWnd,NULL,val,customColors};
choose.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT; choose.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
if (ChooseColor(&choose)) if (ChooseColor(&choose))
{ {
wchar_t text[100]; wchar_t text[100];
Sprintf(text,_countof(text),L"%06X",choose.rgbResult); Sprintf(text,_countof(text),L"%06X",BgrToRgb(choose.rgbResult));
m_EditBox.SetWindowText(text); m_EditBox.SetWindowText(text);
ApplyEditBox(); ApplyEditBox();
m_Tree.Invalidate(); m_Tree.Invalidate();
@@ -717,7 +727,11 @@ void CSkinSettingsDlg::ApplyEditBox( void )
CString str; CString str;
m_EditBox.GetWindowText(str); m_EditBox.GetWindowText(str);
str.TrimLeft(); str.TrimRight(); str.TrimLeft(); str.TrimRight();
m_CurrentSkin.Options[m_EditItemIndex].sValue=str; auto& option=m_CurrentSkin.Options[m_EditItemIndex];
if (option.type==SKIN_OPTION_COLOR)
option.sValue=RgbToBgr(str);
else
option.sValue=str;
StoreSkinOptions(); StoreSkinOptions();
} }
} }
@@ -730,7 +744,7 @@ void CSkinSettingsDlg::ItemSelected( HTREEITEM hItem, int index, bool bEnabled )
const MenuSkin::Option &option=m_CurrentSkin.Options[m_EditItemIndex]; const MenuSkin::Option &option=m_CurrentSkin.Options[m_EditItemIndex];
wchar_t text[256]; wchar_t text[256];
if (option.bValue && option.type>SKIN_OPTION_BOOL) if (option.bValue && option.type>SKIN_OPTION_BOOL)
Sprintf(text,_countof(text),L"%s: %s",option.label,option.sValue); Sprintf(text,_countof(text),L"%s: %s",option.label,(option.type==SKIN_OPTION_COLOR)?BgrToRgb(option.sValue):option.sValue);
else else
Sprintf(text,_countof(text),L"%s",option.label); Sprintf(text,_countof(text),L"%s",option.label);
TVITEM item={TVIF_TEXT,m_EditItem,0,0,text}; TVITEM item={TVIF_TEXT,m_EditItem,0,0,text};
@@ -745,7 +759,10 @@ void CSkinSettingsDlg::ItemSelected( HTREEITEM hItem, int index, bool bEnabled )
const MenuSkin::Option &option=m_CurrentSkin.Options[index]; const MenuSkin::Option &option=m_CurrentSkin.Options[index];
if (option.type>SKIN_OPTION_BOOL) if (option.type>SKIN_OPTION_BOOL)
mode=option.type; mode=option.type;
text=option.sValue; if (option.type==SKIN_OPTION_COLOR)
text=BgrToRgb(option.sValue);
else
text=option.sValue;
} }
RECT rc; RECT rc;
@@ -4946,7 +4963,7 @@ void UpdateSettings( void )
if (GetWinVersion()>WIN_VER_WIN7) if (GetWinVersion()>WIN_VER_WIN7)
{ {
int color=GetSystemGlassColor8(); int color=GetSystemGlassColor8();
UpdateSetting(L"TaskbarColor",CComVariant(((color&0xFF)<<16)|(color&0xFF00)|((color>>16)&0xFF)),false); UpdateSetting(L"TaskbarColor",CComVariant(RgbToBgr(color)),false);
} }
if (GetWinVersion()<=WIN_VER_WIN7) if (GetWinVersion()<=WIN_VER_WIN7)

View File

@@ -1082,7 +1082,7 @@ BEGIN
IDS_MIN_HEIGHT_TIP "The main menu will be at least as tall as this many search results" IDS_MIN_HEIGHT_TIP "The main menu will be at least as tall as this many search results"
IDS_GLASS_OVERRIDE "Override glass color" IDS_GLASS_OVERRIDE "Override glass color"
IDS_GLASS_OVERRIDE_TIP "Check this to override the system glass color to use in the menu" IDS_GLASS_OVERRIDE_TIP "Check this to override the system glass color to use in the menu"
IDS_GLASS_COLOR "Menu glass color" IDS_GLASS_COLOR "Menu glass color (RRGGBB)"
IDS_GLASS_COLOR_TIP "Select the glass color to use in the menu. How much this color affects the menu will depend on the selected skin" IDS_GLASS_COLOR_TIP "Select the glass color to use in the menu. How much this color affects the menu will depend on the selected skin"
IDS_GLASS_INTENSITY "Menu glass intensity" IDS_GLASS_INTENSITY "Menu glass intensity"
IDS_GLASS_INTENSITY_TIP "Select the intensity (brightness) for the glass color in the menu (0 - dark, 100 - bright)" IDS_GLASS_INTENSITY_TIP "Select the intensity (brightness) for the glass color in the menu (0 - dark, 100 - bright)"
@@ -1144,17 +1144,17 @@ BEGIN
IDS_STRING7024 "Shadows on glass#The text and the arrows in the second column of the main menu will have a drop shadow" IDS_STRING7024 "Shadows on glass#The text and the arrows in the second column of the main menu will have a drop shadow"
IDS_STRING7025 "Opaque" IDS_STRING7025 "Opaque"
IDS_STRING7026 "Main menu color" IDS_STRING7026 "Main menu color"
IDS_STRING7027 "Custom color#Select custom color for the main menu" IDS_STRING7027 "Custom color (RRGGBB)#Select custom color for the main menu"
IDS_STRING7028 "Sub-menu color" IDS_STRING7028 "Sub-menu color"
IDS_STRING7029 "Custom color#Select custom color for the sub-menus" IDS_STRING7029 "Custom color (RRGGBB)#Select custom color for the sub-menus"
IDS_STRING7030 "Silver" IDS_STRING7030 "Silver"
IDS_STRING7031 "Gold" IDS_STRING7031 "Gold"
IDS_STRING7032 "Steel" IDS_STRING7032 "Steel"
IDS_STRING7033 "Titanium" IDS_STRING7033 "Titanium"
IDS_STRING7034 "Image for first column#Select custom image for the first column of the main menu" IDS_STRING7034 "Image for first column#Select custom image for the first column of the main menu"
IDS_STRING7035 "Image for second column#Select custom image for the second column of the main menu" IDS_STRING7035 "Image for second column#Select custom image for the second column of the main menu"
IDS_STRING7036 "Text color for first column#Select custom color for the first column of the main menu text" IDS_STRING7036 "Text color for first column (RRGGBB)#Select custom color for the first column of the main menu text"
IDS_STRING7037 "Text color for second column#Select custom color for the second column of the main menu text" IDS_STRING7037 "Text color for second column (RRGGBB)#Select custom color for the second column of the main menu text"
IDS_STRING7038 "Text size#Select custom size for the main menu text" IDS_STRING7038 "Text size#Select custom size for the main menu text"
END END
@@ -1249,7 +1249,7 @@ BEGIN
IDS_TASK_AEROGLASS_TIP "The taskbar will have glass transparency that is compatible with the Aero Glass mod" IDS_TASK_AEROGLASS_TIP "The taskbar will have glass transparency that is compatible with the Aero Glass mod"
IDS_TASK_OPACITY "Taskbar opacity" IDS_TASK_OPACITY "Taskbar opacity"
IDS_TASK_OPACITY_TIP "Set the opacity for the taskbar (0 - transparent, 100 - opaque)" IDS_TASK_OPACITY_TIP "Set the opacity for the taskbar (0 - transparent, 100 - opaque)"
IDS_TASK_COLOR "Taskbar color" IDS_TASK_COLOR "Taskbar color (RRGGBB)"
IDS_TASK_COLOR_TIP "Set the color for the taskbar" IDS_TASK_COLOR_TIP "Set the color for the taskbar"
IDS_PCSETTINGS "Settings" IDS_PCSETTINGS "Settings"
IDS_PCSETTINGS_TIP "Shows the modern Settings window" IDS_PCSETTINGS_TIP "Shows the modern Settings window"
@@ -1288,7 +1288,7 @@ BEGIN
IDS_TASK_BORDERS "Border sizes" IDS_TASK_BORDERS "Border sizes"
IDS_TASK_BORDERS_TIP "Select how many pixel on each side of the texture to exclude from stretching" IDS_TASK_BORDERS_TIP "Select how many pixel on each side of the texture to exclude from stretching"
IDS_TASKBAR_SETTINGS "Taskbar" IDS_TASKBAR_SETTINGS "Taskbar"
IDS_TASK_TEXTCOLOR "Taskbar text color" IDS_TASK_TEXTCOLOR "Taskbar text color (RRGGBB)"
IDS_TASK_TEXTCOLOR_TIP "Select the color for the text on the taskbar" IDS_TASK_TEXTCOLOR_TIP "Select the color for the text on the taskbar"
IDS_SELECT_LAST "Select the last item in shutdown menu" IDS_SELECT_LAST "Select the last item in shutdown menu"
IDS_SELECT_LAST_TIP "When this is checked, the last item will be selected by default when the shutdown menu is opened with the keyboard" IDS_SELECT_LAST_TIP "When this is checked, the last item will be selected by default when the shutdown menu is opened with the keyboard"