Browse Source

Hide inactive tab buttons (Close & Pin)

Fix #15298, close #15781
pull/15794/head
Don Ho 2 weeks ago
parent
commit
5f4610293c
  1. 24
      PowerEditor/src/Notepad_plus.rc
  2. 5
      PowerEditor/src/NppBigSwitch.cpp
  3. 41
      PowerEditor/src/WinControls/TabBar/TabBar.cpp
  4. 29
      PowerEditor/src/WinControls/TabBar/TabBar.h
  5. BIN
      PowerEditor/src/icons/dark/tabbar/closeTabButton_hover.ico
  6. BIN
      PowerEditor/src/icons/dark/tabbar/closeTabButton_hoverIn.ico
  7. 0
      PowerEditor/src/icons/dark/tabbar/closeTabButton_hoverOnTab.ico
  8. BIN
      PowerEditor/src/icons/dark/tabbar/closeTabButton_push.ico
  9. 0
      PowerEditor/src/icons/dark/tabbar/empty.ico
  10. 0
      PowerEditor/src/icons/dark/tabbar/pinTabButton_hoverIn.ico
  11. 0
      PowerEditor/src/icons/dark/tabbar/pinTabButton_pinnedHoverOnTab.ico
  12. 0
      PowerEditor/src/icons/standard/tabbar/closeTabButton_hoverIn.ico
  13. 0
      PowerEditor/src/icons/standard/tabbar/closeTabButton_hoverOnTab.ico
  14. BIN
      PowerEditor/src/icons/standard/tabbar/empty.ico
  15. 52
      PowerEditor/src/resource.h

24
PowerEditor/src/Notepad_plus.rc

@ -275,7 +275,7 @@ IDI_VIEW_MONITORING_DIS_ICON_DM2 ICON "icons/dark/toolbar/filled/monitori
IDI_SAVED_ICON ICON "icons/standard/tabbar/saved.ico"
IDI_SAVED_DM_ICON ICON "icons/dark/tabbar/saved.ico"
IDI_SAVED_DM_ICON ICON "icons/dark/tabbar/empty.ico"
IDI_SAVED_ALT_ICON ICON "icons/standard/tabbar/saved_alt.ico"
IDI_UNSAVED_ICON ICON "icons/standard/tabbar/unsaved.ico"
IDI_UNSAVED_DM_ICON ICON "icons/dark/tabbar/unsaved.ico"
@ -327,22 +327,28 @@ IDR_FILEBROWSER BITMAP "icons/standard/toolbar/fileBrowser.bm
IDR_FILEMONITORING BITMAP "icons/standard/toolbar/monitoring.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_INACT ICON "icons/standard/tabbar/empty.ico"
IDR_CLOSETAB_HOVERIN ICON "icons/standard/tabbar/closeTabButton_hoverIn.ico"
IDR_CLOSETAB_HOVERONTAB ICON "icons/standard/tabbar/closeTabButton_hoverOnTab.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_INACT_DM ICON "icons/dark/tabbar/empty.ico"
IDR_CLOSETAB_HOVERIN_DM ICON "icons/dark/tabbar/closeTabButton_hoverIn.ico"
IDR_CLOSETAB_HOVERONTAB_DM ICON "icons/dark/tabbar/closeTabButton_hoverOnTab.ico"
IDR_CLOSETAB_PUSH_DM ICON "icons/dark/tabbar/closeTabButton_push.ico"
IDR_PINTAB ICON "icons/standard/tabbar/pinTabButton.ico"
IDR_PINTAB_HOVER ICON "icons/standard/tabbar/pinTabButton_pinned.ico"
IDR_PINTAB_INACT ICON "icons/standard/tabbar/empty.ico"
IDR_PINTAB_HOVERIN ICON "icons/standard/tabbar/pinTabButton_pinned.ico"
IDR_PINTAB_HOVERONTAB ICON "icons/standard/tabbar/pinTabButton.ico"
IDR_PINTAB_PINNED ICON "icons/standard/tabbar/pinTabButton_pinned.ico"
IDR_PINTAB_PINNEDHOVER ICON "icons/standard/tabbar/pinTabButton.ico"
IDR_PINTAB_PINNEDHOVERIN ICON "icons/standard/tabbar/pinTabButton.ico"
IDR_PINTAB_DM ICON "icons/dark/tabbar/pinTabButton.ico"
IDR_PINTAB_HOVER_DM ICON "icons/dark/tabbar/pinTabButton_hover.ico"
IDR_PINTAB_INACT_DM ICON "icons/dark/tabbar/empty.ico"
IDR_PINTAB_HOVERIN_DM ICON "icons/dark/tabbar/pinTabButton_pinned.ico"
IDR_PINTAB_HOVERONTAB_DM ICON "icons/dark/tabbar/pinTabButton.ico"
IDR_PINTAB_PINNED_DM ICON "icons/dark/tabbar/pinTabButton_pinned.ico"
IDR_PINTAB_PINNEDHOVER_DM ICON "icons/dark/tabbar/pinTabButton_pinnedHover.ico"
IDR_PINTAB_PINNEDHOVERIN_DM ICON "icons/dark/tabbar/pinTabButton.ico"
IDR_DOCMAP_ICO ICON "icons/standard/panels/tabbar/docMap.ico"
IDR_DOCMAP_ICO2 ICON "icons/light/panels/tabbar/docMap.ico"

