From 92038c1653485a9ed58fe0ba7a2e30faa1d08749 Mon Sep 17 00:00:00 2001 From: Don HO Date: Wed, 7 Apr 2021 18:02:30 +0200 Subject: [PATCH] Make struct VisibleGUIConf conform to coding standard --- PowerEditor/src/Notepad_plus.cpp | 70 ++++++++++++++++---------------- PowerEditor/src/Notepad_plus.h | 21 +++++----- PowerEditor/src/NppBigSwitch.cpp | 4 +- 3 files changed, 47 insertions(+), 48 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index bb5c23811..12455a8c0 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -5191,7 +5191,7 @@ bool Notepad_plus::goToNextIndicator(int indicID2Search, bool isWrap) const void Notepad_plus::fullScreenToggle() { - if (!_beforeSpecialView.isFullScreen) //toggle fullscreen on + if (!_beforeSpecialView._isFullScreen) //toggle fullscreen on { _beforeSpecialView._winPlace.length = sizeof(_beforeSpecialView._winPlace); ::GetWindowPlacement(_pPublicInterface->getHSelf(), &_beforeSpecialView._winPlace); @@ -5220,15 +5220,15 @@ void Notepad_plus::fullScreenToggle() //Setup GUI int bs = buttonStatus_fullscreen; - if (_beforeSpecialView.isPostIt) + if (_beforeSpecialView._isPostIt) { bs |= buttonStatus_postit; } else { //only change the GUI if not already done by postit - _beforeSpecialView.isMenuShown = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_ISMENUHIDDEN, 0, 0) != TRUE; - if (_beforeSpecialView.isMenuShown) + _beforeSpecialView._isMenuShown = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_ISMENUHIDDEN, 0, 0) != TRUE; + if (_beforeSpecialView._isMenuShown) ::SendMessage(_pPublicInterface->getHSelf(), NPPM_HIDEMENU, 0, TRUE); //Hide rebar @@ -5241,13 +5241,13 @@ void Notepad_plus::fullScreenToggle() ::ShowWindow(_pPublicInterface->getHSelf(), SW_HIDE); //Set popup style for fullscreen window and store the old style - if (!_beforeSpecialView.isPostIt) + if (!_beforeSpecialView._isPostIt) { - _beforeSpecialView.preStyle = ::SetWindowLongPtr(_pPublicInterface->getHSelf(), GWL_STYLE, WS_POPUP); - if (!_beforeSpecialView.preStyle) + _beforeSpecialView._preStyle = ::SetWindowLongPtr(_pPublicInterface->getHSelf(), GWL_STYLE, WS_POPUP); + if (!_beforeSpecialView._preStyle) { //something went wrong, use default settings - _beforeSpecialView.preStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; + _beforeSpecialView._preStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; } } @@ -5281,10 +5281,10 @@ void Notepad_plus::fullScreenToggle() _restoreButton.display(false); //Setup GUI - if (!_beforeSpecialView.isPostIt) + if (!_beforeSpecialView._isPostIt) { //only change the GUI if postit isnt active - if (_beforeSpecialView.isMenuShown) + if (_beforeSpecialView._isMenuShown) ::SendMessage(_pPublicInterface->getHSelf(), NPPM_HIDEMENU, 0, FALSE); //Show rebar @@ -5293,9 +5293,9 @@ void Notepad_plus::fullScreenToggle() } //Set old style if not fullscreen - if (!_beforeSpecialView.isPostIt) + if (!_beforeSpecialView._isPostIt) { - ::SetWindowLongPtr( _pPublicInterface->getHSelf(), GWL_STYLE, _beforeSpecialView.preStyle); + ::SetWindowLongPtr( _pPublicInterface->getHSelf(), GWL_STYLE, _beforeSpecialView._preStyle); //Redraw the window and refresh windowmanager cache, dont do anything else, sizing is done later on ::SetWindowPos(_pPublicInterface->getHSelf(), HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_DRAWFRAME|SWP_FRAMECHANGED); ::ShowWindow(_pPublicInterface->getHSelf(), SW_SHOW); @@ -5318,9 +5318,9 @@ void Notepad_plus::fullScreenToggle() } } //::SetForegroundWindow(_pPublicInterface->getHSelf()); - _beforeSpecialView.isFullScreen = !_beforeSpecialView.isFullScreen; + _beforeSpecialView._isFullScreen = !_beforeSpecialView._isFullScreen; ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); - if (_beforeSpecialView.isPostIt) + if (_beforeSpecialView._isPostIt) { // show restore button on the right position RECT rect; @@ -5339,32 +5339,32 @@ void Notepad_plus::fullScreenToggle() void Notepad_plus::postItToggle() { NppParameters& nppParam = NppParameters::getInstance(); - if (!_beforeSpecialView.isPostIt) // PostIt disabled, enable it + if (!_beforeSpecialView._isPostIt) // PostIt disabled, enable it { NppGUI & nppGUI = const_cast(nppParam.getNppGUI()); // get current status before switch to postIt //check these always { - _beforeSpecialView.isAlwaysOnTop = ::GetMenuState(_mainMenuHandle, IDM_VIEW_ALWAYSONTOP, MF_BYCOMMAND) == MF_CHECKED; - _beforeSpecialView.isTabbarShown = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_ISTABBARHIDDEN, 0, 0) != TRUE; - _beforeSpecialView.isStatusbarShown = nppGUI._statusBarShow; + _beforeSpecialView._isAlwaysOnTop = ::GetMenuState(_mainMenuHandle, IDM_VIEW_ALWAYSONTOP, MF_BYCOMMAND) == MF_CHECKED; + _beforeSpecialView._isTabbarShown = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_ISTABBARHIDDEN, 0, 0) != TRUE; + _beforeSpecialView._isStatusbarShown = nppGUI._statusBarShow; if (nppGUI._statusBarShow) ::SendMessage(_pPublicInterface->getHSelf(), NPPM_HIDESTATUSBAR, 0, TRUE); - if (_beforeSpecialView.isTabbarShown) + if (_beforeSpecialView._isTabbarShown) ::SendMessage(_pPublicInterface->getHSelf(), NPPM_HIDETABBAR, 0, TRUE); - if (!_beforeSpecialView.isAlwaysOnTop) + if (!_beforeSpecialView._isAlwaysOnTop) ::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0); } //Only check these if not fullscreen int bs = buttonStatus_postit; - if (_beforeSpecialView.isFullScreen) + if (_beforeSpecialView._isFullScreen) { bs |= buttonStatus_fullscreen; } else { - _beforeSpecialView.isMenuShown = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_ISMENUHIDDEN, 0, 0) != TRUE; - if (_beforeSpecialView.isMenuShown) + _beforeSpecialView._isMenuShown = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_ISMENUHIDDEN, 0, 0) != TRUE; + if (_beforeSpecialView._isMenuShown) ::SendMessage(_pPublicInterface->getHSelf(), NPPM_HIDEMENU, 0, TRUE); //Hide rebar @@ -5376,15 +5376,15 @@ void Notepad_plus::postItToggle() // PostIt! //Set popup style for fullscreen window and store the old style - if (!_beforeSpecialView.isFullScreen) + if (!_beforeSpecialView._isFullScreen) { //Hide window so windows can properly update it ::ShowWindow(_pPublicInterface->getHSelf(), SW_HIDE); - _beforeSpecialView.preStyle = ::SetWindowLongPtr( _pPublicInterface->getHSelf(), GWL_STYLE, WS_POPUP ); - if (!_beforeSpecialView.preStyle) + _beforeSpecialView._preStyle = ::SetWindowLongPtr( _pPublicInterface->getHSelf(), GWL_STYLE, WS_POPUP ); + if (!_beforeSpecialView._preStyle) { //something went wrong, use default settings - _beforeSpecialView.preStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; + _beforeSpecialView._preStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; } //Redraw the window and refresh windowmanager cache, dont do anything else, sizing is done later on ::SetWindowPos(_pPublicInterface->getHSelf(), HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_DRAWFRAME|SWP_FRAMECHANGED); @@ -5413,10 +5413,10 @@ void Notepad_plus::postItToggle() _restoreButton.display(false); //Setup GUI - if (!_beforeSpecialView.isFullScreen) + if (!_beforeSpecialView._isFullScreen) { //only change the these parts of GUI if not already done by fullscreen - if (_beforeSpecialView.isMenuShown) + if (_beforeSpecialView._isMenuShown) ::SendMessage(_pPublicInterface->getHSelf(), NPPM_HIDEMENU, 0, FALSE); //Show rebar @@ -5424,19 +5424,19 @@ void Notepad_plus::postItToggle() _rebarBottom.display(true); } //Do this GUI config always - if (_beforeSpecialView.isStatusbarShown) + if (_beforeSpecialView._isStatusbarShown) ::SendMessage(_pPublicInterface->getHSelf(), NPPM_HIDESTATUSBAR, 0, FALSE); - if (_beforeSpecialView.isTabbarShown) + if (_beforeSpecialView._isTabbarShown) ::SendMessage(_pPublicInterface->getHSelf(), NPPM_HIDETABBAR, 0, FALSE); - if (!_beforeSpecialView.isAlwaysOnTop) + if (!_beforeSpecialView._isAlwaysOnTop) ::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, IDM_VIEW_ALWAYSONTOP, 0); //restore window style if not fullscreen - if (!_beforeSpecialView.isFullScreen) + if (!_beforeSpecialView._isFullScreen) { //dwStyle |= (WS_CAPTION | WS_SIZEBOX); ::ShowWindow(_pPublicInterface->getHSelf(), SW_HIDE); - ::SetWindowLongPtr(_pPublicInterface->getHSelf(), GWL_STYLE, _beforeSpecialView.preStyle); + ::SetWindowLongPtr(_pPublicInterface->getHSelf(), GWL_STYLE, _beforeSpecialView._preStyle); //Redraw the window and refresh windowmanager cache, dont do anything else, sizing is done later on ::SetWindowPos(_pPublicInterface->getHSelf(), HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_DRAWFRAME|SWP_FRAMECHANGED); @@ -5444,7 +5444,7 @@ void Notepad_plus::postItToggle() } } - _beforeSpecialView.isPostIt = !_beforeSpecialView.isPostIt; + _beforeSpecialView._isPostIt = !_beforeSpecialView._isPostIt; ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); } diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 00ce8fd94..03069e324 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -80,20 +80,19 @@ struct TaskListInfo; struct VisibleGUIConf final { - bool isPostIt = false; - bool isFullScreen = false; + bool _isPostIt = false; + bool _isFullScreen = false; - //Used by both views - bool isMenuShown = true; - //bool isToolbarShown; //toolbar forcefully hidden by hiding rebar - DWORD_PTR preStyle = (WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN); + //Used by 2 modes + bool _isMenuShown = true; + DWORD_PTR _preStyle = (WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN); - //used by postit only - bool isTabbarShown = true; - bool isAlwaysOnTop = false; - bool isStatusbarShown = true; + //used by postit & distractionFree + bool _isTabbarShown = true; + bool _isAlwaysOnTop = false; + bool _isStatusbarShown = true; - //used by fullscreen only + //used by fullscreen & distractionFree WINDOWPLACEMENT _winPlace; VisibleGUIConf() diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index bfa4dbc79..57a51935c 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1831,9 +1831,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return FALSE; } - if (_beforeSpecialView.isFullScreen) //closing, return to windowed mode + if (_beforeSpecialView._isFullScreen) //closing, return to windowed mode fullScreenToggle(); - if (_beforeSpecialView.isPostIt) //closing, return to windowed mode + if (_beforeSpecialView._isPostIt) //closing, return to windowed mode postItToggle(); if (_configStyleDlg.isCreated() && ::IsWindowVisible(_configStyleDlg.getHSelf()))