Skip to content

Commit 55c76ce

Browse files
committed
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 Open-Shell#82, Open-Shell#1141.
1 parent 5c31b6d commit 55c76ce

File tree

5 files changed

+70
-31
lines changed

5 files changed

+70
-31
lines changed

Src/ClassicIE/ClassicIEDLL/ClassicIEDLL.rc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,25 @@ BEGIN
135135
IDS_LANGUAGE_SETTINGS "Language"
136136
IDS_CAPTION_FONT "Caption font"
137137
IDS_CAPTION_FONT_TIP "Select the font and text size to use for the caption"
138-
IDS_TEXT_COLOR "Text color"
138+
IDS_TEXT_COLOR "Text color (RRGGBB)"
139139
IDS_TEXT_COLOR_TIP "Select the color for the caption text"
140-
IDS_MAXTEXT_COLOR "Text color (maximized)"
140+
IDS_MAXTEXT_COLOR "Text color (maximized) (RRGGBB)"
141141
IDS_MAXTEXT_COLOR_TIP "Select the color for the caption text when the window is maximized"
142-
IDS_INTEXT_COLOR "Text color (inactive)"
142+
IDS_INTEXT_COLOR "Text color (inactive) (RRGGBB)"
143143
IDS_INTEXT_COLOR_TIP "Select the color for the caption text when the window is inactive"
144-
IDS_MAXINTEXT_COLOR "Text color (maximized, inactive)"
144+
IDS_MAXINTEXT_COLOR "Text color (maximized, inactive) (RRGGBB)"
145145
IDS_MAXINTEXT_COLOR_TIP "Select the color for the caption text when the window is maximized and inactive"
146146
IDS_GLOW "Text glow"
147147
IDS_GLOW_TIP "When this is checked, the text will have a glow around it"
148-
IDS_GLOW_COLOR "Glow color"
148+
IDS_GLOW_COLOR "Glow color (RRGGBB)"
149149
IDS_GLOW_COLOR_TIP "Select the color for the caption glow"
150150
END
151151

152152
STRINGTABLE
153153
BEGIN
154154
IDS_MAXGLOW "Text glow (maximized)"
155155
IDS_MAXGLOW_TIP "When this is checked, the text in the maximized window will have a glow around it"
156-
IDS_MAXGLOW_COLOR "Glow color (maximized)"
156+
IDS_MAXGLOW_COLOR "Glow color (maximized) (RRGGBB)"
157157
IDS_MAXGLOW_COLOR_TIP "Select the color for the caption glow when the window is maximized"
158158
IDS_STATUS_SETTINGS "Status Bar"
159159
IDS_SHOW_PROGRESS "Show progress"

