Add edge highlight color in customized dark colors of Preferences dialog

Fix #11642, close #11641
This commit is contained in:
ozone10 2022-05-05 16:17:48 +02:00 committed by Don Ho
parent 62e916edec
commit ad8b1791b4
8 changed files with 72 additions and 44 deletions

View File

@ -893,14 +893,14 @@ The comments are here for explanation, it's not necessary to translate them.
<DarkMode title="Dark Mode">
<Item id="7101" name="Enable dark mode"/>
<Item id="7102" name="Black tone"/>
<Item id="7103" name="Red tone"/>
<Item id="7104" name="Green tone"/>
<Item id="7105" name="Blue tone"/>
<Item id="7107" name="Purple tone"/>
<Item id="7108" name="Cyan tone"/>
<Item id="7109" name="Olive tone"/>
<Item id="7115" name="Customized tone"/>
<Item id="7102" name="Black"/>
<Item id="7103" name="Red"/>
<Item id="7104" name="Green"/>
<Item id="7105" name="Blue"/>
<Item id="7107" name="Purple"/>
<Item id="7108" name="Cyan"/>
<Item id="7109" name="Olive"/>
<Item id="7115" name="Customized"/>
<Item id="7116" name="Top"/>
<Item id="7117" name="Menu hot track"/>
<Item id="7118" name="Active"/>
@ -911,7 +911,9 @@ The comments are here for explanation, it's not necessary to translate them.
<Item id="7123" name="Disabled text"/>
<Item id="7124" name="Edge"/>
<Item id="7125" name="Link"/>
<Item id="7126" name="Edge highlight"/>
<Item id="7130" name="Reset"/>
<Item id="7135" name="Tones"/>
</DarkMode>
<MarginsBorderEdge title="Margins/Border/Edge">

View File

@ -545,6 +545,13 @@ namespace NppDarkMode
getTheme().change(clrs);
}
void setHotEdgeColor(COLORREF c)
{
Colors clrs = getTheme()._colors;
clrs.hotEdge = c;
getTheme().change(clrs);
}
Colors getDarkModeDefaultColors()
{
return darkColors;

View File

@ -129,6 +129,7 @@ namespace NppDarkMode
void setDisabledTextColor(COLORREF c);
void setLinkTextColor(COLORREF c);
void setEdgeColor(COLORREF c);
void setHotEdgeColor(COLORREF c);
Colors getDarkModeDefaultColors();
void changeCustomTheme(const Colors& colors);

View File

@ -5582,13 +5582,17 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
if (val)
_nppGUI._darkmode._customColors.disabledText = i;
val = element->Attribute(TEXT("customColorLinkText"), &i);
if (val)
_nppGUI._darkmode._customColors.linkText = i;
val = element->Attribute(TEXT("customColorEdge"), &i);
if (val)
_nppGUI._darkmode._customColors.edge = i;
val = element->Attribute(TEXT("customColorLinkText"), &i);
val = element->Attribute(TEXT("customColorHotEdge"), &i);
if (val)
_nppGUI._darkmode._customColors.linkText = i;
_nppGUI._darkmode._customColors.hotEdge = i;
}
}
}
@ -6683,8 +6687,9 @@ void NppParameters::createXmlTreeFromGUIParams()
GUIConfigElement->SetAttribute(TEXT("customColorText"), _nppGUI._darkmode._customColors.text);
GUIConfigElement->SetAttribute(TEXT("customColorDarkText"), _nppGUI._darkmode._customColors.darkerText);
GUIConfigElement->SetAttribute(TEXT("customColorDisabledText"), _nppGUI._darkmode._customColors.disabledText);
GUIConfigElement->SetAttribute(TEXT("customColorEdge"), _nppGUI._darkmode._customColors.edge);
GUIConfigElement->SetAttribute(TEXT("customColorLinkText"), _nppGUI._darkmode._customColors.linkText);
GUIConfigElement->SetAttribute(TEXT("customColorEdge"), _nppGUI._darkmode._customColors.edge);
GUIConfigElement->SetAttribute(TEXT("customColorHotEdge"), _nppGUI._darkmode._customColors.hotEdge);
}
// <GUIConfig name="ScintillaPrimaryView" lineNumberMargin="show" bookMarkMargin="show" indentGuideLine="show" folderMarkStyle="box" lineWrapMethod="aligned" currentLineHilitingShow="show" scrollBeyondLastLine="no" rightClickKeepsSelection="no" disableAdvancedScrolling="no" wrapSymbolShow="hide" Wrap="no" borderEdge="yes" edge="no" edgeNbColumn="80" zoom="0" zoom2="0" whiteSpaceShow="hide" eolShow="hide" borderWidth="2" smoothFont="no" />