5
PowerEditor/src/NppBigSwitch.cpp

@ -4008,6 +4008,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
_mainDocTab.refresh();
_subDocTab.refresh();
break;
}
@ -4059,6 +4062,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight);
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
_mainDocTab.refresh();
_subDocTab.refresh();
return TRUE;
}

41
PowerEditor/src/WinControls/TabBar/TabBar.cpp

@ -499,12 +499,12 @@ void TabBarPlus::setCloseBtnImageList()
if (NppDarkMode::isEnabled())
{
iconSize = g_TabCloseBtnSize_DM;
ids = { IDR_CLOSETAB_DM, IDR_CLOSETAB_INACT_DM, IDR_CLOSETAB_HOVER_DM, IDR_CLOSETAB_PUSH_DM };
ids = { IDR_CLOSETAB_DM, IDR_CLOSETAB_INACT_DM, IDR_CLOSETAB_HOVERIN_DM, IDR_CLOSETAB_HOVERONTAB_DM, IDR_CLOSETAB_PUSH_DM };
}
else
{
iconSize = g_TabCloseBtnSize;
ids = { IDR_CLOSETAB, IDR_CLOSETAB_INACT, IDR_CLOSETAB_HOVER, IDR_CLOSETAB_PUSH };
ids = { IDR_CLOSETAB, IDR_CLOSETAB_INACT, IDR_CLOSETAB_HOVERIN, IDR_CLOSETAB_HOVERONTAB, IDR_CLOSETAB_PUSH };
}
if (_hCloseBtnImgLst != nullptr)
@ -538,12 +538,12 @@ void TabBarPlus::setPinBtnImageList()
if (NppDarkMode::isEnabled())
{
iconSize = g_TabPinBtnSize_DM;
ids = { IDR_PINTAB_DM, IDR_PINTAB_HOVER_DM, IDR_PINTAB_PINNED_DM, IDR_PINTAB_PINNEDHOVER_DM };
ids = { IDR_PINTAB_DM, IDR_PINTAB_INACT_DM, IDR_PINTAB_HOVERIN_DM, IDR_PINTAB_HOVERONTAB_DM, IDR_PINTAB_PINNED_DM, IDR_PINTAB_PINNEDHOVERIN_DM };
}
else
{
iconSize = g_TabPinBtnSize;
ids = { IDR_PINTAB, IDR_PINTAB_HOVER, IDR_PINTAB_PINNED, IDR_PINTAB_PINNEDHOVER };
ids = { IDR_PINTAB, IDR_PINTAB_INACT, IDR_PINTAB_HOVERIN, IDR_PINTAB_HOVERONTAB, IDR_PINTAB_PINNED, IDR_PINTAB_PINNEDHOVERIN };
}
if (_hPinBtnImgLst != nullptr)
@ -912,7 +912,14 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
_isCloseHover = false;
}
if (isFromTabToTab || _isCloseHover != isCloseHoverOld)
if (isFromTabToTab || _isCloseHover != isCloseHoverOld || _currentHoverTabItem != -1)
{
if (_currentHoverTabItem != -1 || isFromTabToTab)
{
InvalidateRect(hwnd, &currentHoverTabRectOld, FALSE);
InvalidateRect(hwnd, &_currentHoverTabRect, FALSE);
}
else
{
if (isCloseHoverOld && (isFromTabToTab || !_isCloseHover))
InvalidateRect(hwnd, &currentHoverTabRectOld, FALSE);
@ -920,6 +927,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
if (_isCloseHover)
InvalidateRect(hwnd, &_currentHoverTabRect, FALSE);
}
}
if (_isCloseHover)
{
@ -945,7 +953,14 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
_isPinHover = false;
}
if (isFromTabToTab || _isPinHover != isPinHoverOld)
if (isFromTabToTab || _isPinHover != isPinHoverOld || _currentHoverTabItem != -1)
{
if (_currentHoverTabItem != -1 || isFromTabToTab)
{
InvalidateRect(hwnd, &currentHoverTabRectOld, FALSE);
InvalidateRect(hwnd, &_currentHoverTabRect, FALSE);
}
else
{
if (isPinHoverOld && (isFromTabToTab || !_isPinHover))
InvalidateRect(hwnd, &currentHoverTabRectOld, FALSE);
@ -953,6 +968,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
if (_isPinHover)
InvalidateRect(hwnd, &_currentHoverTabRect, FALSE);
}
}
if (_isPinHover)
{
@ -970,7 +986,6 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
case WM_MOUSELEAVE:
{
if (_isCloseHover || _isPinHover)
InvalidateRect(hwnd, &_currentHoverTabRect, FALSE);
_currentHoverTabItem = -1;
@ -1455,9 +1470,9 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
if (_isCloseHover && (_currentHoverTabItem == nTab))
{
if (_whichCloseClickDown == -1) // hover
if (_whichCloseClickDown == -1) // hover in
{
idxCloseImg = _closeTabHoverIdx;
idxCloseImg = _closeTabHoverInIdx;
}
else if (_whichCloseClickDown == _currentHoverTabItem) // pushed
{
@ -1466,7 +1481,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
}
else if (!isSelected) // inactive
{
idxCloseImg = _closeTabInactIdx;
idxCloseImg = (_currentHoverTabItem == nTab) ? _closeTabHoverOnTabIdx : _closeTabInactIdx;
}
RECT buttonRect = _closeButtonZone.getButtonRectFrom(rect, _isVertical);
@ -1523,7 +1538,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
{
if (_whichPinClickDown == -1) // hover
{
idxPinImg = _unpinnedHoverIdx;
idxPinImg = _unpinnedHoverInIdx;
}
else if (_whichPinClickDown == _currentHoverTabItem) // pushed
{
@ -1533,13 +1548,13 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT* pDrawItemStruct, bool isDarkMode)
}
else // unpinned inactive
{
idxPinImg = _unpinnedIdx;
idxPinImg = (_currentHoverTabItem == nTab) ? _unpinnedHoverOnTabIdx : _unpinnedInactIdx;
}
}
else // current
{
if (_isPinHover && (_currentHoverTabItem == nTab)) // hover
idxPinImg = _unpinnedHoverIdx;
idxPinImg = _unpinnedHoverInIdx;
else
idxPinImg = _unpinnedIdx;
}

29
PowerEditor/src/WinControls/TabBar/TabBar.h

@ -270,6 +270,13 @@ public :
_closeButtonZone.setOrder(newOrder);
}
// Hack for forcing the tab width change
// ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/15781#issuecomment-2469387409
void refresh() {
int index = insertAtEnd(L"");
deletItemAt(index);
}
protected:
// it's the boss to decide if we do the drag N drop
static bool _doDragNDrop;
@ -293,14 +300,17 @@ protected:
HIMAGELIST _hCloseBtnImgLst = nullptr;
const int _closeTabIdx = 0;
const int _closeTabInactIdx = 1;
const int _closeTabHoverIdx = 2;
const int _closeTabPushIdx = 3;
const int _closeTabHoverInIdx = 2; // hover inside of box
const int _closeTabHoverOnTabIdx = 3; // hover on the tab, but outside of box
const int _closeTabPushIdx = 4;
HIMAGELIST _hPinBtnImgLst = nullptr;
const int _unpinnedIdx = 0;
const int _unpinnedHoverIdx = 1;
const int _pinnedIdx = 2;
const int _pinnedHoverIdx = 3;
const int _unpinnedInactIdx = 1;
const int _unpinnedHoverInIdx = 2; // hover inside of box
const int _unpinnedHoverOnTabIdx = 3; // hover on the tab, but outside of box
const int _pinnedIdx = 4;
const int _pinnedHoverIdx = 5;
bool _isCloseHover = false;
bool _isPinHover = false;
@ -341,21 +351,18 @@ protected:
void drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode = false);
void draggingCursor(POINT screenPoint);
int getTabIndexAt(const POINT & p)
{
int getTabIndexAt(const POINT & p) const {
return getTabIndexAt(p.x, p.y);
}
int32_t getTabIndexAt(int x, int y)
{
int32_t getTabIndexAt(int x, int y) const {
TCHITTESTINFO hitInfo{};
hitInfo.pt.x = x;
hitInfo.pt.y = y;
return static_cast<int32_t>(::SendMessage(_hSelf, TCM_HITTEST, 0, reinterpret_cast<LPARAM>(&hitInfo)));
}
bool isPointInParentZone(POINT screenPoint) const
{
bool isPointInParentZone(POINT screenPoint) const {
RECT parentZone{};
::GetWindowRect(_hParent, &parentZone);
return (((screenPoint.x >= parentZone.left) && (screenPoint.x <= parentZone.right)) &&

BIN
PowerEditor/src/icons/dark/tabbar/closeTabButton_hover.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

BIN
PowerEditor/src/icons/dark/tabbar/closeTabButton_hoverIn.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

0
PowerEditor/src/icons/dark/tabbar/closeTabButton_inact.ico → PowerEditor/src/icons/dark/tabbar/closeTabButton_hoverOnTab.ico

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
PowerEditor/src/icons/dark/tabbar/closeTabButton_push.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

0
PowerEditor/src/icons/dark/tabbar/saved.ico → PowerEditor/src/icons/dark/tabbar/empty.ico

Before

Width:  |  Height:  |  Size: 790 B

After

Width:  |  Height:  |  Size: 790 B

0
PowerEditor/src/icons/dark/tabbar/pinTabButton_hover.ico → PowerEditor/src/icons/dark/tabbar/pinTabButton_hoverIn.ico

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

0
PowerEditor/src/icons/dark/tabbar/pinTabButton_pinnedHover.ico → PowerEditor/src/icons/dark/tabbar/pinTabButton_pinnedHoverOnTab.ico

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

0
PowerEditor/src/icons/standard/tabbar/closeTabButton_hover.ico → PowerEditor/src/icons/standard/tabbar/closeTabButton_hoverIn.ico

Before

Width:  |  Height:  |  Size: 467 B

After

Width:  |  Height:  |  Size: 467 B

0
PowerEditor/src/icons/standard/tabbar/closeTabButton_inact.ico → PowerEditor/src/icons/standard/tabbar/closeTabButton_hoverOnTab.ico

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 435 B

BIN
PowerEditor/src/icons/standard/tabbar/empty.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 790 B

52
PowerEditor/src/resource.h

@ -371,22 +371,24 @@
#define IDR_FILEBROWSER 1529
#define IDR_CLOSETAB 1530
#define IDR_CLOSETAB_INACT 1531
#define IDR_CLOSETAB_HOVER 1532
#define IDR_CLOSETAB_PUSH 1533
#define IDR_FUNC_LIST_ICO 1534
#define IDR_DOCMAP_ICO 1535
#define IDR_PROJECTPANEL_ICO 1536
#define IDR_CLIPBOARDPANEL_ICO 1537
#define IDR_ASCIIPANEL_ICO 1538
#define IDR_DOCSWITCHER_ICO 1539
#define IDR_FILEBROWSER_ICO 1540
#define IDR_FILEMONITORING 1541
#define IDR_CLOSETAB_DM 1542
#define IDR_CLOSETAB_INACT_DM 1543
#define IDR_CLOSETAB_HOVER_DM 1544
#define IDR_CLOSETAB_PUSH_DM 1545
#define IDR_DOCLIST 1546
#define IDR_DOCLIST_ICO 1547
#define IDR_CLOSETAB_HOVERIN 1532
#define IDR_CLOSETAB_HOVERONTAB 1533
#define IDR_CLOSETAB_PUSH 1534
#define IDR_FUNC_LIST_ICO 1535
#define IDR_DOCMAP_ICO 1536
#define IDR_PROJECTPANEL_ICO 1537
#define IDR_CLIPBOARDPANEL_ICO 1538
#define IDR_ASCIIPANEL_ICO 1539
#define IDR_DOCSWITCHER_ICO 1540
#define IDR_FILEBROWSER_ICO 1541
#define IDR_FILEMONITORING 1542
#define IDR_CLOSETAB_DM 1543
#define IDR_CLOSETAB_INACT_DM 1544
#define IDR_CLOSETAB_HOVERIN_DM 1545
#define IDR_CLOSETAB_HOVERONTAB_DM 1546
#define IDR_CLOSETAB_PUSH_DM 1547
#define IDR_DOCLIST 1548
#define IDR_DOCLIST_ICO 1549
#define IDR_FILEBROWSER_ICO2 1550
#define IDR_FILEBROWSER_ICO_DM 1551
@ -406,13 +408,17 @@
#define IDR_FIND_RESULT_ICO_DM 1565
#define IDR_PINTAB 1566
#define IDR_PINTAB_HOVER 1567
#define IDR_PINTAB_PINNED 1568
#define IDR_PINTAB_PINNEDHOVER 1569
#define IDR_PINTAB_DM 1570
#define IDR_PINTAB_HOVER_DM 1571
#define IDR_PINTAB_PINNED_DM 1572
#define IDR_PINTAB_PINNEDHOVER_DM 1573
#define IDR_PINTAB_INACT 1567
#define IDR_PINTAB_HOVERIN 1568
#define IDR_PINTAB_HOVERONTAB 1569
#define IDR_PINTAB_PINNED 1570
#define IDR_PINTAB_PINNEDHOVERIN 1571
#define IDR_PINTAB_DM 1572
#define IDR_PINTAB_INACT_DM 1573
#define IDR_PINTAB_HOVERIN_DM 1574
#define IDR_PINTAB_HOVERONTAB_DM 1575
#define IDR_PINTAB_PINNED_DM 1576
#define IDR_PINTAB_PINNEDHOVERIN_DM 1577
#define ID_MACRO 20000
// O .

Loading…
Cancel
Save