Enhance Distraction Free mode by hidding another view

This commit is contained in:
Don HO 2021-04-13 03:38:40 +02:00
parent 55de911be5
commit 90016a8dc0
2 changed files with 34 additions and 8 deletions

View File

@ -5466,21 +5466,44 @@ void Notepad_plus::distractionFreeToggle()
const ScintillaViewParams& svp = NppParameters::getInstance().getSVP(); const ScintillaViewParams& svp = NppParameters::getInstance().getSVP();
int paddingLeft = 0; int paddingLeft = 0;
int paddingRight = 0; int paddingRight = 0;
// Enable or disable Distraction Free Mode // Enable or disable Distraction Free Mode
if (_beforeSpecialView._isDistractionFree) if (_beforeSpecialView._isDistractionFree) // disable it
{ {
// disable it // restore padding
paddingLeft = svp._paddingLeft; paddingLeft = svp._paddingLeft;
paddingRight = svp._paddingRight; paddingRight = svp._paddingRight;
// restore another view if 2 views mode was on
if (_beforeSpecialView._was2ViewModeOn)
{
showView(otherView());
_beforeSpecialView._was2ViewModeOn = false;
}
// hide restore button
_restoreButton.setButtonStatus(0); _restoreButton.setButtonStatus(0);
_restoreButton.display(false); _restoreButton.display(false);
} }
else else // enable it
{ {
// enable it // set padding
paddingLeft = paddingRight = svp.getDistractionFreePadding(_pEditView->getWidth());; paddingLeft = paddingRight = svp.getDistractionFreePadding(_pEditView->getWidth());
// check if 2 views mode is on
ScintillaEditView & nonFocusedView = (otherView() == MAIN_VIEW) ? _mainEditView : _subEditView;
if (nonFocusedView.isVisible())
{
hideView(otherView());
_beforeSpecialView._was2ViewModeOn = true;
}
else
{
_beforeSpecialView._was2ViewModeOn = false;
}
// set state of restore button (it's already shown by fullScreen & postIt toggling)
_restoreButton.setButtonStatus(buttonStatus_distractionFree); _restoreButton.setButtonStatus(buttonStatus_distractionFree);
} }

View File

@ -84,18 +84,21 @@ struct VisibleGUIConf final
bool _isFullScreen = false; bool _isFullScreen = false;
bool _isDistractionFree = false; bool _isDistractionFree = false;
//Used by 3 modes //Used by postit & fullscreen
bool _isMenuShown = true; bool _isMenuShown = true;
DWORD_PTR _preStyle = (WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN); DWORD_PTR _preStyle = (WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN);
//used by postit & distractionFree //used by postit
bool _isTabbarShown = true; bool _isTabbarShown = true;
bool _isAlwaysOnTop = false; bool _isAlwaysOnTop = false;
bool _isStatusbarShown = true; bool _isStatusbarShown = true;
//used by fullscreen & distractionFree //used by fullscreen
WINDOWPLACEMENT _winPlace; WINDOWPLACEMENT _winPlace;
//used by distractionFree
bool _was2ViewModeOn = false;
VisibleGUIConf() VisibleGUIConf()
{ {
memset(&_winPlace, 0x0, sizeof(_winPlace)); memset(&_winPlace, 0x0, sizeof(_winPlace));