View File

@ -110,26 +110,28 @@ IDD_PREFERENCE_SUB_DARKMODE DIALOGEX 0, 0, 455, 185
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CONTROL "Enable &dark mode",IDC_CHECK_DARKMODE_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,20,150,10
CONTROL "Black tone",IDC_RADIO_DARKMODE_BLACK, "Button",BS_AUTORADIOBUTTON | WS_GROUP,35,40,90,10
CONTROL "Red tone",IDC_RADIO_DARKMODE_RED, "Button",BS_AUTORADIOBUTTON ,35,55,90,10
CONTROL "Green tone",IDC_RADIO_DARKMODE_GREEN, "Button",BS_AUTORADIOBUTTON ,35,70,90,10
CONTROL "Blue tone",IDC_RADIO_DARKMODE_BLUE, "Button",BS_AUTORADIOBUTTON ,35,85,90,10
CONTROL "Purple tone",IDC_RADIO_DARKMODE_PURPLE, "Button",BS_AUTORADIOBUTTON ,35,100,90,10
CONTROL "Cyan tone",IDC_RADIO_DARKMODE_CYAN, "Button",BS_AUTORADIOBUTTON ,35,115,90,10
CONTROL "Olive tone",IDC_RADIO_DARKMODE_OLIVE, "Button",BS_AUTORADIOBUTTON ,35,130,90,10
CONTROL "Customized tone",IDC_RADIO_DARKMODE_CUSTOMIZED, "Button",BS_AUTORADIOBUTTON,135,40,120,10
LTEXT "Top", IDD_CUSTOMIZED_COLOR1_STATIC,165,60,100,8
LTEXT "Menu hot track", IDD_CUSTOMIZED_COLOR2_STATIC,165,80,100,8
LTEXT "Active", IDD_CUSTOMIZED_COLOR3_STATIC,165,100,100,8
LTEXT "Main", IDD_CUSTOMIZED_COLOR4_STATIC,165,120,100,8
LTEXT "Error", IDD_CUSTOMIZED_COLOR5_STATIC,165,140,100,8
LTEXT "Text", IDD_CUSTOMIZED_COLOR6_STATIC,280,60,100,8
LTEXT "Darker text", IDD_CUSTOMIZED_COLOR7_STATIC,280,80,100,8
LTEXT "Disabled text", IDD_CUSTOMIZED_COLOR8_STATIC,280,100,100,8
LTEXT "Edge", IDD_CUSTOMIZED_COLOR9_STATIC,280,120,100,8
LTEXT "Link", IDD_CUSTOMIZED_COLOR10_STATIC,280,140,100,8
PUSHBUTTON "Reset",IDD_CUSTOMIZED_RESET_BUTTON,360,140,45,14
CONTROL "Enable &dark mode",IDC_CHECK_DARKMODE_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,12,150,10
GROUPBOX "Tones",IDC_DARKMODE_TONES_GB_STATIC,10,25,440,154,BS_CENTER
CONTROL "Black",IDC_RADIO_DARKMODE_BLACK,"Button",BS_AUTORADIOBUTTON | WS_GROUP,15,35,80,10
CONTROL "Red",IDC_RADIO_DARKMODE_RED,"Button",BS_AUTORADIOBUTTON ,15,50,80,10
CONTROL "Green",IDC_RADIO_DARKMODE_GREEN,"Button",BS_AUTORADIOBUTTON ,15,65,80,10
CONTROL "Blue",IDC_RADIO_DARKMODE_BLUE,"Button",BS_AUTORADIOBUTTON ,15,80,80,10
CONTROL "Purple",IDC_RADIO_DARKMODE_PURPLE,"Button",BS_AUTORADIOBUTTON ,15,95,80,10
CONTROL "Cyan",IDC_RADIO_DARKMODE_CYAN,"Button",BS_AUTORADIOBUTTON ,15,110,80,10
CONTROL "Olive",IDC_RADIO_DARKMODE_OLIVE,"Button",BS_AUTORADIOBUTTON ,15,125,80,10
CONTROL "Customized",IDC_RADIO_DARKMODE_CUSTOMIZED,"Button",BS_AUTORADIOBUTTON,100,35,120,10
LTEXT "Top",IDD_CUSTOMIZED_COLOR1_STATIC,125,55,95,8
LTEXT "Menu hot track",IDD_CUSTOMIZED_COLOR2_STATIC,125,75,95,8
LTEXT "Active",IDD_CUSTOMIZED_COLOR3_STATIC,125,95,95,8
LTEXT "Main",IDD_CUSTOMIZED_COLOR4_STATIC,125,115,95,8
LTEXT "Error",IDD_CUSTOMIZED_COLOR5_STATIC,125,135,95,8
LTEXT "Text",IDD_CUSTOMIZED_COLOR6_STATIC,240,55,95,8
LTEXT "Darker text",IDD_CUSTOMIZED_COLOR7_STATIC,240,75,95,8
LTEXT "Disabled text",IDD_CUSTOMIZED_COLOR8_STATIC,240,95,95,8
LTEXT "Link",IDD_CUSTOMIZED_COLOR10_STATIC, 240,115,95,8
LTEXT "Edge",IDD_CUSTOMIZED_COLOR9_STATIC,355,55,94,8
LTEXT "Edge highlight",IDD_CUSTOMIZED_COLOR11_STATIC,355,75,94,8
PUSHBUTTON "Reset",IDD_CUSTOMIZED_RESET_BUTTON,252,155,45,14
END
IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE DIALOGEX 0, 0, 455, 185

