mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-24 06:14:47 +02:00
Improve status bar resize handling
- make controls spacing and position consistent. ref #14959 Close #15090
This commit is contained in:
parent
3b515f1242
commit
4cd231114e
@ -294,10 +294,19 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent, bool t
|
|||||||
_statusBar.init(GetModuleHandle(NULL), _hSelf, 0);
|
_statusBar.init(GetModuleHandle(NULL), _hSelf, 0);
|
||||||
_statusBar.display();
|
_statusBar.display();
|
||||||
|
|
||||||
DPIManager& dpiManager = NppParameters::getInstance()._dpiManager;
|
setDpi();
|
||||||
|
|
||||||
|
RECT rcClient{};
|
||||||
|
getClientRect(rcClient);
|
||||||
|
|
||||||
|
const LONG padding = _dpiManager.getSystemMetricsForDpi(SM_CXPADDEDBORDER);
|
||||||
|
_szBorder.cx = (_dpiManager.getSystemMetricsForDpi(SM_CXFRAME) + padding) * 2;
|
||||||
|
_szBorder.cy = (_dpiManager.getSystemMetricsForDpi(SM_CYFRAME) + padding) * 2 + _dpiManager.getSystemMetricsForDpi(SM_CYCAPTION);
|
||||||
|
|
||||||
|
//fill min dialog size info
|
||||||
|
_szMinDialog.cx = rcClient.right - rcClient.left;
|
||||||
|
_szMinDialog.cy = rcClient.bottom - rcClient.top;
|
||||||
|
|
||||||
RECT rect{};
|
|
||||||
getClientRect(rect);
|
|
||||||
_tab.init(_hInst, _hSelf, false, true);
|
_tab.init(_hInst, _hSelf, false, true);
|
||||||
NppDarkMode::subclassTabControl(_tab.getHSelf());
|
NppDarkMode::subclassTabControl(_tab.getHSelf());
|
||||||
|
|
||||||
@ -313,23 +322,10 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent, bool t
|
|||||||
_tab.insertAtEnd(findInProjects);
|
_tab.insertAtEnd(findInProjects);
|
||||||
_tab.insertAtEnd(mark);
|
_tab.insertAtEnd(mark);
|
||||||
|
|
||||||
_tab.reSizeTo(rect);
|
_tab.reSizeTo(rcClient);
|
||||||
_tab.display();
|
_tab.display();
|
||||||
|
|
||||||
_initialClientWidth = rect.right - rect.left;
|
_initialClientWidth = rcClient.right - rcClient.left;
|
||||||
|
|
||||||
//fill min dialog size info
|
|
||||||
getWindowRect(_initialWindowRect);
|
|
||||||
_initialWindowRect.right = _initialWindowRect.right - _initialWindowRect.left + dpiManager.scaleX(10);
|
|
||||||
_initialWindowRect.left = 0;
|
|
||||||
_initialWindowRect.bottom = _initialWindowRect.bottom - _initialWindowRect.top;
|
|
||||||
_initialWindowRect.top = 0;
|
|
||||||
|
|
||||||
RECT dlgRc{};
|
|
||||||
getWindowRect(dlgRc);
|
|
||||||
|
|
||||||
RECT countRc{};
|
|
||||||
::GetWindowRect(::GetDlgItem(_hSelf, IDCCOUNTALL), &countRc);
|
|
||||||
|
|
||||||
NppParameters& nppParam = NppParameters::getInstance();
|
NppParameters& nppParam = NppParameters::getInstance();
|
||||||
NppGUI& nppGUI = nppParam.getNppGUI();
|
NppGUI& nppGUI = nppParam.getNppGUI();
|
||||||
@ -347,9 +343,15 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent, bool t
|
|||||||
goToCenter(swpFlags);
|
goToCenter(swpFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RECT rcCount{};
|
||||||
|
getMappedChildRect(IDCCOUNTALL, rcCount);
|
||||||
|
|
||||||
|
RECT rcOk{};
|
||||||
|
getMappedChildRect(IDOK, rcOk);
|
||||||
|
|
||||||
RECT rcStatusBar{};
|
RECT rcStatusBar{};
|
||||||
::GetClientRect(_statusBar.getHSelf(), &rcStatusBar);
|
::GetClientRect(_statusBar.getHSelf(), &rcStatusBar);
|
||||||
_lesssModeHeight = (countRc.bottom - dlgRc.top) + (rcStatusBar.bottom - rcStatusBar.top) + dpiManager.scaleY(10);
|
_lesssModeHeight = (rcCount.bottom + (rcCount.top - rcOk.bottom) + (rcStatusBar.bottom - rcStatusBar.top));
|
||||||
|
|
||||||
if (nppGUI._findWindowLessMode)
|
if (nppGUI._findWindowLessMode)
|
||||||
{
|
{
|
||||||
@ -1169,13 +1171,13 @@ void FindReplaceDlg::resizeDialogElements(LONG newWidth)
|
|||||||
IDC_FINDPREV, IDC_FINDNEXT, IDC_2_BUTTONS_MODE, IDC_COPY_MARKED_TEXT, IDD_FINDINFILES_REPLACEINPROJECTS, IDD_RESIZE_TOGGLE_BUTTON
|
IDC_FINDPREV, IDC_FINDNEXT, IDC_2_BUTTONS_MODE, IDC_COPY_MARKED_TEXT, IDD_FINDINFILES_REPLACEINPROJECTS, IDD_RESIZE_TOGGLE_BUTTON
|
||||||
};
|
};
|
||||||
|
|
||||||
const UINT flags = SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS;
|
constexpr UINT flags = SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS;
|
||||||
|
|
||||||
auto newDeltaWidth = newWidth - _initialClientWidth;
|
auto newDeltaWidth = newWidth - _initialClientWidth;
|
||||||
auto addWidth = newDeltaWidth - _deltaWidth;
|
auto addWidth = newDeltaWidth - _deltaWidth;
|
||||||
_deltaWidth = newDeltaWidth;
|
_deltaWidth = newDeltaWidth;
|
||||||
|
|
||||||
RECT rc;
|
RECT rc{};
|
||||||
for (int id : resizeWindowIDs)
|
for (int id : resizeWindowIDs)
|
||||||
{
|
{
|
||||||
HWND resizeHwnd = ::GetDlgItem(_hSelf, id);
|
HWND resizeHwnd = ::GetDlgItem(_hSelf, id);
|
||||||
@ -1202,13 +1204,8 @@ void FindReplaceDlg::resizeDialogElements(LONG newWidth)
|
|||||||
::SetWindowPos(moveHwnd, NULL, rc.left + addWidth, rc.top, 0, 0, SWP_NOSIZE | flags);
|
::SetWindowPos(moveHwnd, NULL, rc.left + addWidth, rc.top, 0, 0, SWP_NOSIZE | flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto additionalWindowHwndsToResize = { _tab.getHSelf() , _statusBar.getHSelf() };
|
::GetClientRect(_tab.getHSelf(), &rc);
|
||||||
|
::SetWindowPos(_tab.getHSelf(), nullptr, 0, 0, rc.right + addWidth, rc.bottom, SWP_NOMOVE | flags);
|
||||||
for (HWND resizeHwnd : additionalWindowHwndsToResize)
|
|
||||||
{
|
|
||||||
::GetClientRect(resizeHwnd, &rc);
|
|
||||||
::SetWindowPos(resizeHwnd, NULL, 0, 0, rc.right + addWidth, rc.bottom, SWP_NOMOVE | flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::mutex findOps_mutex;
|
std::mutex findOps_mutex;
|
||||||
@ -1221,16 +1218,18 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
{
|
{
|
||||||
bool isLessModeOn = NppParameters::getInstance().getNppGUI()._findWindowLessMode;
|
bool isLessModeOn = NppParameters::getInstance().getNppGUI()._findWindowLessMode;
|
||||||
MINMAXINFO* mmi = reinterpret_cast<MINMAXINFO*>(lParam);
|
MINMAXINFO* mmi = reinterpret_cast<MINMAXINFO*>(lParam);
|
||||||
mmi->ptMinTrackSize.y = isLessModeOn ? _lesssModeHeight : _initialWindowRect.bottom;
|
mmi->ptMinTrackSize.x = _szMinDialog.cx + _szBorder.cx;
|
||||||
mmi->ptMinTrackSize.x = _initialWindowRect.right;
|
const LONG h = (isLessModeOn ? _lesssModeHeight : _szMinDialog.cy) + _szBorder.cy;
|
||||||
mmi->ptMaxTrackSize.y = isLessModeOn ? _lesssModeHeight : _initialWindowRect.bottom;
|
mmi->ptMinTrackSize.y = h;
|
||||||
|
mmi->ptMaxTrackSize.y = h;
|
||||||
|
|
||||||
return 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
resizeDialogElements(LOWORD(lParam));
|
resizeDialogElements(LOWORD(lParam));
|
||||||
|
::SendMessage(_statusBar.getHSelf(), WM_SIZE, 0, 0); // pass WM_SIZE to status bar to automatically adjusts its size
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2398,22 +2397,12 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
|||||||
LONG w = rc.right - rc.left;
|
LONG w = rc.right - rc.left;
|
||||||
bool& isLessModeOn = NppParameters::getInstance().getNppGUI()._findWindowLessMode;
|
bool& isLessModeOn = NppParameters::getInstance().getNppGUI()._findWindowLessMode;
|
||||||
isLessModeOn = !isLessModeOn;
|
isLessModeOn = !isLessModeOn;
|
||||||
long dlgH = isLessModeOn ? _lesssModeHeight : _initialWindowRect.bottom;
|
long dlgH = (isLessModeOn ? _lesssModeHeight : _szMinDialog.cy) + _szBorder.cy;
|
||||||
|
|
||||||
DIALOG_TYPE dlgT = getCurrentStatus();
|
DIALOG_TYPE dlgT = getCurrentStatus();
|
||||||
calcAndSetCtrlsPos(dlgT, true);
|
calcAndSetCtrlsPos(dlgT, true);
|
||||||
|
|
||||||
// For unknown reason, the original default width doesn't make the status bar moveed
|
::SetWindowPos(_hSelf, nullptr, 0, 0, w, dlgH, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
|
||||||
// Here we use a dirty workaround: increase 1 pixel so WM_SIZE message will be triggered
|
|
||||||
if (w == _initialWindowRect.right)
|
|
||||||
w += 1;
|
|
||||||
|
|
||||||
::SetWindowPos(_hSelf, nullptr, 0, 0, w, dlgH, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW); // WM_SIZE message to call resizeDialogElements - status bar will be reposition correctly.
|
|
||||||
|
|
||||||
// Reposition the status bar
|
|
||||||
constexpr UINT flags = SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOCOPYBITS | SWP_FRAMECHANGED;
|
|
||||||
::GetClientRect(_statusBar.getHSelf(), &rc);
|
|
||||||
::SetWindowPos(_statusBar.getHSelf(), nullptr, 0, 0, w, rc.bottom, flags);
|
|
||||||
|
|
||||||
hideOrShowCtrl4reduceOrNormalMode(dlgT);
|
hideOrShowCtrl4reduceOrNormalMode(dlgT);
|
||||||
|
|
||||||
@ -4483,18 +4472,20 @@ void FindReplaceDlg::calcAndSetCtrlsPos(DIALOG_TYPE dlgT, bool fromColBtn)
|
|||||||
|
|
||||||
if (fromColBtn)
|
if (fromColBtn)
|
||||||
{
|
{
|
||||||
LONG yColBtn = 0;
|
RECT rc2ModeCheck{};
|
||||||
|
getMappedChildRect(IDC_2_BUTTONS_MODE, rc2ModeCheck);
|
||||||
|
LONG yColBtn = btnGap / 2;
|
||||||
if (isNotLessMode)
|
if (isNotLessMode)
|
||||||
{
|
{
|
||||||
RECT rcSlider{};
|
RECT rcSlider{};
|
||||||
getMappedChildRect(IDC_PERCENTAGE_SLIDER, rcSlider);
|
getMappedChildRect(IDC_PERCENTAGE_SLIDER, rcSlider);
|
||||||
yColBtn = rcSlider.top + btnGap;
|
yColBtn += rcSlider.top;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yColBtn = rcBtn2ndPos.top + btnGap / 2;
|
yColBtn += rcBtn2ndPos.top;
|
||||||
}
|
}
|
||||||
::SetWindowPos(::GetDlgItem(_hSelf, IDD_RESIZE_TOGGLE_BUTTON), nullptr, rcBtn2ndPos.right + btnGap, yColBtn, 0, 0, SWP_NOSIZE | flags);
|
::SetWindowPos(::GetDlgItem(_hSelf, IDD_RESIZE_TOGGLE_BUTTON), nullptr, rc2ModeCheck.left, yColBtn, 0, 0, SWP_NOSIZE | flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,8 +412,10 @@ protected :
|
|||||||
|
|
||||||
void combo2ExtendedMode(int comboID);
|
void combo2ExtendedMode(int comboID);
|
||||||
|
|
||||||
private :
|
private:
|
||||||
RECT _initialWindowRect{};
|
SIZE _szMinDialog{};
|
||||||
|
SIZE _szBorder{};
|
||||||
|
|
||||||
LONG _deltaWidth = 0;
|
LONG _deltaWidth = 0;
|
||||||
LONG _initialClientWidth = 0;
|
LONG _initialClientWidth = 0;
|
||||||
LONG _lesssModeHeight = 0;
|
LONG _lesssModeHeight = 0;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "FindReplaceDlg_rc.h"
|
#include "FindReplaceDlg_rc.h"
|
||||||
|
|
||||||
IDD_FIND_REPLACE_DLG DIALOGEX 0, 0, 392, 200
|
IDD_FIND_REPLACE_DLG DIALOGEX 0, 0, 391, 197
|
||||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||||
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
|
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
|
||||||
CAPTION "Replace"
|
CAPTION "Replace"
|
||||||
@ -60,13 +60,13 @@ BEGIN
|
|||||||
GROUPBOX "",IDC_REPLACEINSELECTION,192,50,180,23
|
GROUPBOX "",IDC_REPLACEINSELECTION,192,50,180,23
|
||||||
CONTROL "In select&ion",IDC_IN_SELECTION_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,58,59,10
|
CONTROL "In select&ion",IDC_IN_SELECTION_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,58,59,10
|
||||||
|
|
||||||
PUSHBUTTON "",IDC_FINDPREV,278,20,18,14,WS_GROUP | BS_MULTILINE
|
PUSHBUTTON "",IDC_FINDPREV,278,20,17,14,WS_GROUP
|
||||||
PUSHBUTTON "",IDC_FINDNEXT,299,20,70,14,WS_GROUP | BS_MULTILINE
|
PUSHBUTTON "",IDC_FINDNEXT,299,20,70,14,WS_GROUP
|
||||||
PUSHBUTTON "Find Next",IDOK,278,20,91,14,WS_GROUP
|
PUSHBUTTON "Find Next",IDOK,278,20,91,14,WS_GROUP
|
||||||
CONTROL "",IDC_2_BUTTONS_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,373,22,14,10
|
CONTROL "",IDC_2_BUTTONS_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,373,22,14,10
|
||||||
PUSHBUTTON "Coun&t",IDCCOUNTALL,278,38,91,14
|
PUSHBUTTON "Coun&t",IDCCOUNTALL,278,38,91,14
|
||||||
PUSHBUTTON "Find All in Current &Document",IDC_FINDALL_CURRENTFILE,278,56,91,21,BS_MULTILINE
|
PUSHBUTTON "Find All in Current &Document",IDC_FINDALL_CURRENTFILE,278,56,91,21,BS_MULTILINE
|
||||||
PUSHBUTTON "Find All in All &Opened Documents",IDC_FINDALL_OPENEDFILES,278,80,91,21,BS_MULTILINE
|
PUSHBUTTON "Find All in All &Opened Documents",IDC_FINDALL_OPENEDFILES,278,81,91,21,BS_MULTILINE
|
||||||
|
|
||||||
PUSHBUTTON "&Replace",IDREPLACE,278,38,91,14
|
PUSHBUTTON "&Replace",IDREPLACE,278,38,91,14
|
||||||
PUSHBUTTON "Replace &All",IDREPLACEALL,278,56,91,14
|
PUSHBUTTON "Replace &All",IDREPLACEALL,278,56,91,14
|
||||||
@ -82,15 +82,15 @@ BEGIN
|
|||||||
PUSHBUTTON "Clear all marks",IDC_CLEAR_ALL,278,38,91,14
|
PUSHBUTTON "Clear all marks",IDC_CLEAR_ALL,278,38,91,14
|
||||||
PUSHBUTTON "Copy Marked Text",IDC_COPY_MARKED_TEXT,278,56,91,14
|
PUSHBUTTON "Copy Marked Text",IDC_COPY_MARKED_TEXT,278,56,91,14
|
||||||
|
|
||||||
PUSHBUTTON "Close",IDCANCEL,278,98,91,14
|
PUSHBUTTON "Close",IDCANCEL,278,106,91,14
|
||||||
|
|
||||||
GROUPBOX "",IDC_TRANSPARENT_GRPBOX,268,131,99,48
|
GROUPBOX "",IDC_TRANSPARENT_GRPBOX,268,131,101,48
|
||||||
CONTROL "Transparenc&y",IDC_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,264,131,80,10
|
CONTROL "Transparenc&y",IDC_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,264,131,80,10
|
||||||
CONTROL "On losing focus",IDC_TRANSPARENT_LOSSFOCUS_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,278,143,85,10
|
CONTROL "On losing focus",IDC_TRANSPARENT_LOSSFOCUS_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,278,143,85,10
|
||||||
CONTROL "Always",IDC_TRANSPARENT_ALWAYS_RADIO,"Button",BS_AUTORADIOBUTTON ,278,155,85,10
|
CONTROL "Always",IDC_TRANSPARENT_ALWAYS_RADIO,"Button",BS_AUTORADIOBUTTON ,278,155,85,10
|
||||||
CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | NOT WS_VISIBLE | WS_TABSTOP,275,166,85,10
|
CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | WS_TABSTOP,275,166,85,10
|
||||||
|
|
||||||
PUSHBUTTON "",IDD_RESIZE_TOGGLE_BUTTON,375,171,16,14
|
PUSHBUTTON "",IDD_RESIZE_TOGGLE_BUTTON,373,168,16,14
|
||||||
END
|
END
|
||||||
|
|
||||||
IDB_INCREMENTAL_BG BITMAP "../icons/incrementalBg.bmp"
|
IDB_INCREMENTAL_BG BITMAP "../icons/incrementalBg.bmp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user