Refactoring & cleanup Tabbar (part 2)

Remove unnecessary static functions, centralize the Tabbar settings on _tabStatus.

Close #16297
This commit is contained in:
Don Ho 2025-03-17 02:37:09 +01:00
parent a679e8ebfb
commit ff734af115
13 changed files with 283 additions and 313 deletions

View File

@ -242,7 +242,6 @@ LRESULT Notepad_plus::init(HWND hwnd)
const ScintillaViewParams & svp = nppParam.getSVP(); const ScintillaViewParams & svp = nppParam.getSVP();
int tabBarStatus = nppGUI._tabStatus; int tabBarStatus = nppGUI._tabStatus;
TabBarPlus::setReduced((tabBarStatus & TAB_REDUCE) != 0, &_mainDocTab);
const int tabIconSet = NppDarkMode::getTabIconSet(NppDarkMode::isEnabled()); const int tabIconSet = NppDarkMode::getTabIconSet(NppDarkMode::isEnabled());
unsigned char indexDocTabIcon = 0; unsigned char indexDocTabIcon = 0;
@ -392,32 +391,21 @@ LRESULT Notepad_plus::init(HWND hwnd)
_mainEditView.execute(SCI_STYLESETCHECKMONOSPACED, STYLE_DEFAULT, true); _mainEditView.execute(SCI_STYLESETCHECKMONOSPACED, STYLE_DEFAULT, true);
_subEditView.execute(SCI_STYLESETCHECKMONOSPACED, STYLE_DEFAULT, true); _subEditView.execute(SCI_STYLESETCHECKMONOSPACED, STYLE_DEFAULT, true);
TabBarPlus::doDragNDrop(true); const auto& hf = _mainDocTab.getFont(nppGUI._tabStatus & TAB_REDUCE);
const auto& hf = _mainDocTab.getFont(TabBarPlus::isReduced());
if (hf) if (hf)
{ {
::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0)); ::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0)); ::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
} }
int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(TabBarPlus::isReduced() ? g_TabHeight : g_TabHeightLarge); int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(nppGUI._tabStatus & TAB_REDUCE ? g_TabHeight : g_TabHeightLarge);
int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? g_TabWidthButton : g_TabWidth); int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(nppGUI._tabStatus & TAB_PINBUTTON ? g_TabWidthButton : g_TabWidth);
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
_mainDocTab.display(); _mainDocTab.display();
TabBarPlus::triggerOwnerDrawTabbar(&(_mainDocTab.dpiManager()));
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();
// //
// Initialize the default foreground & background color // Initialize the default foreground & background color
@ -907,20 +895,6 @@ bool Notepad_plus::saveGUIParams()
nppGUI._toolbarShow = _rebarTop.getIDVisible(REBAR_BAR_TOOLBAR); nppGUI._toolbarShow = _rebarTop.getIDVisible(REBAR_BAR_TOOLBAR);
nppGUI._toolBarStatus = _toolBar.getState(); 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; nppGUI._splitterPos = _subSplitter.isVertical()?POS_VERTICAL:POS_HORIZOTAL;
UserDefineDialog *udd = _pEditView->getUserDefineDlg(); UserDefineDialog *udd = _pEditView->getUserDefineDlg();
bool b = udd->isDocked(); bool b = udd->isDocked();
@ -6452,21 +6426,21 @@ void Notepad_plus::drawTabbarColoursFromStylerArray()
{ {
Style *stActText = getStyleFromName(TABBAR_ACTIVETEXT); Style *stActText = getStyleFromName(TABBAR_ACTIVETEXT);
if (stActText && static_cast<long>(stActText->_fgColor) != -1) if (stActText && static_cast<long>(stActText->_fgColor) != -1)
TabBarPlus::setColour(stActText->_fgColor, TabBarPlus::activeText, &_mainDocTab); TabBarPlus::setColour(stActText->_fgColor, TabBarPlus::activeText, &(_mainDocTab.dpiManager()));
Style *stActfocusTop = getStyleFromName(TABBAR_ACTIVEFOCUSEDINDCATOR); Style *stActfocusTop = getStyleFromName(TABBAR_ACTIVEFOCUSEDINDCATOR);
if (stActfocusTop && static_cast<long>(stActfocusTop->_fgColor) != -1) if (stActfocusTop && static_cast<long>(stActfocusTop->_fgColor) != -1)
TabBarPlus::setColour(stActfocusTop->_fgColor, TabBarPlus::activeFocusedTop, &_mainDocTab); TabBarPlus::setColour(stActfocusTop->_fgColor, TabBarPlus::activeFocusedTop, &(_mainDocTab.dpiManager()));
Style *stActunfocusTop = getStyleFromName(TABBAR_ACTIVEUNFOCUSEDINDCATOR); Style *stActunfocusTop = getStyleFromName(TABBAR_ACTIVEUNFOCUSEDINDCATOR);
if (stActunfocusTop && static_cast<long>(stActunfocusTop->_fgColor) != -1) if (stActunfocusTop && static_cast<long>(stActunfocusTop->_fgColor) != -1)
TabBarPlus::setColour(stActunfocusTop->_fgColor, TabBarPlus::activeUnfocusedTop, &_mainDocTab); TabBarPlus::setColour(stActunfocusTop->_fgColor, TabBarPlus::activeUnfocusedTop, &(_mainDocTab.dpiManager()));
Style *stInact = getStyleFromName(TABBAR_INACTIVETEXT); Style *stInact = getStyleFromName(TABBAR_INACTIVETEXT);
if (stInact && static_cast<long>(stInact->_fgColor) != -1) if (stInact && static_cast<long>(stInact->_fgColor) != -1)
TabBarPlus::setColour(stInact->_fgColor, TabBarPlus::inactiveText, &_mainDocTab); TabBarPlus::setColour(stInact->_fgColor, TabBarPlus::inactiveText, &(_mainDocTab.dpiManager()));
if (stInact && static_cast<long>(stInact->_bgColor) != -1) if (stInact && static_cast<long>(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) void Notepad_plus::drawAutocompleteColoursFromTheme(COLORREF fgColor, COLORREF bgColor)

View File

@ -896,7 +896,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_INTERNAL_SAVEBACKUP: case NPPM_INTERNAL_SAVEBACKUP:
{ {
if (NppParameters::getInstance().getNppGUI().isSnapshotMode()) if (nppParam.getNppGUI().isSnapshotMode())
{ {
MainFileManager.backupCurrentBuffer(); MainFileManager.backupCurrentBuffer();
} }
@ -1209,7 +1209,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return TRUE; return TRUE;
} }
if (NppParameters::getInstance().getNppGUI()._styleMRU) if (nppParam.getNppGUI()._styleMRU)
{ {
tli->_currentIndex = 0; tli->_currentIndex = 0;
std::sort(tli->_tlfsLst.begin(),tli->_tlfsLst.end(),SortTaskListPred(_mainDocTab,_subDocTab)); 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: case NPPM_INTERNAL_ISTABBARREDUCED:
{ {
return TabBarPlus::isReduced() ? TRUE : FALSE; return nppParam.getNppGUI()._tabStatus & TAB_REDUCE ? TRUE : FALSE;
} }
// ADD: success->hwnd; failure->NULL // ADD: success->hwnd; failure->NULL
@ -2299,11 +2299,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
drawDocumentMapColoursFromStylerArray(); drawDocumentMapColoursFromStylerArray();
// Update default fg/bg colors in Parameters for both internal/plugins docking dialog // 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) if (pStyle)
{ {
NppParameters::getInstance().setCurrentDefaultFgColor(pStyle->_fgColor); nppParam.setCurrentDefaultFgColor(pStyle->_fgColor);
NppParameters::getInstance().setCurrentDefaultBgColor(pStyle->_bgColor); nppParam.setCurrentDefaultBgColor(pStyle->_bgColor);
drawAutocompleteColoursFromTheme(pStyle->_fgColor, 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: case NPPM_GETWINDOWSVERSION:
{ {
return (NppParameters::getInstance()).getWinVersion(); return nppParam.getWinVersion();
} }
case NPPM_MAKECURRENTBUFFERDIRTY: case NPPM_MAKECURRENTBUFFERDIRTY:
@ -3151,24 +3151,25 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_HIDETABBAR: case NPPM_HIDETABBAR:
{ {
bool hide = (lParam != 0); bool hide = (lParam != 0);
bool oldVal = DocTabView::getHideTabBarStatus();
NppGUI& nppGUI = nppParam.getNppGUI();
bool oldVal = (nppGUI._tabStatus & TAB_HIDE);
if (hide == oldVal) return oldVal; if (hide == oldVal) return oldVal;
DocTabView::setHideTabBarStatus(hide);
::SendMessage(hwnd, WM_SIZE, 0, 0);
NppGUI & nppGUI = (NppParameters::getInstance()).getNppGUI();
if (hide) if (hide)
nppGUI._tabStatus |= TAB_HIDE; nppGUI._tabStatus |= TAB_HIDE;
else else
nppGUI._tabStatus &= ~TAB_HIDE; nppGUI._tabStatus &= ~TAB_HIDE;
::SendMessage(hwnd, WM_SIZE, 0, 0);
return oldVal; return oldVal;
} }
case NPPM_ISTABBARHIDDEN: case NPPM_ISTABBARHIDDEN:
{ {
return _mainDocTab.getHideTabBarStatus(); NppGUI& nppGUI = nppParam.getNppGUI();
return nppGUI._tabStatus & TAB_HIDE;
} }
case NPPM_HIDETOOLBAR: case NPPM_HIDETOOLBAR:
@ -3297,7 +3298,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
_mainEditView.setNpcAndCcUniEOL(); _mainEditView.setNpcAndCcUniEOL();
_subEditView.setNpcAndCcUniEOL(); _subEditView.setNpcAndCcUniEOL();
const auto& svp = NppParameters::getInstance().getSVP(); const auto& svp = nppParam.getSVP();
if (svp._npcShow) if (svp._npcShow)
{ {
_findReplaceDlg.updateFinderScintillaForNpc(true); _findReplaceDlg.updateFinderScintillaForNpc(true);
@ -3506,8 +3507,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR: case NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR:
{ {
return (message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR return (message == NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR
?(NppParameters::getInstance()).getCurrentDefaultFgColor() ? nppParam.getCurrentDefaultFgColor()
:(NppParameters::getInstance()).getCurrentDefaultBgColor()); : nppParam.getCurrentDefaultBgColor());
} }
case NPPM_SHOWDOCLIST: case NPPM_SHOWDOCLIST:
@ -3573,7 +3574,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
ScintillaViewParams &svp = const_cast<ScintillaViewParams &>(nppParam.getSVP()); ScintillaViewParams &svp = const_cast<ScintillaViewParams &>(nppParam.getSVP());
COLORREF multiEdgeColor = liteGrey; COLORREF multiEdgeColor = liteGrey;
const Style * pStyle = NppParameters::getInstance().getMiscStylerArray().findByName(L"Edge colour"); const Style * pStyle = nppParam.getMiscStylerArray().findByName(L"Edge colour");
if (pStyle) if (pStyle)
{ {
multiEdgeColor = pStyle->_fgColor; multiEdgeColor = pStyle->_fgColor;
@ -3930,52 +3931,38 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
} }
break; break;
case NPPM_INTERNAL_LOCKTABBAR:
{
bool isDrag = TabBarPlus::doDragNDropOrNot();
TabBarPlus::doDragNDrop(!isDrag);
break;
}
case NPPM_INTERNAL_DRAWINACIVETAB: case NPPM_INTERNAL_DRAWINACIVETAB:
{
TabBarPlus::setDrawInactiveTab(!TabBarPlus::drawInactiveTab(), &_mainDocTab);
break;
}
case NPPM_INTERNAL_DRAWTABTOPBAR: case NPPM_INTERNAL_DRAWTABTOPBAR:
{ {
TabBarPlus::setDrawTopBar(!TabBarPlus::drawTopBar(), &_mainDocTab); TabBarPlus::triggerOwnerDrawTabbar(&(_mainDocTab.dpiManager()));
break;
}
case NPPM_INTERNAL_TABDBCLK2CLOSE:
{
TabBarPlus::setDbClk2Close(!TabBarPlus::isDbClk2Close());
break; break;
} }
case NPPM_INTERNAL_VERTICALTABBAR: case NPPM_INTERNAL_VERTICALTABBAR:
{ {
TabBarPlus::setVertical(!TabBarPlus::isVertical()); TabBarPlus::doVertical();
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
break; break;
} }
case NPPM_INTERNAL_MULTILINETABBAR: case NPPM_INTERNAL_MULTILINETABBAR:
{ {
TabBarPlus::setMultiLine(!TabBarPlus::isMultiLine()); TabBarPlus::doMultiLine();
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
break; break;
} }
case NPPM_INTERNAL_REDUCETABBAR: case NPPM_INTERNAL_REDUCETABBAR:
{ {
TabBarPlus::setReduced(!TabBarPlus::isReduced(), &_mainDocTab); TabBarPlus::triggerOwnerDrawTabbar(&(_mainDocTab.dpiManager()));
bool isReduceed = TabBarPlus::isReduced(); bool isReduceed = nppParam.getNppGUI()._tabStatus & TAB_REDUCE;
//Resize the tab height //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); int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(isReduceed ? g_TabHeight : g_TabHeightLarge);
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); 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: case NPPM_INTERNAL_DRAWTABBARCLOSEBUTTON:
{ {
TabBarPlus::setDrawTabCloseButton(!TabBarPlus::drawTabCloseButton(), &_mainDocTab); TabBarPlus::triggerOwnerDrawTabbar(&(_mainDocTab.dpiManager()));
bool drawTabPinButton = TabBarPlus::drawTabPinButton(); NppGUI& nppGUI = NppParameters::getInstance().getNppGUI();
bool drawTabCloseButton = TabBarPlus::drawTabCloseButton(); bool drawTabCloseButton = nppGUI._tabStatus & TAB_CLOSEBUTTON;
bool drawTabPinButton = nppGUI._tabStatus & TAB_PINBUTTON;
if (drawTabCloseButton && drawTabPinButton) 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 // This part is just for updating (redraw) the tabs
int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(TabBarPlus::isReduced() ? g_TabHeight : g_TabHeightLarge); int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(nppParam.getNppGUI()._tabStatus & TAB_REDUCE ? g_TabHeight : g_TabHeightLarge);
int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? g_TabWidthButton : g_TabWidth); int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(drawTabCloseButton ? g_TabWidthButton : g_TabWidth);
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
TabCtrl_SetItemSize(_subDocTab.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: case NPPM_INTERNAL_DRAWTABBARPINBUTTON:
{ {
TabBarPlus::setDrawTabPinButton(!TabBarPlus::drawTabPinButton(), &_mainDocTab); TabBarPlus::triggerOwnerDrawTabbar(&(_mainDocTab.dpiManager()));
bool drawTabPinButton = TabBarPlus::drawTabPinButton(); NppGUI& nppGUI = NppParameters::getInstance().getNppGUI();
bool drawTabCloseButton = TabBarPlus::drawTabCloseButton(); bool drawTabCloseButton = nppGUI._tabStatus & TAB_CLOSEBUTTON;
bool drawTabPinButton = nppGUI._tabStatus & TAB_PINBUTTON;
if (!drawTabPinButton) 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 // This part is just for updating (redraw) the tabs
int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(TabBarPlus::isReduced() ? g_TabHeight : g_TabHeightLarge); int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(nppParam.getNppGUI()._tabStatus & TAB_REDUCE ? g_TabHeight : g_TabHeightLarge);
int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(TabBarPlus::drawTabPinButton() ? g_TabWidthButton : g_TabWidth); int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(drawTabPinButton ? g_TabWidthButton : g_TabWidth);
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
TabCtrl_SetItemSize(_subDocTab.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 // 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. // 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. // 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); Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER);
Buffer* oldBuf = _invisibleEditView.getCurrentBuffer(); Buffer* oldBuf = _invisibleEditView.getCurrentBuffer();

View File

@ -1103,7 +1103,8 @@ BOOL Notepad_plus::notify(SCNotification *notification)
_tabPopupMenu.enableItem(IDM_FILE_SAVEAS, !isInaccessible); _tabPopupMenu.enableItem(IDM_FILE_SAVEAS, !isInaccessible);
_tabPopupMenu.enableItem(IDM_FILE_RENAME, !isInaccessible); _tabPopupMenu.enableItem(IDM_FILE_RENAME, !isInaccessible);
bool isTabPinEnabled = TabBarPlus::drawTabPinButton(); NppGUI& nppGUI = NppParameters::getInstance().getNppGUI();
bool isTabPinEnabled = nppGUI._tabStatus & TAB_PINBUTTON;
wstring newName; wstring newName;
if (isTabPinEnabled) if (isTabPinEnabled)
{ {

View File

@ -4880,13 +4880,15 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
{ {
bool isFailed = false; bool isFailed = false;
int oldValue = _nppGUI._tabStatus; int oldValue = _nppGUI._tabStatus;
_nppGUI._tabStatus = 0;
const wchar_t* val = element->Attribute(L"dragAndDrop"); const wchar_t* val = element->Attribute(L"dragAndDrop");
if (val) if (val)
{ {
if (!lstrcmp(val, L"yes")) if (!lstrcmp(val, L"yes"))
_nppGUI._tabStatus = TAB_DRAGNDROP; _nppGUI._tabStatus |= TAB_DRAGNDROP;
else if (!lstrcmp(val, L"no")) else if (!lstrcmp(val, L"no"))
_nppGUI._tabStatus = 0; _nppGUI._tabStatus |= 0;
else else
isFailed = true; isFailed = true;
} }
@ -7300,10 +7302,10 @@ void NppParameters::createXmlTreeFromGUIParams()
TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(L"GUIConfig")))->ToElement(); TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(L"GUIConfig")))->ToElement();
GUIConfigElement->SetAttribute(L"name", L"TabBar"); 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); 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); GUIConfigElement->SetAttribute(L"drawTopBar", pStr);
pStr = (_nppGUI._tabStatus & TAB_DRAWINACTIVETAB) ? L"yes" : L"no"; pStr = (_nppGUI._tabStatus & TAB_DRAWINACTIVETAB) ? L"yes" : L"no";

View File

@ -23,9 +23,6 @@
#define _WIN32_IE 0x0600 #define _WIN32_IE 0x0600
#endif //_WIN32_IE #endif //_WIN32_IE
bool DocTabView::_hideTabBarStatus = false;
int docTabIconIDs[] = { IDI_SAVED_ICON, IDI_UNSAVED_ICON, IDI_READONLY_ICON, IDI_MONITORING_ICON }; 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_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 }; 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) void DocTabView::reSizeTo(RECT & rc)
{ {
int borderWidth = ((NppParameters::getInstance()).getSVP())._borderWidth; NppParameters& nppParam = NppParameters::getInstance();
if (_hideTabBarStatus) int borderWidth = nppParam.getSVP()._borderWidth;
NppGUI& nppGUI = nppParam.getNppGUI();
if (nppGUI._tabStatus & TAB_HIDE)
{ {
RECT rcTmp = rc; RECT rcTmp = rc;
TabBar::reSizeTo(rcTmp); TabBar::reSizeTo(rcTmp);

View File

@ -60,16 +60,6 @@ public :
void setBuffer(size_t index, BufferID id); 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 reSizeTo(RECT & rc) override;
void resizeIconsDpi() { void resizeIconsDpi() {
@ -102,7 +92,6 @@ public :
private : private :
ScintillaEditView *_pView = nullptr; ScintillaEditView *_pView = nullptr;
static bool _hideTabBarStatus;
IconList _docTabIconList; IconList _docTabIconList;
IconList _docTabIconListAlt; IconList _docTabIconListAlt;

View File

@ -1012,7 +1012,7 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA
{ {
_pUserLang = _pCurrentUserLang; _pUserLang = _pCurrentUserLang;
_ctrlTab.init(_hInst, _hSelf, false); _ctrlTab.init(_hInst, _hSelf);
NppDarkMode::subclassTabControl(_ctrlTab.getHSelf()); NppDarkMode::subclassTabControl(_ctrlTab.getHSelf());
_folderStyleDlg.init(_hInst, _hSelf); _folderStyleDlg.init(_hInst, _hSelf);

View File

@ -713,7 +713,12 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
case IDC_CHECK_TAB_HIDE : 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_MULTILINE), !toBeHidden);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_TAB_VERTICAL), !toBeHidden); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_TAB_VERTICAL), !toBeHidden);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REDUCE), !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_DRAWINACTIVE), !toBeHidden);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLETABCLOSE), !toBeHidden); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLETABCLOSE), !toBeHidden);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLETABPIN), !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_DBCLICK2CLOSE), !toBeHidden);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_TAB_LAST_EXIT), !toBeHidden); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_TAB_LAST_EXIT), !toBeHidden);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_TAB_ALTICONS), !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; return TRUE;
} }
case IDC_CHECK_TAB_VERTICAL: 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); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_VERTICALTABBAR, 0, 0);
return TRUE; return TRUE;
}
case IDC_CHECK_TAB_MULTILINE: case IDC_CHECK_TAB_MULTILINE:
{
const bool isChecked = isCheckedOrNot(IDC_CHECK_TAB_MULTILINE);
if (isChecked)
nppGUI._tabStatus |= TAB_MULTILINE;
else
nppGUI._tabStatus &= ~TAB_MULTILINE;
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_MULTILINETABBAR, 0, 0); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_MULTILINETABBAR, 0, 0);
return TRUE; return TRUE;
}
case IDC_CHECK_TAB_LAST_EXIT: 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; return TRUE;
case IDC_CHECK_TAB_ALTICONS: case IDC_CHECK_TAB_ALTICONS:
{ {
nppGUI._tabStatus ^= TAB_ALTICONS;
const bool isChecked = isCheckedOrNot(IDC_CHECK_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; const bool isBtnCmd = true;
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_CHANGETABBARICONSET, static_cast<WPARAM>(isBtnCmd), isChecked ? 1 : (nppGUI._darkmode._isEnabled ? 2 : 0)); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_CHANGETABBARICONSET, static_cast<WPARAM>(isBtnCmd), isChecked ? 1 : (nppGUI._darkmode._isEnabled ? 2 : 0));
NppDarkMode::setTabIconSet(isChecked, NppDarkMode::isEnabled()); NppDarkMode::setTabIconSet(isChecked, NppDarkMode::isEnabled());
@ -756,25 +788,71 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
case IDC_CHECK_REDUCE: 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); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_REDUCETABBAR, 0, 0);
return TRUE; return TRUE;
} }
case IDC_CHECK_LOCK: case IDC_CHECK_LOCK:
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_LOCKTABBAR, 0, 0); {
bool islocked = isCheckedOrNot(IDC_CHECK_LOCK);
if (islocked)
nppGUI._tabStatus &= ~TAB_DRAGNDROP;
else
nppGUI._tabStatus |= TAB_DRAGNDROP;
return TRUE; 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); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_DRAWTABTOPBAR, 0, 0);
return TRUE; 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); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_DRAWINACIVETAB, 0, 0);
return TRUE; return TRUE;
}
case IDC_CHECK_ENABLETABCLOSE: case IDC_CHECK_ENABLETABCLOSE:
case IDC_CHECK_ENABLETABPIN: 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); ::SendMessage(::GetParent(_hParent), wParam == IDC_CHECK_ENABLETABCLOSE ? NPPM_INTERNAL_DRAWTABBARCLOSEBUTTON : NPPM_INTERNAL_DRAWTABBARPINBUTTON, 0, 0);
bool showCloseButton = isCheckedOrNot(IDC_CHECK_ENABLETABCLOSE); bool showCloseButton = isCheckedOrNot(IDC_CHECK_ENABLETABCLOSE);
@ -804,8 +882,14 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
} }
case IDC_CHECK_DBCLICK2CLOSE: case IDC_CHECK_DBCLICK2CLOSE:
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_TABDBCLK2CLOSE, 0, 0); {
const bool isChecked = isCheckedOrNot(IDC_CHECK_DBCLICK2CLOSE);
if (isChecked)
nppGUI._tabStatus |= TAB_DBCLK2CLOSE;
else
nppGUI._tabStatus &= ~TAB_DBCLK2CLOSE;
return TRUE; return TRUE;
}
case IDC_CHECK_HIDE : case IDC_CHECK_HIDE :
{ {

View File

@ -41,19 +41,6 @@ void ControlsTab::reSizeTo(RECT & rc)
TabBar::reSizeTo(rc); TabBar::reSizeTo(rc);
rc.left += marge; rc.left += marge;
rc.top += 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.bottom -= 55; rc.bottom -= 55;
rc.right -= 20; rc.right -= 20;

View File

@ -41,8 +41,7 @@ public :
virtual void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isMultiLine = false) virtual void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isMultiLine = false)
{ {
_isVertical = isVertical; TabBar::init(hInst, hwnd, isVertical, isMultiLine);
TabBar::init(hInst, hwnd, false, isMultiLine);
} }
void createTabs(WindowVector & winVector); void createTabs(WindowVector & winVector);

