mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-21 12:54:42 +02:00
Switch to default dark theme as dark mode is enabled
1. Add default dark theme. 2. Switch to default dark theme when dark mode is enabled considering both situations: Style Configurator is or ont launched. Close #9847
This commit is contained in:
parent
db27172ca8
commit
4aa459ef47
1385
PowerEditor/installer/themes/DarkModeDefault.xml
Normal file
1385
PowerEditor/installer/themes/DarkModeDefault.xml
Normal file
File diff suppressed because it is too large
Load Diff
@ -7546,6 +7546,43 @@ void Notepad_plus::refreshDarkMode()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NppParameters& nppParams = NppParameters::getInstance();
|
||||||
|
ThemeSwitcher & themeSwitcher = nppParams.getThemeSwitcher();
|
||||||
|
generic_string themePath;
|
||||||
|
generic_string themeName;
|
||||||
|
const TCHAR darkModeXmlFileName[] = TEXT("DarkModeDefault.xml");
|
||||||
|
if (NppDarkMode::isEnabled())
|
||||||
|
{
|
||||||
|
themePath = themeSwitcher.getThemeDirPath();
|
||||||
|
PathAppend(themePath, darkModeXmlFileName);
|
||||||
|
|
||||||
|
themeName = themeSwitcher.getThemeFromXmlFileName(themePath.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//use _stylerPath;
|
||||||
|
|
||||||
|
pair<generic_string, generic_string> & themeInfo = themeSwitcher.getElementFromIndex(0);
|
||||||
|
themePath = themeInfo.second;
|
||||||
|
themeName = themeSwitcher.getDefaultThemeLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (::PathFileExists(themePath.c_str()))
|
||||||
|
{
|
||||||
|
nppParams.getNppGUI()._themeName = themePath;
|
||||||
|
|
||||||
|
if (_configStyleDlg.isCreated())
|
||||||
|
{
|
||||||
|
_configStyleDlg.selectThemeByName(themeName.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nppParams.reloadStylers(themePath.c_str());
|
||||||
|
::SendMessage(_pPublicInterface->getHSelf(), WM_UPDATESCINTILLAS, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (NppDarkMode::isExperimentalEnabled())
|
if (NppDarkMode::isExperimentalEnabled())
|
||||||
{
|
{
|
||||||
RECT rcClient;
|
RECT rcClient;
|
||||||
|
@ -203,6 +203,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
|
|||||||
{
|
{
|
||||||
themeDir = nppParams.getAppDataNppDir();
|
themeDir = nppParams.getAppDataNppDir();
|
||||||
PathAppend(themeDir, TEXT("themes\\"));
|
PathAppend(themeDir, TEXT("themes\\"));
|
||||||
|
themeSwitcher.setThemeDirPath(themeDir);
|
||||||
_notepad_plus_plus_core.getMatchedFileNames(themeDir.c_str(), patterns, fileNames, false, false);
|
_notepad_plus_plus_core.getMatchedFileNames(themeDir.c_str(), patterns, fileNames, false, false);
|
||||||
for (size_t i = 0, len = fileNames.size() ; i < len ; ++i)
|
for (size_t i = 0, len = fileNames.size() ; i < len ; ++i)
|
||||||
{
|
{
|
||||||
|
@ -895,7 +895,7 @@ NppParameters::~NppParameters()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NppParameters::reloadStylers(TCHAR* stylePath)
|
bool NppParameters::reloadStylers(const TCHAR* stylePath)
|
||||||
{
|
{
|
||||||
delete _pXmlUserStylerDoc;
|
delete _pXmlUserStylerDoc;
|
||||||
|
|
||||||
|
@ -1277,7 +1277,7 @@ public:
|
|||||||
|
|
||||||
void addDefaultThemeFromXml(const generic_string& xmlFullPath)
|
void addDefaultThemeFromXml(const generic_string& xmlFullPath)
|
||||||
{
|
{
|
||||||
_themeList.push_back(std::pair<generic_string, generic_string>(TEXT("Default (stylers.xml)"), xmlFullPath));
|
_themeList.push_back(std::pair<generic_string, generic_string>(_defaultThemeLabel, xmlFullPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
generic_string getThemeFromXmlFileName(const TCHAR *fn) const;
|
generic_string getThemeFromXmlFileName(const TCHAR *fn) const;
|
||||||
@ -1312,8 +1312,15 @@ public:
|
|||||||
return _themeList[index];
|
return _themeList[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setThemeDirPath(generic_string themeDirPath) { _themeDirPath = themeDirPath; }
|
||||||
|
generic_string getThemeDirPath() const { return _themeDirPath; }
|
||||||
|
|
||||||
|
generic_string getDefaultThemeLabel() const { return _defaultThemeLabel; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::pair<generic_string, generic_string>> _themeList;
|
std::vector<std::pair<generic_string, generic_string>> _themeList;
|
||||||
|
generic_string _themeDirPath;
|
||||||
|
const generic_string _defaultThemeLabel = TEXT("Default (stylers.xml)");
|
||||||
generic_string _stylesXmlPath;
|
generic_string _stylesXmlPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1364,7 +1371,7 @@ public:
|
|||||||
|
|
||||||
bool load();
|
bool load();
|
||||||
bool reloadLang();
|
bool reloadLang();
|
||||||
bool reloadStylers(TCHAR *stylePath = nullptr);
|
bool reloadStylers(const TCHAR *stylePath = nullptr);
|
||||||
void destroyInstance();
|
void destroyInstance();
|
||||||
generic_string getSettingsFolder();
|
generic_string getSettingsFolder();
|
||||||
|
|
||||||
|
@ -226,8 +226,8 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
|
|||||||
NppParameters& nppParamInst = NppParameters::getInstance();
|
NppParameters& nppParamInst = NppParameters::getInstance();
|
||||||
if (_restoreInvalid)
|
if (_restoreInvalid)
|
||||||
{
|
{
|
||||||
generic_string str( nppParamInst.getNppGUI()._themeName );
|
generic_string str(nppParamInst.getNppGUI()._themeName);
|
||||||
nppParamInst.reloadStylers( &str[0] );
|
nppParamInst.reloadStylers(str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
LexerStylerArray & lsArray = nppParamInst.getLStylerArray();
|
LexerStylerArray & lsArray = nppParamInst.getLStylerArray();
|
||||||
@ -395,11 +395,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_SWITCH2THEME_COMBO :
|
case IDC_SWITCH2THEME_COMBO :
|
||||||
switchToTheme();
|
applyCurrentSelectedThemeAndUpdateUI();
|
||||||
setVisualFromStyleList();
|
|
||||||
notifyDataModified();
|
|
||||||
_isThemeDirty = false;
|
|
||||||
apply();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -646,13 +642,35 @@ void WordStyleDlg::switchToTheme()
|
|||||||
if ( mb_response == IDYES )
|
if ( mb_response == IDYES )
|
||||||
(NppParameters::getInstance()).writeStyles(_lsArray, _globalStyles);
|
(NppParameters::getInstance()).writeStyles(_lsArray, _globalStyles);
|
||||||
}
|
}
|
||||||
nppParamInst.reloadStylers(&_themeName[0]);
|
nppParamInst.reloadStylers(_themeName.c_str());
|
||||||
|
|
||||||
loadLangListFromNppParam();
|
loadLangListFromNppParam();
|
||||||
_restoreInvalid = true;
|
_restoreInvalid = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WordStyleDlg::applyCurrentSelectedThemeAndUpdateUI()
|
||||||
|
{
|
||||||
|
switchToTheme();
|
||||||
|
setVisualFromStyleList();
|
||||||
|
notifyDataModified();
|
||||||
|
_isThemeDirty = false;
|
||||||
|
apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WordStyleDlg::selectThemeByName(const TCHAR* themeName)
|
||||||
|
{
|
||||||
|
LRESULT iTheme = ::SendMessage(_hSwitch2ThemeCombo, CB_FINDSTRING, 1, reinterpret_cast<LPARAM>(themeName));
|
||||||
|
if (iTheme == CB_ERR)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
::SendMessage(_hSwitch2ThemeCombo, CB_SETCURSEL, iTheme, 0);
|
||||||
|
|
||||||
|
applyCurrentSelectedThemeAndUpdateUI();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void WordStyleDlg::setStyleListFromLexer(int index)
|
void WordStyleDlg::setStyleListFromLexer(int index)
|
||||||
{
|
{
|
||||||
_currentLexerIndex = index;
|
_currentLexerIndex = index;
|
||||||
|
@ -107,6 +107,7 @@ public :
|
|||||||
::SendMessage(_hSwitch2ThemeCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(themeInfo.first.c_str()));
|
::SendMessage(_hSwitch2ThemeCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(themeInfo.first.c_str()));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool selectThemeByName(const TCHAR* themeName);
|
||||||
|
|
||||||
private :
|
private :
|
||||||
ColourPicker *_pFgColour = nullptr;
|
ColourPicker *_pFgColour = nullptr;
|
||||||
@ -225,4 +226,6 @@ private :
|
|||||||
::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_UNDERLINE_CHECK), show?SW_SHOW:SW_HIDE);
|
::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_UNDERLINE_CHECK), show?SW_SHOW:SW_HIDE);
|
||||||
_isShownGOCtrls = show;
|
_isShownGOCtrls = show;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void applyCurrentSelectedThemeAndUpdateUI();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user