View File

@ -951,6 +951,7 @@ void DarkModeSubDlg::enableCustomizedColorCtrls(bool doEnable)
::EnableWindow(_pDisabledTextColorPicker->getHSelf(), doEnable);
::EnableWindow(_pEdgeColorPicker->getHSelf(), doEnable);
::EnableWindow(_pLinkColorPicker->getHSelf(), doEnable);
::EnableWindow(_pHotEdgeColorPicker->getHSelf(), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_RESET_BUTTON), doEnable);
@ -966,6 +967,7 @@ void DarkModeSubDlg::enableCustomizedColorCtrls(bool doEnable)
_pDisabledTextColorPicker->setColour(NppDarkMode::getDisabledTextColor());
_pEdgeColorPicker->setColour(NppDarkMode::getEdgeColor());
_pLinkColorPicker->setColour(NppDarkMode::getLinkTextColor());
_pHotEdgeColorPicker->setColour(NppDarkMode::getHotEdgeColor());
redraw();
}
@ -1039,6 +1041,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
_pDisabledTextColorPicker = new ColourPicker;
_pEdgeColorPicker = new ColourPicker;
_pLinkColorPicker = new ColourPicker;
_pHotEdgeColorPicker = new ColourPicker;
_pBackgroundColorPicker->init(_hInst, _hSelf);
_pSofterBackgroundColorPicker->init(_hInst, _hSelf);
@ -1051,6 +1054,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
_pDisabledTextColorPicker->init(_hInst, _hSelf);
_pEdgeColorPicker->init(_hInst, _hSelf);
_pLinkColorPicker->init(_hInst, _hSelf);
_pHotEdgeColorPicker->init(_hInst, _hSelf);
int cpDynamicalWidth = NppParameters::getInstance()._dpiManager.scaleX(25);
int cpDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(25);
@ -1065,6 +1069,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
move2CtrlLeft(IDD_CUSTOMIZED_COLOR8_STATIC, _pDisabledTextColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight);
move2CtrlLeft(IDD_CUSTOMIZED_COLOR9_STATIC, _pEdgeColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight);
move2CtrlLeft(IDD_CUSTOMIZED_COLOR10_STATIC, _pLinkColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight);
move2CtrlLeft(IDD_CUSTOMIZED_COLOR11_STATIC, _pHotEdgeColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight);
_pBackgroundColorPicker->display();
_pSofterBackgroundColorPicker->display();
@ -1076,6 +1081,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
_pDisabledTextColorPicker->display();
_pEdgeColorPicker->display();
_pLinkColorPicker->display();
_pHotEdgeColorPicker->display();
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_BLACK), nppGUI._darkmode._isEnabled);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_RED), nppGUI._darkmode._isEnabled);
@ -1092,13 +1098,9 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
}
case WM_CTLCOLORDLG:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORSTATIC:
{
@ -1114,7 +1116,8 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
dlgCtrlID == IDD_CUSTOMIZED_COLOR7_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR8_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR9_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR10_STATIC);
dlgCtrlID == IDD_CUSTOMIZED_COLOR10_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR11_STATIC);
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (isStaticText)
{
@ -1122,12 +1125,8 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
}
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
return FALSE;
}
case WM_PRINTCLIENT:
{
@ -1150,6 +1149,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
_pDisabledTextColorPicker->destroy();
_pEdgeColorPicker->destroy();
_pLinkColorPicker->destroy();
_pHotEdgeColorPicker->destroy();
delete _pBackgroundColorPicker;
delete _pSofterBackgroundColorPicker;
@ -1161,6 +1161,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
delete _pDisabledTextColorPicker;
delete _pEdgeColorPicker;
delete _pLinkColorPicker;
delete _pHotEdgeColorPicker;
}
case WM_COMMAND:
@ -1346,6 +1347,12 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
NppDarkMode::setLinkTextColor(c);
nppGUI._darkmode._customColors.linkText = c;
}
else if (reinterpret_cast<HWND>(lParam) == _pHotEdgeColorPicker->getHSelf())
{
c = _pHotEdgeColorPicker->getColour();
NppDarkMode::setHotEdgeColor(c);
nppGUI._darkmode._customColors.hotEdge = c;
}
else
{
return FALSE;
@ -1382,6 +1389,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
_pDisabledTextColorPicker->setColour(disabledColor);
_pEdgeColorPicker->setColour(disabledColor);
_pLinkColorPicker->setColour(disabledColor);
_pHotEdgeColorPicker->setColour(disabledColor);
redraw();
}

View File

@ -71,6 +71,7 @@ private:
ColourPicker* _pDisabledTextColorPicker = nullptr;
ColourPicker* _pEdgeColorPicker = nullptr;
ColourPicker* _pLinkColorPicker = nullptr;
ColourPicker* _pHotEdgeColorPicker = nullptr;
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
void enableCustomizedColorCtrls(bool doEnable);

View File

@ -416,5 +416,7 @@
#define IDD_CUSTOMIZED_COLOR8_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 23)
#define IDD_CUSTOMIZED_COLOR9_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 24)
#define IDD_CUSTOMIZED_COLOR10_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 25)
#define IDD_CUSTOMIZED_COLOR11_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 26)
#define IDD_CUSTOMIZED_RESET_BUTTON (IDD_PREFERENCE_SUB_DARKMODE + 30)
#define IDC_DARKMODE_TONES_GB_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 35)
#endif //PREFERENCE_RC_H