diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index a0429f657..c34fee002 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -49,9 +49,6 @@ enum tb_stat {tb_saved, tb_unsaved, tb_ro, tb_monitored}; #define DIR_LEFT true #define DIR_RIGHT 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 }; ToolBarButtonUnit toolBarIcons[] = { @@ -228,17 +225,7 @@ LRESULT Notepad_plus::init(HWND hwnd) const ScintillaViewParams & svp = nppParam.getSVP(); int tabBarStatus = nppGUI._tabStatus; - - _toReduceTabBar = ((tabBarStatus & TAB_REDUCE) != 0); - int iconDpiDynamicalSize = nppParam._dpiManager.scaleX(g_TabIconSize); - _docTabIconList.create(iconDpiDynamicalSize, _pPublicInterface->getHinst(), docTabIconIDs, sizeof(docTabIconIDs) / sizeof(int)); - _docTabIconListAlt.create(iconDpiDynamicalSize, _pPublicInterface->getHinst(), docTabIconIDs_alt, sizeof(docTabIconIDs_alt) / sizeof(int)); - _docTabIconListDarkMode.create(iconDpiDynamicalSize, _pPublicInterface->getHinst(), docTabIconIDs_darkMode, sizeof(docTabIconIDs_darkMode) / sizeof(int)); - - vector pIconListVector; - pIconListVector.push_back(&_docTabIconList); // 0 - pIconListVector.push_back(&_docTabIconListAlt); // 1 - pIconListVector.push_back(&_docTabIconListDarkMode);// 2 + TabBarPlus::setReduced((tabBarStatus & TAB_REDUCE) != 0); const int tabIconSet = NppDarkMode::getTabIconSet(NppDarkMode::isEnabled()); unsigned char indexDocTabIcon = 0; @@ -268,8 +255,11 @@ LRESULT Notepad_plus::init(HWND hwnd) } } - _mainDocTab.init(_pPublicInterface->getHinst(), hwnd, &_mainEditView, pIconListVector, indexDocTabIcon); - _subDocTab.init(_pPublicInterface->getHinst(), hwnd, &_subEditView, pIconListVector, indexDocTabIcon); + _mainDocTab.dpiManager().setDpiWithParent(hwnd); + _subDocTab.dpiManager().setDpiWithParent(hwnd); + + _mainDocTab.init(_pPublicInterface->getHinst(), hwnd, &_mainEditView, indexDocTabIcon); + _subDocTab.init(_pPublicInterface->getHinst(), hwnd, &_subEditView, indexDocTabIcon); _mainEditView.display(); @@ -382,15 +372,19 @@ LRESULT Notepad_plus::init(HWND hwnd) TabBarPlus::doDragNDrop(true); - const auto& hf = _mainDocTab.getFont(_toReduceTabBar); + const auto& hf = _mainDocTab.getFont(TabBarPlus::isReduced()); 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 = nppParam._dpiManager.scaleY(_toReduceTabBar ? g_TabHeight : g_TabHeightLarge); - int tabDpiDynamicalWidth = nppParam._dpiManager.scaleX(g_TabWidth); + int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(TabBarPlus::isReduced() ? g_TabHeight : g_TabHeightLarge); + int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? g_TabWidthCloseBtn : g_TabWidth); + + TabCtrl_SetPadding(_mainDocTab.getHSelf(), _mainDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? 10 : 6), 0); + TabCtrl_SetPadding(_subDocTab.getHSelf(), _subDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? 10 : 6), 0); + TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); @@ -398,9 +392,9 @@ LRESULT Notepad_plus::init(HWND hwnd) TabBarPlus::doDragNDrop((tabBarStatus & TAB_DRAGNDROP) != 0); - TabBarPlus::setDrawTopBar((tabBarStatus & TAB_DRAWTOPBAR) != 0); - TabBarPlus::setDrawInactiveTab((tabBarStatus & TAB_DRAWINACTIVETAB) != 0); - TabBarPlus::setDrawTabCloseButton((tabBarStatus & TAB_CLOSEBUTTON) != 0); + TabBarPlus::setDrawTopBar((tabBarStatus & TAB_DRAWTOPBAR) != 0, &_mainDocTab); + TabBarPlus::setDrawInactiveTab((tabBarStatus & TAB_DRAWINACTIVETAB) != 0, &_mainDocTab); + TabBarPlus::setDrawTabCloseButton((tabBarStatus & TAB_CLOSEBUTTON) != 0, &_mainDocTab); TabBarPlus::setDbClk2Close((tabBarStatus & TAB_DBCLK2CLOSE) != 0); TabBarPlus::setVertical((tabBarStatus & TAB_VERTICAL) != 0); drawTabbarColoursFromStylerArray(); @@ -896,14 +890,14 @@ 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) | \ - (_toReduceTabBar?TAB_REDUCE:0) | \ - (TabBarPlus::drawTabCloseButton()?TAB_CLOSEBUTTON:0) | \ - (TabBarPlus::isDbClk2Close()?TAB_DBCLK2CLOSE:0) | \ - (TabBarPlus::isVertical() ? TAB_VERTICAL:0) | \ - (TabBarPlus::isMultiLine() ? TAB_MULTILINE:0) |\ + 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::isDbClk2Close() ? TAB_DBCLK2CLOSE : 0) | \ + (TabBarPlus::isVertical() ? TAB_VERTICAL : 0) | \ + (TabBarPlus::isMultiLine() ? TAB_MULTILINE : 0) |\ (nppGUI._tabStatus & TAB_HIDE) | \ (nppGUI._tabStatus & TAB_QUITONEMPTY) | \ (nppGUI._tabStatus & TAB_ALTICONS); @@ -6291,21 +6285,21 @@ void Notepad_plus::drawTabbarColoursFromStylerArray() { Style *stActText = getStyleFromName(TABBAR_ACTIVETEXT); if (stActText && static_cast(stActText->_fgColor) != -1) - TabBarPlus::setColour(stActText->_fgColor, TabBarPlus::activeText); + TabBarPlus::setColour(stActText->_fgColor, TabBarPlus::activeText, &_mainDocTab); Style *stActfocusTop = getStyleFromName(TABBAR_ACTIVEFOCUSEDINDCATOR); if (stActfocusTop && static_cast(stActfocusTop->_fgColor) != -1) - TabBarPlus::setColour(stActfocusTop->_fgColor, TabBarPlus::activeFocusedTop); + TabBarPlus::setColour(stActfocusTop->_fgColor, TabBarPlus::activeFocusedTop, &_mainDocTab); Style *stActunfocusTop = getStyleFromName(TABBAR_ACTIVEUNFOCUSEDINDCATOR); if (stActunfocusTop && static_cast(stActunfocusTop->_fgColor) != -1) - TabBarPlus::setColour(stActunfocusTop->_fgColor, TabBarPlus::activeUnfocusedTop); + TabBarPlus::setColour(stActunfocusTop->_fgColor, TabBarPlus::activeUnfocusedTop, &_mainDocTab); Style *stInact = getStyleFromName(TABBAR_INACTIVETEXT); if (stInact && static_cast(stInact->_fgColor) != -1) - TabBarPlus::setColour(stInact->_fgColor, TabBarPlus::inactiveText); + TabBarPlus::setColour(stInact->_fgColor, TabBarPlus::inactiveText, &_mainDocTab); if (stInact && static_cast(stInact->_bgColor) != -1) - TabBarPlus::setColour(stInact->_bgColor, TabBarPlus::inactiveBg); + TabBarPlus::setColour(stInact->_bgColor, TabBarPlus::inactiveBg, &_mainDocTab); } void Notepad_plus::drawAutocompleteColoursFromTheme(COLORREF fgColor, COLORREF bgColor) @@ -7188,29 +7182,14 @@ void Notepad_plus::launchDocumentListPanel(bool changeFromBtnCmd) _pDocumentListPanel = new VerticalFileSwitcher; - HIMAGELIST hImgLst = nullptr; - const int tabIconSet = changeFromBtnCmd ? -1 : NppDarkMode::getTabIconSet(NppDarkMode::isEnabled()); - switch (tabIconSet) - { - case 0: - { - hImgLst = _docTabIconList.getHandle(); - break; - } - case 1: - { - hImgLst = _docTabIconListAlt.getHandle(); - break; - } - case 2: - { - hImgLst = _docTabIconListDarkMode.getHandle(); - break; - } - //case -1: - default: - hImgLst = (((tabBarStatus & TAB_ALTICONS) == TAB_ALTICONS) ? _docTabIconListAlt.getHandle() : NppDarkMode::isEnabled() ? _docTabIconListDarkMode.getHandle() : _docTabIconList.getHandle()); - } + + int tabIconSet = changeFromBtnCmd ? -1 : NppDarkMode::getTabIconSet(NppDarkMode::isEnabled()); + + if (tabIconSet == -1) + tabIconSet = (((tabBarStatus & TAB_ALTICONS) == TAB_ALTICONS) ? 1 : NppDarkMode::isEnabled() ? 2 : 0); + + HIMAGELIST hImgLst = _mainDocTab.getImgLst(tabIconSet); + _pDocumentListPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), hImgLst); NativeLangSpeaker *pNativeSpeaker = nppParams.getNativeLangSpeaker(); @@ -7254,6 +7233,41 @@ void Notepad_plus::launchDocumentListPanel(bool changeFromBtnCmd) _pDocumentListPanel->display(); } +void Notepad_plus::changeDocumentListIconSet(bool changeFromBtnCmd) +{ + //restart document list with the same icons as the DocTabs + if (_pDocumentListPanel) + { + if (!_pDocumentListPanel->isClosed()) // if doclist is open + { + //close the doclist + _pDocumentListPanel->display(false); + + //clean doclist + _pDocumentListPanel->destroy(); + _pDocumentListPanel = nullptr; + + //relaunch with new icons + launchDocumentListPanel(changeFromBtnCmd); + } + else //if doclist is closed + { + //clean doclist + _pDocumentListPanel->destroy(); + _pDocumentListPanel = nullptr; + + //relaunch doclist with new icons and close it + launchDocumentListPanel(changeFromBtnCmd); + if (_pDocumentListPanel) + { + _pDocumentListPanel->display(false); + _pDocumentListPanel->setClosed(true); + checkMenuItem(IDM_VIEW_DOCLIST, false); + _toolBar.setCheck(IDM_VIEW_DOCLIST, false); + } + } + } +} void Notepad_plus::launchAnsiCharPanel() { @@ -8327,14 +8341,14 @@ void Notepad_plus::refreshDarkMode(bool resetStyle) if (tabIconSet != -1) { _preference._generalSubDlg.setTabbarAlternateIcons(tabIconSet == 1); - ::SendMessage(_pPublicInterface->getHSelf(), NPPM_INTERNAL_CHANGETABBAEICONS, static_cast(false), tabIconSet); + ::SendMessage(_pPublicInterface->getHSelf(), NPPM_INTERNAL_CHANGETABBARICONSET, static_cast(false), tabIconSet); } else { const bool isChecked = _preference._generalSubDlg.isCheckedOrNot(IDC_CHECK_TAB_ALTICONS); if (!isChecked) { - ::SendMessage(_pPublicInterface->getHSelf(), NPPM_INTERNAL_CHANGETABBAEICONS, static_cast(false), NppDarkMode::isEnabled() ? 2 : 0); + ::SendMessage(_pPublicInterface->getHSelf(), NPPM_INTERNAL_CHANGETABBARICONSET, static_cast(false), NppDarkMode::isEnabled() ? 2 : 0); } } diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 294563dc7..4afcb8e36 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -299,12 +299,8 @@ private: ContextMenu _fileSwitcherMultiFilePopupMenu; ToolBar _toolBar; - IconList _docTabIconList; - IconList _docTabIconListAlt; - IconList _docTabIconListDarkMode; StatusBar _statusBar; - bool _toReduceTabBar = false; ReBar _rebarTop; ReBar _rebarBottom; @@ -618,6 +614,7 @@ private: void launchAnsiCharPanel(); void launchClipboardHistoryPanel(); void launchDocumentListPanel(bool changeFromBtnCmd = false); + void changeDocumentListIconSet(bool changeFromBtnCmd); void checkProjectMenuItem(); void launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int panelID); void launchDocMap(); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index f89e768d3..e7ceaab10 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -915,44 +915,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } - case NPPM_INTERNAL_CHANGETABBAEICONS: + case NPPM_INTERNAL_CHANGETABBARICONSET: { - _mainDocTab.changeIcons(static_cast(lParam)); - _subDocTab.changeIcons(static_cast(lParam)); - - //restart document list with the same icons as the DocTabs - if (_pDocumentListPanel) - { - if (!_pDocumentListPanel->isClosed()) // if doclist is open - { - //close the doclist - _pDocumentListPanel->display(false); - - //clean doclist - _pDocumentListPanel->destroy(); - _pDocumentListPanel = nullptr; - - //relaunch with new icons - launchDocumentListPanel(static_cast(wParam)); - } - else //if doclist is closed - { - //clean doclist - _pDocumentListPanel->destroy(); - _pDocumentListPanel = nullptr; - - //relaunch doclist with new icons and close it - launchDocumentListPanel(static_cast(wParam)); - if (_pDocumentListPanel) - { - _pDocumentListPanel->display(false); - _pDocumentListPanel->setClosed(true); - checkMenuItem(IDM_VIEW_DOCLIST, false); - _toolBar.setCheck(IDM_VIEW_DOCLIST, false); - } - } - } + _mainDocTab.changeIconSet(static_cast(lParam)); + _subDocTab.changeIconSet(static_cast(lParam)); + changeDocumentListIconSet(static_cast(wParam)); return TRUE; } @@ -1921,7 +1889,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_ISTABBARREDUCED: { - return _toReduceTabBar?TRUE:FALSE; + return TabBarPlus::isReduced() ? TRUE : FALSE; } // ADD: success->hwnd; failure->NULL @@ -3516,6 +3484,16 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa const UINT dpi = LOWORD(wParam); _toolBar.resizeIconsDpi(dpi); + _mainDocTab.dpiManager().setDpi(dpi); + _subDocTab.dpiManager().setDpi(dpi); + _mainDocTab.setFont(); + _subDocTab.setFont(); + _mainDocTab.resizeIconsDpi(); + _subDocTab.resizeIconsDpi(); + ::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, IDM_VIEW_REDUCETABBAR, 0); + + changeDocumentListIconSet(false); + _statusBar.setPartWidth(STATUSBAR_DOC_SIZE, DPIManagerV2::scale(220, dpi)); _statusBar.setPartWidth(STATUSBAR_CUR_POS, DPIManagerV2::scale(260, dpi)); _statusBar.setPartWidth(STATUSBAR_EOF_FORMAT, DPIManagerV2::scale(110, dpi)); diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 073d1c4d4..8b4881b51 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -2273,17 +2273,20 @@ void Notepad_plus::command(int id) case IDM_VIEW_REDUCETABBAR: { - _toReduceTabBar = !_toReduceTabBar; - auto& dpiManager = NppParameters::getInstance()._dpiManager; + bool isReduceed = TabBarPlus::isReduced(); //Resize the tab height - int tabDpiDynamicalWidth = dpiManager.scaleX(g_TabWidth); - int tabDpiDynamicalHeight = dpiManager.scaleY(_toReduceTabBar ? g_TabHeight : g_TabHeightLarge); + int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? g_TabWidthCloseBtn : g_TabWidth); + int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(isReduceed ? g_TabHeight : g_TabHeightLarge); + + TabCtrl_SetPadding(_mainDocTab.getHSelf(), _mainDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? 10 : 6), 0); + TabCtrl_SetPadding(_subDocTab.getHSelf(), _subDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? 10 : 6), 0); + TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); //change the font - const auto& hf = _mainDocTab.getFont(_toReduceTabBar); + const auto& hf = _mainDocTab.getFont(isReduceed); if (hf) { ::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, reinterpret_cast(hf), MAKELPARAM(TRUE, 0)); @@ -2309,23 +2312,22 @@ void Notepad_plus::command(int id) case IDM_VIEW_DRAWTABBAR_INACIVETAB: { - TabBarPlus::setDrawInactiveTab(!TabBarPlus::drawInactiveTab()); + TabBarPlus::setDrawInactiveTab(!TabBarPlus::drawInactiveTab(), &_mainDocTab); break; } case IDM_VIEW_DRAWTABBAR_TOPBAR: { - TabBarPlus::setDrawTopBar(!TabBarPlus::drawTopBar()); + TabBarPlus::setDrawTopBar(!TabBarPlus::drawTopBar(), &_mainDocTab); break; } case IDM_VIEW_DRAWTABBAR_CLOSEBOTTUN: { - TabBarPlus::setDrawTabCloseButton(!TabBarPlus::drawTabCloseButton()); - auto& dpiManager = NppParameters::getInstance()._dpiManager; + TabBarPlus::setDrawTabCloseButton(!TabBarPlus::drawTabCloseButton(), &_mainDocTab); // This part is just for updating (redraw) the tabs - int tabDpiDynamicalHeight = dpiManager.scaleY(_toReduceTabBar ? g_TabHeight : g_TabHeightLarge); - int tabDpiDynamicalWidth = dpiManager.scaleX(TabBarPlus::drawTabCloseButton() ? g_TabWidthCloseBtn : g_TabWidth); + int tabDpiDynamicalHeight = _mainDocTab.dpiManager().scale(TabBarPlus::isReduced() ? g_TabHeight : g_TabHeightLarge); + int tabDpiDynamicalWidth = _mainDocTab.dpiManager().scale(TabBarPlus::drawTabCloseButton() ? g_TabWidthCloseBtn : g_TabWidth); TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); @@ -3812,25 +3814,9 @@ void Notepad_plus::command(int id) if (TaskListDlg::_instanceCount == 0) { TaskListDlg tld; - HIMAGELIST hImgLst = nullptr; const int tabIconSet = NppDarkMode::getTabIconSet(NppDarkMode::isEnabled()); - switch (tabIconSet) - { - case 1: - { - hImgLst = _docTabIconListAlt.getHandle(); - break; - } - case 2: - { - hImgLst = _docTabIconListDarkMode.getHandle(); - break; - } - //case 0: - //case -1: - default: - hImgLst = _docTabIconList.getHandle(); - } + HIMAGELIST hImgLst = _mainDocTab.getImgLst(tabIconSet); + tld.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), hImgLst, direction); tld.doDialog(_nativeLangSpeaker.isRTL()); } diff --git a/PowerEditor/src/ScintillaComponent/DocTabView.cpp b/PowerEditor/src/ScintillaComponent/DocTabView.cpp index fb4393441..1a00960ea 100644 --- a/PowerEditor/src/ScintillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScintillaComponent/DocTabView.cpp @@ -23,9 +23,45 @@ #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 }; + + + +void DocTabView::init(HINSTANCE hInst, HWND parent, ScintillaEditView* pView, unsigned char indexChoice) +{ + TabBarPlus::init(hInst, parent); + _pView = pView; + + createIconSets(); + + _pIconListVector.push_back(&_docTabIconList); // 0 + _pIconListVector.push_back(&_docTabIconListAlt); // 1 + _pIconListVector.push_back(&_docTabIconListDarkMode); // 2 + + if (indexChoice >= _pIconListVector.size()) + _iconListIndexChoice = 0; + else + _iconListIndexChoice = indexChoice; + + if (_iconListIndexChoice != -1) + TabBar::setImageList(_pIconListVector[_iconListIndexChoice]->getHandle()); + return; +} + +void DocTabView::createIconSets() +{ + int iconDpiDynamicalSize = _dpiManager.scale(g_TabIconSize); + + _docTabIconList.create(iconDpiDynamicalSize, _hInst, docTabIconIDs, sizeof(docTabIconIDs) / sizeof(int)); + _docTabIconListAlt.create(iconDpiDynamicalSize, _hInst, docTabIconIDs_alt, sizeof(docTabIconIDs_alt) / sizeof(int)); + _docTabIconListDarkMode.create(iconDpiDynamicalSize, _hInst, docTabIconIDs_darkMode, sizeof(docTabIconIDs_darkMode) / sizeof(int)); +} + void DocTabView::addBuffer(BufferID buffer) { if (buffer == BUFFER_INVALID) //valid only @@ -48,7 +84,6 @@ void DocTabView::addBuffer(BufferID buffer) ::SendMessage(_hParent, WM_SIZE, 0, 0); } - void DocTabView::closeBuffer(BufferID buffer) { int indexToClose = getIndexByBuffer(buffer); diff --git a/PowerEditor/src/ScintillaComponent/DocTabView.h b/PowerEditor/src/ScintillaComponent/DocTabView.h index 0c9231eda..07d06dba0 100644 --- a/PowerEditor/src/ScintillaComponent/DocTabView.h +++ b/PowerEditor/src/ScintillaComponent/DocTabView.h @@ -24,6 +24,7 @@ const int UNSAVED_IMG_INDEX = 1; const int REDONLY_IMG_INDEX = 2; const int MONITORING_IMG_INDEX = 3; + class DocTabView : public TabBarPlus { public : @@ -34,26 +35,11 @@ public : TabBarPlus::destroy(); }; - void init(HINSTANCE hInst, HWND parent, ScintillaEditView * pView, std::vector pIconListVector, unsigned char indexChoice) { - TabBarPlus::init(hInst, parent); - _pView = pView; + void init(HINSTANCE hInst, HWND parent, ScintillaEditView * pView, unsigned char indexChoice); - if (!pIconListVector.empty()) - { - _pIconListVector = pIconListVector; + void createIconSets(); - if (indexChoice >= pIconListVector.size()) - _iconListIndexChoice = 0; - else - _iconListIndexChoice = indexChoice; - } - - if (_iconListIndexChoice != -1) - TabBar::setImageList(_pIconListVector[_iconListIndexChoice]->getHandle()); - return; - }; - - void changeIcons(unsigned char choice) { + void changeIconSet(unsigned char choice) { if (choice >= _pIconListVector.size()) return; _iconListIndexChoice = choice; @@ -86,17 +72,42 @@ public : void reSizeTo(RECT & rc) override; + void resizeIconsDpi() { + UINT newSize = dpiManager().scale(g_TabIconSize); + for (const auto& i : _pIconListVector) + { + ImageList_SetIconSize(i->getHandle(), newSize, newSize); + } + + createIconSets(); + + if (_iconListIndexChoice < 0 || static_cast(_iconListIndexChoice) >= _pIconListVector.size()) + _iconListIndexChoice = 0; + + TabBar::setImageList(_pIconListVector[_iconListIndexChoice]->getHandle()); + }; + const ScintillaEditView* getScintillaEditView() const { return _pView; }; void setIndividualTabColour(BufferID bufferId, int colorId); int getIndividualTabColour(int tabIndex) override; + + HIMAGELIST getImgLst(UINT index) { + if (index >= _pIconListVector.size()) + index = 0; + return _pIconListVector[index]->getHandle(); + }; private : ScintillaEditView *_pView = nullptr; static bool _hideTabBarStatus; + IconList _docTabIconList; + IconList _docTabIconListAlt; + IconList _docTabIconListDarkMode; + std::vector _pIconListVector; int _iconListIndexChoice = -1; }; diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index 1ddc9f3fc..17c8f1314 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -531,7 +531,7 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM int tabColourIndex; if ((tabColourIndex = whichTabColourIndex()) != -1) { - TabBarPlus::setColour(_pFgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex); + TabBarPlus::setColour(_pFgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex, nullptr); } else if (isDocumentMapStyle()) { @@ -548,7 +548,7 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM if ((tabColourIndex = whichTabColourIndex()) != -1) { tabColourIndex = (tabColourIndex == TabBarPlus::inactiveText ? TabBarPlus::inactiveBg : tabColourIndex); - TabBarPlus::setColour(_pBgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex); + TabBarPlus::setColour(_pBgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex, nullptr); } else if (isDocumentMapStyle()) { diff --git a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp index 2edbc984b..da3da32e3 100644 --- a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp +++ b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp @@ -19,6 +19,7 @@ #include #include "ImageListSet.h" #include "NppDarkMode.h" +#include "dpiManagerV2.h" void IconList::init(HINSTANCE hInst, int iconSize) { @@ -31,19 +32,22 @@ void IconList::init(HINSTANCE hInst, int iconSize) throw std::runtime_error("IconList::create : ImageList_Create() function returns null"); } -void IconList::create(int iconSize, HINSTANCE hInst, int *iconIDArray, int iconIDArraySize) + +void IconList::create(int iconSize, HINSTANCE hInst, int* iconIDArray, int iconIDArraySize) { init(hInst, iconSize); _pIconIDArray = iconIDArray; _iconIDArraySize = iconIDArraySize; - for (int i = 0 ; i < iconIDArraySize ; ++i) - addIcon(iconIDArray[i]); + for (int i = 0; i < iconIDArraySize; ++i) + addIcon(iconIDArray[i], iconSize, iconSize); } -void IconList::addIcon(int iconID) const +void IconList::addIcon(int iconID, int cx, int cy) const { - HICON hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(iconID)); + HICON hIcon = nullptr; + DPIManagerV2::loadIcon(_hInst, MAKEINTRESOURCE(iconID), cx, cy, &hIcon, LR_DEFAULTSIZE); + if (!hIcon) throw std::runtime_error("IconList::addIcon : LoadIcon() function return null"); @@ -99,15 +103,15 @@ void ToolBarIcons::reInit(int size) { if (_tbiis[i]._defaultIcon != -1) { - _iconListVector[HLIST_DEFAULT].addIcon(_tbiis[i]._defaultIcon); - _iconListVector[HLIST_DISABLE].addIcon(_tbiis[i]._grayIcon); - _iconListVector[HLIST_DEFAULT2].addIcon(_tbiis[i]._defaultIcon2); - _iconListVector[HLIST_DISABLE2].addIcon(_tbiis[i]._grayIcon2); + _iconListVector[HLIST_DEFAULT].addIcon(_tbiis[i]._defaultIcon, size, size); + _iconListVector[HLIST_DISABLE].addIcon(_tbiis[i]._grayIcon, size, size); + _iconListVector[HLIST_DEFAULT2].addIcon(_tbiis[i]._defaultIcon2, size, size); + _iconListVector[HLIST_DISABLE2].addIcon(_tbiis[i]._grayIcon2, size, size); - _iconListVector[HLIST_DEFAULT_DM].addIcon(_tbiis[i]._defaultDarkModeIcon); - _iconListVector[HLIST_DISABLE_DM].addIcon(_tbiis[i]._grayDarkModeIcon); - _iconListVector[HLIST_DEFAULT_DM2].addIcon(_tbiis[i]._defaultDarkModeIcon2); - _iconListVector[HLIST_DISABLE_DM2].addIcon(_tbiis[i]._grayDarkModeIcon2); + _iconListVector[HLIST_DEFAULT_DM].addIcon(_tbiis[i]._defaultDarkModeIcon, size, size); + _iconListVector[HLIST_DISABLE_DM].addIcon(_tbiis[i]._grayDarkModeIcon, size, size); + _iconListVector[HLIST_DEFAULT_DM2].addIcon(_tbiis[i]._defaultDarkModeIcon2, size, size); + _iconListVector[HLIST_DISABLE_DM2].addIcon(_tbiis[i]._grayDarkModeIcon2, size, size); } } diff --git a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h index 25bec0bc1..ccdb406d3 100644 --- a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h +++ b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h @@ -39,7 +39,7 @@ public : }; HIMAGELIST getHandle() const {return _hImglst;}; - void addIcon(int iconID) const; + void addIcon(int iconID, int cx = 32, int cy = 32) const; void addIcon(HICON hIcon) const; bool changeIcon(size_t index, const TCHAR *iconLocation) const; @@ -52,7 +52,7 @@ private : int _iconSize = 0; }; -typedef struct +struct ToolBarButtonUnit { int _cmdID; @@ -69,7 +69,7 @@ typedef struct int _grayDarkModeIcon2; int _stdIcon; -} ToolBarButtonUnit; +}; struct DynamicCmdIcoBmp { UINT _message = 0; // identification of icon in tool bar (menu ID) diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 003ffdfe8..db55410cb 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -717,15 +717,19 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM nppGUI._tabStatus ^= TAB_ALTICONS; const bool isChecked = isCheckedOrNot(IDC_CHECK_TAB_ALTICONS); const bool isBtnCmd = true; - ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_CHANGETABBAEICONS, static_cast(isBtnCmd), isChecked ? 1 : (nppGUI._darkmode._isEnabled ? 2 : 0)); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_CHANGETABBARICONSET, static_cast(isBtnCmd), isChecked ? 1 : (nppGUI._darkmode._isEnabled ? 2 : 0)); NppDarkMode::setTabIconSet(isChecked, NppDarkMode::isEnabled()); return TRUE; } - case IDC_CHECK_REDUCE : + case IDC_CHECK_REDUCE: + { + const bool isChecked = isCheckedOrNot(IDC_CHECK_REDUCE); + TabBarPlus::setReduced(isChecked); ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_REDUCETABBAR, 0); return TRUE; - + } + case IDC_CHECK_LOCK : ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_LOCKTABBAR, 0); return TRUE; diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index bea9b4b29..f9f5fd2fc 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -31,6 +31,7 @@ bool TabBarPlus::_drawTabCloseButton = false; 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); @@ -85,7 +86,6 @@ void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLin } - void TabBar::destroy() { if (_hFont) @@ -140,23 +140,6 @@ void TabBar::getCurrentTitle(TCHAR *title, int titleLen) ::SendMessage(_hSelf, TCM_GETITEM, getCurrentTabIndex(), reinterpret_cast(&tci)); } - -void TabBar::setFont(const TCHAR *fontName, int fontSize) -{ - if (_hFont) - ::DeleteObject(_hFont); - - _hFont = ::CreateFont( fontSize, 0, - (_isVertical) ? 900:0, - (_isVertical) ? 900:0, - FW_NORMAL, - 0, 0, 0, 0, - 0, 0, 0, 0, - fontName); - if (_hFont) - ::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast(_hFont), 0); -} - int TabBar::getNextOrPrevTabIdx(bool isNext) const { const HWND hTab = _hSelf; @@ -293,7 +276,12 @@ void TabBarPlus::destroy() void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLine) { Window::init(hInst, parent); - int vertical = isVertical?(TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY):0; + + const UINT dpi = DPIManagerV2::getDpiForWindow(_hParent); + _closeButtonZone.setParent(_hParent); + _dpiManager.setDpi(dpi); + + int vertical = isVertical ? (TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY) : 0; _isVertical = isVertical; _isMultiLine = isMultiLine; @@ -304,35 +292,16 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMult int multiLine = isMultiLine ? TCS_MULTILINE : 0; int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | TCS_FOCUSNEVER | TCS_TABS | vertical | multiLine; - style |= TCS_OWNERDRAWFIXED; - _hSelf = ::CreateWindowEx( - 0, - WC_TABCONTROL, - TEXT("Tab"), - style, - 0, 0, 0, 0, - _hParent, - NULL, - _hInst, - 0); + _hSelf = ::CreateWindowEx(0, WC_TABCONTROL, TEXT("Tab"), style, 0, 0, 0, 0, _hParent, NULL, _hInst, 0); if (!_hSelf) { throw std::runtime_error("TabBarPlus::init : CreateWindowEx() function return null"); } - _tooltips = ::CreateWindowEx( - 0, - TOOLTIPS_CLASS, - NULL, - TTS_ALWAYSTIP | TTS_NOPREFIX, - 0, 0, 0, 0, - _hParent, - NULL, - _hInst, - 0); + _tooltips = ::CreateWindowEx(0, TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP | TTS_NOPREFIX, 0, 0, 0, 0, _hParent, NULL, _hInst, 0); if (!_tooltips) { @@ -352,7 +321,7 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMult { int i = 0; bool found = false; - for ( ; i < nbCtrlMax && !found ; ++i) + for (; i < nbCtrlMax && !found; ++i) if (!_hwndArray[i]) found = true; if (!found) @@ -369,8 +338,24 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMult ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, reinterpret_cast(this)); _tabBarDefaultProc = reinterpret_cast(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast(TabBarPlus_Proc))); - const UINT dpi = DPIManagerV2::getDpiForWindow(_hParent); - LOGFONT lf{ DPIManagerV2::getDefaultGUIFontForDpi(dpi) }; + setFont(); +} + +void TabBar::setFont() +{ + if (_hFont) + ::DeleteObject(_hFont); + + if (_hLargeFont) + ::DeleteObject(_hLargeFont); + + if (_hVerticalFont) + ::DeleteObject(_hVerticalFont); + + if (_hVerticalLargeFont) + ::DeleteObject(_hVerticalLargeFont); + + LOGFONT lf{ DPIManagerV2::getDefaultGUIFontForDpi(_dpiManager.getDpi()) }; LOGFONT lfVer{ lf }; if (_hFont != nullptr) { @@ -378,44 +363,47 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMult _hFont = nullptr; } _hFont = ::CreateFontIndirect(&lf); + lf.lfWeight = FW_HEAVY; - lf.lfHeight = DPIManagerV2::scaleFont(10, dpi); + lf.lfHeight = DPIManagerV2::scaleFont(10, _dpiManager.getDpi()); + _hLargeFont = ::CreateFontIndirect(&lf); lfVer.lfEscapement = 900; lfVer.lfOrientation = 900; + _hVerticalFont = CreateFontIndirect(&lfVer); lfVer.lfWeight = FW_HEAVY; + _hVerticalLargeFont = CreateFontIndirect(&lfVer); } -void TabBarPlus::doOwnerDrawTab() +void TabBarPlus::doOwnerDrawTab(TabBarPlus* tbpObj) { - ::SendMessage(_hwndArray[0], TCM_SETPADDING, 0, MAKELPARAM(6, 0)); for (int i = 0 ; i < _nbCtrl ; ++i) { if (_hwndArray[i]) { LONG_PTR style = ::GetWindowLongPtr(_hwndArray[i], GWL_STYLE); - if (isOwnerDrawTab()) - style |= TCS_OWNERDRAWFIXED; - else - style &= ~TCS_OWNERDRAWFIXED; + style |= TCS_OWNERDRAWFIXED; ::SetWindowLongPtr(_hwndArray[i], GWL_STYLE, style); ::InvalidateRect(_hwndArray[i], NULL, TRUE); - const int paddingSizeDynamicW = NppParameters::getInstance()._dpiManager.scaleX(6); - const int paddingSizePlusClosebuttonDynamicW = NppParameters::getInstance()._dpiManager.scaleX(10); - ::SendMessage(_hwndArray[i], TCM_SETPADDING, 0, MAKELPARAM(_drawTabCloseButton ? paddingSizePlusClosebuttonDynamicW : paddingSizeDynamicW, 0)); + if (tbpObj) + { + const int paddingSizeDynamicW = tbpObj->_dpiManager.scale(6); + const int paddingSizePlusClosebuttonDynamicW = tbpObj->_dpiManager.scale(10); + ::SendMessage(_hwndArray[i], TCM_SETPADDING, 0, MAKELPARAM(_drawTabCloseButton ? paddingSizePlusClosebuttonDynamicW : paddingSizeDynamicW, 0)); + } } } } -void TabBarPlus::setColour(COLORREF colour2Set, tabColourIndex i) +void TabBarPlus::setColour(COLORREF colour2Set, tabColourIndex i, TabBarPlus* tbpObj) { switch (i) { @@ -437,7 +425,7 @@ void TabBarPlus::setColour(COLORREF colour2Set, tabColourIndex i) default : return; } - doOwnerDrawTab(); + doOwnerDrawTab(tbpObj); } void TabBarPlus::currentTabToStart() @@ -605,7 +593,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara // get index of the first visible tab TC_HITTESTINFO hti{}; - LONG xy = NppParameters::getInstance()._dpiManager.scaleX(12); // an arbitrary coordinate inside the first visible tab + LONG xy = _dpiManager.scale(12); // an arbitrary coordinate inside the first visible tab hti.pt = { xy, xy }; int scrollTabIndex = static_cast(::SendMessage(_hSelf, TCM_HITTEST, 0, reinterpret_cast(&hti))); @@ -614,7 +602,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara // maximal width/height of the msctls_updown32 class (arrow box in the tab bar), // this area may hide parts of the last tab and needs to be excluded - LONG maxLengthUpDownCtrl = NppParameters::getInstance()._dpiManager.scaleX(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 if ((_isVertical ? ((rcTabCtrl.bottom - rcLastTab.bottom) < maxLengthUpDownCtrl) : ((rcTabCtrl.right - rcLastTab.right) < maxLengthUpDownCtrl)) || !isForward) @@ -969,9 +957,8 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara holdClip = nullptr; } - auto& dpiManager = NppParameters::getInstance()._dpiManager; - int paddingDynamicTwoX = dpiManager.scaleX(2); - int paddingDynamicTwoY = dpiManager.scaleY(2); + int paddingDynamicTwoX = _dpiManager.scale(2); + int paddingDynamicTwoY = paddingDynamicTwoX; int nTabs = TabCtrl_GetItemCount(hwnd); int nFocusTab = TabCtrl_GetCurFocus(hwnd); @@ -1129,7 +1116,9 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode) if (!::SendMessage(_hSelf, TCM_GETITEM, nTab, reinterpret_cast(&tci))) { - ::MessageBox(NULL, TEXT("! TCM_GETITEM"), TEXT(""), MB_OK); + std::wstring errorMessageTitle = TEXT("TabBarPlus::drawItem wrong: ! TCM_GETITEM"); + std::wstring errorMessage = GetLastErrorAsString(GetLastError()); + ::MessageBox(NULL, errorMessage.c_str(), errorMessageTitle.c_str(), MB_OK); } const COLORREF colorActiveBg = isDarkMode ? NppDarkMode::getSofterBackgroundColor() : ::GetSysColor(COLOR_BTNFACE); @@ -1162,9 +1151,8 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode) ::DeleteObject((HGDIOBJ)hBrush); // equalize drawing areas of active and inactive tabs - auto& dpiManager = NppParameters::getInstance()._dpiManager; - int paddingDynamicTwoX = dpiManager.scaleX(2); - int paddingDynamicTwoY = dpiManager.scaleY(2); + int paddingDynamicTwoX = _dpiManager.scale(2); + int paddingDynamicTwoY = paddingDynamicTwoX; if (isSelected && !isDarkMode) { // the drawing area of the active tab extends on all borders by default @@ -1228,7 +1216,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode) if (_drawTopBar) { - int topBarHeight = dpiManager.scaleX(4); + int topBarHeight = _dpiManager.scale(4); if (_isVertical) { barRect.left -= (hasMultipleLines && isDarkMode) ? 0 : paddingDynamicTwoX; @@ -1303,8 +1291,8 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode) BITMAP bmp{}; ::GetObject(hBmp, sizeof(bmp), &bmp); - _closeButtonZone._width = dpiManager.scaleX(bmp.bmWidth); - _closeButtonZone._height = dpiManager.scaleY(bmp.bmHeight); + _closeButtonZone._width = _dpiManager.scale(bmp.bmWidth); + _closeButtonZone._height = _dpiManager.scale(bmp.bmHeight); RECT buttonRect = _closeButtonZone.getButtonRectFrom(rect, _isVertical); @@ -1550,7 +1538,10 @@ void TabBarPlus::exchangeItemData(POINT point) CloseButtonZone::CloseButtonZone() { // TODO: get width/height of close button dynamically - _width = NppParameters::getInstance()._dpiManager.scaleX(g_TabCloseBtnSize); + if (_parent) + { + _width = DPIManagerV2::scale(g_TabCloseBtnSize, _parent); + } _height = _width; } diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.h b/PowerEditor/src/WinControls/TabBar/TabBar.h index 5acd76176..171760a77 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.h +++ b/PowerEditor/src/WinControls/TabBar/TabBar.h @@ -27,6 +27,7 @@ #include #include #include "Window.h" +#include "dpiManagerV2.h" //Notification message #define TCN_TABDROPPED (TCN_FIRST - 10) @@ -94,7 +95,7 @@ public: return _nbItem; } - void setFont(const TCHAR *fontName, int fontSize); + void setFont(); void setVertical(bool b) { _isVertical = b; @@ -110,9 +111,12 @@ public: int getNextOrPrevTabIdx(bool isNext) const; + DPIManagerV2& dpiManager() { return _dpiManager; }; + protected: size_t _nbItem = 0; bool _hasImgLst = false; + HFONT _hFont = nullptr; HFONT _hLargeFont = nullptr; HFONT _hVerticalFont = nullptr; @@ -123,6 +127,8 @@ protected: bool _isVertical = false; bool _isMultiLine = false; + DPIManagerV2 _dpiManager; + long getRowCount() const { return long(::SendMessage(_hSelf, TCM_GETROWCOUNT, 0, 0)); } @@ -134,7 +140,9 @@ struct CloseButtonZone CloseButtonZone(); bool isHit(int x, int y, const RECT & tabRect, bool isVertical) const; RECT getButtonRectFrom(const RECT & tabRect, bool isVertical) const; + void setParent(HWND parent) { _parent = parent; } + HWND _parent = nullptr; int _width = 0; int _height = 0; }; @@ -170,30 +178,30 @@ public : _draggingPoint.y = 0; }; - static void doOwnerDrawTab(); + static void doOwnerDrawTab(TabBarPlus* tbpObj); static void doVertical(); static void doMultiLine(); - static bool isOwnerDrawTab() {return true;}; static bool drawTopBar() {return _drawTopBar;}; static bool drawInactiveTab() {return _drawInactiveTab;}; static bool drawTabCloseButton() {return _drawTabCloseButton;}; 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) { + static void setDrawTopBar(bool b, TabBarPlus* tbpObj) { _drawTopBar = b; - doOwnerDrawTab(); + doOwnerDrawTab(tbpObj); } - static void setDrawInactiveTab(bool b) { + static void setDrawInactiveTab(bool b, TabBarPlus* tbpObj) { _drawInactiveTab = b; - doOwnerDrawTab(); + doOwnerDrawTab(tbpObj); } - static void setDrawTabCloseButton(bool b) { + static void setDrawTabCloseButton(bool b, TabBarPlus* tbpObj) { _drawTabCloseButton = b; - doOwnerDrawTab(); + doOwnerDrawTab(tbpObj); } static void setDbClk2Close(bool b) { @@ -210,7 +218,11 @@ public : doMultiLine(); } - static void setColour(COLORREF colour2Set, tabColourIndex i); + static void setReduced(bool b) { + _isReduced = b; + } + + static void setColour(COLORREF colour2Set, tabColourIndex i, TabBarPlus* tbpObj); virtual int getIndividualTabColour(int tabIndex) = 0; void currentTabToStart(); @@ -256,6 +268,7 @@ protected: static bool _isDbClk2Close; static bool _isCtrlVertical; static bool _isCtrlMultiLine; + static bool _isReduced; static COLORREF _activeTextColour; static COLORREF _activeTopBarFocusedColour; diff --git a/PowerEditor/src/icons/readonly.ico.old b/PowerEditor/src/icons/readonly.ico.old deleted file mode 100644 index 001f9ceb8..000000000 Binary files a/PowerEditor/src/icons/readonly.ico.old and /dev/null differ diff --git a/PowerEditor/src/icons/saved.ico.old b/PowerEditor/src/icons/saved.ico.old deleted file mode 100644 index a8c2ab308..000000000 Binary files a/PowerEditor/src/icons/saved.ico.old and /dev/null differ diff --git a/PowerEditor/src/icons/unsaved.ico.old b/PowerEditor/src/icons/unsaved.ico.old deleted file mode 100644 index 923cadec2..000000000 Binary files a/PowerEditor/src/icons/unsaved.ico.old and /dev/null differ diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 81f6d4361..fdde35644 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -609,7 +609,7 @@ #define NPPM_INTERNAL_RELOADNATIVELANG (NOTEPADPLUS_USER_INTERNAL + 25) #define NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED (NOTEPADPLUS_USER_INTERNAL + 26) #define NPPM_INTERNAL_SCINTILLAFINDERCLEARALL (NOTEPADPLUS_USER_INTERNAL + 27) - #define NPPM_INTERNAL_CHANGETABBAEICONS (NOTEPADPLUS_USER_INTERNAL + 28) + #define NPPM_INTERNAL_CHANGETABBARICONSET (NOTEPADPLUS_USER_INTERNAL + 28) #define NPPM_INTERNAL_SETTING_TAB_REPLCESPACE (NOTEPADPLUS_USER_INTERNAL + 29) #define NPPM_INTERNAL_SETTING_TAB_SIZE (NOTEPADPLUS_USER_INTERNAL + 30) #define NPPM_INTERNAL_RELOADSTYLERS (NOTEPADPLUS_USER_INTERNAL + 31)