From f607044da0b51d6a2fac992ff9de7df0a5cb2150 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Wed, 13 Nov 2024 02:11:20 +0100 Subject: [PATCH] Fix wrong position of pin button while close disabled and pin enabled After disable close button and enable pin button, relaunch Notepad++ will make wrong position of pin button on tab. This commit fix the bug. --- PowerEditor/src/Notepad_plus.cpp | 8 +++-- .../src/ScintillaComponent/DocTabView.cpp | 4 +-- .../src/ScintillaComponent/DocTabView.h | 2 +- PowerEditor/src/WinControls/TabBar/TabBar.cpp | 31 +++++++++++++++++-- PowerEditor/src/WinControls/TabBar/TabBar.h | 2 +- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index eb82b3dec..722e11af5 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -268,8 +268,12 @@ LRESULT Notepad_plus::init(HWND hwnd) _mainDocTab.dpiManager().setDpiWithParent(hwnd); _subDocTab.dpiManager().setDpiWithParent(hwnd); - _mainDocTab.init(_pPublicInterface->getHinst(), hwnd, &_mainEditView, indexDocTabIcon); - _subDocTab.init(_pPublicInterface->getHinst(), hwnd, &_subEditView, indexDocTabIcon); + unsigned char buttonsStatus = 0; + buttonsStatus |= (tabBarStatus & TAB_CLOSEBUTTON) ? 1 : 0; + buttonsStatus |= (tabBarStatus & TAB_PINBUTTON) ? 2 : 0; + + _mainDocTab.init(_pPublicInterface->getHinst(), hwnd, &_mainEditView, indexDocTabIcon, buttonsStatus); + _subDocTab.init(_pPublicInterface->getHinst(), hwnd, &_subEditView, indexDocTabIcon, buttonsStatus); _mainEditView.display(); diff --git a/PowerEditor/src/ScintillaComponent/DocTabView.cpp b/PowerEditor/src/ScintillaComponent/DocTabView.cpp index 52826230a..4aff0d42a 100644 --- a/PowerEditor/src/ScintillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScintillaComponent/DocTabView.cpp @@ -32,9 +32,9 @@ int docTabIconIDs_alt[] = { IDI_SAVED_ALT_ICON, IDI_UNSAVED_ALT_ICON, IDI_READON -void DocTabView::init(HINSTANCE hInst, HWND parent, ScintillaEditView* pView, unsigned char indexChoice) +void DocTabView::init(HINSTANCE hInst, HWND parent, ScintillaEditView* pView, unsigned char indexChoice, unsigned char buttonsStatus) { - TabBarPlus::init(hInst, parent); + TabBarPlus::init(hInst, parent, false, false, buttonsStatus); _pView = pView; createIconSets(); diff --git a/PowerEditor/src/ScintillaComponent/DocTabView.h b/PowerEditor/src/ScintillaComponent/DocTabView.h index ffe35cc75..c8c59d2a4 100644 --- a/PowerEditor/src/ScintillaComponent/DocTabView.h +++ b/PowerEditor/src/ScintillaComponent/DocTabView.h @@ -35,7 +35,7 @@ public : TabBarPlus::destroy(); }; - void init(HINSTANCE hInst, HWND parent, ScintillaEditView * pView, unsigned char indexChoice); + void init(HINSTANCE hInst, HWND parent, ScintillaEditView * pView, unsigned char indexChoice, unsigned char buttonsStatus); void createIconSets(); diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 88714101f..f041c464d 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -288,13 +288,38 @@ void TabBarPlus::destroy() } -void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLine) +void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLine, unsigned char buttonsStatus) { Window::init(hInst, parent); const UINT dpi = DPIManagerV2::getDpiForWindow(_hParent); - _closeButtonZone.init(_hParent, 0); - _pinButtonZone.init(_hParent, 1); + + int closeOrder = -1; + int pinOder = -1; + + if (buttonsStatus == 0) // 0000: both buttons disabled + { + closeOrder = -1; + pinOder = -1; + } + else if (buttonsStatus == 1) // 0001: close enabled, pin disabled + { + closeOrder = 0; + pinOder = -1; + } + else if (buttonsStatus == 2) // 0010: close disabled, pin enabled + { + closeOrder = -1; + pinOder = 0; + } + else if (buttonsStatus == 3) // 0011: both buttons enabled + { + closeOrder = 0; + pinOder = 1; + } + + _closeButtonZone.init(_hParent, closeOrder); + _pinButtonZone.init(_hParent, pinOder); _dpiManager.setDpi(dpi); int vertical = isVertical ? (TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY) : 0; diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.h b/PowerEditor/src/WinControls/TabBar/TabBar.h index 95abfbba8..9f16368f1 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.h +++ b/PowerEditor/src/WinControls/TabBar/TabBar.h @@ -186,7 +186,7 @@ public : _doDragNDrop = justDoIt; }; - void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isMultiLine = false) override; + void init(HINSTANCE hInst, HWND hwnd, bool isVertical, bool isMultiLine, unsigned char buttonsStatus = 0); void destroy() override;