View File

@ -25,16 +25,7 @@
#define IDC_DRAG_PLUS_TAB 1406 #define IDC_DRAG_PLUS_TAB 1406
#define IDC_DRAG_OUT_TAB 1407 #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::_activeTextColour = ::GetSysColor(COLOR_BTNTEXT);
COLORREF TabBarPlus::_activeTopBarFocusedColour = RGB(250, 170, 60); COLORREF TabBarPlus::_activeTopBarFocusedColour = RGB(250, 170, 60);
@ -42,25 +33,22 @@ COLORREF TabBarPlus::_activeTopBarUnfocusedColour = RGB(250, 210, 150);
COLORREF TabBarPlus::_inactiveTextColour = grey; COLORREF TabBarPlus::_inactiveTextColour = grey;
COLORREF TabBarPlus::_inactiveBgColour = RGB(192, 192, 192); 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; int TabBarPlus::_nbCtrl = 0;
void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLine) void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLine)
{ {
Window::init(hInst, parent); Window::init(hInst, parent);
int vertical = isVertical?(TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY):0; int verticalFlag = isVertical ? (TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY) : 0;
_isVertical = isVertical;
_isMultiLine = isMultiLine;
INITCOMMONCONTROLSEX icce{}; INITCOMMONCONTROLSEX icce{};
icce.dwSize = sizeof(icce); icce.dwSize = sizeof(icce);
icce.dwICC = ICC_TAB_CLASSES; icce.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icce); InitCommonControlsEx(&icce);
int multiLine = isMultiLine ? TCS_MULTILINE : 0; int multiLineFlag = isMultiLine ? TCS_MULTILINE : 0;
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE |\ 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( _hSelf = ::CreateWindowEx(
0, 0,
@ -236,8 +224,10 @@ void TabBar::reSizeTo(RECT & rc2Ajust)
rowCount = TabCtrl_GetRowCount(_hSelf); rowCount = TabCtrl_GetRowCount(_hSelf);
TabCtrl_GetItemRect(_hSelf, 0, &rowRect); TabCtrl_GetItemRect(_hSelf, 0, &rowRect);
int larger = _isVertical ? rowRect.right : rowRect.bottom; bool isVertical = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_VERTICAL;
int smaller = _isVertical ? rowRect.left : rowRect.top;
int larger = isVertical ? rowRect.right : rowRect.bottom;
int smaller = isVertical ? rowRect.left : rowRect.top;
int marge = 0; int marge = 0;
LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE); LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
@ -253,9 +243,9 @@ void TabBar::reSizeTo(RECT & rc2Ajust)
::SetWindowLongPtr(_hSelf, GWL_STYLE, style); ::SetWindowLongPtr(_hSelf, GWL_STYLE, style);
tabsHight = rowCount * (larger - smaller) + marge; 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.left += tabsHight;
rc2Ajust.right -= tabsHight; rc2Ajust.right -= tabsHight;
@ -323,8 +313,6 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMult
_dpiManager.setDpi(dpi); _dpiManager.setDpi(dpi);
int vertical = isVertical ? (TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY) : 0; int vertical = isVertical ? (TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY) : 0;
_isVertical = isVertical;
_isMultiLine = isMultiLine;
INITCOMMONCONTROLSEX icce{}; INITCOMMONCONTROLSEX icce{};
icce.dwSize = sizeof(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<WPARAM>(_tooltips), 0); ::SendMessage(_hSelf, TCM_SETTOOLTIPS, reinterpret_cast<WPARAM>(_tooltips), 0);
if (!_hwndArray[_nbCtrl]) if (!_tabbrPlusInstanceHwndArray[_nbCtrl])
{ {
_hwndArray[_nbCtrl] = _hSelf; _tabbrPlusInstanceHwndArray[_nbCtrl] = _hSelf;
_ctrlID = _nbCtrl;
} }
else else
{ {
int i = 0; int i = 0;
bool found = false; bool found = false;
for (; i < nbCtrlMax && !found; ++i) for (; i < nbCtrlMax && !found; ++i)
if (!_hwndArray[i]) if (!_tabbrPlusInstanceHwndArray[i])
{
found = true; found = true;
break;
}
if (!found) if (!found)
{ {
_ctrlID = -1;
destroy(); destroy();
throw std::runtime_error("TabBarPlus::init : Tab Control error - Tab Control # is over its limit"); throw std::runtime_error("TabBarPlus::init : Tab Control error - Tab Control # is over its limit");
} }
_hwndArray[i] = _hSelf; _tabbrPlusInstanceHwndArray[i] = _hSelf;
_ctrlID = i;
} }
++_nbCtrl; ++_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) 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; int paddingSize = 0;
if (_drawTabCloseButton && _drawTabPinButton) // 2 buttons if (drawTabCloseButton && drawTabPinButton) // 2 buttons
{ {
paddingSize = 16; paddingSize = 16;
} }
else if (!_drawTabCloseButton && !_drawTabPinButton) // no button else if (!drawTabCloseButton && !drawTabPinButton) // no button
{ {
paddingSize = 6; paddingSize = 6;
} }
@ -449,15 +443,15 @@ void TabBarPlus::doOwnerDrawTab(TabBarPlus* tbpObj)
{ {
paddingSize = 10; paddingSize = 10;
} }
const int paddingSizeDynamicW = tbpObj->_dpiManager.scale(paddingSize); const int paddingSizeDynamicW = pDPIManager->scale(paddingSize);
::SendMessage(_hwndArray[i], TCM_SETPADDING, 0, MAKELPARAM(paddingSizeDynamicW, 0)); ::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) switch (i)
{ {
@ -479,7 +473,7 @@ void TabBarPlus::setColour(COLORREF colour2Set, tabColourIndex i, TabBarPlus* tb
default : default :
return; return;
} }
doOwnerDrawTab(tbpObj); triggerOwnerDrawTabbar(pDPIManager);
} }
void TabBarPlus::tabToStart(int index) void TabBarPlus::tabToStart(int index)
@ -614,20 +608,22 @@ void TabBarPlus::setPinBtnImageList()
void TabBarPlus::doVertical() void TabBarPlus::doVertical()
{ {
bool isVertical = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_VERTICAL;
for (int i = 0 ; i < _nbCtrl ; ++i) for (int i = 0 ; i < _nbCtrl ; ++i)
{ {
if (_hwndArray[i]) if (_tabbrPlusInstanceHwndArray[i])
SendMessage(_hwndArray[i], WM_TABSETSTYLE, isVertical(), TCS_VERTICAL); SendMessage(_tabbrPlusInstanceHwndArray[i], WM_TABSETSTYLE, isVertical, TCS_VERTICAL);
} }
} }
void TabBarPlus::doMultiLine() void TabBarPlus::doMultiLine()
{ {
bool isMultiLine = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_MULTILINE;
for (int i = 0 ; i < _nbCtrl ; ++i) for (int i = 0 ; i < _nbCtrl ; ++i)
{ {
if (_hwndArray[i]) if (_tabbrPlusInstanceHwndArray[i])
SendMessage(_hwndArray[i], WM_TABSETSTYLE, isMultiLine(), TCS_MULTILINE); SendMessage(_tabbrPlusInstanceHwndArray[i], WM_TABSETSTYLE, isMultiLine, TCS_MULTILINE);
} }
} }
@ -664,9 +660,6 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
else else
style &= ~lParam; style &= ~lParam;
_isVertical = ((style & TCS_VERTICAL) != 0);
_isMultiLine = ((style & TCS_MULTILINE) != 0);
::SetWindowLongPtr(hwnd, GWL_STYLE, style); ::SetWindowLongPtr(hwnd, GWL_STYLE, style);
::InvalidateRect(hwnd, NULL, TRUE); ::InvalidateRect(hwnd, NULL, TRUE);
@ -705,11 +698,16 @@ 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 bool isForward = ((short)HIWORD(wParam)) < 0; // wheel rotation towards the user will be considered as forward direction
const int lastTabIndex = static_cast<int32_t>(::SendMessage(_hSelf, TCM_GETITEMCOUNT, 0, 0) - 1); const int lastTabIndex = static_cast<int32_t>(::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)) if ((wParam & MK_CONTROL) && (wParam & MK_SHIFT))
{ {
setActiveTab((isForward ? lastTabIndex : 0)); setActiveTab((isForward ? lastTabIndex : 0));
} }
else if ((wParam & MK_SHIFT) && _doDragNDrop) else if ((wParam & MK_SHIFT) && doDragNDrop)
{ {
int oldTabIndex = static_cast<int32_t>(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0)); int oldTabIndex = static_cast<int32_t>(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0));
int newTabIndex = oldTabIndex + (isForward ? 1 : -1); int newTabIndex = oldTabIndex + (isForward ? 1 : -1);
@ -747,7 +745,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
} }
setActiveTab(tabIndex); 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{}; RECT rcTabCtrl{}, rcLastTab{};
::SendMessage(_hSelf, TCM_GETITEMRECT, lastTabIndex, reinterpret_cast<LPARAM>(&rcLastTab)); ::SendMessage(_hSelf, TCM_GETITEMRECT, lastTabIndex, reinterpret_cast<LPARAM>(&rcLastTab));
@ -759,7 +757,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
hti.pt = { xy, xy }; hti.pt = { xy, xy };
int scrollTabIndex = static_cast<int32_t>(::SendMessage(_hSelf, TCM_HITTEST, 0, reinterpret_cast<LPARAM>(&hti))); int scrollTabIndex = static_cast<int32_t>(::SendMessage(_hSelf, TCM_HITTEST, 0, reinterpret_cast<LPARAM>(&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; return TRUE;
// maximal width/height of the msctls_updown32 class (arrow box in the tab bar), // 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 LONG maxLengthUpDownCtrl = _dpiManager.scale(44); // sufficient static value
// scroll forward as long as the last tab is hidden; scroll backward till the first tab // 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) if (isForward)
++scrollTabIndex; ++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); _whichCloseClickDown = getTabIndexAt(xPos, yPos);
::SendMessage(_hParent, WM_SIZE, 0, 0); ::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); _whichPinClickDown = getTabIndexAt(xPos, yPos);
::SendMessage(_hParent, WM_SIZE, 0, 0); ::SendMessage(_hParent, WM_SIZE, 0, 0);
@ -832,7 +835,8 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
if (wParam == 2) if (wParam == 2)
return TRUE; return TRUE;
if (_doDragNDrop) bool doDragNDrop = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_DRAGNDROP;
if (doDragNDrop)
{ {
_mightBeDragging = true; _mightBeDragging = true;
} }
@ -940,7 +944,12 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
// do nothing // 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; RECT currentHoverTabRectOld = _currentHoverTabRect;
bool isCloseHoverOld = _isCloseHover; 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 if (_currentHoverTabItem != -1) // tab item is being hovered
{ {
::SendMessage(_hSelf, TCM_GETITEMRECT, _currentHoverTabItem, reinterpret_cast<LPARAM>(&_currentHoverTabRect)); ::SendMessage(_hSelf, TCM_GETITEMRECT, _currentHoverTabItem, reinterpret_cast<LPARAM>(&_currentHoverTabRect));
_isCloseHover = _closeButtonZone.isHit(p.x, p.y, _currentHoverTabRect, _isVertical); _isCloseHover = _closeButtonZone.isHit(p.x, p.y, _currentHoverTabRect, isVertical);
} }
else else
{ {
@ -980,7 +989,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
} }
} }
if (_drawTabPinButton) if (drawTabPinButton)
{ {
RECT currentHoverTabRectOld = _currentHoverTabRect; RECT currentHoverTabRectOld = _currentHoverTabRect;
bool isPinHoverOld = _isPinHover; 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 if (_currentHoverTabItem != -1) // tab item is being hovered
{ {
::SendMessage(_hSelf, TCM_GETITEMRECT, _currentHoverTabItem, reinterpret_cast<LPARAM>(&_currentHoverTabRect)); ::SendMessage(_hSelf, TCM_GETITEMRECT, _currentHoverTabItem, reinterpret_cast<LPARAM>(&_currentHoverTabRect));
_isPinHover = _pinButtonZone.isHit(p.x, p.y, _currentHoverTabRect, _isVertical); _isPinHover = _pinButtonZone.isHit(p.x, p.y, _currentHoverTabRect, isVertical);
} }
else else
{ {
@ -1065,9 +1074,14 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
return TRUE; 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); notify(TCN_TABDELETE, currentTabOn);
_whichCloseClickDown = -1; _whichCloseClickDown = -1;
@ -1080,16 +1094,16 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
if (nextTab != -1) if (nextTab != -1)
{ {
::SendMessage(_hSelf, TCM_GETITEMRECT, nextTab, reinterpret_cast<LPARAM>(&_currentHoverTabRect)); ::SendMessage(_hSelf, TCM_GETITEMRECT, nextTab, reinterpret_cast<LPARAM>(&_currentHoverTabRect));
_isCloseHover = _closeButtonZone.isHit(xPos, yPos, _currentHoverTabRect, _isVertical); _isCloseHover = _closeButtonZone.isHit(xPos, yPos, _currentHoverTabRect, isVertical);
} }
return TRUE; return TRUE;
} }
_whichCloseClickDown = -1; _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); notify(TCN_TABPINNED, currentTabOn);
_whichPinClickDown = -1; _whichPinClickDown = -1;
@ -1102,7 +1116,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
if (nextTab != -1) if (nextTab != -1)
{ {
::SendMessage(_hSelf, TCM_GETITEMRECT, nextTab, reinterpret_cast<LPARAM>(&_currentHoverTabRect)); ::SendMessage(_hSelf, TCM_GETITEMRECT, nextTab, reinterpret_cast<LPARAM>(&_currentHoverTabRect));
_isPinHover = _pinButtonZone.isHit(xPos, yPos, _currentHoverTabRect, _isVertical); _isPinHover = _pinButtonZone.isHit(xPos, yPos, _currentHoverTabRect, isVertical);
} }
return TRUE; return TRUE;
} }
@ -1147,7 +1161,8 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
{ {
if (_isDbClk2Close) bool isDbClk2Close = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_DBCLK2CLOSE;
if (isDbClk2Close)
{ {
int xPos = LOWORD(lParam); int xPos = LOWORD(lParam);
int yPos = HIWORD(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 nTabs = TabCtrl_GetItemCount(hwnd);
int nFocusTab = TabCtrl_GetCurFocus(hwnd); int nFocusTab = TabCtrl_GetCurFocus(hwnd);
int nSelTab = TabCtrl_GetCurSel(hwnd); int nSelTab = TabCtrl_GetCurSel(hwnd);
NppGUI& nppGUI = NppParameters::getInstance().getNppGUI();
bool isVertical = nppGUI._tabStatus & TAB_VERTICAL;
for (int i = 0; i < nTabs; ++i) for (int i = 0; i < nTabs; ++i)
{ {
DRAWITEMSTRUCT dis = { ODT_TAB, id, (UINT)i, ODA_DRAWENTIRE, ODS_DEFAULT, hwnd, hdc, {}, 0 }; 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 (!hasMultipleLines)
{ {
if (_isVertical) if (isVertical)
{ {
POINT edges[] = { POINT edges[] = {
{dis.rcItem.left, dis.rcItem.bottom - 1}, {dis.rcItem.left, dis.rcItem.bottom - 1},
@ -1271,7 +1290,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
RECT rcFirstTab{}; RECT rcFirstTab{};
TabCtrl_GetItemRect(hwnd, 0, &rcFirstTab); TabCtrl_GetItemRect(hwnd, 0, &rcFirstTab);
if (_isVertical) if (isVertical)
{ {
POINT edges[] = { POINT edges[] = {
{rcFirstTab.left, rcFirstTab.top}, {rcFirstTab.left, rcFirstTab.top},
@ -1385,6 +1404,13 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
::FillRect(hDC, &rect, hBrush); ::FillRect(hDC, &rect, hBrush);
::DeleteObject(static_cast<HGDIOBJ>(hBrush)); ::DeleteObject(static_cast<HGDIOBJ>(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 // equalize drawing areas of active and inactive tabs
int paddingDynamicTwoX = _dpiManager.scale(2); int paddingDynamicTwoX = _dpiManager.scale(2);
int paddingDynamicTwoY = paddingDynamicTwoX; int paddingDynamicTwoY = paddingDynamicTwoX;
@ -1395,20 +1421,20 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
const int yEdge = _dpiManager.getSystemMetricsForDpi(SM_CYEDGE); const int yEdge = _dpiManager.getSystemMetricsForDpi(SM_CYEDGE);
::InflateRect(&rect, -xEdge, -yEdge); ::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) // 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.left += drawTopBar ? paddingDynamicTwoX : 0;
rect.right -= _drawTopBar ? 0 : paddingDynamicTwoX; rect.right -= drawTopBar ? 0 : paddingDynamicTwoX;
} }
else else
{ {
rect.top += _drawTopBar ? paddingDynamicTwoY : 0; rect.top += drawTopBar ? paddingDynamicTwoY : 0;
rect.bottom -= _drawTopBar ? 0 : paddingDynamicTwoY; rect.bottom -= drawTopBar ? 0 : paddingDynamicTwoY;
} }
} }
else else
{ {
if (_isVertical) if (isVertical)
{ {
rect.left += paddingDynamicTwoX; rect.left += paddingDynamicTwoX;
rect.right += 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); const bool hasMultipleLines = ((::GetWindowLongPtr(_hSelf, GWL_STYLE) & TCS_BUTTONS) == TCS_BUTTONS);
if (hasMultipleLines) if (hasMultipleLines)
{ {
if (_isVertical) if (isVertical)
{ {
rect.left -= paddingDynamicTwoX; rect.left -= paddingDynamicTwoX;
} }
@ -1449,10 +1475,10 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
::FillRect(hDC, &pDrawItemStruct->rcItem, hBrush); ::FillRect(hDC, &pDrawItemStruct->rcItem, hBrush);
::DeleteObject(static_cast<HGDIOBJ>(hBrush)); ::DeleteObject(static_cast<HGDIOBJ>(hBrush));
if (_drawTopBar) if (drawTopBar)
{ {
int topBarHeight = _dpiManager.scale(4); int topBarHeight = _dpiManager.scale(4);
if (_isVertical) if (isVertical)
{ {
barRect.left -= (hasMultipleLines && isDarkMode) ? 0 : paddingDynamicTwoX; barRect.left -= (hasMultipleLines && isDarkMode) ? 0 : paddingDynamicTwoX;
barRect.right = barRect.left + topBarHeight; barRect.right = barRect.left + topBarHeight;
@ -1482,7 +1508,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
RECT inactiveRect = hasMultipleLines ? pDrawItemStruct->rcItem : barRect; RECT inactiveRect = hasMultipleLines ? pDrawItemStruct->rcItem : barRect;
COLORREF brushColour{}; COLORREF brushColour{};
if (_drawInactiveTab && individualColourId == -1) if (drawInactiveTab && individualColourId == -1)
{ {
brushColour = colorInactiveBg; brushColour = colorInactiveBg;
} }
@ -1512,7 +1538,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
} }
// draw close button // draw close button
if (_drawTabCloseButton && _hCloseBtnImgLst != nullptr) if (drawTabCloseButton && _hCloseBtnImgLst != nullptr)
{ {
// 3 status for each inactive tab and selected tab close item : // 3 status for each inactive tab and selected tab close item :
// normal / hover / pushed // normal / hover / pushed
@ -1534,14 +1560,14 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
idxCloseImg = (_currentHoverTabItem == nTab) ? _closeTabHoverOnTabIdx : _closeTabInactIdx; 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); ::ImageList_Draw(_hCloseBtnImgLst, idxCloseImg, hDC, buttonRect.left, buttonRect.top, ILD_TRANSPARENT);
} }
// draw pin button // draw pin button
Buffer* buf = reinterpret_cast<Buffer*>(tci.lParam); Buffer* buf = reinterpret_cast<Buffer*>(tci.lParam);
if (_drawTabPinButton && _hPinBtnImgLst != nullptr && buf) if (drawTabPinButton && _hPinBtnImgLst != nullptr && buf)
{ {
// Each tab combined with the following stats : // Each tab combined with the following stats :
// (active / inactive) | (pinned / unpinned) | (hover / not hover / pushed) // (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); ::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 fromBorder;
int xPos, yPos; int xPos, yPos;
if (_isVertical) if (isVertical)
{ {
fromBorder = (rect.right - rect.left - (imageRect.right - imageRect.left) + 1) / 2; fromBorder = (rect.right - rect.left - (imageRect.right - imageRect.left) + 1) / 2;
xPos = rect.left + fromBorder; xPos = rect.left + fromBorder;
@ -1649,14 +1675,14 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
if (isStandardSize) if (isStandardSize)
{ {
if (_isVertical) if (isVertical)
SelectObject(hDC, _hVerticalFont); SelectObject(hDC, _hVerticalFont);
else else
SelectObject(hDC, _hFont); SelectObject(hDC, _hFont);
} }
else else
{ {
if (_isVertical) if (isVertical)
SelectObject(hDC, _hVerticalLargeFont); SelectObject(hDC, _hVerticalLargeFont);
else else
SelectObject(hDC, _hLargeFont); SelectObject(hDC, _hLargeFont);
@ -1686,7 +1712,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
*out++ = *in++; *out++ = *in++;
*out = '\0'; *out = '\0';
if (_isVertical) if (isVertical)
{ {
// center text horizontally (rotated text is positioned as if it were unrotated, therefore manual positioning is necessary) // center text horizontally (rotated text is positioned as if it were unrotated, therefore manual positioning is necessary)
flags |= DT_LEFT; flags |= DT_LEFT;
@ -1712,7 +1738,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
rect.top = pDrawItemStruct->rcItem.top + paddingText + paddingDescent; rect.top = pDrawItemStruct->rcItem.top + paddingText + paddingDescent;
rect.bottom = pDrawItemStruct->rcItem.bottom - paddingText + paddingDescent; rect.bottom = pDrawItemStruct->rcItem.bottom - paddingText + paddingDescent;
if (isDarkMode || !isSelected || _drawTopBar) if (isDarkMode || !isSelected || drawTopBar)
{ {
rect.top += paddingDynamicTwoY; rect.top += paddingDynamicTwoY;
} }

View File

@ -113,14 +113,6 @@ public:
void setFont(); void setFont();
void setVertical(bool b) {
_isVertical = b;
};
void setMultiLine(bool b) {
_isMultiLine = b;
};
HFONT& getFont(bool isReduced = true) { HFONT& getFont(bool isReduced = true) {
return isReduced ? _hFont : _hLargeFont; return isReduced ? _hFont : _hLargeFont;
} }
@ -138,10 +130,6 @@ protected:
HFONT _hVerticalFont = nullptr; HFONT _hVerticalFont = nullptr;
HFONT _hVerticalLargeFont = nullptr; HFONT _hVerticalLargeFont = nullptr;
int _ctrlID = 0;
bool _isVertical = false;
bool _isMultiLine = false;
DPIManagerV2 _dpiManager; DPIManagerV2 _dpiManager;
@ -182,18 +170,10 @@ public :
id0, id1, id2, id3, id4, id5, id6, id7, id8, id9 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 init(HINSTANCE hInst, HWND hwnd, bool isVertical, bool isMultiLine, unsigned char buttonsStatus = 0);
void destroy() override; void destroy() override;
static bool doDragNDropOrNot() {
return _doDragNDrop;
};
POINT getDraggingPoint() const { POINT getDraggingPoint() const {
return _draggingPoint; return _draggingPoint;
}; };
@ -203,58 +183,11 @@ public :
_draggingPoint.y = 0; _draggingPoint.y = 0;
}; };
static void doOwnerDrawTab(TabBarPlus* tbpObj); static void triggerOwnerDrawTabbar(DPIManagerV2* pDPIManager);
static void doVertical(); static void doVertical();
static void doMultiLine(); 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) { static void setColour(COLORREF colour2Set, tabColourIndex i, DPIManagerV2* pDPIManager);
_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);
virtual int getIndividualTabColourId(int tabIndex) = 0; virtual int getIndividualTabColourId(int tabIndex) = 0;
void tabToStart(int index = -1); void tabToStart(int index = -1);
@ -279,9 +212,7 @@ public :
} }
protected: protected:
// it's the boss to decide if we do the drag N drop // drag & drop members
static bool _doDragNDrop;
// drag N drop members
bool _mightBeDragging = false; bool _mightBeDragging = false;
int _dragCount = 0; int _dragCount = 0;
bool _isDragging = false; bool _isDragging = false;
@ -329,17 +260,6 @@ protected:
bool exchangeTabItemData(int oldTab, int newTab); bool exchangeTabItemData(int oldTab, int newTab);
void exchangeItemData(POINT point); 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 _activeTextColour;
static COLORREF _activeTopBarFocusedColour; static COLORREF _activeTopBarFocusedColour;
static COLORREF _activeTopBarUnfocusedColour; static COLORREF _activeTopBarUnfocusedColour;
@ -347,7 +267,7 @@ protected:
static COLORREF _inactiveBgColour; static COLORREF _inactiveBgColour;
static int _nbCtrl; static int _nbCtrl;
static HWND _hwndArray[nbCtrlMax]; static HWND _tabbrPlusInstanceHwndArray[nbCtrlMax];
void drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode = false); void drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode = false);
void draggingCursor(POINT screenPoint); void draggingCursor(POINT screenPoint);

View File

@ -722,10 +722,10 @@
#define NPPM_INTERNAL_DRAWTABBARCLOSEBUTTON (NOTEPADPLUS_USER_INTERNAL + 81) #define NPPM_INTERNAL_DRAWTABBARCLOSEBUTTON (NOTEPADPLUS_USER_INTERNAL + 81)
#define NPPM_INTERNAL_DRAWINACTIVETABBARBUTTON (NOTEPADPLUS_USER_INTERNAL + 82) #define NPPM_INTERNAL_DRAWINACTIVETABBARBUTTON (NOTEPADPLUS_USER_INTERNAL + 82)
#define NPPM_INTERNAL_REDUCETABBAR (NOTEPADPLUS_USER_INTERNAL + 83) #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_DRAWINACIVETAB (NOTEPADPLUS_USER_INTERNAL + 85)
#define NPPM_INTERNAL_DRAWTABTOPBAR (NOTEPADPLUS_USER_INTERNAL + 86) #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_VERTICALTABBAR (NOTEPADPLUS_USER_INTERNAL + 88)
#define NPPM_INTERNAL_MULTILINETABBAR (NOTEPADPLUS_USER_INTERNAL + 89) #define NPPM_INTERNAL_MULTILINETABBAR (NOTEPADPLUS_USER_INTERNAL + 89)
#define NPPM_INTERNAL_TOOLBARREDUCE (NOTEPADPLUS_USER_INTERNAL + 90) #define NPPM_INTERNAL_TOOLBARREDUCE (NOTEPADPLUS_USER_INTERNAL + 90)