Src/Lib/SettingsUIHelper.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,15 +2651,14 @@ LRESULT CTreeSettingsDlg::OnBrowse( WORD wNotifyCode, WORD wID, HWND hWndCtl, BO
26512651
CString str;
26522652
m_EditBox.GetWindowText(str);
26532653
str.TrimLeft(); str.TrimRight();
2654-
wchar_t *end;
2655-
COLORREF val=wcstol(str,&end,16)&0xFFFFFF;
2654+
COLORREF val=RgbToBgr(ParseColor(str));
26562655
static COLORREF customColors[16];
26572656
CHOOSECOLOR choose={sizeof(choose),m_hWnd,NULL,val,customColors};
26582657
choose.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
26592658
if (ChooseColor(&choose))
26602659
{
26612660
wchar_t text[100];
2662-
Sprintf(text,_countof(text),L"%06X",choose.rgbResult);
2661+
Sprintf(text,_countof(text),L"%06X",BgrToRgb(choose.rgbResult));
26632662
m_EditBox.SetWindowText(text);
26642663
ApplyEditBox();
26652664
UpdateGroup(m_pEditSetting);
@@ -3048,8 +3047,7 @@ void CTreeSettingsDlg::ApplyEditBox( void )
30483047
}
30493048
else if (pSetting->type==CSetting::TYPE_COLOR)
30503049
{
3051-
wchar_t *end;
3052-
int val=wcstol(str,&end,16)&0xFFFFFF;
3050+
int val=RgbToBgr(ParseColor(str));
30533051
if (pSetting->value.vt!=VT_I4 || pSetting->value.intVal!=val)
30543052
{
30553053
pSetting->value=CComVariant(val);
@@ -3156,7 +3154,7 @@ void CTreeSettingsDlg::ItemSelected( HTREEITEM hItem, CSetting *pSetting, bool b
31563154
mode=EDIT_COLOR;
31573155
int val=0;
31583156
if (valVar.vt==VT_I4)
3159-
val=valVar.intVal;
3157+
val=BgrToRgb(valVar.intVal);
31603158
Sprintf(text,_countof(text),L"%06X",val);
31613159
}
31623160
}
@@ -3462,7 +3460,7 @@ void CTreeSettingsDlg::UpdateGroup( const CSetting *pModified )
34623460
CString str=LoadStringEx(pSetting->nameID);
34633461
int val=0;
34643462
if (valVar.vt==VT_I4)
3465-
val=valVar.intVal;
3463+
val=BgrToRgb(valVar.intVal);
34663464
Sprintf(text,_countof(text),L"%s: %06X",str,val);
34673465
item.mask|=TVIF_TEXT;
34683466
}
@@ -3616,3 +3614,19 @@ bool CDefaultSettingsPanel::Validate( HWND parent )
36163614
s_Dialog.Validate();
36173615
return true;
36183616
}
3617+
3618+
DWORD RgbToBgr(DWORD val)
3619+
{
3620+
return ((val & 0xFF) << 16) | (val & 0xFF00) | ((val >> 16) & 0xFF);
3621+
}
3622+
3623+
DWORD BgrToRgb(DWORD val)
3624+
{
3625+
return RgbToBgr(val);
3626+
}
3627+
3628+
DWORD ParseColor(const wchar_t* str)
3629+
{
3630+
wchar_t* end;
3631+
return wcstoul(str, &end, 16) & 0xFFFFFF;
3632+
}

Src/Lib/SettingsUIHelper.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,3 +387,11 @@ extern const GUID FOLDERID_DesktopRoot;
387387
bool BrowseCommandHelper( HWND parent, wchar_t *text );
388388
bool BrowseLinkHelper( HWND parent, wchar_t *text, bool bFoldersOnly );
389389
bool BrowseIconHelper( HWND parent, wchar_t *text );
390+
391+
// convert color in RRGGBB format to BBGGRR
392+
DWORD RgbToBgr(DWORD val);
393+
// convert color in BBGGRR format to RRGGBB
394+
DWORD BgrToRgb(DWORD val);
395+
396+
// parse color from hexadecimal string
397+
DWORD ParseColor(const wchar_t* str);

Src/StartMenu/StartMenuDLL/SettingsUI.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ const int DEFAULT_TASK_OPACITY10=85; // 85%
3030

3131
///////////////////////////////////////////////////////////////////////////////
3232

