From 90016a8dc0c470882c698c396d1b7e04c38cac0b Mon Sep 17 00:00:00 2001 From: Don HO Date: Tue, 13 Apr 2021 03:38:40 +0200 Subject: [PATCH] Enhance Distraction Free mode by hidding another view --- PowerEditor/src/Notepad_plus.cpp | 33 +++++++++++++++++++++++++++----- PowerEditor/src/Notepad_plus.h | 9 ++++++--- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index c09d0aa18..7d4cc6316 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -5466,21 +5466,44 @@ void Notepad_plus::distractionFreeToggle() const ScintillaViewParams& svp = NppParameters::getInstance().getSVP(); int paddingLeft = 0; int paddingRight = 0; + // Enable or disable Distraction Free Mode - if (_beforeSpecialView._isDistractionFree) + if (_beforeSpecialView._isDistractionFree) // disable it { - // disable it + // restore padding paddingLeft = svp._paddingLeft; 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.display(false); } - else + else // enable it { - // enable it - paddingLeft = paddingRight = svp.getDistractionFreePadding(_pEditView->getWidth());; + // set padding + 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); } diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 890547463..751952f17 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -84,18 +84,21 @@ struct VisibleGUIConf final bool _isFullScreen = false; bool _isDistractionFree = false; - //Used by 3 modes + //Used by postit & fullscreen bool _isMenuShown = true; DWORD_PTR _preStyle = (WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN); - //used by postit & distractionFree + //used by postit bool _isTabbarShown = true; bool _isAlwaysOnTop = false; bool _isStatusbarShown = true; - //used by fullscreen & distractionFree + //used by fullscreen WINDOWPLACEMENT _winPlace; + //used by distractionFree + bool _was2ViewModeOn = false; + VisibleGUIConf() { memset(&_winPlace, 0x0, sizeof(_winPlace));