diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 61a1954be..805ee4775 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -242,7 +242,6 @@ LRESULT Notepad_plus::init(HWND hwnd) const ScintillaViewParams & svp = nppParam.getSVP(); int tabBarStatus = nppGUI._tabStatus; - TabBarPlus::setReduced((tabBarStatus & TAB_REDUCE) != 0, &_mainDocTab); const int tabIconSet = NppDarkMode::getTabIconSet(NppDarkMode::isEnabled()); unsigned char indexDocTabIcon = 0; @@ -392,32 +391,21 @@ LRESULT Notepad_plus::init(HWND hwnd) _mainEditView.execute(SCI_STYLESETCHECKMONOSPACED, STYLE_DEFAULT, true); _subEditView.execute(SCI_STYLESETCHECKMONOSPACED, STYLE_DEFAULT, true); - TabBarPlus::doDragNDrop(true); - - const auto& hf = _mainDocTab.getFont(TabBarPlus::isReduced()); + const auto& hf = _mainDocTab.getFont(nppGUI._tabStatus & TAB_REDUCE); if (hf) { ::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, reinterpret_cast(hf), MAKELPARAM(TRUE, 0)); ::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, reinterpret_cast(hf), MAKELPARAM(TRUE, 0)); } - int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(TabBarPlus::isReduced() ? g_TabHeight : g_TabHeightLarge); - int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? g_TabWidthButton : g_TabWidth); + int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(nppGUI._tabStatus & TAB_REDUCE ? g_TabHeight : g_TabHeightLarge); + int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(nppGUI._tabStatus & TAB_PINBUTTON ? g_TabWidthButton : g_TabWidth); TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); _mainDocTab.display(); - - - TabBarPlus::doDragNDrop((tabBarStatus & TAB_DRAGNDROP) != 0); - TabBarPlus::setDrawTopBar((tabBarStatus & TAB_DRAWTOPBAR) != 0, &_mainDocTab); - TabBarPlus::setDrawInactiveTab((tabBarStatus & TAB_DRAWINACTIVETAB) != 0, &_mainDocTab); - TabBarPlus::setDrawTabCloseButton((tabBarStatus & TAB_CLOSEBUTTON) != 0, &_mainDocTab); - TabBarPlus::setDrawTabPinButton((tabBarStatus & TAB_PINBUTTON) != 0, &_mainDocTab); - TabBarPlus::setDbClk2Close((tabBarStatus & TAB_DBCLK2CLOSE) != 0); - TabBarPlus::setVertical((tabBarStatus & TAB_VERTICAL) != 0); - drawTabbarColoursFromStylerArray(); + TabBarPlus::triggerOwnerDrawTabbar(&(_mainDocTab.dpiManager())); // // Initialize the default foreground & background color @@ -907,20 +895,6 @@ bool Notepad_plus::saveGUIParams() nppGUI._toolbarShow = _rebarTop.getIDVisible(REBAR_BAR_TOOLBAR); nppGUI._toolBarStatus = _toolBar.getState(); - nppGUI._tabStatus = (TabBarPlus::doDragNDropOrNot() ? TAB_DRAWTOPBAR : 0) | \ - (TabBarPlus::drawTopBar() ? TAB_DRAGNDROP : 0) | \ - (TabBarPlus::drawInactiveTab() ? TAB_DRAWINACTIVETAB : 0) | \ - (TabBarPlus::isReduced() ? TAB_REDUCE : 0) | \ - (TabBarPlus::drawTabCloseButton() ? TAB_CLOSEBUTTON : 0) | \ - (TabBarPlus::drawTabPinButton() ? TAB_PINBUTTON : 0) | \ - (TabBarPlus::isDbClk2Close() ? TAB_DBCLK2CLOSE : 0) | \ - (TabBarPlus::isVertical() ? TAB_VERTICAL : 0) | \ - (TabBarPlus::isMultiLine() ? TAB_MULTILINE : 0) |\ - (nppGUI._tabStatus & TAB_INACTIVETABSHOWBUTTON) | \ - (nppGUI._tabStatus & TAB_HIDE) | \ - (nppGUI._tabStatus & TAB_QUITONEMPTY) | \ - (nppGUI._tabStatus & TAB_ALTICONS); - nppGUI._splitterPos = _subSplitter.isVertical()?POS_VERTICAL:POS_HORIZOTAL; UserDefineDialog *udd = _pEditView->getUserDefineDlg(); bool b = udd->isDocked(); @@ -6452,21 +6426,21 @@ void Notepad_plus::drawTabbarColoursFromStylerArray() { Style *stActText = getStyleFromName(TABBAR_ACTIVETEXT); if (stActText && static_cast(stActText->_fgColor) != -1) - TabBarPlus::setColour(stActText->_fgColor, TabBarPlus::activeText, &_mainDocTab); + TabBarPlus::setColour(stActText->_fgColor, TabBarPlus::activeText, &(_mainDocTab.dpiManager())); Style *stActfocusTop = getStyleFromName(TABBAR_ACTIVEFOCUSEDINDCATOR); if (stActfocusTop && static_cast(stActfocusTop->_fgColor) != -1) - TabBarPlus::setColour(stActfocusTop->_fgColor, TabBarPlus::activeFocusedTop, &_mainDocTab); + TabBarPlus::setColour(stActfocusTop->_fgColor, TabBarPlus::activeFocusedTop, &(_mainDocTab.dpiManager())); Style *stActunfocusTop = getStyleFromName(TABBAR_ACTIVEUNFOCUSEDINDCATOR); if (stActunfocusTop && static_cast(stActunfocusTop->_fgColor) != -1) - TabBarPlus::setColour(stActunfocusTop->_fgColor, TabBarPlus::activeUnfocusedTop, &_mainDocTab); + TabBarPlus::setColour(stActunfocusTop->_fgColor, TabBarPlus::activeUnfocusedTop, &(_mainDocTab.dpiManager())); Style *stInact = getStyleFromName(TABBAR_INACTIVETEXT); if (stInact && static_cast(stInact->_fgColor) != -1) - TabBarPlus::setColour(stInact->_fgColor, TabBarPlus::inactiveText, &_mainDocTab); + TabBarPlus::setColour(stInact->_fgColor, TabBarPlus::inactiveText, &(_mainDocTab.dpiManager())); if (stInact && static_cast(stInact->_bgColor) != -1) - TabBarPlus::setColour(stInact->_bgColor, TabBarPlus::inactiveBg, &_mainDocTab); + TabBarPlus::setColour(stInact->_bgColor, TabBarPlus::inactiveBg, &(_mainDocTab.dpiManager())); } void Notepad_plus::drawAutocompleteColoursFromTheme(COLORREF fgColor, COLORREF bgColor) diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 7ba622135..6c41af0ac 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -896,7 +896,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_SAVEBACKUP: { - if (NppParameters::getInstance().getNppGUI().isSnapshotMode()) + if (nppParam.getNppGUI().isSnapshotMode()) { MainFileManager.backupCurrentBuffer(); } @@ -1209,7 +1209,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } - if (NppParameters::getInstance().getNppGUI()._styleMRU) + if (nppParam.getNppGUI()._styleMRU) { tli->_currentIndex = 0; std::sort(tli->_tlfsLst.begin(),tli->_tlfsLst.end(),SortTaskListPred(_mainDocTab,_subDocTab)); @@ -1888,7 +1888,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_ISTABBARREDUCED: { - return TabBarPlus::isReduced() ? TRUE : FALSE; + return nppParam.getNppGUI()._tabStatus & TAB_REDUCE ? TRUE : FALSE; } // ADD: success->hwnd; failure->NULL @@ -2299,11 +2299,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa drawDocumentMapColoursFromStylerArray(); // Update default fg/bg colors in Parameters for both internal/plugins docking dialog - const Style* pStyle = NppParameters::getInstance().getGlobalStylers().findByID(STYLE_DEFAULT); + const Style* pStyle = nppParam.getGlobalStylers().findByID(STYLE_DEFAULT); if (pStyle) { - NppParameters::getInstance().setCurrentDefaultFgColor(pStyle->_fgColor); - NppParameters::getInstance().setCurrentDefaultBgColor(pStyle->_bgColor); + nppParam.setCurrentDefaultFgColor(pStyle->_fgColor); + nppParam.setCurrentDefaultBgColor(pStyle->_bgColor); drawAutocompleteColoursFromTheme(pStyle->_fgColor, pStyle->_bgColor); } @@ -3005,7 +3005,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_GETWINDOWSVERSION: { - return (NppParameters::getInstance()).getWinVersion(); + return nppParam.getWinVersion(); } case NPPM_MAKECURRENTBUFFERDIRTY: @@ -3151,24 +3151,25 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_HIDETABBAR: { bool hide = (lParam != 0); - bool oldVal = DocTabView::getHideTabBarStatus(); + + NppGUI& nppGUI = nppParam.getNppGUI(); + bool oldVal = (nppGUI._tabStatus & TAB_HIDE); if (hide == oldVal) return oldVal; - DocTabView::setHideTabBarStatus(hide); - ::SendMessage(hwnd, WM_SIZE, 0, 0); - - NppGUI & nppGUI = (NppParameters::getInstance()).getNppGUI(); if (hide) nppGUI._tabStatus |= TAB_HIDE; else nppGUI._tabStatus &= ~TAB_HIDE; + ::SendMessage(hwnd, WM_SIZE, 0, 0); + return oldVal; } case NPPM_ISTABBARHIDDEN: { - return _mainDocTab.getHideTabBarStatus(); + NppGUI& nppGUI = nppParam.getNppGUI(); + return nppGUI._tabStatus & TAB_HIDE; } case NPPM_HIDETOOLBAR: @@ -3297,7 +3298,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa _mainEditView.setNpcAndCcUniEOL(); _subEditView.setNpcAndCcUniEOL(); - const auto& svp = NppParameters::getInstance().getSVP(); + const auto& svp = nppParam.getSVP(); if (svp._npcShow) { _findReplaceDlg.updateFinderScintillaForNpc(true); @@ -3506,8 +3507,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR: { return (message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR - ?(NppParameters::getInstance()).getCurrentDefaultFgColor() - :(NppParameters::getInstance()).getCurrentDefaultBgColor()); + ? nppParam.getCurrentDefaultFgColor() + : nppParam.getCurrentDefaultBgColor()); } case NPPM_SHOWDOCLIST: @@ -3573,7 +3574,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa ScintillaViewParams &svp = const_cast(nppParam.getSVP()); COLORREF multiEdgeColor = liteGrey; - const Style * pStyle = NppParameters::getInstance().getMiscStylerArray().findByName(L"Edge colour"); + const Style * pStyle = nppParam.getMiscStylerArray().findByName(L"Edge colour"); if (pStyle) { multiEdgeColor = pStyle->_fgColor; @@ -3930,52 +3931,38 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa } break; - case NPPM_INTERNAL_LOCKTABBAR: - { - bool isDrag = TabBarPlus::doDragNDropOrNot(); - TabBarPlus::doDragNDrop(!isDrag); - break; - } - - case NPPM_INTERNAL_DRAWINACIVETAB: - { - TabBarPlus::setDrawInactiveTab(!TabBarPlus::drawInactiveTab(), &_mainDocTab); - break; - } case NPPM_INTERNAL_DRAWTABTOPBAR: { - TabBarPlus::setDrawTopBar(!TabBarPlus::drawTopBar(), &_mainDocTab); - break; - } - - case NPPM_INTERNAL_TABDBCLK2CLOSE: - { - TabBarPlus::setDbClk2Close(!TabBarPlus::isDbClk2Close()); + TabBarPlus::triggerOwnerDrawTabbar(&(_mainDocTab.dpiManager())); break; } case NPPM_INTERNAL_VERTICALTABBAR: { - TabBarPlus::setVertical(!TabBarPlus::isVertical()); + TabBarPlus::doVertical(); ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); break; } case NPPM_INTERNAL_MULTILINETABBAR: { - TabBarPlus::setMultiLine(!TabBarPlus::isMultiLine()); + TabBarPlus::doMultiLine(); ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); break; } case NPPM_INTERNAL_REDUCETABBAR: { - TabBarPlus::setReduced(!TabBarPlus::isReduced(), &_mainDocTab); - bool isReduceed = TabBarPlus::isReduced(); + TabBarPlus::triggerOwnerDrawTabbar(&(_mainDocTab.dpiManager())); + bool isReduceed = nppParam.getNppGUI()._tabStatus & TAB_REDUCE; //Resize the tab height - int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale((TabBarPlus::drawTabCloseButton() || TabBarPlus::drawTabPinButton()) ? g_TabWidthButton : g_TabWidth); + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool drawTabCloseButton = nppGUI._tabStatus & TAB_CLOSEBUTTON; + bool drawTabPinButton = nppGUI._tabStatus & TAB_PINBUTTON; + + int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale((drawTabCloseButton || drawTabPinButton) ? g_TabWidthButton : g_TabWidth); int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(isReduceed ? g_TabHeight : g_TabHeightLarge); TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); @@ -3998,10 +3985,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_DRAWTABBARCLOSEBUTTON: { - TabBarPlus::setDrawTabCloseButton(!TabBarPlus::drawTabCloseButton(), &_mainDocTab); + TabBarPlus::triggerOwnerDrawTabbar(&(_mainDocTab.dpiManager())); - bool drawTabPinButton = TabBarPlus::drawTabPinButton(); - bool drawTabCloseButton = TabBarPlus::drawTabCloseButton(); + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool drawTabCloseButton = nppGUI._tabStatus & TAB_CLOSEBUTTON; + bool drawTabPinButton = nppGUI._tabStatus & TAB_PINBUTTON; if (drawTabCloseButton && drawTabPinButton) { @@ -4033,8 +4021,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa } // This part is just for updating (redraw) the tabs - int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(TabBarPlus::isReduced() ? g_TabHeight : g_TabHeightLarge); - int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? g_TabWidthButton : g_TabWidth); + int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(nppParam.getNppGUI()._tabStatus & TAB_REDUCE ? g_TabHeight : g_TabHeightLarge); + int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(drawTabCloseButton ? g_TabWidthButton : g_TabWidth); TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); @@ -4047,10 +4035,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_DRAWTABBARPINBUTTON: { - TabBarPlus::setDrawTabPinButton(!TabBarPlus::drawTabPinButton(), &_mainDocTab); + TabBarPlus::triggerOwnerDrawTabbar(&(_mainDocTab.dpiManager())); - bool drawTabPinButton = TabBarPlus::drawTabPinButton(); - bool drawTabCloseButton = TabBarPlus::drawTabCloseButton(); + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool drawTabCloseButton = nppGUI._tabStatus & TAB_CLOSEBUTTON; + bool drawTabPinButton = nppGUI._tabStatus & TAB_PINBUTTON; if (!drawTabPinButton) { @@ -4087,8 +4076,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa } // This part is just for updating (redraw) the tabs - int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(TabBarPlus::isReduced() ? g_TabHeight : g_TabHeightLarge); - int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(TabBarPlus::drawTabPinButton() ? g_TabWidthButton : g_TabWidth); + int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(nppParam.getNppGUI()._tabStatus & TAB_REDUCE ? g_TabHeight : g_TabHeightLarge); + int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(drawTabPinButton ? g_TabWidthButton : g_TabWidth); TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); @@ -4140,7 +4129,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa // Go through all open files, and if there are any SQL files open, make sure the sql.backslash.escapes propery // is updated for each of the SQL buffers' Scintilla wrapper. // This message will only be called on the rare circumstance when the backslash-is-escape-for-sql preference is toggled, so this loop won't be run very often. - const bool kbBackSlash = NppParameters::getInstance().getNppGUI()._backSlashIsEscapeCharacterForSql; + const bool kbBackSlash = nppParam.getNppGUI()._backSlashIsEscapeCharacterForSql; Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER); Buffer* oldBuf = _invisibleEditView.getCurrentBuffer(); diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 2c385651c..d190e1903 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -1102,8 +1102,9 @@ BOOL Notepad_plus::notify(SCNotification *notification) _tabPopupMenu.enableItem(IDM_FILE_SAVEAS, !isInaccessible); _tabPopupMenu.enableItem(IDM_FILE_RENAME, !isInaccessible); - - bool isTabPinEnabled = TabBarPlus::drawTabPinButton(); + + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool isTabPinEnabled = nppGUI._tabStatus & TAB_PINBUTTON; wstring newName; if (isTabPinEnabled) { diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 64ce26772..0e0c87be9 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -4880,13 +4880,15 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) { bool isFailed = false; int oldValue = _nppGUI._tabStatus; + _nppGUI._tabStatus = 0; + const wchar_t* val = element->Attribute(L"dragAndDrop"); if (val) { if (!lstrcmp(val, L"yes")) - _nppGUI._tabStatus = TAB_DRAGNDROP; + _nppGUI._tabStatus |= TAB_DRAGNDROP; else if (!lstrcmp(val, L"no")) - _nppGUI._tabStatus = 0; + _nppGUI._tabStatus |= 0; else isFailed = true; } @@ -7300,10 +7302,10 @@ void NppParameters::createXmlTreeFromGUIParams() TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(L"GUIConfig")))->ToElement(); GUIConfigElement->SetAttribute(L"name", L"TabBar"); - const wchar_t *pStr = (_nppGUI._tabStatus & TAB_DRAWTOPBAR) ? L"yes" : L"no"; + const wchar_t *pStr = (_nppGUI._tabStatus & TAB_DRAGNDROP) ? L"yes" : L"no"; GUIConfigElement->SetAttribute(L"dragAndDrop", pStr); - pStr = (_nppGUI._tabStatus & TAB_DRAGNDROP) ? L"yes" : L"no"; + pStr = (_nppGUI._tabStatus & TAB_DRAWTOPBAR) ? L"yes" : L"no"; GUIConfigElement->SetAttribute(L"drawTopBar", pStr); pStr = (_nppGUI._tabStatus & TAB_DRAWINACTIVETAB) ? L"yes" : L"no"; diff --git a/PowerEditor/src/ScintillaComponent/DocTabView.cpp b/PowerEditor/src/ScintillaComponent/DocTabView.cpp index 1d615dc80..5f5a759b1 100644 --- a/PowerEditor/src/ScintillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScintillaComponent/DocTabView.cpp @@ -23,9 +23,6 @@ #define _WIN32_IE 0x0600 #endif //_WIN32_IE -bool DocTabView::_hideTabBarStatus = false; - - int docTabIconIDs[] = { IDI_SAVED_ICON, IDI_UNSAVED_ICON, IDI_READONLY_ICON, IDI_MONITORING_ICON }; int docTabIconIDs_darkMode[] = { IDI_SAVED_DM_ICON, IDI_UNSAVED_DM_ICON, IDI_READONLY_DM_ICON, IDI_MONITORING_DM_ICON }; int docTabIconIDs_alt[] = { IDI_SAVED_ALT_ICON, IDI_UNSAVED_ALT_ICON, IDI_READONLY_ALT_ICON, IDI_MONITORING_ICON }; @@ -249,8 +246,10 @@ void DocTabView::setBuffer(size_t index, BufferID id) void DocTabView::reSizeTo(RECT & rc) { - int borderWidth = ((NppParameters::getInstance()).getSVP())._borderWidth; - if (_hideTabBarStatus) + NppParameters& nppParam = NppParameters::getInstance(); + int borderWidth = nppParam.getSVP()._borderWidth; + NppGUI& nppGUI = nppParam.getNppGUI(); + if (nppGUI._tabStatus & TAB_HIDE) { RECT rcTmp = rc; TabBar::reSizeTo(rcTmp); diff --git a/PowerEditor/src/ScintillaComponent/DocTabView.h b/PowerEditor/src/ScintillaComponent/DocTabView.h index c8c59d2a4..9a46d8bb5 100644 --- a/PowerEditor/src/ScintillaComponent/DocTabView.h +++ b/PowerEditor/src/ScintillaComponent/DocTabView.h @@ -60,16 +60,6 @@ public : void setBuffer(size_t index, BufferID id); - static bool setHideTabBarStatus(bool hideOrNot) { - bool temp = _hideTabBarStatus; - _hideTabBarStatus = hideOrNot; - return temp; - }; - - static bool getHideTabBarStatus() { - return _hideTabBarStatus; - }; - void reSizeTo(RECT & rc) override; void resizeIconsDpi() { @@ -102,7 +92,6 @@ public : private : ScintillaEditView *_pView = nullptr; - static bool _hideTabBarStatus; IconList _docTabIconList; IconList _docTabIconListAlt; diff --git a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp index d784490ff..74c20e98a 100644 --- a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp @@ -1012,7 +1012,7 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA { _pUserLang = _pCurrentUserLang; - _ctrlTab.init(_hInst, _hSelf, false); + _ctrlTab.init(_hInst, _hSelf); NppDarkMode::subclassTabControl(_ctrlTab.getHSelf()); _folderStyleDlg.init(_hInst, _hSelf); diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 08c42d8cd..a6142ae09 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -713,7 +713,12 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM case IDC_CHECK_TAB_HIDE : { - bool toBeHidden = (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_TAB_HIDE), BM_GETCHECK, 0, 0)); + bool toBeHidden = isCheckedOrNot(IDC_CHECK_TAB_HIDE); + if (toBeHidden) + nppGUI._tabStatus |= TAB_HIDE; + else + nppGUI._tabStatus &= ~TAB_HIDE; + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_TAB_MULTILINE), !toBeHidden); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_TAB_VERTICAL), !toBeHidden); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REDUCE), !toBeHidden); @@ -722,32 +727,59 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_DRAWINACTIVE), !toBeHidden); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLETABCLOSE), !toBeHidden); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLETABPIN), !toBeHidden); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_INACTTABDRAWBUTTON), !toBeHidden); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_DBCLICK2CLOSE), !toBeHidden); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_TAB_LAST_EXIT), !toBeHidden); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_TAB_ALTICONS), !toBeHidden); - ::SendMessage(::GetParent(_hParent), NPPM_HIDETABBAR, 0, toBeHidden); + ::SendMessage(::GetParent(_hParent), WM_SIZE, 0, 0); + return TRUE; } case IDC_CHECK_TAB_VERTICAL: + { + const bool isChecked = isCheckedOrNot(IDC_CHECK_TAB_VERTICAL); + if (isChecked) + nppGUI._tabStatus |= TAB_VERTICAL; + else + nppGUI._tabStatus &= ~TAB_VERTICAL; + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_VERTICALTABBAR, 0, 0); return TRUE; + } + + case IDC_CHECK_TAB_MULTILINE: + { + + const bool isChecked = isCheckedOrNot(IDC_CHECK_TAB_MULTILINE); + if (isChecked) + nppGUI._tabStatus |= TAB_MULTILINE; + else + nppGUI._tabStatus &= ~TAB_MULTILINE; - case IDC_CHECK_TAB_MULTILINE : ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_MULTILINETABBAR, 0, 0); return TRUE; + } case IDC_CHECK_TAB_LAST_EXIT: { - nppGUI._tabStatus ^= TAB_QUITONEMPTY; + const bool isChecked = isCheckedOrNot(IDC_CHECK_TAB_LAST_EXIT); + if (isChecked) + nppGUI._tabStatus |= TAB_QUITONEMPTY; + else + nppGUI._tabStatus &= ~TAB_QUITONEMPTY; } return TRUE; case IDC_CHECK_TAB_ALTICONS: { - nppGUI._tabStatus ^= TAB_ALTICONS; const bool isChecked = isCheckedOrNot(IDC_CHECK_TAB_ALTICONS); + if (isChecked) + nppGUI._tabStatus |= TAB_ALTICONS; + else + nppGUI._tabStatus &= ~TAB_ALTICONS; + const bool isBtnCmd = true; ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_CHANGETABBARICONSET, static_cast(isBtnCmd), isChecked ? 1 : (nppGUI._darkmode._isEnabled ? 2 : 0)); NppDarkMode::setTabIconSet(isChecked, NppDarkMode::isEnabled()); @@ -756,25 +788,71 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM case IDC_CHECK_REDUCE: { + const bool isChecked = isCheckedOrNot(IDC_CHECK_REDUCE); + if (isChecked) + nppGUI._tabStatus |= TAB_REDUCE; + else + nppGUI._tabStatus &= ~TAB_REDUCE; + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_REDUCETABBAR, 0, 0); return TRUE; } - case IDC_CHECK_LOCK : - ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_LOCKTABBAR, 0, 0); + case IDC_CHECK_LOCK: + { + bool islocked = isCheckedOrNot(IDC_CHECK_LOCK); + if (islocked) + nppGUI._tabStatus &= ~TAB_DRAGNDROP; + else + nppGUI._tabStatus |= TAB_DRAGNDROP; + return TRUE; - - case IDC_CHECK_ORANGE : + } + + case IDC_CHECK_ORANGE: + { + const bool isChecked = isCheckedOrNot(IDC_CHECK_ORANGE); + if (isChecked) + nppGUI._tabStatus |= TAB_DRAWTOPBAR; + else + nppGUI._tabStatus &= ~TAB_DRAWTOPBAR; + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_DRAWTABTOPBAR, 0, 0); return TRUE; + } - case IDC_CHECK_DRAWINACTIVE : + case IDC_CHECK_DRAWINACTIVE: + { + const bool isChecked = isCheckedOrNot(IDC_CHECK_DRAWINACTIVE); + if (isChecked) + nppGUI._tabStatus |= TAB_DRAWINACTIVETAB; + else + nppGUI._tabStatus &= ~TAB_DRAWINACTIVETAB; + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_DRAWINACIVETAB, 0, 0); return TRUE; - + } + case IDC_CHECK_ENABLETABCLOSE: case IDC_CHECK_ENABLETABPIN: { + if (wParam == IDC_CHECK_ENABLETABCLOSE) + { + const bool isChecked = isCheckedOrNot(IDC_CHECK_ENABLETABCLOSE); + if (isChecked) + nppGUI._tabStatus |= TAB_CLOSEBUTTON; + else + nppGUI._tabStatus &= ~TAB_CLOSEBUTTON; + } + else + { + const bool isChecked = isCheckedOrNot(IDC_CHECK_ENABLETABPIN); + if (isChecked) + nppGUI._tabStatus |= TAB_PINBUTTON; + else + nppGUI._tabStatus &= ~TAB_PINBUTTON; + } + ::SendMessage(::GetParent(_hParent), wParam == IDC_CHECK_ENABLETABCLOSE ? NPPM_INTERNAL_DRAWTABBARCLOSEBUTTON : NPPM_INTERNAL_DRAWTABBARPINBUTTON, 0, 0); bool showCloseButton = isCheckedOrNot(IDC_CHECK_ENABLETABCLOSE); @@ -803,9 +881,15 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM return TRUE; } - case IDC_CHECK_DBCLICK2CLOSE : - ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_TABDBCLK2CLOSE, 0, 0); + case IDC_CHECK_DBCLICK2CLOSE: + { + const bool isChecked = isCheckedOrNot(IDC_CHECK_DBCLICK2CLOSE); + if (isChecked) + nppGUI._tabStatus |= TAB_DBCLK2CLOSE; + else + nppGUI._tabStatus &= ~TAB_DBCLK2CLOSE; return TRUE; + } case IDC_CHECK_HIDE : { diff --git a/PowerEditor/src/WinControls/TabBar/ControlsTab.cpp b/PowerEditor/src/WinControls/TabBar/ControlsTab.cpp index 87b6e29f3..996873d88 100644 --- a/PowerEditor/src/WinControls/TabBar/ControlsTab.cpp +++ b/PowerEditor/src/WinControls/TabBar/ControlsTab.cpp @@ -40,20 +40,7 @@ void ControlsTab::reSizeTo(RECT & rc) { TabBar::reSizeTo(rc); rc.left += marge; - rc.top += marge; - - //-- We do those dirty things - //-- because it's a "vertical" tab control - if (_isVertical) - { - rc.right -= 40; - rc.bottom -= 20; - if (getRowCount() == 2) - { - rc.right -= 20; - } - } - //-- end of dirty things + rc.top += marge; rc.bottom -= 55; rc.right -= 20; diff --git a/PowerEditor/src/WinControls/TabBar/ControlsTab.h b/PowerEditor/src/WinControls/TabBar/ControlsTab.h index 4b51c0d51..95280aeb7 100644 --- a/PowerEditor/src/WinControls/TabBar/ControlsTab.h +++ b/PowerEditor/src/WinControls/TabBar/ControlsTab.h @@ -41,8 +41,7 @@ public : virtual void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isMultiLine = false) { - _isVertical = isVertical; - TabBar::init(hInst, hwnd, false, isMultiLine); + TabBar::init(hInst, hwnd, isVertical, isMultiLine); } void createTabs(WindowVector & winVector); diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index ea5274001..dcb01fb45 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -25,16 +25,7 @@ #define IDC_DRAG_PLUS_TAB 1406 #define IDC_DRAG_OUT_TAB 1407 -bool TabBarPlus::_doDragNDrop = false; -bool TabBarPlus::_drawTopBar = true; -bool TabBarPlus::_drawInactiveTab = true; -bool TabBarPlus::_drawTabCloseButton = true; -bool TabBarPlus::_drawTabPinButton = true; -bool TabBarPlus::_isDbClk2Close = false; -bool TabBarPlus::_isCtrlVertical = false; -bool TabBarPlus::_isCtrlMultiLine = false; -bool TabBarPlus::_isReduced = true; COLORREF TabBarPlus::_activeTextColour = ::GetSysColor(COLOR_BTNTEXT); COLORREF TabBarPlus::_activeTopBarFocusedColour = RGB(250, 170, 60); @@ -42,25 +33,22 @@ COLORREF TabBarPlus::_activeTopBarUnfocusedColour = RGB(250, 210, 150); COLORREF TabBarPlus::_inactiveTextColour = grey; COLORREF TabBarPlus::_inactiveBgColour = RGB(192, 192, 192); -HWND TabBarPlus::_hwndArray[nbCtrlMax] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; +HWND TabBarPlus::_tabbrPlusInstanceHwndArray[nbCtrlMax] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; int TabBarPlus::_nbCtrl = 0; void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLine) { Window::init(hInst, parent); - int vertical = isVertical?(TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY):0; - - _isVertical = isVertical; - _isMultiLine = isMultiLine; + int verticalFlag = isVertical ? (TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY) : 0; INITCOMMONCONTROLSEX icce{}; icce.dwSize = sizeof(icce); icce.dwICC = ICC_TAB_CLASSES; InitCommonControlsEx(&icce); - int multiLine = isMultiLine ? TCS_MULTILINE : 0; + int multiLineFlag = isMultiLine ? TCS_MULTILINE : 0; int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE |\ - TCS_FOCUSNEVER | TCS_TABS | WS_TABSTOP | vertical | multiLine; + TCS_FOCUSNEVER | TCS_TABS | WS_TABSTOP | verticalFlag | multiLineFlag; _hSelf = ::CreateWindowEx( 0, @@ -236,8 +224,10 @@ void TabBar::reSizeTo(RECT & rc2Ajust) rowCount = TabCtrl_GetRowCount(_hSelf); TabCtrl_GetItemRect(_hSelf, 0, &rowRect); - int larger = _isVertical ? rowRect.right : rowRect.bottom; - int smaller = _isVertical ? rowRect.left : rowRect.top; + bool isVertical = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_VERTICAL; + + int larger = isVertical ? rowRect.right : rowRect.bottom; + int smaller = isVertical ? rowRect.left : rowRect.top; int marge = 0; LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE); @@ -253,9 +243,9 @@ void TabBar::reSizeTo(RECT & rc2Ajust) ::SetWindowLongPtr(_hSelf, GWL_STYLE, style); tabsHight = rowCount * (larger - smaller) + marge; - tabsHight += _dpiManager.getSystemMetricsForDpi(_isVertical ? SM_CXEDGE : SM_CYEDGE); + tabsHight += _dpiManager.getSystemMetricsForDpi(isVertical ? SM_CXEDGE : SM_CYEDGE); - if (_isVertical) + if (isVertical) { rc2Ajust.left += tabsHight; rc2Ajust.right -= tabsHight; @@ -323,8 +313,6 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMult _dpiManager.setDpi(dpi); int vertical = isVertical ? (TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY) : 0; - _isVertical = isVertical; - _isMultiLine = isMultiLine; INITCOMMONCONTROLSEX icce{}; icce.dwSize = sizeof(icce); @@ -353,26 +341,27 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMult ::SendMessage(_hSelf, TCM_SETTOOLTIPS, reinterpret_cast(_tooltips), 0); - if (!_hwndArray[_nbCtrl]) + if (!_tabbrPlusInstanceHwndArray[_nbCtrl]) { - _hwndArray[_nbCtrl] = _hSelf; - _ctrlID = _nbCtrl; + _tabbrPlusInstanceHwndArray[_nbCtrl] = _hSelf; } else { int i = 0; bool found = false; for (; i < nbCtrlMax && !found; ++i) - if (!_hwndArray[i]) + if (!_tabbrPlusInstanceHwndArray[i]) + { found = true; + break; + } + if (!found) { - _ctrlID = -1; destroy(); throw std::runtime_error("TabBarPlus::init : Tab Control error - Tab Control # is over its limit"); } - _hwndArray[i] = _hSelf; - _ctrlID = i; + _tabbrPlusInstanceHwndArray[i] = _hSelf; } ++_nbCtrl; @@ -426,22 +415,27 @@ void TabBar::setFont() } -void TabBarPlus::doOwnerDrawTab(TabBarPlus* tbpObj) +void TabBarPlus::triggerOwnerDrawTabbar(DPIManagerV2* pDPIManager) { + + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool drawTabCloseButton = nppGUI._tabStatus & TAB_CLOSEBUTTON; + bool drawTabPinButton = nppGUI._tabStatus & TAB_PINBUTTON; + for (int i = 0 ; i < _nbCtrl ; ++i) { - if (_hwndArray[i]) + if (_tabbrPlusInstanceHwndArray[i]) { - ::InvalidateRect(_hwndArray[i], NULL, TRUE); // needed by "Change inactive tab color" & "Draw a couloued bar on active tab" + ::InvalidateRect(_tabbrPlusInstanceHwndArray[i], NULL, TRUE); // needed by "Change inactive tab color" & "Draw a couloued bar on active tab" - if (tbpObj) + if (pDPIManager) { int paddingSize = 0; - if (_drawTabCloseButton && _drawTabPinButton) // 2 buttons + if (drawTabCloseButton && drawTabPinButton) // 2 buttons { paddingSize = 16; } - else if (!_drawTabCloseButton && !_drawTabPinButton) // no button + else if (!drawTabCloseButton && !drawTabPinButton) // no button { paddingSize = 6; } @@ -449,15 +443,15 @@ void TabBarPlus::doOwnerDrawTab(TabBarPlus* tbpObj) { paddingSize = 10; } - const int paddingSizeDynamicW = tbpObj->_dpiManager.scale(paddingSize); - ::SendMessage(_hwndArray[i], TCM_SETPADDING, 0, MAKELPARAM(paddingSizeDynamicW, 0)); + const int paddingSizeDynamicW = pDPIManager->scale(paddingSize); + ::SendMessage(_tabbrPlusInstanceHwndArray[i], TCM_SETPADDING, 0, MAKELPARAM(paddingSizeDynamicW, 0)); } } } } -void TabBarPlus::setColour(COLORREF colour2Set, tabColourIndex i, TabBarPlus* tbpObj) +void TabBarPlus::setColour(COLORREF colour2Set, tabColourIndex i, DPIManagerV2* pDPIManager) { switch (i) { @@ -479,7 +473,7 @@ void TabBarPlus::setColour(COLORREF colour2Set, tabColourIndex i, TabBarPlus* tb default : return; } - doOwnerDrawTab(tbpObj); + triggerOwnerDrawTabbar(pDPIManager); } void TabBarPlus::tabToStart(int index) @@ -614,20 +608,22 @@ void TabBarPlus::setPinBtnImageList() void TabBarPlus::doVertical() { + bool isVertical = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_VERTICAL; for (int i = 0 ; i < _nbCtrl ; ++i) { - if (_hwndArray[i]) - SendMessage(_hwndArray[i], WM_TABSETSTYLE, isVertical(), TCS_VERTICAL); + if (_tabbrPlusInstanceHwndArray[i]) + SendMessage(_tabbrPlusInstanceHwndArray[i], WM_TABSETSTYLE, isVertical, TCS_VERTICAL); } } void TabBarPlus::doMultiLine() { + bool isMultiLine = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_MULTILINE; for (int i = 0 ; i < _nbCtrl ; ++i) { - if (_hwndArray[i]) - SendMessage(_hwndArray[i], WM_TABSETSTYLE, isMultiLine(), TCS_MULTILINE); + if (_tabbrPlusInstanceHwndArray[i]) + SendMessage(_tabbrPlusInstanceHwndArray[i], WM_TABSETSTYLE, isMultiLine, TCS_MULTILINE); } } @@ -664,9 +660,6 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara else style &= ~lParam; - _isVertical = ((style & TCS_VERTICAL) != 0); - _isMultiLine = ((style & TCS_MULTILINE) != 0); - ::SetWindowLongPtr(hwnd, GWL_STYLE, style); ::InvalidateRect(hwnd, NULL, TRUE); @@ -704,12 +697,17 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara const bool isForward = ((short)HIWORD(wParam)) < 0; // wheel rotation towards the user will be considered as forward direction const int lastTabIndex = static_cast(::SendMessage(_hSelf, TCM_GETITEMCOUNT, 0, 0) - 1); - + + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool doDragNDrop = nppGUI._tabStatus & TAB_DRAGNDROP; + bool isMultiLine = nppGUI._tabStatus & TAB_MULTILINE; + bool isVertical = nppGUI._tabStatus & TAB_VERTICAL; + if ((wParam & MK_CONTROL) && (wParam & MK_SHIFT)) { setActiveTab((isForward ? lastTabIndex : 0)); } - else if ((wParam & MK_SHIFT) && _doDragNDrop) + else if ((wParam & MK_SHIFT) && doDragNDrop) { int oldTabIndex = static_cast(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0)); int newTabIndex = oldTabIndex + (isForward ? 1 : -1); @@ -747,7 +745,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara } setActiveTab(tabIndex); } - else if (!_isMultiLine) // don't scroll if in multi-line mode + else if (!isMultiLine) // don't scroll if in multi-line mode { RECT rcTabCtrl{}, rcLastTab{}; ::SendMessage(_hSelf, TCM_GETITEMRECT, lastTabIndex, reinterpret_cast(&rcLastTab)); @@ -759,7 +757,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara hti.pt = { xy, xy }; int scrollTabIndex = static_cast(::SendMessage(_hSelf, TCM_HITTEST, 0, reinterpret_cast(&hti))); - if (scrollTabIndex < 1 && (_isVertical ? rcLastTab.bottom < rcTabCtrl.bottom : rcLastTab.right < rcTabCtrl.right)) // nothing to scroll + if (scrollTabIndex < 1 && (isVertical ? rcLastTab.bottom < rcTabCtrl.bottom : rcLastTab.right < rcTabCtrl.right)) // nothing to scroll return TRUE; // maximal width/height of the msctls_updown32 class (arrow box in the tab bar), @@ -767,7 +765,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara LONG maxLengthUpDownCtrl = _dpiManager.scale(44); // sufficient static value // scroll forward as long as the last tab is hidden; scroll backward till the first tab - if ((_isVertical ? ((rcTabCtrl.bottom - rcLastTab.bottom) < maxLengthUpDownCtrl) : ((rcTabCtrl.right - rcLastTab.right) < maxLengthUpDownCtrl)) || !isForward) + if ((isVertical ? ((rcTabCtrl.bottom - rcLastTab.bottom) < maxLengthUpDownCtrl) : ((rcTabCtrl.right - rcLastTab.right) < maxLengthUpDownCtrl)) || !isForward) { if (isForward) ++scrollTabIndex; @@ -806,9 +804,14 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara } } - if (_drawTabCloseButton) + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool isVertical = nppGUI._tabStatus & TAB_VERTICAL; + bool drawTabCloseButton = nppGUI._tabStatus & TAB_CLOSEBUTTON; + bool drawTabPinButton = nppGUI._tabStatus & TAB_PINBUTTON; + + if (drawTabCloseButton) { - if (_closeButtonZone.isHit(xPos, yPos, _currentHoverTabRect, _isVertical)) + if (_closeButtonZone.isHit(xPos, yPos, _currentHoverTabRect, isVertical)) { _whichCloseClickDown = getTabIndexAt(xPos, yPos); ::SendMessage(_hParent, WM_SIZE, 0, 0); @@ -816,9 +819,9 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara } } - if (_drawTabPinButton) + if (drawTabPinButton) { - if (_pinButtonZone.isHit(xPos, yPos, _currentHoverTabRect, _isVertical)) + if (_pinButtonZone.isHit(xPos, yPos, _currentHoverTabRect, isVertical)) { _whichPinClickDown = getTabIndexAt(xPos, yPos); ::SendMessage(_hParent, WM_SIZE, 0, 0); @@ -832,7 +835,8 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara if (wParam == 2) return TRUE; - if (_doDragNDrop) + bool doDragNDrop = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_DRAGNDROP; + if (doDragNDrop) { _mightBeDragging = true; } @@ -940,7 +944,12 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara // do nothing } - if (_drawTabCloseButton) + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool isVertical = nppGUI._tabStatus & TAB_VERTICAL; + bool drawTabCloseButton = nppGUI._tabStatus & TAB_CLOSEBUTTON; + bool drawTabPinButton = nppGUI._tabStatus & TAB_PINBUTTON; + + if (drawTabCloseButton) { RECT currentHoverTabRectOld = _currentHoverTabRect; bool isCloseHoverOld = _isCloseHover; @@ -948,7 +957,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara if (_currentHoverTabItem != -1) // tab item is being hovered { ::SendMessage(_hSelf, TCM_GETITEMRECT, _currentHoverTabItem, reinterpret_cast(&_currentHoverTabRect)); - _isCloseHover = _closeButtonZone.isHit(p.x, p.y, _currentHoverTabRect, _isVertical); + _isCloseHover = _closeButtonZone.isHit(p.x, p.y, _currentHoverTabRect, isVertical); } else { @@ -980,7 +989,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara } } - if (_drawTabPinButton) + if (drawTabPinButton) { RECT currentHoverTabRectOld = _currentHoverTabRect; bool isPinHoverOld = _isPinHover; @@ -988,7 +997,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara if (_currentHoverTabItem != -1) // tab item is being hovered { ::SendMessage(_hSelf, TCM_GETITEMRECT, _currentHoverTabItem, reinterpret_cast(&_currentHoverTabRect)); - _isPinHover = _pinButtonZone.isHit(p.x, p.y, _currentHoverTabRect, _isVertical); + _isPinHover = _pinButtonZone.isHit(p.x, p.y, _currentHoverTabRect, isVertical); } else { @@ -1065,9 +1074,14 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara return TRUE; } - if (_drawTabCloseButton) + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool isVertical = nppGUI._tabStatus & TAB_VERTICAL; + bool drawTabCloseButton = nppGUI._tabStatus & TAB_CLOSEBUTTON; + bool drawTabPinButton = nppGUI._tabStatus & TAB_PINBUTTON; + + if (drawTabCloseButton) { - if ((_whichCloseClickDown == currentTabOn) && _closeButtonZone.isHit(xPos, yPos, _currentHoverTabRect, _isVertical)) + if ((_whichCloseClickDown == currentTabOn) && _closeButtonZone.isHit(xPos, yPos, _currentHoverTabRect, isVertical)) { notify(TCN_TABDELETE, currentTabOn); _whichCloseClickDown = -1; @@ -1080,16 +1094,16 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara if (nextTab != -1) { ::SendMessage(_hSelf, TCM_GETITEMRECT, nextTab, reinterpret_cast(&_currentHoverTabRect)); - _isCloseHover = _closeButtonZone.isHit(xPos, yPos, _currentHoverTabRect, _isVertical); + _isCloseHover = _closeButtonZone.isHit(xPos, yPos, _currentHoverTabRect, isVertical); } return TRUE; } _whichCloseClickDown = -1; } - if (_drawTabPinButton) + if (drawTabPinButton) { - if ((_whichPinClickDown == currentTabOn) && _pinButtonZone.isHit(xPos, yPos, _currentHoverTabRect, _isVertical)) + if ((_whichPinClickDown == currentTabOn) && _pinButtonZone.isHit(xPos, yPos, _currentHoverTabRect, isVertical)) { notify(TCN_TABPINNED, currentTabOn); _whichPinClickDown = -1; @@ -1102,7 +1116,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara if (nextTab != -1) { ::SendMessage(_hSelf, TCM_GETITEMRECT, nextTab, reinterpret_cast(&_currentHoverTabRect)); - _isPinHover = _pinButtonZone.isHit(xPos, yPos, _currentHoverTabRect, _isVertical); + _isPinHover = _pinButtonZone.isHit(xPos, yPos, _currentHoverTabRect, isVertical); } return TRUE; } @@ -1147,7 +1161,8 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara case WM_LBUTTONDBLCLK: { - if (_isDbClk2Close) + bool isDbClk2Close = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_DBCLK2CLOSE; + if (isDbClk2Close) { int xPos = LOWORD(lParam); int yPos = HIWORD(lParam); @@ -1201,6 +1216,10 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara int nTabs = TabCtrl_GetItemCount(hwnd); int nFocusTab = TabCtrl_GetCurFocus(hwnd); int nSelTab = TabCtrl_GetCurSel(hwnd); + + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool isVertical = nppGUI._tabStatus & TAB_VERTICAL; + for (int i = 0; i < nTabs; ++i) { DRAWITEMSTRUCT dis = { ODT_TAB, id, (UINT)i, ODA_DRAWENTIRE, ODS_DEFAULT, hwnd, hdc, {}, 0 }; @@ -1222,7 +1241,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara { if (!hasMultipleLines) { - if (_isVertical) + if (isVertical) { POINT edges[] = { {dis.rcItem.left, dis.rcItem.bottom - 1}, @@ -1271,7 +1290,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara RECT rcFirstTab{}; TabCtrl_GetItemRect(hwnd, 0, &rcFirstTab); - if (_isVertical) + if (isVertical) { POINT edges[] = { {rcFirstTab.left, rcFirstTab.top}, @@ -1385,6 +1404,13 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) ::FillRect(hDC, &rect, hBrush); ::DeleteObject(static_cast(hBrush)); + NppGUI& nppGUI = NppParameters::getInstance().getNppGUI(); + bool isVertical = nppGUI._tabStatus & TAB_VERTICAL; + bool drawTopBar = nppGUI._tabStatus & TAB_DRAWTOPBAR; + bool drawTabCloseButton = nppGUI._tabStatus & TAB_CLOSEBUTTON; + bool drawTabPinButton = nppGUI._tabStatus & TAB_PINBUTTON; + bool drawInactiveTab = nppGUI._tabStatus & TAB_DRAWINACTIVETAB; + // equalize drawing areas of active and inactive tabs int paddingDynamicTwoX = _dpiManager.scale(2); int paddingDynamicTwoY = paddingDynamicTwoX; @@ -1395,20 +1421,20 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) const int yEdge = _dpiManager.getSystemMetricsForDpi(SM_CYEDGE); ::InflateRect(&rect, -xEdge, -yEdge); // the active tab is also slightly higher by default (use this to shift the tab cotent up bx two pixels if tobBar is not drawn) - if (_isVertical) + if (isVertical) { - rect.left += _drawTopBar ? paddingDynamicTwoX : 0; - rect.right -= _drawTopBar ? 0 : paddingDynamicTwoX; + rect.left += drawTopBar ? paddingDynamicTwoX : 0; + rect.right -= drawTopBar ? 0 : paddingDynamicTwoX; } else { - rect.top += _drawTopBar ? paddingDynamicTwoY : 0; - rect.bottom -= _drawTopBar ? 0 : paddingDynamicTwoY; + rect.top += drawTopBar ? paddingDynamicTwoY : 0; + rect.bottom -= drawTopBar ? 0 : paddingDynamicTwoY; } } else { - if (_isVertical) + if (isVertical) { rect.left += paddingDynamicTwoX; rect.right += paddingDynamicTwoX; @@ -1428,7 +1454,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) const bool hasMultipleLines = ((::GetWindowLongPtr(_hSelf, GWL_STYLE) & TCS_BUTTONS) == TCS_BUTTONS); if (hasMultipleLines) { - if (_isVertical) + if (isVertical) { rect.left -= paddingDynamicTwoX; } @@ -1449,10 +1475,10 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) ::FillRect(hDC, &pDrawItemStruct->rcItem, hBrush); ::DeleteObject(static_cast(hBrush)); - if (_drawTopBar) + if (drawTopBar) { int topBarHeight = _dpiManager.scale(4); - if (_isVertical) + if (isVertical) { barRect.left -= (hasMultipleLines && isDarkMode) ? 0 : paddingDynamicTwoX; barRect.right = barRect.left + topBarHeight; @@ -1482,7 +1508,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) RECT inactiveRect = hasMultipleLines ? pDrawItemStruct->rcItem : barRect; COLORREF brushColour{}; - if (_drawInactiveTab && individualColourId == -1) + if (drawInactiveTab && individualColourId == -1) { brushColour = colorInactiveBg; } @@ -1512,7 +1538,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) } // draw close button - if (_drawTabCloseButton && _hCloseBtnImgLst != nullptr) + if (drawTabCloseButton && _hCloseBtnImgLst != nullptr) { // 3 status for each inactive tab and selected tab close item : // normal / hover / pushed @@ -1534,14 +1560,14 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) idxCloseImg = (_currentHoverTabItem == nTab) ? _closeTabHoverOnTabIdx : _closeTabInactIdx; } - RECT buttonRect = _closeButtonZone.getButtonRectFrom(rect, _isVertical); + RECT buttonRect = _closeButtonZone.getButtonRectFrom(rect, isVertical); ::ImageList_Draw(_hCloseBtnImgLst, idxCloseImg, hDC, buttonRect.left, buttonRect.top, ILD_TRANSPARENT); } // draw pin button Buffer* buf = reinterpret_cast(tci.lParam); - if (_drawTabPinButton && _hPinBtnImgLst != nullptr && buf) + if (drawTabPinButton && _hPinBtnImgLst != nullptr && buf) { // Each tab combined with the following stats : // (active / inactive) | (pinned / unpinned) | (hover / not hover / pushed) @@ -1610,7 +1636,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) } } - RECT buttonRect = _pinButtonZone.getButtonRectFrom(rect, _isVertical); + RECT buttonRect = _pinButtonZone.getButtonRectFrom(rect, isVertical); ::ImageList_Draw(_hPinBtnImgLst, idxPinImg, hDC, buttonRect.left, buttonRect.top, ILD_TRANSPARENT); } @@ -1627,7 +1653,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) int fromBorder; int xPos, yPos; - if (_isVertical) + if (isVertical) { fromBorder = (rect.right - rect.left - (imageRect.right - imageRect.left) + 1) / 2; xPos = rect.left + fromBorder; @@ -1649,14 +1675,14 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) if (isStandardSize) { - if (_isVertical) + if (isVertical) SelectObject(hDC, _hVerticalFont); else SelectObject(hDC, _hFont); } else { - if (_isVertical) + if (isVertical) SelectObject(hDC, _hVerticalLargeFont); else SelectObject(hDC, _hLargeFont); @@ -1686,7 +1712,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) *out++ = *in++; *out = '\0'; - if (_isVertical) + if (isVertical) { // center text horizontally (rotated text is positioned as if it were unrotated, therefore manual positioning is necessary) flags |= DT_LEFT; @@ -1712,7 +1738,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode) rect.top = pDrawItemStruct->rcItem.top + paddingText + paddingDescent; rect.bottom = pDrawItemStruct->rcItem.bottom - paddingText + paddingDescent; - if (isDarkMode || !isSelected || _drawTopBar) + if (isDarkMode || !isSelected || drawTopBar) { rect.top += paddingDynamicTwoY; } diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.h b/PowerEditor/src/WinControls/TabBar/TabBar.h index 2873665e3..bc444cedf 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.h +++ b/PowerEditor/src/WinControls/TabBar/TabBar.h @@ -113,14 +113,6 @@ public: void setFont(); - void setVertical(bool b) { - _isVertical = b; - }; - - void setMultiLine(bool b) { - _isMultiLine = b; - }; - HFONT& getFont(bool isReduced = true) { return isReduced ? _hFont : _hLargeFont; } @@ -138,10 +130,6 @@ protected: HFONT _hVerticalFont = nullptr; HFONT _hVerticalLargeFont = nullptr; - int _ctrlID = 0; - - bool _isVertical = false; - bool _isMultiLine = false; DPIManagerV2 _dpiManager; @@ -182,18 +170,10 @@ public : id0, id1, id2, id3, id4, id5, id6, id7, id8, id9 }; - static void doDragNDrop(bool justDoIt) { - _doDragNDrop = justDoIt; - }; - void init(HINSTANCE hInst, HWND hwnd, bool isVertical, bool isMultiLine, unsigned char buttonsStatus = 0); void destroy() override; - static bool doDragNDropOrNot() { - return _doDragNDrop; - }; - POINT getDraggingPoint() const { return _draggingPoint; }; @@ -203,58 +183,11 @@ public : _draggingPoint.y = 0; }; - static void doOwnerDrawTab(TabBarPlus* tbpObj); + static void triggerOwnerDrawTabbar(DPIManagerV2* pDPIManager); static void doVertical(); static void doMultiLine(); - static bool drawTopBar() {return _drawTopBar;}; - static bool drawInactiveTab() {return _drawInactiveTab;}; - static bool drawTabCloseButton() {return _drawTabCloseButton;}; - static bool drawTabPinButton() {return _drawTabPinButton;}; - static bool isDbClk2Close() {return _isDbClk2Close;}; - static bool isVertical() { return _isCtrlVertical;}; - static bool isMultiLine() { return _isCtrlMultiLine;}; - static bool isReduced() { return _isReduced;}; - static void setDrawTopBar(bool b, TabBarPlus* tbpObj) { - _drawTopBar = b; - doOwnerDrawTab(tbpObj); - } - - static void setDrawInactiveTab(bool b, TabBarPlus* tbpObj) { - _drawInactiveTab = b; - doOwnerDrawTab(tbpObj); - } - - static void setDrawTabCloseButton(bool b, TabBarPlus* tbpObj) { - _drawTabCloseButton = b; - doOwnerDrawTab(tbpObj); - } - - static void setDrawTabPinButton(bool b, TabBarPlus* tbpObj) { - _drawTabPinButton = b; - doOwnerDrawTab(tbpObj); - } - - static void setDbClk2Close(bool b) { - _isDbClk2Close = b; - } - - static void setVertical(bool b) { - _isCtrlVertical = b; - doVertical(); - } - - static void setMultiLine(bool b) { - _isCtrlMultiLine = b; - doMultiLine(); - } - - static void setReduced(bool b, TabBarPlus* tbpObj) { - _isReduced = b; - doOwnerDrawTab(tbpObj); - } - - static void setColour(COLORREF colour2Set, tabColourIndex i, TabBarPlus* tbpObj); + static void setColour(COLORREF colour2Set, tabColourIndex i, DPIManagerV2* pDPIManager); virtual int getIndividualTabColourId(int tabIndex) = 0; void tabToStart(int index = -1); @@ -279,9 +212,7 @@ public : } protected: - // it's the boss to decide if we do the drag N drop - static bool _doDragNDrop; - // drag N drop members + // drag & drop members bool _mightBeDragging = false; int _dragCount = 0; bool _isDragging = false; @@ -329,17 +260,6 @@ protected: bool exchangeTabItemData(int oldTab, int newTab); void exchangeItemData(POINT point); - - // it's the boss to decide if we do the ownerDraw style tab - static bool _drawInactiveTab; - static bool _drawTopBar; - static bool _drawTabCloseButton; - static bool _drawTabPinButton; - static bool _isDbClk2Close; - static bool _isCtrlVertical; - static bool _isCtrlMultiLine; - static bool _isReduced; - static COLORREF _activeTextColour; static COLORREF _activeTopBarFocusedColour; static COLORREF _activeTopBarUnfocusedColour; @@ -347,7 +267,7 @@ protected: static COLORREF _inactiveBgColour; static int _nbCtrl; - static HWND _hwndArray[nbCtrlMax]; + static HWND _tabbrPlusInstanceHwndArray[nbCtrlMax]; void drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode = false); void draggingCursor(POINT screenPoint); diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 1e1c8a0db..c15fa0042 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -722,10 +722,10 @@ #define NPPM_INTERNAL_DRAWTABBARCLOSEBUTTON (NOTEPADPLUS_USER_INTERNAL + 81) #define NPPM_INTERNAL_DRAWINACTIVETABBARBUTTON (NOTEPADPLUS_USER_INTERNAL + 82) #define NPPM_INTERNAL_REDUCETABBAR (NOTEPADPLUS_USER_INTERNAL + 83) - #define NPPM_INTERNAL_LOCKTABBAR (NOTEPADPLUS_USER_INTERNAL + 84) + //#define NPPM_INTERNAL_LOCKTABBAR (NOTEPADPLUS_USER_INTERNAL + 84) #define NPPM_INTERNAL_DRAWINACIVETAB (NOTEPADPLUS_USER_INTERNAL + 85) #define NPPM_INTERNAL_DRAWTABTOPBAR (NOTEPADPLUS_USER_INTERNAL + 86) - #define NPPM_INTERNAL_TABDBCLK2CLOSE (NOTEPADPLUS_USER_INTERNAL + 87) + //#define NPPM_INTERNAL_TABDBCLK2CLOSE (NOTEPADPLUS_USER_INTERNAL + 87) #define NPPM_INTERNAL_VERTICALTABBAR (NOTEPADPLUS_USER_INTERNAL + 88) #define NPPM_INTERNAL_MULTILINETABBAR (NOTEPADPLUS_USER_INTERNAL + 89) #define NPPM_INTERNAL_TOOLBARREDUCE (NOTEPADPLUS_USER_INTERNAL + 90)