Skip to content

Commit

Permalink
[HD] Add menu "Use Large Toolbar" to adjust toolbar size, issue #867.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Oct 22, 2024
1 parent 7752980 commit a263fdd
Show file tree
Hide file tree
Showing 26 changed files with 169 additions and 31 deletions.
6 changes: 6 additions & 0 deletions locale/de/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ BEGIN
MENUITEM "Sym&bolleiste anzeigen\tStrg+F11", IDM_VIEW_TOOLBAR
MENUITEM "Symbolleiste an&passen...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "Symbolleiste automatisch s&kalieren", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use Lar&ge Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "Statusleiste &anzeigen\tShift+F11", IDM_VIEW_STATUSBAR
MENUITEM SEPARATOR
MENUITEM "&Transparenter Modus\tStrg+0", IDM_VIEW_TRANSPARENT
Expand Down Expand Up @@ -790,6 +793,9 @@ BEGIN
MENUITEM "&Symbolleiste anzeigen", IDM_VIEW_TOOLBAR
MENUITEM "Symbolleiste &anpassen...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "Symbolleiste automatisch s&kalieren", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "S&tatusleiste anzeigen", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
3 changes: 3 additions & 0 deletions locale/de/matepath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ BEGIN
MENUITEM "&Symbolleiste anzeigen", IDM_VIEW_TOOLBAR
MENUITEM "Symbolleiste &anpassen...", IDM_VIEW_CUSTOMIZETB
MENUITEM "Symbolleiste automatisch s&kalieren", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "S&tatusleiste anzeigen", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
6 changes: 6 additions & 0 deletions locale/fr/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ BEGIN
MENUITEM "Afficher la barre d'outils\tCtrl+F11", IDM_VIEW_TOOLBAR
MENUITEM "Personnalisater la barre d'outil...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "Redimensionner automatiquement la barre d'outil", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use Lar&ge Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "Afficher la barre de statut\tShift+F11", IDM_VIEW_STATUSBAR
MENUITEM SEPARATOR
MENUITEM "Mode transparent\tCtrl+0", IDM_VIEW_TRANSPARENT
Expand Down Expand Up @@ -790,6 +793,9 @@ BEGIN
MENUITEM "Afficher la barre d'outil", IDM_VIEW_TOOLBAR
MENUITEM "Personnaliser la barre d'outil...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "Redimensionner automatiquement la barre d'outil", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "Afficher la barre de statut", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
3 changes: 3 additions & 0 deletions locale/fr/matepath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ BEGIN
MENUITEM "Show &Toolbar", IDM_VIEW_TOOLBAR
MENUITEM "&Customize Toolbar...", IDM_VIEW_CUSTOMIZETB
MENUITEM "&Auto Scale Toolbar", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "Show &Statusbar", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
6 changes: 6 additions & 0 deletions locale/it/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ BEGIN
MENUITEM "Mostra &barra degli strumenti\tCtrl+F11", IDM_VIEW_TOOLBAR
MENUITEM "&Personalizza barra degli strumenti...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "&Auto scala barra degli strumenti", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use Lar&ge Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "M&ostra barra di stato\tShift+F11", IDM_VIEW_STATUSBAR
MENUITEM SEPARATOR
MENUITEM "Modalità &trasparente\tCtrl+0", IDM_VIEW_TRANSPARENT
Expand Down Expand Up @@ -790,6 +793,9 @@ BEGIN
MENUITEM "Mostra barra degli s&trumenti", IDM_VIEW_TOOLBAR
MENUITEM "&Personalizza barra degli strumenti...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "&Auto Scala barra degli strumenti", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "Mo&stra barra di stato", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
3 changes: 3 additions & 0 deletions locale/it/matepath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ BEGIN
MENUITEM "Mostra Barra degli strumenti", IDM_VIEW_TOOLBAR
MENUITEM "Personalizza Barra degli strumenti...", IDM_VIEW_CUSTOMIZETB
MENUITEM "&Auto scala barra degli strumenti", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "Mostra Barra di stato", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
6 changes: 6 additions & 0 deletions locale/ja/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ BEGIN
MENUITEM "ツールバーを表示(&H)\tCtrl+F11", IDM_VIEW_TOOLBAR
MENUITEM "ツールバーの編集(&Z)...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "ツールバーの自動縮尺(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use Lar&ge Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "ステータスバーを表示(&U)\tShift+F11", IDM_VIEW_STATUSBAR
MENUITEM SEPARATOR
MENUITEM "ウィンドウ透化(&T)\tCtrl+0", IDM_VIEW_TRANSPARENT
Expand Down Expand Up @@ -790,6 +793,9 @@ BEGIN
MENUITEM "ツールバーの表示(&T)", IDM_VIEW_TOOLBAR
MENUITEM "ツールバーの編集(&C)...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "ツールバーの自動縮尺(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "ステータスバーの表示(&S)", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
3 changes: 3 additions & 0 deletions locale/ja/matepath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ BEGIN
MENUITEM "ツールバーを表示(&T)", IDM_VIEW_TOOLBAR
MENUITEM "ツールバーの編集(&C)...", IDM_VIEW_CUSTOMIZETB
MENUITEM "ツールバーの自動縮尺(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "ステータスバーを表示(&S)", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
6 changes: 6 additions & 0 deletions locale/ko/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ BEGIN
MENUITEM "도구모음 표시(&H)\tCtrl+F11", IDM_VIEW_TOOLBAR
MENUITEM "도구모음 사용자 지정(&Z)...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "도구모음 자동 크기 조정(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use Lar&ge Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "상태 표시줄 표시(&U)\tShift+F11", IDM_VIEW_STATUSBAR
MENUITEM SEPARATOR
MENUITEM "투명 모드(&T)\tCtrl+0", IDM_VIEW_TRANSPARENT
Expand Down Expand Up @@ -790,6 +793,9 @@ BEGIN
MENUITEM "도구모음 표시(&T)", IDM_VIEW_TOOLBAR
MENUITEM "도구모음 사용자 지정(&C)...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "도구모음 자동 크기 조정(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "상태 표시줄 표시(&S)", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
3 changes: 3 additions & 0 deletions locale/ko/matepath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ BEGIN
MENUITEM "도구 모음 표시(&T)", IDM_VIEW_TOOLBAR
MENUITEM "도구 모음 편집(&E)...", IDM_VIEW_CUSTOMIZETB
MENUITEM "도구 모음 자동 크기 조정(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "상태 표시줄 표시(&S)", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
6 changes: 6 additions & 0 deletions locale/pt-BR/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ BEGIN
MENUITEM "S&how Toolbar\tCtrl+F11", IDM_VIEW_TOOLBAR
MENUITEM "Customi&ze Toolbar...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "&Auto Scale Toolbar", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use Lar&ge Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "Show Stat&usbar\tShift+F11", IDM_VIEW_STATUSBAR
MENUITEM SEPARATOR
MENUITEM "&Transparent Mode\tCtrl+0", IDM_VIEW_TRANSPARENT
Expand Down Expand Up @@ -790,6 +793,9 @@ BEGIN
MENUITEM "Show &Toolbar", IDM_VIEW_TOOLBAR
MENUITEM "&Customize Toolbar...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "&Auto Scale Toolbar", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "Show &Statusbar", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
3 changes: 3 additions & 0 deletions locale/pt-BR/matepath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ BEGIN
MENUITEM "Show &Toolbar", IDM_VIEW_TOOLBAR
MENUITEM "&Customize Toolbar...", IDM_VIEW_CUSTOMIZETB
MENUITEM "&Auto Scale Toolbar", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "Show &Statusbar", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
6 changes: 6 additions & 0 deletions locale/zh-Hans/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ BEGIN
MENUITEM "显示工具栏(&H)\tCtrl+F11", IDM_VIEW_TOOLBAR
MENUITEM "自定义工具栏(&Z)...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "工具栏比例自适应(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "使用大工具栏(&G)", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "显示状态栏(&U)\tShift+F11", IDM_VIEW_STATUSBAR
MENUITEM SEPARATOR
MENUITEM "透明模式(&T)\tCtrl+0", IDM_VIEW_TRANSPARENT
Expand Down Expand Up @@ -790,6 +793,9 @@ BEGIN
MENUITEM "显示工具栏(&T)", IDM_VIEW_TOOLBAR
MENUITEM "自定义工具栏(&C)...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "工具栏比例自适应(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "使用大工具栏(&L)", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "显示状态栏(&S)", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
3 changes: 3 additions & 0 deletions locale/zh-Hans/matepath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ BEGIN
MENUITEM "显示工具栏(&T)", IDM_VIEW_TOOLBAR
MENUITEM "自定义工具栏(&C)...", IDM_VIEW_CUSTOMIZETB
MENUITEM "工具栏比例自适应(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "使用大工具栏(&L)", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "显示状态栏(&S)", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
6 changes: 6 additions & 0 deletions locale/zh-Hant/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ BEGIN
MENUITEM "顯示工具列(&H)\tCtrl+F11", IDM_VIEW_TOOLBAR
MENUITEM "自訂工具列(&Z)...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "工具列自動縮放(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "使用大工具列(&G)", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "顯示狀態列(&U)\tShift+F11", IDM_VIEW_STATUSBAR
MENUITEM SEPARATOR
MENUITEM "透明模式(&T)\tCtrl+0", IDM_VIEW_TRANSPARENT
Expand Down Expand Up @@ -790,6 +793,9 @@ BEGIN
MENUITEM "顯示工具列(&T)", IDM_VIEW_TOOLBAR
MENUITEM "自訂工具列(&C)...", IDM_VIEW_CUSTOMIZE_TOOLBAR
MENUITEM "工具列自動縮放(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "使用大工具列(&L)", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "顯示狀態列(&S)", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
3 changes: 3 additions & 0 deletions locale/zh-Hant/matepath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ BEGIN
MENUITEM "顯示工具列(&T)", IDM_VIEW_TOOLBAR
MENUITEM "自訂工具列(&C)...", IDM_VIEW_CUSTOMIZETB
MENUITEM "工具列自動縮放(&A)", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "使用大工具列(&L)", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "顯示狀態列(&S)", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
6 changes: 3 additions & 3 deletions matepath/src/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ HBITMAP LoadBitmapFile(LPCWSTR path) noexcept {
return hbmp;
}

HBITMAP ResizeImageForCurrentDPI(HBITMAP hbmp) noexcept {
HBITMAP ResizeImageForDPI(HBITMAP hbmp, UINT dpi) noexcept {
BITMAP bmp;
if (GetObject(hbmp, sizeof(BITMAP), &bmp)) {
// assume 16x16 at 100% scaling
const int height = (g_uCurrentDPI*16) / USER_DEFAULT_SCREEN_DPI;
const int height = (dpi*16) / USER_DEFAULT_SCREEN_DPI;
if (height == bmp.bmHeight && bmp.bmBitsPixel == 32) {
return hbmp;
}
Expand All @@ -359,7 +359,7 @@ HBITMAP ResizeImageForCurrentDPI(HBITMAP hbmp) noexcept {
#if 0
BITMAP bmp2;
if (GetObject(hCopy, sizeof(BITMAP), &bmp2)) {
printf("%s %u: (%d x %d, %d) => (%d x %d, %d)\n", __func__, g_uCurrentDPI,
printf("%s %u: (%d x %d, %d) => (%d x %d, %d)\n", __func__, dpi,
bmp.bmWidth, bmp.bmHeight, bmp.bmBitsPixel, bmp2.bmWidth, bmp2.bmHeight, bmp2.bmBitsPixel);
}
#endif
Expand Down
15 changes: 11 additions & 4 deletions matepath/src/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,19 @@ BOOL AdjustWindowRectForDpi(LPRECT lpRect, DWORD dwStyle, DWORD dwExStyle, UINT
#endif

#if defined(NP2_ENABLE_HIDPI_IMAGE_RESOURCE) && NP2_ENABLE_HIDPI_IMAGE_RESOURCE
inline int GetBitmapResourceIdForCurrentDPI(int resourceId) noexcept {
if (g_uCurrentDPI > USER_DEFAULT_SCREEN_DPI + USER_DEFAULT_SCREEN_DPI/4) {
int scale = (g_uCurrentDPI + USER_DEFAULT_SCREEN_DPI/4 - 1) / (USER_DEFAULT_SCREEN_DPI/2);
inline int GetBitmapResourceIdForDPI(int resourceId, UINT dpi) noexcept {
if (dpi > USER_DEFAULT_SCREEN_DPI + USER_DEFAULT_SCREEN_DPI/4) {
int scale = (dpi + USER_DEFAULT_SCREEN_DPI/4 - 1) / (USER_DEFAULT_SCREEN_DPI/2);
scale = min(scale, 6);
resourceId += scale - 2;
}
return resourceId;
}
inline int GetBitmapResourceIdForCurrentDPI(int resourceId) noexcept {
return GetBitmapResourceIdForDPI(resourceId, g_uCurrentDPI);
}
#else
#define GetBitmapResourceIdForDPI(resourceId, dpi) (resourceId)
#define GetBitmapResourceIdForCurrentDPI(resourceId) (resourceId)
#endif

Expand Down Expand Up @@ -386,7 +390,10 @@ bool ExeNameFromWnd(HWND hwnd, LPWSTR szExeName, DWORD cchExeName) noexcept;

bool FindUserResourcePath(LPCWSTR path, LPWSTR outPath) noexcept;
HBITMAP LoadBitmapFile(LPCWSTR path) noexcept;
HBITMAP ResizeImageForCurrentDPI(HBITMAP hbmp) noexcept;
HBITMAP ResizeImageForDPI(HBITMAP hbmp, UINT dpi) noexcept;
inline HBITMAP ResizeImageForCurrentDPI(HBITMAP hbmp) noexcept {
return ResizeImageForDPI(hbmp, g_uCurrentDPI);
}

bool BitmapMergeAlpha(HBITMAP hbmp, COLORREF crDest) noexcept;
bool BitmapAlphaBlend(HBITMAP hbmp, COLORREF crDest, BYTE alpha) noexcept;
Expand Down
36 changes: 28 additions & 8 deletions matepath/src/matepath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ bool bMinimizeToTray;
bool fUseRecycleBin;
bool fNoConfirmDelete;
static bool bShowToolbar;
static bool bAutoScaleToolbar;
static int iAutoScaleToolbar;
static bool bShowStatusbar;
static bool bShowDriveBox;
int cxRunDlg;
Expand Down Expand Up @@ -888,18 +888,24 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) noexcept {
SendMessage(hwndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);

bool internalBitmap = false;
const int scale = iAutoScaleToolbar;
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
const UINT dpi = (scale > USER_DEFAULT_SCREEN_DPI) ? (g_uCurrentDPI + scale - USER_DEFAULT_SCREEN_DPI) : g_uCurrentDPI;
#else
const UINT dpi = g_uCurrentDPI;
#endif
// Add normal Toolbar Bitmap
HBITMAP hbmp = nullptr;
if (tchToolbarBitmap != nullptr) {
hbmp = LoadBitmapFile(tchToolbarBitmap);
}
if (hbmp == nullptr) {
internalBitmap = true;
const int resource = GetBitmapResourceIdForCurrentDPI(IDB_TOOLBAR16);
const int resource = GetBitmapResourceIdForDPI(IDB_TOOLBAR16, dpi);
hbmp = static_cast<HBITMAP>(LoadImage(g_exeInstance, MAKEINTRESOURCE(resource), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION));
}
if (bAutoScaleToolbar) {
hbmp = ResizeImageForCurrentDPI(hbmp);
if (scale != 0) {
hbmp = ResizeImageForDPI(hbmp, dpi);
}

BITMAP bmp;
Expand Down Expand Up @@ -1172,7 +1178,10 @@ void MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) {

CheckCmd(hmenu, IDM_VIEW_TOOLBAR, bShowToolbar);
EnableCmd(hmenu, IDM_VIEW_CUSTOMIZETB, bShowToolbar);
CheckCmd(hmenu, IDM_VIEW_AUTO_SCALE_TOOLBAR, bAutoScaleToolbar);
CheckCmd(hmenu, IDM_VIEW_AUTO_SCALE_TOOLBAR, iAutoScaleToolbar);
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
CheckCmd(hmenu, IDM_VIEW_USE_LARGE_TOOLBAR, iAutoScaleToolbar > USER_DEFAULT_SCREEN_DPI);
#endif
CheckCmd(hmenu, IDM_VIEW_STATUSBAR, bShowStatusbar);
CheckCmd(hmenu, IDM_VIEW_DRIVEBOX, bShowDriveBox);

Expand Down Expand Up @@ -1716,10 +1725,21 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
break;

case IDM_VIEW_AUTO_SCALE_TOOLBAR:
bAutoScaleToolbar = !bAutoScaleToolbar;
iAutoScaleToolbar = iAutoScaleToolbar ? 0 : USER_DEFAULT_SCREEN_DPI;
MsgThemeChanged(hwnd, 0, 0);
break;

#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
case IDM_VIEW_USE_LARGE_TOOLBAR:
if (iAutoScaleToolbar >= USER_DEFAULT_SCREEN_DPI && iAutoScaleToolbar < USER_DEFAULT_SCREEN_DPI*2) {
iAutoScaleToolbar += USER_DEFAULT_SCREEN_DPI/2;
} else {
iAutoScaleToolbar = USER_DEFAULT_SCREEN_DPI;
}
MsgThemeChanged(hwnd, 0, 0);
break;
#endif

case IDM_VIEW_STATUSBAR:
bShowStatusbar = !bShowStatusbar;
ShowWindow(hwndStatus, bShowStatusbar ? SW_SHOW : SW_HIDE);
Expand Down Expand Up @@ -2576,7 +2596,7 @@ void LoadSettings() noexcept {
}

bShowToolbar = section.GetBool(L"ShowToolbar", true);
bAutoScaleToolbar = section.GetBool(L"AutoScaleToolbar", true);
iAutoScaleToolbar = section.GetInt(L"AutoScaleToolbar", USER_DEFAULT_SCREEN_DPI);
bShowStatusbar = section.GetBool(L"ShowStatusbar", true);
bShowDriveBox = section.GetBool(L"ShowDriveBox", true);

Expand Down Expand Up @@ -2739,7 +2759,7 @@ void SaveSettings(bool bSaveSettingsNow) noexcept {
Toolbar_GetButtons(hwndToolbar, TOOLBAR_COMMAND_BASE, tchToolbarButtons, COUNTOF(tchToolbarButtons));
section.SetStringEx(L"ToolbarButtons", tchToolbarButtons, DefaultToolbarButtons);
section.SetBoolEx(L"ShowToolbar", bShowToolbar, true);
section.SetBoolEx(L"AutoScaleToolbar", bAutoScaleToolbar, true);
section.SetIntEx(L"AutoScaleToolbar", iAutoScaleToolbar, USER_DEFAULT_SCREEN_DPI);
section.SetBoolEx(L"ShowStatusbar", bShowStatusbar, true);
section.SetBoolEx(L"ShowDriveBox", bShowDriveBox, true);

Expand Down
3 changes: 3 additions & 0 deletions matepath/src/matepath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ BEGIN
MENUITEM "Show &Toolbar", IDM_VIEW_TOOLBAR
MENUITEM "&Customize Toolbar...", IDM_VIEW_CUSTOMIZETB
MENUITEM "&Auto Scale Toolbar", IDM_VIEW_AUTO_SCALE_TOOLBAR
#if NP2_ENABLE_HIDPI_IMAGE_RESOURCE
MENUITEM "Use &Large Toolbar", IDM_VIEW_USE_LARGE_TOOLBAR
#endif
MENUITEM "Show &Statusbar", IDM_VIEW_STATUSBAR
END
POPUP "+"
Expand Down
Loading

0 comments on commit a263fdd

Please sign in to comment.