33+
CString RgbToBgr(const wchar_t* str)
34+
{
35+
CString retval;
36+
retval.Format(L"%06X", RgbToBgr(ParseColor(str)));
37+
38+
return retval;
39+
}
40+
41+
CString BgrToRgb(const wchar_t* str)
42+
{
43+
return RgbToBgr(str);
44+
}
45+
3346
class CSkinSettingsDlg: public CResizeableDlg<CSkinSettingsDlg>
3447
{
3548
public:
@@ -422,7 +435,7 @@ void CSkinSettingsDlg::UpdateSkinSettings( void )
422435
if (!option.bEnabled || bLocked)
423436
image|=SETTING_STATE_DISABLED;
424437
if (option.bValue && option.type>SKIN_OPTION_BOOL)
425-
Sprintf(text,_countof(text),L"%s: %s",option.label,option.sValue);
438+
Sprintf(text,_countof(text),L"%s: %s",option.label,(option.type==SKIN_OPTION_COLOR)?BgrToRgb(option.sValue):option.sValue);
426439
else
427440
Sprintf(text,_countof(text),L"%s",option.label);
428441

@@ -482,9 +495,7 @@ LRESULT CSkinSettingsDlg::OnCustomDraw( int idCtrl, LPNMHDR pnmh, BOOL& bHandled
482495
if (TreeView_GetItemRect(m_Tree,(HTREEITEM)pDraw->nmcd.dwItemSpec,&rc,TRUE))
483496
{
484497
const wchar_t *str=m_CurrentSkin.Options[pDraw->nmcd.lItemlParam].sValue;
485-
wchar_t *end;
486-
COLORREF color=wcstoul(str,&end,16);
487-
SetDCBrushColor(pDraw->nmcd.hdc,color&0xFFFFFF);
498+
SetDCBrushColor(pDraw->nmcd.hdc,ParseColor(str));
488499
SelectObject(pDraw->nmcd.hdc,GetStockObject(DC_BRUSH));
489500
SelectObject(pDraw->nmcd.hdc,GetStockObject(BLACK_PEN));
490501
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
690701
CString str;
691702
m_EditBox.GetWindowText(str);
692703
str.TrimLeft(); str.TrimRight();
693-
wchar_t *end;
694-
COLORREF val=wcstol(str,&end,16)&0xFFFFFF;
704+
COLORREF val=RgbToBgr(ParseColor(str));
695705
static COLORREF customColors[16];
696706
CHOOSECOLOR choose={sizeof(choose),m_hWnd,NULL,val,customColors};
697707
choose.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
698708
if (ChooseColor(&choose))
699709
{
700710
wchar_t text[100];
701-
Sprintf(text,_countof(text),L"%06X",choose.rgbResult);
711+
Sprintf(text,_countof(text),L"%06X",BgrToRgb(choose.rgbResult));
702712
m_EditBox.SetWindowText(text);
703713
ApplyEditBox();
704714
m_Tree.Invalidate();
@@ -717,7 +727,11 @@ void CSkinSettingsDlg::ApplyEditBox( void )
717727
CString str;
718728
m_EditBox.GetWindowText(str);
719729
str.TrimLeft(); str.TrimRight();
720-
m_CurrentSkin.Options[m_EditItemIndex].sValue=str;
730+
auto& option=m_CurrentSkin.Options[m_EditItemIndex];
731+
if (option.type==SKIN_OPTION_COLOR)
732+
option.sValue=RgbToBgr(str);
733+
else
734+
option.sValue=str;
721735
StoreSkinOptions();
722736
}
723737
}
@@ -730,7 +744,7 @@ void CSkinSettingsDlg::ItemSelected( HTREEITEM hItem, int index, bool bEnabled )
730744
const MenuSkin::Option &option=m_CurrentSkin.Options[m_EditItemIndex];
731745
wchar_t text[256];
732746
if (option.bValue && option.type>SKIN_OPTION_BOOL)
733-
Sprintf(text,_countof(text),L"%s: %s",option.label,option.sValue);
747+
Sprintf(text,_countof(text),L"%s: %s",option.label,(option.type==SKIN_OPTION_COLOR)?BgrToRgb(option.sValue):option.sValue);
734748
else
735749
Sprintf(text,_countof(text),L"%s",option.label);
736750
TVITEM item={TVIF_TEXT,m_EditItem,0,0,text};
@@ -745,7 +759,10 @@ void CSkinSettingsDlg::ItemSelected( HTREEITEM hItem, int index, bool bEnabled )
745759
const MenuSkin::Option &option=m_CurrentSkin.Options[index];
746760
if (option.type>SKIN_OPTION_BOOL)
747761
mode=option.type;
748-
text=option.sValue;
762+
if (option.type==SKIN_OPTION_COLOR)
763+
text=BgrToRgb(option.sValue);
764+
else
765+
text=option.sValue;
749766
}
750767

751768
RECT rc;
@@ -4946,7 +4963,7 @@ void UpdateSettings( void )
49464963
if (GetWinVersion()>WIN_VER_WIN7)
49474964
{
49484965
int color=GetSystemGlassColor8();
4949-
UpdateSetting(L"TaskbarColor",CComVariant(((color&0xFF)<<16)|(color&0xFF00)|((color>>16)&0xFF)),false);
4966+
UpdateSetting(L"TaskbarColor",CComVariant(RgbToBgr(color)),false);
49504967
}
49514968

49524969
if (GetWinVersion()<=WIN_VER_WIN7)

Src/StartMenu/StartMenuDLL/StartMenuDLL.rc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ BEGIN
10821082
IDS_MIN_HEIGHT_TIP "The main menu will be at least as tall as this many search results"
10831083
IDS_GLASS_OVERRIDE "Override glass color"
10841084
IDS_GLASS_OVERRIDE_TIP "Check this to override the system glass color to use in the menu"
1085-
IDS_GLASS_COLOR "Menu glass color"
1085+
IDS_GLASS_COLOR "Menu glass color (RRGGBB)"
10861086
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"
10871087
IDS_GLASS_INTENSITY "Menu glass intensity"
10881088
IDS_GLASS_INTENSITY_TIP "Select the intensity (brightness) for the glass color in the menu (0 - dark, 100 - bright)"
@@ -1144,17 +1144,17 @@ BEGIN
11441144
IDS_STRING7024 "Shadows on glass#The text and the arrows in the second column of the main menu will have a drop shadow"
11451145
IDS_STRING7025 "Opaque"
11461146
IDS_STRING7026 "Main menu color"
1147-
IDS_STRING7027 "Custom color#Select custom color for the main menu"
1147+
IDS_STRING7027 "Custom color (RRGGBB)#Select custom color for the main menu"
11481148
IDS_STRING7028 "Sub-menu color"
1149-
IDS_STRING7029 "Custom color#Select custom color for the sub-menus"
1149+
IDS_STRING7029 "Custom color (RRGGBB)#Select custom color for the sub-menus"
11501150
IDS_STRING7030 "Silver"
11511151
IDS_STRING7031 "Gold"
11521152
IDS_STRING7032 "Steel"
11531153
IDS_STRING7033 "Titanium"
11541154
IDS_STRING7034 "Image for first column#Select custom image for the first column of the main menu"
11551155
IDS_STRING7035 "Image for second column#Select custom image for the second column of the main menu"
1156-
IDS_STRING7036 "Text color for first column#Select custom color for the first column of the main menu text"
1157-
IDS_STRING7037 "Text color for second column#Select custom color for the second column of the main menu text"
1156+
IDS_STRING7036 "Text color for first column (RRGGBB)#Select custom color for the first column of the main menu text"
1157+
IDS_STRING7037 "Text color for second column (RRGGBB)#Select custom color for the second column of the main menu text"
11581158
IDS_STRING7038 "Text size#Select custom size for the main menu text"
11591159
END
11601160

@@ -1249,7 +1249,7 @@ BEGIN
12491249
IDS_TASK_AEROGLASS_TIP "The taskbar will have glass transparency that is compatible with the Aero Glass mod"
12501250
IDS_TASK_OPACITY "Taskbar opacity"
12511251
IDS_TASK_OPACITY_TIP "Set the opacity for the taskbar (0 - transparent, 100 - opaque)"
1252-
IDS_TASK_COLOR "Taskbar color"
1252+
IDS_TASK_COLOR "Taskbar color (RRGGBB)"
12531253
IDS_TASK_COLOR_TIP "Set the color for the taskbar"
12541254
IDS_PCSETTINGS "Settings"
12551255
IDS_PCSETTINGS_TIP "Shows the modern Settings window"
@@ -1288,7 +1288,7 @@ BEGIN
12881288
IDS_TASK_BORDERS "Border sizes"
12891289
IDS_TASK_BORDERS_TIP "Select how many pixel on each side of the texture to exclude from stretching"
12901290
IDS_TASKBAR_SETTINGS "Taskbar"
1291-
IDS_TASK_TEXTCOLOR "Taskbar text color"
1291+
IDS_TASK_TEXTCOLOR "Taskbar text color (RRGGBB)"
12921292
IDS_TASK_TEXTCOLOR_TIP "Select the color for the text on the taskbar"
12931293
IDS_SELECT_LAST "Select the last item in shutdown menu"
12941294
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"

0 commit comments

Comments
 (0)