Skip to content

Commit

Permalink
Fix wrong position of pin button while close disabled and pin enabled
Browse files Browse the repository at this point in the history
After disable close button and enable pin button, relaunch Notepad++ will make wrong position of pin button on tab.
This commit fix the bug.
  • Loading branch information
donho committed Nov 13, 2024
1 parent 5f46102 commit f607044
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
8 changes: 6 additions & 2 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/ScintillaComponent/DocTabView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/ScintillaComponent/DocTabView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
31 changes: 28 additions & 3 deletions PowerEditor/src/WinControls/TabBar/TabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/WinControls/TabBar/TabBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit f607044

Please sign in to comment.