From 8e1b4e35a38710e4455d71a6ee3d17e95073bfc3 Mon Sep 17 00:00:00 2001 From: Anis Errais Date: Sun, 24 Jan 2021 21:23:08 +0100 Subject: [PATCH] Added options for moving the start menu and showing the start menu at the edge of working area instead of against the taskbar --- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 83 ++++++++++++++------ Src/StartMenu/StartMenuDLL/SettingsUI.cpp | 3 + Src/StartMenu/StartMenuDLL/StartMenuDLL.rc | 6 ++ Src/StartMenu/StartMenuDLL/resource.h | 6 ++ 4 files changed, 75 insertions(+), 23 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index 74e7904..8ad791b 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -7401,35 +7401,46 @@ bool CMenuContainer::HasMoreResults( void ) RECT CMenuContainer::CalculateWorkArea( const RECT &taskbarRect ) { - RECT rc=s_MenuLimits; - if ((s_TaskBarEdge==ABE_LEFT || s_TaskBarEdge==ABE_RIGHT) && GetSettingBool(L"ShowNextToTaskbar")) + RECT rc; + if (!GetSettingBool(L"AlignToWorkArea")) { - // when the taskbar is on the side and the menu is not on top of it - // the start button is assumed at the top - if (s_TaskBarEdge==ABE_LEFT) - rc.left=taskbarRect.right; + rc = s_MenuLimits; + if ((s_TaskBarEdge == ABE_LEFT || s_TaskBarEdge == ABE_RIGHT) && GetSettingBool(L"ShowNextToTaskbar")) + { + // when the taskbar is on the side and the menu is not on top of it + // the start button is assumed at the top + if (s_TaskBarEdge == ABE_LEFT) + rc.left = taskbarRect.right; + else + rc.right = taskbarRect.left; + } else - rc.right=taskbarRect.left; + { + if (s_TaskBarEdge == ABE_BOTTOM) + { + // taskbar is at the bottom + rc.bottom = taskbarRect.top; + } + else if (s_TaskBarEdge == ABE_TOP) + { + // taskbar is at the top + rc.top = taskbarRect.bottom; + } + else + { + // taskbar is on the side, start button must be at the top + rc.top = s_StartRect.bottom; + } + } } else { - if (s_TaskBarEdge==ABE_BOTTOM) - { - // taskbar is at the bottom - rc.bottom=taskbarRect.top; - } - else if (s_TaskBarEdge==ABE_TOP) - { - // taskbar is at the top - rc.top=taskbarRect.bottom; - } - else - { - // taskbar is on the side, start button must be at the top - rc.top=s_StartRect.bottom; - } + // Get working area of the monitor the specified taskbar is on + MONITORINFO info{ sizeof(MONITORINFO) }; + HMONITOR mon = MonitorFromRect(&taskbarRect, 0); + GetMonitorInfo(mon, &info); + rc = info.rcWork; } - if (!s_bLockWorkArea) { // exclude floating keyboard @@ -7455,6 +7466,32 @@ RECT CMenuContainer::CalculateWorkArea( const RECT &taskbarRect ) } } } + + //calculate offsets + int xOff = GetSettingInt(L"HorizontalMenuOffset"); + int yOff = GetSettingInt(L"VerticalMenuOffset"); + if (s_TaskBarEdge == ABE_BOTTOM) + { + if (xOff != 0) + rc.left += xOff; + if (yOff != 0) + rc.bottom += yOff; + } + else if (s_TaskBarEdge == ABE_TOP || s_TaskBarEdge == ABE_LEFT) + { + if (xOff != 0) + rc.left += xOff; + if (yOff != 0) + rc.top += yOff; + } + else + { + if (xOff != 0) + rc.right += xOff; + if (yOff != 0) + rc.top += yOff; + } + return rc; } diff --git a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp index a54c7e3..c2fb2e9 100644 --- a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp +++ b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp @@ -4348,6 +4348,9 @@ CSetting g_Settings[]={ {L"InvertMetroIcons",CSetting::TYPE_BOOL,IDS_INVERT_ICONS,IDS_INVERT_ICONS_TIP,0}, {L"MaxMainMenuWidth",CSetting::TYPE_INT,IDS_MENU_WIDTH,IDS_MENU_WIDTH_TIP,60,CSetting::FLAG_MENU_CLASSIC_BOTH}, {L"MaxMenuWidth",CSetting::TYPE_INT,IDS_SUBMENU_WIDTH,IDS_SUBMENU_WIDTH_TIP,60}, + {L"AlignToWorkArea",CSetting::TYPE_BOOL,IDS_ALIGN_WORK_AREA,IDS_ALIGN_WORK_AREA_TIP,0}, + {L"HorizontalMenuOffset",CSetting::TYPE_INT,IDS_HOR_OFFSET,IDS_HOR_OFFSET_TIP,0}, + {L"VerticalMenuOffset",CSetting::TYPE_INT,IDS_VERT_OFFSET,IDS_VERT_OFFSET_TIP,0 }, {L"OverrideDPI",CSetting::TYPE_INT,IDS_DPI_OVERRIDE,IDS_DPI_OVERRIDE_TIP,0,CSetting::FLAG_COLD}, {L"MainMenuAnimate",CSetting::TYPE_BOOL,IDS_ANIMATION7,IDS_ANIMATION7_TIP,1,CSetting::FLAG_MENU_WIN7}, {L"MainMenuAnimation",CSetting::TYPE_INT,IDS_ANIMATION,IDS_ANIMATION_TIP,-1}, // system animation type diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc b/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc index 113528a..1660b84 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc @@ -644,6 +644,12 @@ BEGIN IDS_PIC_COMMAND_TIP "Enter the command you want to run when you click on the user picture" IDS_NAME_COMMAND "User name command" IDS_NAME_COMMAND_TIP "Enter the command you want to run when you click on the user name" + IDS_ALIGN_WORK_AREA "Align start menu to working area" + IDS_ALIGN_WORK_AREA_TIP "Align the start menu to the working area instead of to the taskbar. Use with custom taskbars" + IDS_HOR_OFFSET "Horizontal position offset" + IDS_HOR_OFFSET_TIP "Offset the start menu horizontally by the amount of pixels specified" + IDS_VERT_OFFSET "Vertical position offset" + IDS_VERT_OFFSET_TIP "Offset the start menu vertically by the amount of pixels specified" IDS_SMALL_SIZE_SM "Small icon size" IDS_SMALL_SIZE_SM_TIP "Set the small icon size. The default is 16 for DPI<=96, 20 for 96120" IDS_LARGE_SIZE_SM "Large icon size" diff --git a/Src/StartMenu/StartMenuDLL/resource.h b/Src/StartMenu/StartMenuDLL/resource.h index 0aed486..ca08926 100644 --- a/Src/StartMenu/StartMenuDLL/resource.h +++ b/Src/StartMenu/StartMenuDLL/resource.h @@ -754,6 +754,12 @@ #define IDS_SELECT_LAST 3657 #define IDS_SELECT_LAST_TIP 3658 #define IDS_CLEAR_CACHE 3659 +#define IDS_ALIGN_WORK_AREA 3660 +#define IDS_ALIGN_WORK_AREA_TIP 3661 +#define IDS_HOR_OFFSET 3662 +#define IDS_HOR_OFFSET_TIP 3663 +#define IDS_VERT_OFFSET 3664 +#define IDS_VERT_OFFSET_TIP 3665 #define IDS_STRING7001 7001 #define IDS_STRING7002 7002 #define IDS_STRING7003 7003