diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 5ec00c48e..5cb19c6fc 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -326,14 +326,14 @@ IDR_FUNC_LIST BITMAP "icons/standard/toolbar/funcList.bmp" IDR_FILEBROWSER BITMAP "icons/standard/toolbar/fileBrowser.bmp" IDR_FILEMONITORING BITMAP "icons/standard/toolbar/monitoring.bmp" -IDR_CLOSETAB BITMAP "icons/standard/tabbar/closeTabButton.bmp" -IDR_CLOSETAB_INACT BITMAP "icons/standard/tabbar/closeTabButton_inact.bmp" -IDR_CLOSETAB_HOVER BITMAP "icons/standard/tabbar/closeTabButton_hover.bmp" -IDR_CLOSETAB_PUSH BITMAP "icons/standard/tabbar/closeTabButton_push.bmp" -IDR_CLOSETAB_DM BITMAP "icons/dark/tabbar/closeTabButton.bmp" -IDR_CLOSETAB_INACT_DM BITMAP "icons/dark/tabbar/closeTabButton_inact.bmp" -IDR_CLOSETAB_HOVER_DM BITMAP "icons/dark/tabbar/closeTabButton_hover.bmp" -IDR_CLOSETAB_PUSH_DM BITMAP "icons/dark/tabbar/closeTabButton_push.bmp" +IDR_CLOSETAB ICON "icons/standard/tabbar/closeTabButton.ico" +IDR_CLOSETAB_INACT ICON "icons/standard/tabbar/closeTabButton_inact.ico" +IDR_CLOSETAB_HOVER ICON "icons/standard/tabbar/closeTabButton_hover.ico" +IDR_CLOSETAB_PUSH ICON "icons/standard/tabbar/closeTabButton_push.ico" +IDR_CLOSETAB_DM ICON "icons/dark/tabbar/closeTabButton.ico" +IDR_CLOSETAB_INACT_DM ICON "icons/dark/tabbar/closeTabButton_inact.ico" +IDR_CLOSETAB_HOVER_DM ICON "icons/dark/tabbar/closeTabButton_hover.ico" +IDR_CLOSETAB_PUSH_DM ICON "icons/dark/tabbar/closeTabButton_push.ico" IDR_DOCMAP_ICO ICON "icons/standard/panels/tabbar/docMap.ico" IDR_DOCMAP_ICO2 ICON "icons/light/panels/tabbar/docMap.ico" diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index d57e5eedc..0a0fa1201 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -3678,6 +3678,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa _subDocTab.setFont(); _mainDocTab.resizeIconsDpi(); _subDocTab.resizeIconsDpi(); + _subDocTab.setCloseBtnImageList(); + _subDocTab.setCloseBtnImageList(); ::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, IDM_VIEW_REDUCETABBAR, 0); changeDocumentListIconSet(false); diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 73f6fcbcc..cac48ddeb 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -270,6 +270,12 @@ void TabBarPlus::destroy() TabBar::destroy(); ::DestroyWindow(_tooltips); _tooltips = NULL; + + if (_hCloseBtnImgLst != nullptr) + { + ::ImageList_Destroy(_hCloseBtnImgLst); + _hCloseBtnImgLst = nullptr; + } } @@ -339,6 +345,8 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMult _tabBarDefaultProc = reinterpret_cast(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast(TabBarPlus_Proc))); setFont(); + + setCloseBtnImageList(); } void TabBar::setFont() @@ -452,6 +460,34 @@ void TabBarPlus::currentTabToEnd() } } +void TabBarPlus::setCloseBtnImageList() +{ + if (_hCloseBtnImgLst != nullptr) + { + ::ImageList_Destroy(_hCloseBtnImgLst); + _hCloseBtnImgLst = nullptr; + } + + const int btnSize = _dpiManager.scale(g_TabCloseBtnSize); + + const auto idsCloseIcons = { + IDR_CLOSETAB, IDR_CLOSETAB_INACT, IDR_CLOSETAB_HOVER, IDR_CLOSETAB_PUSH, + IDR_CLOSETAB_DM, IDR_CLOSETAB_INACT_DM, IDR_CLOSETAB_HOVER_DM, IDR_CLOSETAB_PUSH_DM }; + + _hCloseBtnImgLst = ::ImageList_Create(btnSize, btnSize, ILC_COLOR32 | ILC_MASK, static_cast(idsCloseIcons.size()), 0); + + for (const auto& id : idsCloseIcons) + { + HICON hIcon = nullptr; + DPIManagerV2::loadIcon(_hInst, MAKEINTRESOURCE(id), btnSize, btnSize, &hIcon); + ::ImageList_AddIcon(_hCloseBtnImgLst, hIcon); + ::DestroyIcon(hIcon); + } + + _closeButtonZone._width = btnSize; + _closeButtonZone._height = btnSize; +} + void TabBarPlus::doVertical() { for (int i = 0 ; i < _nbCtrl ; ++i) @@ -1264,36 +1300,31 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode) } // draw close button - if (_drawTabCloseButton) + if (_drawTabCloseButton && _hCloseBtnImgLst != nullptr) { // 3 status for each inactive tab and selected tab close item : // normal / hover / pushed - int idCloseImg; + int idxCloseImg = isDarkMode ? 4 : 0; // selected - if (_isCloseHover && (_currentHoverTabItem == nTab) && (_whichCloseClickDown == -1)) // hover - idCloseImg = isDarkMode ? IDR_CLOSETAB_HOVER_DM : IDR_CLOSETAB_HOVER; - else if (_isCloseHover && (_currentHoverTabItem == nTab) && (_whichCloseClickDown == _currentHoverTabItem)) // pushed - idCloseImg = isDarkMode ? IDR_CLOSETAB_PUSH_DM : IDR_CLOSETAB_PUSH; - else - idCloseImg = isSelected ? (isDarkMode ? IDR_CLOSETAB_DM : IDR_CLOSETAB) : (isDarkMode ? IDR_CLOSETAB_INACT_DM : IDR_CLOSETAB_INACT); - - HDC hdcMemory = ::CreateCompatibleDC(hDC); - HBITMAP hBmp = ::LoadBitmap(_hInst, MAKEINTRESOURCE(idCloseImg)); - BITMAP bmp{}; - ::GetObject(hBmp, sizeof(bmp), &bmp); - - _closeButtonZone._width = _dpiManager.scale(bmp.bmWidth); - _closeButtonZone._height = _dpiManager.scale(bmp.bmHeight); + if (_isCloseHover && (_currentHoverTabItem == nTab)) + { + if (_whichCloseClickDown == -1) // hover + { + idxCloseImg += 2; + } + else if (_whichCloseClickDown == _currentHoverTabItem) // pushed + { + idxCloseImg += 3; + } + } + else if (!isSelected) // inactive + { + idxCloseImg += 1; + } RECT buttonRect = _closeButtonZone.getButtonRectFrom(rect, _isVertical); - - // StretchBlt will crop image in RTL if there is no stretching, thus move image by -1 - const bool isRTL = (::GetWindowLongPtr(::GetParent(_hSelf), GWL_EXSTYLE) & WS_EX_LAYOUTRTL) == WS_EX_LAYOUTRTL; - const int offset = isRTL && (_closeButtonZone._width == bmp.bmWidth) ? -1 : 0; - ::SelectObject(hdcMemory, hBmp); - ::StretchBlt(hDC, buttonRect.left + offset, buttonRect.top, _closeButtonZone._width, _closeButtonZone._height, hdcMemory, offset, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); - ::DeleteDC(hdcMemory); - ::DeleteObject(hBmp); + + ::ImageList_Draw(_hCloseBtnImgLst, idxCloseImg, hDC, buttonRect.left, buttonRect.top, ILD_TRANSPARENT); } // draw image diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.h b/PowerEditor/src/WinControls/TabBar/TabBar.h index 2e15b32cd..b907ad93d 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.h +++ b/PowerEditor/src/WinControls/TabBar/TabBar.h @@ -229,6 +229,8 @@ public : void currentTabToStart(); void currentTabToEnd(); + void setCloseBtnImageList(); + protected: // it's the boss to decide if we do the drag N drop static bool _doDragNDrop; @@ -248,6 +250,7 @@ protected: int _currentHoverTabItem = -1; // -1 : no mouse on any tab CloseButtonZone _closeButtonZone; + HIMAGELIST _hCloseBtnImgLst = nullptr; bool _isCloseHover = false; int _whichCloseClickDown = -1; bool _lmbdHit = false; // Left Mouse Button Down Hit diff --git a/PowerEditor/src/icons/dark/tabbar/closeTabButton.bmp b/PowerEditor/src/icons/dark/tabbar/closeTabButton.bmp deleted file mode 100644 index ea6e6c4eb..000000000 Binary files a/PowerEditor/src/icons/dark/tabbar/closeTabButton.bmp and /dev/null differ diff --git a/PowerEditor/src/icons/dark/tabbar/closeTabButton.ico b/PowerEditor/src/icons/dark/tabbar/closeTabButton.ico new file mode 100644 index 000000000..d7d8950c3 Binary files /dev/null and b/PowerEditor/src/icons/dark/tabbar/closeTabButton.ico differ diff --git a/PowerEditor/src/icons/dark/tabbar/closeTabButton_hover.bmp b/PowerEditor/src/icons/dark/tabbar/closeTabButton_hover.bmp deleted file mode 100644 index b5bc396eb..000000000 Binary files a/PowerEditor/src/icons/dark/tabbar/closeTabButton_hover.bmp and /dev/null differ diff --git a/PowerEditor/src/icons/dark/tabbar/closeTabButton_hover.ico b/PowerEditor/src/icons/dark/tabbar/closeTabButton_hover.ico new file mode 100644 index 000000000..5fbddbb36 Binary files /dev/null and b/PowerEditor/src/icons/dark/tabbar/closeTabButton_hover.ico differ diff --git a/PowerEditor/src/icons/dark/tabbar/closeTabButton_inact.bmp b/PowerEditor/src/icons/dark/tabbar/closeTabButton_inact.bmp deleted file mode 100644 index 22fb92486..000000000 Binary files a/PowerEditor/src/icons/dark/tabbar/closeTabButton_inact.bmp and /dev/null differ diff --git a/PowerEditor/src/icons/dark/tabbar/closeTabButton_inact.ico b/PowerEditor/src/icons/dark/tabbar/closeTabButton_inact.ico new file mode 100644 index 000000000..caa5dabea Binary files /dev/null and b/PowerEditor/src/icons/dark/tabbar/closeTabButton_inact.ico differ diff --git a/PowerEditor/src/icons/dark/tabbar/closeTabButton_push.bmp b/PowerEditor/src/icons/dark/tabbar/closeTabButton_push.bmp deleted file mode 100644 index b5bc396eb..000000000 Binary files a/PowerEditor/src/icons/dark/tabbar/closeTabButton_push.bmp and /dev/null differ diff --git a/PowerEditor/src/icons/dark/tabbar/closeTabButton_push.ico b/PowerEditor/src/icons/dark/tabbar/closeTabButton_push.ico new file mode 100644 index 000000000..47d0f3433 Binary files /dev/null and b/PowerEditor/src/icons/dark/tabbar/closeTabButton_push.ico differ diff --git a/PowerEditor/src/icons/standard/tabbar/closeTabButton.bmp b/PowerEditor/src/icons/standard/tabbar/closeTabButton.bmp deleted file mode 100644 index 211027e7c..000000000 Binary files a/PowerEditor/src/icons/standard/tabbar/closeTabButton.bmp and /dev/null differ diff --git a/PowerEditor/src/icons/standard/tabbar/closeTabButton.ico b/PowerEditor/src/icons/standard/tabbar/closeTabButton.ico new file mode 100644 index 000000000..8b7527e81 Binary files /dev/null and b/PowerEditor/src/icons/standard/tabbar/closeTabButton.ico differ diff --git a/PowerEditor/src/icons/standard/tabbar/closeTabButton_hover.bmp b/PowerEditor/src/icons/standard/tabbar/closeTabButton_hover.bmp deleted file mode 100644 index 44490fd3e..000000000 Binary files a/PowerEditor/src/icons/standard/tabbar/closeTabButton_hover.bmp and /dev/null differ diff --git a/PowerEditor/src/icons/standard/tabbar/closeTabButton_hover.ico b/PowerEditor/src/icons/standard/tabbar/closeTabButton_hover.ico new file mode 100644 index 000000000..92d3d8e27 Binary files /dev/null and b/PowerEditor/src/icons/standard/tabbar/closeTabButton_hover.ico differ diff --git a/PowerEditor/src/icons/standard/tabbar/closeTabButton_inact.bmp b/PowerEditor/src/icons/standard/tabbar/closeTabButton_inact.bmp deleted file mode 100644 index 948cd6390..000000000 Binary files a/PowerEditor/src/icons/standard/tabbar/closeTabButton_inact.bmp and /dev/null differ diff --git a/PowerEditor/src/icons/standard/tabbar/closeTabButton_inact.ico b/PowerEditor/src/icons/standard/tabbar/closeTabButton_inact.ico new file mode 100644 index 000000000..8ec6a3ddf Binary files /dev/null and b/PowerEditor/src/icons/standard/tabbar/closeTabButton_inact.ico differ diff --git a/PowerEditor/src/icons/standard/tabbar/closeTabButton_push.bmp b/PowerEditor/src/icons/standard/tabbar/closeTabButton_push.bmp deleted file mode 100644 index e136d11df..000000000 Binary files a/PowerEditor/src/icons/standard/tabbar/closeTabButton_push.bmp and /dev/null differ diff --git a/PowerEditor/src/icons/standard/tabbar/closeTabButton_push.ico b/PowerEditor/src/icons/standard/tabbar/closeTabButton_push.ico new file mode 100644 index 000000000..795a5cf27 Binary files /dev/null and b/PowerEditor/src/icons/standard/tabbar/closeTabButton_push.ico differ