From 67421df674870f8751fdb94b492da777afe22123 Mon Sep 17 00:00:00 2001 From: Emilio Heredia <60711791+emilioheredia-source@users.noreply.github.com> Date: Sat, 7 Nov 2026 10:39:01 -0600 Subject: [PATCH 1/6] Allow more than two columns in the Classic two-column main menu Every column break now starts a column. The last one still starts the second pane, and earlier ones add columns to the first pane, so a menu with one break looks exactly as before. The Windows 7 style keeps using only its first break. A new setting on the Menu Look tab, Second pane look, picks which column gets the skin's second-pane look: the last column (the default, as before), none (all columns alike), or the first column, drawn on the left. For the first column the background is drawn as usual and then mirrored, so the skin's outer borders stay on the outside; emblems, the user picture and the user name are placed in their pane afterwards. What had to change for that, since the layout assumed column 0 and column 1 in many places: each pane's width is the sum of its columns, items are offset from their own pane's content rectangle, every column is aligned to the bottom on its own (COLUMN_PADDING), and the columns inside a pane get the skin's vertical separators like sub-menu columns do. The icon size of an item, which AddStandardItems picks before the layout, follows the same panes: until now every item after the first column break got the second pane's icon size, so a middle column lost its icons with skins that hide them in the second pane. The pager scrolls the first column, where the pinned programs are, and until now it used the whole first pane for that, which was the same thing. With more columns it is not: the arrows were drawn in the middle of the pane, and hovering or clicking at the top or bottom of any column of the pane hit the pager. GetScrollRect gives the pager its own column. With Second pane look = First that column is in the second pane, whose items can draw composited text (their own opacity setting). Composited text ignores the clip rectangle, so the pager also checks those items before it draws its background again over the spilled text. --- Src/StartMenu/StartMenuDLL/MenuCommands.cpp | 5 +- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 272 ++++++++++++++----- Src/StartMenu/StartMenuDLL/MenuContainer.h | 20 ++ Src/StartMenu/StartMenuDLL/MenuPaint.cpp | 134 ++++++--- Src/StartMenu/StartMenuDLL/SettingsUI.cpp | 4 + Src/StartMenu/StartMenuDLL/SettingsUI.h | 8 + Src/StartMenu/StartMenuDLL/StartMenuDLL.rc | 13 +- Src/StartMenu/StartMenuDLL/resource.h | 8 + 8 files changed, 350 insertions(+), 114 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/MenuCommands.cpp b/Src/StartMenu/StartMenuDLL/MenuCommands.cpp index ac35f04f7..0251b1fc2 100644 --- a/Src/StartMenu/StartMenuDLL/MenuCommands.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuCommands.cpp @@ -1497,9 +1497,10 @@ void CMenuContainer::ActivateItem( int index, TActivateType type, const POINT *p { // scroll the pager to make this item visible RECT rc=item.itemRect; - OffsetRect(&rc,0,-m_rContent.top); + int scrollTop=GetScrollRect().top; + OffsetRect(&rc,0,-scrollTop); int pos=m_ScrollOffset; - int total=m_Items[m_ScrollCount-1].itemRect.bottom-m_rContent.top-m_ScrollHeight; + int total=m_Items[m_ScrollCount-1].itemRect.bottom-scrollTop-m_ScrollHeight; if (pos>rc.top-m_ScrollButtonSize) pos=rc.top-m_ScrollButtonSize; else if (posid==MENU_LAST) @@ -1090,7 +1094,7 @@ void CMenuContainer::AddStandardItems( void ) continue; if (pStdItem->id==MENU_COLUMN_BREAK && !m_bSubMenu && s_Skin.TwoColumns) - bSecondColumn=true; + breaks++; int stdOptions=GetStdOptions(pStdItem->id); if (!(stdOptions&MENU_ENABLED)) continue; @@ -1271,7 +1275,7 @@ void CMenuContainer::AddStandardItems( void ) item.bSplit=item.bFolder && (item.pStdItem->settings&StdMenuItem::MENU_SPLIT_BUTTON)!=0; // get icon - MenuSkin::TIconSize mainIconSize=!bSecondColumn ? s_Skin.Main_icon_size : s_Skin.Main2_icon_size; + MenuSkin::TIconSize mainIconSize=!IsSecondPaneAfterBreaks(breaks,breakCount) ? s_Skin.Main_icon_size : s_Skin.Main2_icon_size; if (item.bInline && mainIconSize==MenuSkin::ICON_SIZE_NONE) mainIconSize=s_Skin.Main_icon_size; @@ -1499,6 +1503,131 @@ void CMenuContainer::AddStandardItems( void ) } } +// The SecondPane setting in effect +TSecondPane CMenuContainer::GetSecondPaneMode( void ) +{ + // the Windows 7 style always uses the last column, and right-to-left menus are mirrored already + if (s_bWin7Style) return SECOND_PANE_LAST; + TSecondPane mode=(TSecondPane)GetSettingInt(L"SecondPane"); + if (mode==SECOND_PANE_FIRST && s_bRTL) return SECOND_PANE_LAST; + return mode; +} + +// The number of column breaks in a menu's items +int CMenuContainer::CountColumnBreaks( const StdMenuItem *pStdItem ) +{ + int count=0; + for (;pStdItem->id!=MENU_LAST;pStdItem++) + if (pStdItem->id==MENU_COLUMN_BREAK) + count++; + return count; +} + +// Whether the items after the given number of column breaks (out of count) get the second-pane look. +// AddStandardItems needs it for their icon size, before the layout knows the columns +bool CMenuContainer::IsSecondPaneAfterBreaks( int breaks, int count ) +{ + if (m_bSubMenu || !s_Skin.TwoColumns || count==0) return false; + if (s_bWin7Style) return breaks>0; // the Windows 7 style uses only the first break + switch (GetSecondPaneMode()) + { + case SECOND_PANE_NONE: return false; + case SECOND_PANE_FIRST: return breaks==0; + default: return breaks==count; + } +} + +// Reads the SecondPane setting for the layout. Returns the index of the last column break, +// or -1 when only the first break starts a column (the Windows 7 style keeps two columns) +int CMenuContainer::InitSecondPane( void ) +{ + m_bSecondPane=true; + m_bSecondPaneFirst=false; + m_Pane2Column=1; // until a column break says otherwise + if (!IsClassicMainMenu()) + return -1; + + int lastBreak=-1; + for (int i=1;i<(int)m_Items.size();i++) + if (m_Items[i].bBreak) + lastBreak=i; + TSecondPane mode=GetSecondPaneMode(); + if (mode==SECOND_PANE_NONE) + m_bSecondPane=false; // every break starts another first-pane column + else if (mode==SECOND_PANE_FIRST && lastBreak>=0) + m_bSecondPaneFirst=true; // the first column has the second-pane look, every break starts a first-pane column + return lastBreak; +} + +// The pane (0 or 1) of the column that a column break starts, given the pane of the column before it. +// Remembers where the panes meet in m_Pane2Column +int CMenuContainer::GetPaneOfNewColumn( int column, int pane, bool bLastBreak ) +{ + if (m_bSecondPaneFirst) + { + if (pane==1) + m_Pane2Column=column; // the first break ends the second pane + return 0; + } + if (m_bSecondPane && bLastBreak) + { + m_Pane2Column=column; + return 1; + } + return pane; +} + +// Sets m_PaneColumns from m_Pane2Column once the number of columns is known +void CMenuContainer::UpdatePaneColumns( void ) +{ + int count=(int)m_ColumnOffsets.size(); + int boundary=m_Pane2Column &columnWidths ) +{ + const PaneColumns &columns=m_PaneColumns[pane]; + if (columns.last<=columns.first) return 0; + return m_ColumnOffsets[columns.last-1]+columnWidths[columns.last-1]-m_ColumnOffsets[columns.first]; +} + +// The left edge of a column, in window coordinates. Each pane starts at its own content rectangle +int CMenuContainer::GetColumnX( int column ) +{ + if (IsSecondPaneColumn(column)) + return m_rContent2.left+m_ColumnOffsets[column]-m_ColumnOffsets[m_PaneColumns[1].first]; + return m_rContent.left+m_ColumnOffsets[column]-m_ColumnOffsets[m_PaneColumns[0].first]; +} + +// Where the pager scrolls: the content of a sub-menu, or the first column of the main menu, where the pinned programs are +RECT CMenuContainer::GetScrollRect( void ) +{ + if (!m_bTwoColumns || m_ColumnOffsets.empty()) + return m_rContent; + int pane=IsSecondPaneColumn(0)?1:0; + RECT rc=pane?m_rContent2:m_rContent; + if (m_PaneColumns[pane].last>1) + rc.right=GetColumnX(1)-s_Skin.Main_separatorWidth; // more columns share the pane: stop at the gap before the next one + return rc; +} + void CMenuContainer::UpdateAccelerators( int first, int last ) { TRecentKeys recentKeys=(TRecentKeys)GetSettingInt(L"RecentProgKeys"); @@ -3233,16 +3362,21 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, bool bMultiColumn=s_ScrollMenus!=0 && (m_Options&CONTAINER_MULTICOLUMN); int shutdownIndex=-1; + // in the Classic two-column menu the last column break starts the second pane, and any earlier break adds a column to the first pane. + // the Windows 7 style keeps using only the first break + int lastBreak=InitSecondPane(); + { int row=0, column=0, subColumn=0; int y=0; int maxw=0; - int index=0; + int index=m_bSecondPaneFirst?1:0; for (int i=0;i<(int)m_Items.size();i++) { MenuItem &item=m_Items[i]; - if (m_bTwoColumns && column==0 && i>0 && item.bBreak) + bool bColumnBreak=item.bBreak && (index==0 || m_bSecondPaneFirst) && (column==0 || lastBreak>=0); + if (m_bTwoColumns && i>0 && bColumnBreak) { // start a new column column++; @@ -3256,7 +3390,7 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, else y=s_Skin.User_frame_position.x+s_Skin.User_image_padding.y-menuPadding[0].top; } - index=1; + index=GetPaneOfNewColumn(column,index,lastBreak<0 || i==lastBreak); } item.bNew=false; if (m_bTwoColumns && im_SearchIndex) && item.id!=MENU_SHUTDOWN_BUTTON) @@ -3455,7 +3589,7 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, y=0; } } - else if (item.id==MENU_SEPARATOR && !item.bBlankSeparator && !item.bInline && m_bTwoColumns && column==0 && i+1<(int)m_Items.size() && m_Items[i+1].bBreak) + else if (item.id==MENU_SEPARATOR && !item.bBlankSeparator && !item.bInline && m_bTwoColumns && (index==0 || m_bSecondPaneFirst) && i+1<(int)m_Items.size() && m_Items[i+1].bBreak) h=0; item.row=row; item.column=column; @@ -3490,6 +3624,8 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, row++; } } + if (!m_bSecondPane) + m_Pane2Column=(int)columnWidths.size(); // past the last column: every column is in the first pane SelectObject(hdc,font0); DeleteDC(hdc); @@ -3561,7 +3697,8 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, // calculate the horizontal position of each item int maxw=0; - int maxh[2]={0,0}; + int maxh[2]={0,0}; // height of the tallest column in each pane + int scrollHeight=0; // the pager scrolls only the first column of the main menu, where the pinned programs are int scrollWidth=GetSystemMetrics(SM_CXVSCROLL); { m_ColumnOffsets.resize(columnWidths.size()); @@ -3571,6 +3708,7 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, m_ColumnOffsets[i]=maxw; maxw+=columnWidths[i]; } + UpdatePaneColumns(); columnWidths.push_back(maxw); bool bInline=false; for (int i=0;i<(int)m_Items.size();i++) @@ -3606,16 +3744,11 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, item.itemRect.right-=scrollWidth; } } - if (m_bTwoColumns) - { - if (maxh[item.column]2) { - w1=columnWidths[0]; - w2=columnWidths[1]; + w1=GetPaneWidth(0,columnWidths); + w2=GetPaneWidth(1,columnWidths); if (s_bWin7Style) { @@ -3794,10 +3927,16 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, MenuItem &item=m_Items[i]; int dx=m_rContent.left; int dy=m_rContent.top; - if (m_bTwoColumns && item.column==1) + if (m_bTwoColumns) { - dx=m_rContent2.left-m_ColumnOffsets[1]; - dy=m_rContent2.top; + // each pane starts at its own content rectangle + if (IsSecondPaneColumn(item.column)) + { + dx=m_rContent2.left-m_ColumnOffsets[m_PaneColumns[1].first]; + dy=m_rContent2.top; + } + else if (m_PaneColumns[0].first<(int)m_ColumnOffsets.size()) + dx=m_rContent.left-m_ColumnOffsets[m_PaneColumns[0].first]; } if (item.id==MENU_SHUTDOWN_BUTTON) dx=0; @@ -3806,49 +3945,34 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, if (m_bTwoColumns && columnWidths.size()>2) { - int dh1=0, dh2=0; + // each column is aligned to the bottom separately (from its first COLUMN_PADDING on) + std::vector columnDH(m_ColumnOffsets.size(),0); // how far down the column's aligned items move for (int i=0;i bAlign(columnDH.size(),false); for (int i=0;imaxHeight[0] && m_ScrollCount>0 && (m_bSubMenu || !s_bWin7Style)) + int scrollPane=IsSecondPaneColumn(0)?1:0; // the first column can have the second-pane look (SecondPane=First) + int scrollTop=GetScrollRect().top; + if (!bMultiColumn && scrollHeight>maxHeight[scrollPane] && m_ScrollCount>0 && (m_bSubMenu || !s_bWin7Style)) { - int d=maxh[0]-maxHeight[0]; - m_ScrollHeight=m_Items[m_ScrollCount-1].itemRect.bottom-d-m_rContent.top; + int d=scrollHeight-maxHeight[scrollPane]; + m_ScrollHeight=m_Items[m_ScrollCount-1].itemRect.bottom-d-scrollTop; if (m_ScrollHeight<=0) { if (m_ScrollCount<(int)m_Items.size()) - d=m_Items[m_ScrollCount].itemRect.bottom-m_rContent.top; + d=m_Items[m_ScrollCount].itemRect.bottom-scrollTop; m_ScrollOffset=m_ScrollHeight=0; for (int i=0;ibottom) m_Items[i].itemRect.bottom=m_Items[i].itemRect.top; } @@ -4120,8 +4246,8 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, { m_SearchBox.Create(L"EDIT",m_hWnd,itemRect,NULL,WS_CHILD|(s_Skin.Search_frame?WS_BORDER:0)|ES_AUTOHSCROLL|ES_WANTRETURN); SetWindowSubclass(m_SearchBox,SubclassSearchBox,(UINT_PTR)this,0); - int index=(m_bTwoColumns && m_Items[m_SearchIndex].column==1)?1:0; - if (index==1 && (m_SearchIndex==0 || m_Items[m_SearchIndex-1].column==0)) + int index=IsSecondPaneColumn(m_Items[m_SearchIndex].column)?1:0; + if (index==1 && (m_SearchIndex==0 || !IsSecondPaneColumn(m_Items[m_SearchIndex-1].column))) m_SearchBox.SetFont(s_Skin.ItemSettings[MenuSkin::COLUMN2_ITEM].font); else m_SearchBox.SetFont(s_Skin.ItemSettings[MenuSkin::COLUMN1_ITEM].font); @@ -4355,7 +4481,7 @@ void CMenuContainer::UpdateScroll( void ) else { m_bScrollUp=(m_ScrollOffset>0); - m_bScrollDown=(m_ScrollOffset+m_ScrollHeight0 && index=m_rContent.top+m_ScrollHeight-m_ScrollButtonSize) + if (m_bScrollDown && rc.top>=scrollTop+m_ScrollHeight-m_ScrollButtonSize) return false; } if (m_SearchScrollCount>m_SearchScrollHeight && index>=m_OriginalCount) @@ -4529,10 +4656,13 @@ bool CMenuContainer::GetItemRect( int index, RECT &rc ) int CMenuContainer::HitTest( const POINT &pt, bool *bArrow, bool bDrop ) { - if (m_bScrollUp && pt.y=rScroll.left && pt.x=m_rContent.top+m_ScrollHeight-m_ScrollButtonSize) + if (m_bScrollDown && bInPager && pt.y>=rScroll.top+m_ScrollHeight-m_ScrollButtonSize) start=m_ScrollCount; int n=(int)m_Items.size(); for (int i=start;im_SearchIndex>=0 && GetSettingInt(L"SearchBox")==SEARCHBOX_NORMAL && GetSettingBool(L"SearchSelect")) { pStartMenu->ActivateItem(pStartMenu->m_SearchIndex,ACTIVATE_SELECT,NULL); - if (pStartMenu->m_bTwoColumns && pStartMenu->m_Items[pStartMenu->m_SearchIndex].column==0 && pStartMenu->m_SearchIndex+1<(int)pStartMenu->m_Items.size() && pStartMenu->m_Items[pStartMenu->m_SearchIndex+1].column==1) + if (pStartMenu->m_bTwoColumns && pStartMenu->m_Items[pStartMenu->m_SearchIndex].column==0 && pStartMenu->m_SearchIndex+1<(int)pStartMenu->m_Items.size() && pStartMenu->m_Items[pStartMenu->m_SearchIndex+1].column!=0) s_bOverrideFirstDown=true; } else if (!bTreeSelected) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.h b/Src/StartMenu/StartMenuDLL/MenuContainer.h index 057982104..99a856d0a 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.h +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.h @@ -25,6 +25,7 @@ #endif enum TRecentPrograms; +enum TSecondPane; enum TMenuID { @@ -661,6 +662,14 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub POINT m_PaintOffset; int m_MaxWidth; bool m_bTwoColumns; + bool m_bSecondPane; // false when the SecondPane setting gives no column the second-pane look + bool m_bSecondPaneFirst; // SecondPane=First: the second pane is the columns before m_Pane2Column, on the left + int m_Pane2Column; // where the panes meet: the second pane starts here (or ends here with m_bSecondPaneFirst) + struct PaneColumns + { + int first, last; // [first,last) + }; + PaneColumns m_PaneColumns[2]; // the columns of the first and the second pane, set by InitWindowInternal RECT m_rMenu; RECT m_rContent; RECT m_rContent2; @@ -701,6 +710,17 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub int AddSearchItems( const std::vector &items, const CString &categoryName, unsigned int categoryHash, int originalCount ); void GetRecentPrograms( std::vector &items, int maxCount ); + static TSecondPane GetSecondPaneMode( void ); + static int CountColumnBreaks( const StdMenuItem *pStdItem ); + bool IsSecondPaneAfterBreaks( int breaks, int count ); + int InitSecondPane( void ); + int GetPaneOfNewColumn( int column, int pane, bool bLastBreak ); + void UpdatePaneColumns( void ); + int GetPaneWidth( int pane, const std::vector &columnWidths ); + int GetColumnX( int column ); + RECT GetScrollRect( void ); + bool IsClassicMainMenu( void ) { return m_bTwoColumns && !m_bSubMenu && !s_bWin7Style; } + bool IsSecondPaneColumn( int column ) { return column>=m_PaneColumns[1].first && column0 && !s_bRTL; + int pane1[2]={0,totalWidth1}, pane2[2]={totalWidth1,totalWidth}; // [left,right) of each pane, to align emblems and the user + if (bPane2First) + { + pane2[0]=textHeight; + pane2[1]=textHeight+totalWidth2; + pane1[0]=pane2[1]; + pane1[1]=totalWidth; + } totalHeight=height1+menuPadding[0].top+menuPadding[0].bottom; - if (m_bTwoColumns) + if (m_bTwoColumns && m_bSecondPane) { int totalHeight2=height2+menuPadding[1].top+menuPadding[1].bottom; if (totalHeight0) - pos.x=totalWidth1+(totalWidth2-frameSize.cx)/2; + pos.x=(pane2[0]+pane2[1]-frameSize.cx)/2; else pos.x=(totalWidth-frameSize.cx)/2; } @@ -1228,10 +1274,7 @@ void CMenuContainer::CreateBackground( int width1, int width2, int height1, int { RECT rc0; int x0=0, x1=totalWidth; - if (s_Skin.User_name_align==MenuSkin::HALIGN_CENTER1 || s_Skin.User_name_align==MenuSkin::HALIGN_LEFT1 || s_Skin.User_name_align==MenuSkin::HALIGN_RIGHT1) - x1=totalWidth1; - else if (s_Skin.User_name_align==MenuSkin::HALIGN_CENTER2 || s_Skin.User_name_align==MenuSkin::HALIGN_LEFT2 || s_Skin.User_name_align==MenuSkin::HALIGN_RIGHT2) - x0=totalWidth1; + AlignToPane(s_Skin.User_name_align,pane1,pane2,x0,x1); if (s_Skin.User_name_position.left<0) rc0.left=x1+s_Skin.User_name_position.left; @@ -1606,8 +1649,13 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect ) MenuBitmap bmpPagerArrows; SIZE pagArrowSize; MenuSkin::TOpacity opacity=m_bSubMenu?s_Skin.Submenu_opacity:s_Skin.Main_opacity; - int glow=s_Skin.ItemSettings[m_bSubMenu?MenuSkin::SUBMENU_ITEM:MenuSkin::COLUMN1_ITEM].glowSize; + // the scrolling items can be in the second pane (SecondPane=First) + const MenuSkin::ItemDrawSettings &scrollSettings=s_Skin.ItemSettings[m_bSubMenu?MenuSkin::SUBMENU_ITEM:(IsSecondPaneColumn(0)?MenuSkin::COLUMN2_ITEM:MenuSkin::COLUMN1_ITEM)]; + int glow=scrollSettings.glowSize; if (!s_Theme) glow=0; + // composited text ignores the clip rectangle, so the pager buttons need their background drawn again (see DrawThemeTextEx below) + bool bTextSpills=(glow || opacity==MenuSkin::OPACITY_FULLALPHA || opacity==MenuSkin::OPACITY_FULLGLASS || + scrollSettings.opacity==MenuSkin::OPACITY_FULLALPHA || scrollSettings.opacity==MenuSkin::OPACITY_FULLGLASS); TRecentKeys recentType=(TRecentKeys)GetSettingInt(L"RecentProgKeys"); if (m_bSubMenu) @@ -1638,13 +1686,14 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect ) HGDIOBJ font0=GetCurrentObject(hdc,OBJ_FONT); SetBkMode(hdc,TRANSPARENT); - // set clip rectangle for the scrollable items - int clipTop=m_rContent.top; - int clipBottom=m_rContent.bottom; + // set clip rectangle for the scrollable items (the pager covers only the column that scrolls, see GetScrollRect) + RECT rScroll=GetScrollRect(); + int clipTop=rScroll.top; + int clipBottom=rScroll.bottom; if (m_bScrollUp) - clipTop=m_rContent.top+m_ScrollButtonSize; + clipTop=rScroll.top+m_ScrollButtonSize; if (m_bScrollDown) - clipBottom=m_rContent.top+m_ScrollHeight-m_ScrollButtonSize; + clipBottom=rScroll.top+m_ScrollHeight-m_ScrollButtonSize; if (m_ScrollHeight>0) IntersectClipRect(hdc,0,clipTop,m_rMenu.right,clipBottom); @@ -1665,10 +1714,10 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect ) SelectClipRgn(hdc,NULL); if (m_bScrollUp) { - if (glow || opacity==MenuSkin::OPACITY_FULLALPHA || opacity==MenuSkin::OPACITY_FULLGLASS) + if (bTextSpills) { // fix background behind the up button (DrawThemeTextEx may spill onto the tablecloth) - RECT rc={m_rContent.left,0,m_rContent.right,clipTop}; + RECT rc={rScroll.left,0,rScroll.right,clipTop}; if (bAlphaMain || !bmpMain) { SetDCBrushColor(hdc,m_bSubMenu?s_Skin.Submenu_background:s_Skin.Main_background); @@ -1677,7 +1726,7 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect ) if (bmpMain) { HGDIOBJ bmp0=SelectObject(hdc2,bmpMain); - IntersectClipRect(hdc,m_rContent.left,0,m_rContent.right,clipTop); + IntersectClipRect(hdc,rScroll.left,0,rScroll.right,clipTop); MarginsBlit(hdc2,hdc,rSrcMain,m_rMenu,rMarginsMain,bAlphaMain); SelectObject(hdc2,bmp0); SelectClipRgn(hdc,NULL); @@ -1685,7 +1734,7 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect ) } // draw up button - RECT rc=m_rContent; + RECT rc=rScroll; rc.bottom=clipTop; if (bmpPager.GetBitmap() && bmpPagerArrows.GetBitmap()) { @@ -1722,10 +1771,10 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect ) { int bottom=clipBottom+s_Skin.ItemSettings[m_bSubMenu?MenuSkin::SUBMENU_ITEM:MenuSkin::COLUMN1_ITEM].itemHeight; if (bottom>=m_rMenu.bottom) bottom=m_rMenu.bottom; - if (bottom>clipBottom && (glow || opacity==MenuSkin::OPACITY_FULLALPHA || opacity==MenuSkin::OPACITY_FULLGLASS)) + if (bottom>clipBottom && bTextSpills) { // fix background behind the up button (DrawThemeTextEx may spill onto the tablecloth) - RECT rc={m_rContent.left,clipBottom,m_rContent.right,bottom}; + RECT rc={rScroll.left,clipBottom,rScroll.right,bottom}; if (bAlphaMain || !bmpMain) { SetDCBrushColor(hdc,m_bSubMenu?s_Skin.Submenu_background:s_Skin.Main_background); @@ -1734,7 +1783,7 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect ) if (bmpMain) { HGDIOBJ bmp0=SelectObject(hdc2,bmpMain); - IntersectClipRect(hdc,m_rContent.left,clipBottom,m_rContent.right,bottom); + IntersectClipRect(hdc,rScroll.left,clipBottom,rScroll.right,bottom); MarginsBlit(hdc2,hdc,rSrcMain,m_rMenu,rMarginsMain,bAlphaMain); SelectObject(hdc2,bmp0); SelectClipRgn(hdc,NULL); @@ -1742,8 +1791,8 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect ) } // draw down button - RECT rc=m_rContent; - rc.bottom=m_rContent.top+m_ScrollHeight; + RECT rc=rScroll; + rc.bottom=rScroll.top+m_ScrollHeight; rc.top=clipBottom; if (bmpPager.GetBitmap() && bmpPagerArrows.GetBitmap()) { @@ -2451,18 +2500,23 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect ) } } - // draw vertical separators - if (m_bSubMenu && m_ColumnOffsets.size()>1) + // draw vertical separators between the columns of a sub-menu, or within each pane of the main menu + // (the separator between the two panes is part of the background) + for (int pane=0;pane<2;pane++) { + const RECT &content=pane?m_rContent2:m_rContent; + int sepFirst=m_PaneColumns[pane].first+1, sepLast=m_PaneColumns[pane].last; // separators go before these columns + if (sepFirst>=sepLast) + continue; if (bmpSeparatorV.GetBitmap()) { HGDIOBJ bmp0=SelectObject(hdc2,bmpSeparatorV.GetBitmap()); RECT rSrc={0,0,sepWidth,sepSlicesY[0]+sepSlicesY[1]+sepSlicesY[2]}; RECT rMargins={0,sepSlicesY[0],0,sepSlicesY[2]}; - for (size_t i=1;i Date: Sat, 7 Nov 2026 15:42:32 -0600 Subject: [PATCH 2/6] Use the pager's column for its scroll range too The scroll range for touch, hover, keyboard and wheel scrolling was still measured from the top of the first pane (m_rContent). With Second pane look = First column the pinned programs are in the second pane, whose top can be at another height, depending on the skin's padding, so the last pinned program could be cut off or followed by a gap. It now comes from GetScrollRect, like the rest of the pager. With Immersive both panes start at the same height, so the screenshots in this PR don't change. --- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index 588f34c80..42f8e9ddd 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -4934,7 +4934,7 @@ LRESULT CMenuContainer::OnGesture( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL scroll=0; bOverpan=true; } - int total=m_Items[m_ScrollCount-1].itemRect.bottom-m_rContent.top-m_ScrollHeight; + int total=m_Items[m_ScrollCount-1].itemRect.bottom-GetScrollRect().top-m_ScrollHeight; if (scroll>total) { scroll=total; @@ -5406,7 +5406,7 @@ LRESULT CMenuContainer::OnTimer( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& else if (m_bScrollDown && m_bScrollDownHot) { scroll+=s_Skin.ItemSettings[m_bSubMenu?MenuSkin::SUBMENU_ITEM:MenuSkin::COLUMN1_ITEM].itemHeight*speed/6; - int total=m_Items[m_ScrollCount-1].itemRect.bottom-m_rContent.top-m_ScrollHeight; + int total=m_Items[m_ScrollCount-1].itemRect.bottom-GetScrollRect().top-m_ScrollHeight; if (scroll>total) scroll=total; } if (m_ScrollOffset!=scroll) @@ -5903,7 +5903,7 @@ LRESULT CMenuContainer::OnKeyDown( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL int y0=m_Items[index].itemRect.top; int scrollOffset=0; if (m_ScrollCount>0) - scrollOffset=m_Items[m_ScrollCount-1].itemRect.bottom-m_rContent.top-m_ScrollHeight; + scrollOffset=m_Items[m_ScrollCount-1].itemRect.bottom-GetScrollRect().top-m_ScrollHeight; if (index0) - scrollOffset=m_Items[m_ScrollCount-1].itemRect.bottom-m_rContent.top-m_ScrollHeight; + scrollOffset=m_Items[m_ScrollCount-1].itemRect.bottom-GetScrollRect().top-m_ScrollHeight; if (indextotal) scroll=total; if (m_ScrollOffset!=scroll) { From 72625b0dfab95749380bcbbe4ad4a9715a8450f2 Mon Sep 17 00:00:00 2001 From: Emilio Heredia <60711791+emilioheredia-source@users.noreply.github.com> Date: Sat, 7 Nov 2026 20:22:41 -0600 Subject: [PATCH 3/6] Pin a drop on empty space only in the pinned programs' column A drop on empty space adds the program to the pinned programs. It was measured against the first pane (m_rContent), which until now was the same as their column. With more columns, a drop on empty space in another column of the first pane pinned the program too, and with Second pane look = First column a drop in the pinned programs' own column did nothing. It now uses GetScrollRect, like the pager. The pager's scroll range was the same expression in six places; GetScrollRange now gives it once. --- Src/StartMenu/StartMenuDLL/DragDrop.cpp | 3 ++- Src/StartMenu/StartMenuDLL/MenuCommands.cpp | 5 ++--- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 18 ++++++++++++------ Src/StartMenu/StartMenuDLL/MenuContainer.h | 1 + 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/DragDrop.cpp b/Src/StartMenu/StartMenuDLL/DragDrop.cpp index 7b3262db8..f272f75f0 100644 --- a/Src/StartMenu/StartMenuDLL/DragDrop.cpp +++ b/Src/StartMenu/StartMenuDLL/DragDrop.cpp @@ -609,7 +609,8 @@ HRESULT STDMETHODCALLTYPE CMenuContainer::DragOver( DWORD grfKeyState, POINTL pt } else { - if (!m_bSubMenu && indexrc.top-m_ScrollButtonSize) pos=rc.top-m_ScrollButtonSize; else if (pos0); - m_bScrollDown=(m_ScrollOffset+m_ScrollHeighttotal) { scroll=total; @@ -5406,7 +5412,7 @@ LRESULT CMenuContainer::OnTimer( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& else if (m_bScrollDown && m_bScrollDownHot) { scroll+=s_Skin.ItemSettings[m_bSubMenu?MenuSkin::SUBMENU_ITEM:MenuSkin::COLUMN1_ITEM].itemHeight*speed/6; - int total=m_Items[m_ScrollCount-1].itemRect.bottom-GetScrollRect().top-m_ScrollHeight; + int total=GetScrollRange(); if (scroll>total) scroll=total; } if (m_ScrollOffset!=scroll) @@ -5903,7 +5909,7 @@ LRESULT CMenuContainer::OnKeyDown( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL int y0=m_Items[index].itemRect.top; int scrollOffset=0; if (m_ScrollCount>0) - scrollOffset=m_Items[m_ScrollCount-1].itemRect.bottom-GetScrollRect().top-m_ScrollHeight; + scrollOffset=GetScrollRange(); if (index0) - scrollOffset=m_Items[m_ScrollCount-1].itemRect.bottom-GetScrollRect().top-m_ScrollHeight; + scrollOffset=GetScrollRange(); if (indextotal) scroll=total; if (m_ScrollOffset!=scroll) { diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.h b/Src/StartMenu/StartMenuDLL/MenuContainer.h index 99a856d0a..f8107635c 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.h +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.h @@ -719,6 +719,7 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub int GetPaneWidth( int pane, const std::vector &columnWidths ); int GetColumnX( int column ); RECT GetScrollRect( void ); + int GetScrollRange( void ); bool IsClassicMainMenu( void ) { return m_bTwoColumns && !m_bSubMenu && !s_bWin7Style; } bool IsSecondPaneColumn( int column ) { return column>=m_PaneColumns[1].first && column Date: Sun, 15 Nov 2026 12:36:13 -0600 Subject: [PATCH 4/6] Move the per-column bottom alignment and the pager column test into helpers Behavior is unchanged. InitWindowInternal and HitTest are long upstream functions, so the new code they needed now lives in two helpers instead of growing them: GetColumnBottomShifts works out how far each column's bottom-aligned items move, and IsInScrollColumn tells whether a point is in the column the pager scrolls. --- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 51 ++++++++++++-------- Src/StartMenu/StartMenuDLL/MenuContainer.h | 2 + 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index e3e3c5fea..baa38172b 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -1628,6 +1628,32 @@ RECT CMenuContainer::GetScrollRect( void ) return rc; } +// How far each column's bottom-aligned items move down: from the bottom of the column's items to the bottom of its pane +void CMenuContainer::GetColumnBottomShifts( std::vector &shifts ) +{ + shifts.assign(m_ColumnOffsets.size(),0); + for (int i=0;i=rc.left && pt.x2) { // each column is aligned to the bottom separately (from its first COLUMN_PADDING on) - std::vector columnDH(m_ColumnOffsets.size(),0); // how far down the column's aligned items move - for (int i=0;i columnDH; + GetColumnBottomShifts(columnDH); // only the Windows 7 style trims overlapping items below, and it always has the second pane in column m_Pane2Column int dh1=columnDH[0], dh2=m_Pane2Column<(int)columnDH.size()?columnDH[m_Pane2Column]:0; @@ -4662,13 +4676,12 @@ bool CMenuContainer::GetItemRect( int index, RECT &rc ) int CMenuContainer::HitTest( const POINT &pt, bool *bArrow, bool bDrop ) { - // the pager buttons cover only the column that scrolls - RECT rScroll=GetScrollRect(); - bool bInPager=(pt.x>=rScroll.left && pt.x=rScroll.top+m_ScrollHeight-m_ScrollButtonSize) + if (m_bScrollDown && bInPager && pt.y>=scrollTop+m_ScrollHeight-m_ScrollButtonSize) start=m_ScrollCount; int n=(int)m_Items.size(); for (int i=start;i &shifts ); bool IsClassicMainMenu( void ) { return m_bTwoColumns && !m_bSubMenu && !s_bWin7Style; } bool IsSecondPaneColumn( int column ) { return column>=m_PaneColumns[1].first && column Date: Sat, 7 Nov 2026 15:06:03 -0600 Subject: [PATCH 5/6] Let the Classic two-column menu place its pinned programs, in rows per column Until now the pinned programs always lead the first column of the main menu. A new item, Pinned programs (pinned_programs, Classic two-column style only), puts them where it is in the menu: after a column break it gives them a column of their own, next to the places, for example. The pinned programs stay at the start of the item list (0..m_ScrollCount) because the pager, painting, keyboard and drag and drop rely on that. Only the layout order changes: GetLayoutOrder lays out the items configured before the Pinned programs item first, then the pinned programs and their separator, then the rest. MovePinnedPadding keeps a leading COLUMN_PADDING with the items it belongs to. The item has a Rows per column setting in the item editor (Item.Rows, 0 = no limit). After that many rows the list continues in the next column, aligned under its first row: SetOverflowBreaks marks those breaks as overflow breaks, which start a column in the same pane and never move the boundary between the panes. One list and one order, so drag and drop works as before. The pager follows the pinned programs to their column (GetScrollColumn), including its pane and its skin settings. Restore Defaults in the item editor also clears the rows. --- Src/Lib/SettingsUIHelper.h | 3 +- Src/StartMenu/StartMenuDLL/CustomMenu.cpp | 5 + Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 153 ++++++++++++++++--- Src/StartMenu/StartMenuDLL/MenuContainer.h | 17 ++- Src/StartMenu/StartMenuDLL/MenuPaint.cpp | 4 +- Src/StartMenu/StartMenuDLL/SettingsUI.cpp | 33 +++- Src/StartMenu/StartMenuDLL/StartMenuDLL.rc | 5 + Src/StartMenu/StartMenuDLL/resource.h | 7 +- 8 files changed, 196 insertions(+), 31 deletions(-) diff --git a/Src/Lib/SettingsUIHelper.h b/Src/Lib/SettingsUIHelper.h index e85388b8f..387c0b63d 100644 --- a/Src/Lib/SettingsUIHelper.h +++ b/Src/Lib/SettingsUIHelper.h @@ -243,9 +243,10 @@ struct CTreeItem CString icon; CString iconD; unsigned int settings; + int rows; // rows per column of a Pinned programs list (0 - no limit) const CStdCommand *pStdCommand; // always valid - CTreeItem( void ) { settings=0; pStdCommand=NULL; } + CTreeItem( void ) { settings=0; rows=0; pStdCommand=NULL; } void SetCommand( CString command, const CStdCommand *pStdCommands, int style, int mask ); unsigned int GetIconKey( void ) const; HICON LoadIcon( bool bSmall, std::vector &modules ) const; diff --git a/Src/StartMenu/StartMenuDLL/CustomMenu.cpp b/Src/StartMenu/StartMenuDLL/CustomMenu.cpp index 8e7875c74..0cc9fdf96 100644 --- a/Src/StartMenu/StartMenuDLL/CustomMenu.cpp +++ b/Src/StartMenu/StartMenuDLL/CustomMenu.cpp @@ -55,6 +55,7 @@ static StdMenuItem g_StdMenu[]= {L"switch_user",MENU_SWITCHUSER}, {L"lock",MENU_LOCK}, {L"*recent_programs",MENU_RECENT_PROGRAMS}, + {L"*pinned_programs",MENU_PINNED_PROGRAMS}, {L"search_box",MENU_SEARCH_BOX}, {L"*apps",MENU_APPS}, @@ -285,6 +286,9 @@ static void ParseMenuItem( StdMenuItem &item, const wchar_t *name ) item.iconPath=g_CustomMenuParser.FindSetting(buf); item.settings=ParseItemSettings(name); + Sprintf(buf,_countof(buf),L"%s.Rows",name); + str=g_CustomMenuParser.FindSetting(buf); + item.rows=str?_wtol(str):0; if (custom7>=0) { if (g_StdCommands7[custom7].flags&CStdCommand7::ITEM_SINGLE) @@ -491,6 +495,7 @@ const StdMenuItem *ParseCustomMenu( unsigned int &rootSettings ) item.folder1=item.folder2=NULL; item.label=item.tip=item.iconPath=item.link=NULL; item.settings=0; + item.rows=0; item.submenu=NULL; // handle special names diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index baa38172b..a2c590048 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -709,6 +709,7 @@ CMenuContainer::CMenuContainer( CMenuContainer *pParent, int index, int options, m_MaxWidth=0; m_bTwoColumns=false; + m_PinnedPosition=-1; m_bSecondPane=true; m_bSecondPaneFirst=false; m_Pane2Column=1; // the first column is the first pane, the rest the second pane (the layout sets it from the column breaks) @@ -1055,8 +1056,10 @@ void CMenuContainer::AddInternetSearch( size_t index ) m_Items.insert(m_Items.begin()+index,1,item); } -void CMenuContainer::AddStandardItems( void ) +void CMenuContainer::AddStandardItems( bool bPlacePinned ) { + if (bPlacePinned) + m_PinnedPosition=-1; if (m_pStdItem && m_pStdItem->id!=MENU_NO) { bool bItemsFirst=(m_Options&(CONTAINER_ITEMS_FIRST|CONTAINER_SEARCH))==CONTAINER_ITEMS_FIRST; @@ -1194,6 +1197,17 @@ void CMenuContainer::AddStandardItems( void ) item.bAlignBottom=bAlignBottom; item.bInlineFirst=bInlineFirst; bAlignBottom=bInlineFirst=false; + + if (pStdItem->id==MENU_PINNED_PROGRAMS) + { + // a placeholder, replaced once all other items are known (PlacePinnedPrograms). + // only the Classic main menu can place its pinned programs + if (pInlineParent || m_bSubMenu || s_bWin7Style) + continue; + m_Items.insert(m_Items.begin()+menuIdx,1,item); + menuIdx++; + continue; + } TNetworkType networkType=NETWORK_NONE; Assert(pStdItem->folder1 || !pStdItem->folder2); @@ -1500,9 +1514,90 @@ void CMenuContainer::AddStandardItems( void ) menuIdx++; } } + PlacePinnedPrograms(bPlacePinned); + } +} + +// Passes a placeholder's column break and bottom alignment to the item that takes its place +void CMenuContainer::InheritColumnFlags( const MenuItem &placeholder, MenuItem &item ) +{ + if (placeholder.bBreak) item.bBreak=true; + if (placeholder.bAlignBottom) item.bAlignBottom=true; +} + +// Starts a new column after every rows items of items[first..last) +void CMenuContainer::SetOverflowBreaks( std::vector &items, int first, int last, int rows ) +{ + if (rows<=0) return; + for (int i=first+rows;i0) + { + m_PinnedPosition=i; + InheritColumnFlags(placeholder,m_Items[0]); + MovePinnedPadding(); + SetOverflowBreaks(m_Items,0,m_ScrollCount,placeholder.pStdItem?placeholder.pStdItem->rows:0); + } + else if (i<(int)m_Items.size()) + InheritColumnFlags(placeholder,m_Items[i]); + i--; // continue with the item that took the placeholder's place } } +// Moves the bottom alignment from the separator after the pinned programs to the item laid out first +void CMenuContainer::MovePinnedPadding( void ) +{ + // when the menu starts with COLUMN_PADDING, AddStandardItems aligns that separator to the bottom. if the pinned programs + // are laid out later, the alignment belongs to the items laid out first instead + int separator=m_ScrollCount; + if (m_PinnedPosition<=separator+1 || separator+1>=(int)m_Items.size()) return; // the layout order doesn't change + if (m_Items[separator].id!=MENU_SEPARATOR || !m_Items[separator].bAlignBottom) return; + m_Items[separator].bAlignBottom=false; + m_Items[separator+1].bAlignBottom=true; +} + +// The order in which InitWindowInternal lays out the items +void CMenuContainer::GetLayoutOrder( std::vector &order ) +{ + // normally the order of m_Items. with a Pinned Programs item, the items configured before it come first, + // then the pinned programs and their separator, then the rest + int count=(int)m_Items.size(); + order.resize(count); + for (int i=0;ipinnedEnd) // otherwise the pinned programs come first anyway + std::rotate(order.begin(),order.begin()+pinnedEnd,order.begin()+position); +} + +// Where the pinned programs end in m_Items, including the separator after them +int CMenuContainer::GetPinnedEnd( void ) +{ + int end=m_ScrollCount; + if (end<(int)m_Items.size() && m_Items[end].id==MENU_SEPARATOR) + end++; + return end; +} + // The SecondPane setting in effect TSecondPane CMenuContainer::GetSecondPaneMode( void ) { @@ -1537,9 +1632,9 @@ bool CMenuContainer::IsSecondPaneAfterBreaks( int breaks, int count ) } } -// Reads the SecondPane setting for the layout. Returns the index of the last column break, +// Reads the SecondPane setting for the layout. Returns the position in the layout order of the last column break, // or -1 when only the first break starts a column (the Windows 7 style keeps two columns) -int CMenuContainer::InitSecondPane( void ) +int CMenuContainer::InitSecondPane( const std::vector &order ) { m_bSecondPane=true; m_bSecondPaneFirst=false; @@ -1548,9 +1643,9 @@ int CMenuContainer::InitSecondPane( void ) return -1; int lastBreak=-1; - for (int i=1;i<(int)m_Items.size();i++) - if (m_Items[i].bBreak) - lastBreak=i; + for (int k=1;k<(int)order.size();k++) + if (m_Items[order[k]].bBreak && !m_Items[order[k]].bOverflow) // overflow columns never change the panes + lastBreak=k; TSecondPane mode=GetSecondPaneMode(); if (mode==SECOND_PANE_NONE) m_bSecondPane=false; // every break starts another first-pane column @@ -1616,15 +1711,17 @@ int CMenuContainer::GetColumnX( int column ) return m_rContent.left+m_ColumnOffsets[column]-m_ColumnOffsets[m_PaneColumns[0].first]; } -// Where the pager scrolls: the content of a sub-menu, or the first column of the main menu, where the pinned programs are +// Where the pager scrolls: the content of a sub-menu, or the column of the main menu where the pinned programs start RECT CMenuContainer::GetScrollRect( void ) { if (!m_bTwoColumns || m_ColumnOffsets.empty()) return m_rContent; - int pane=IsSecondPaneColumn(0)?1:0; + int column=GetScrollColumn(); + int pane=IsSecondPaneColumn(column)?1:0; RECT rc=pane?m_rContent2:m_rContent; - if (m_PaneColumns[pane].last>1) - rc.right=GetColumnX(1)-s_Skin.Main_separatorWidth; // more columns share the pane: stop at the gap before the next one + rc.left=GetColumnX(column); + if (column+1 order; // positions below are in this order (see GetLayoutOrder) + GetLayoutOrder(order); + int lastBreak=InitSecondPane(order); { int row=0, column=0, subColumn=0; int y=0; int maxw=0; int index=m_bSecondPaneFirst?1:0; - for (int i=0;i<(int)m_Items.size();i++) + int overflowTop=0; // where the pinned programs start, so their overflow columns line up with them + for (int k=0;k<(int)order.size();k++) { + int i=order[k]; MenuItem &item=m_Items[i]; - bool bColumnBreak=item.bBreak && (index==0 || m_bSecondPaneFirst) && (column==0 || lastBreak>=0); - if (m_bTwoColumns && i>0 && bColumnBreak) + bool bColumnBreak=item.bBreak && !item.bOverflow && (index==0 || m_bSecondPaneFirst) && (column==0 || lastBreak>=0); + bool bOverflowBreak=item.bOverflow && !s_bWin7Style; + if (m_bTwoColumns && k>0 && (bColumnBreak || bOverflowBreak)) { // start a new column column++; @@ -3422,8 +3524,13 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, else y=s_Skin.User_frame_position.x+s_Skin.User_image_padding.y-menuPadding[0].top; } - index=GetPaneOfNewColumn(column,index,lastBreak<0 || i==lastBreak); + if (item.bOverflow) + y=overflowTop; // stays in the same pane + else + index=GetPaneOfNewColumn(column,index,lastBreak<0 || k==lastBreak); } + if (i==0 && m_ScrollCount>0) + overflowTop=y; item.bNew=false; if (m_bTwoColumns && im_SearchIndex) && item.id!=MENU_SHUTDOWN_BUTTON) { @@ -3621,7 +3728,7 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, y=0; } } - else if (item.id==MENU_SEPARATOR && !item.bBlankSeparator && !item.bInline && m_bTwoColumns && (index==0 || m_bSecondPaneFirst) && i+1<(int)m_Items.size() && m_Items[i+1].bBreak) + else if (item.id==MENU_SEPARATOR && !item.bBlankSeparator && !item.bInline && m_bTwoColumns && (index==0 || m_bSecondPaneFirst) && k+1<(int)order.size() && m_Items[order[k+1]].bBreak) h=0; item.row=row; item.column=column; @@ -3730,7 +3837,7 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, // calculate the horizontal position of each item int maxw=0; int maxh[2]={0,0}; // height of the tallest column in each pane - int scrollHeight=0; // the pager scrolls only the first column of the main menu, where the pinned programs are + int scrollHeight=0; // the pager scrolls only the column of the main menu where the pinned programs start int scrollWidth=GetSystemMetrics(SM_CXVSCROLL); { m_ColumnOffsets.resize(columnWidths.size()); @@ -3779,7 +3886,7 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, int pane=IsSecondPaneColumn(item.column)?1:0; if (maxh[pane]maxHeight[scrollPane] && m_ScrollCount>0 && (m_bSubMenu || !s_bWin7Style)) { @@ -4165,7 +4272,7 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, m_Items[i].itemRect.bottom=m_Items[i].itemRect.top; } for (size_t i=m_ScrollCount;i::iterator it=s_MenuScrolls.find(m_FolderHash[0]); @@ -4700,8 +4807,8 @@ int CMenuContainer::HitTest( const POINT &pt, bool *bArrow, bool bDrop ) { OffsetRect(&rc,0,-m_SearchScrollPos*(rc.bottom-rc.top)); } - else if (bDrop && m_bTwoColumns && i &items, const CString &categoryName, unsigned int categoryHash, int originalCount ); void GetRecentPrograms( std::vector &items, int maxCount ); + static void InheritColumnFlags( const MenuItem &placeholder, MenuItem &item ); + static void SetOverflowBreaks( std::vector &items, int first, int last, int rows ); + void PlacePinnedPrograms( bool bSetPosition ); + void MovePinnedPadding( void ); + void GetLayoutOrder( std::vector &order ); + int GetPinnedEnd( void ); static TSecondPane GetSecondPaneMode( void ); static int CountColumnBreaks( const StdMenuItem *pStdItem ); bool IsSecondPaneAfterBreaks( int breaks, int count ); - int InitSecondPane( void ); + int InitSecondPane( const std::vector &order ); int GetPaneOfNewColumn( int column, int pane, bool bLastBreak ); void UpdatePaneColumns( void ); int GetPaneWidth( int pane, const std::vector &columnWidths ); @@ -722,6 +732,7 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub int GetScrollRange( void ); bool IsInScrollColumn( const POINT &pt ); void GetColumnBottomShifts( std::vector &shifts ); + int GetScrollColumn( void ) { return (m_ScrollCount>0 && !m_Items.empty())?m_Items[0].column:0; } // where the pinned programs start bool IsClassicMainMenu( void ) { return m_bTwoColumns && !m_bSubMenu && !s_bWin7Style; } bool IsSecondPaneColumn( int column ) { return column>=m_PaneColumns[1].first && columnpStdCommand && wcscmp(m_pItem->pStdCommand->name,L"pinned_programs")==0; } + void EnableRows( void ); + int m_Style, m_StyleMask; }; @@ -1535,6 +1540,8 @@ LRESULT CEditMenuDlg::OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam, BOO CheckDlgButton(IDC_CHECKINLINE,(m_pItem->settings&StdMenuItem::MENU_INLINE)?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(IDC_CHECKSPLIT,(m_pItem->settings&StdMenuItem::MENU_SPLIT_BUTTON)?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(IDC_CHECKNOEXT,(m_pItem->settings&StdMenuItem::MENU_NOEXTENSIONS)?BST_CHECKED:BST_UNCHECKED); + if (m_pItem->rows>0) SetDlgItemInt(IDC_EDITROWS,m_pItem->rows,FALSE); + EnableRows(); if (m_pItem->pStdCommand && (wcscmp(m_pItem->pStdCommand->name,L"programs")==0 || wcscmp(m_pItem->pStdCommand->name,L"apps")==0)) { CheckDlgButton(IDC_CHECKMULTICOLUMN,BST_CHECKED); @@ -1647,6 +1654,11 @@ LRESULT CEditMenuDlg::OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam, BOO tool.uId=(UINT_PTR)(HWND)GetDlgItem(IDC_CHECKNOEXT); tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); + str=LoadStringEx(IDS_ROWS_TIP); + tool.lpszText=(LPWSTR)(LPCWSTR)str; + tool.uId=(UINT_PTR)(HWND)GetDlgItem(IDC_EDITROWS); + tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); + str=LoadStringEx(IDS_RESTORE_TIP); tool.lpszText=(LPWSTR)(LPCWSTR)str; tool.uId=(UINT_PTR)(HWND)GetDlgItem(IDC_BUTTONRESET); @@ -1677,6 +1689,7 @@ LRESULT CEditMenuDlg::OnOK( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHan if (IsDlgButtonChecked(IDC_CHECKINLINE)==BST_CHECKED) m_pItem->settings|=StdMenuItem::MENU_INLINE; if (IsDlgButtonChecked(IDC_CHECKSPLIT)==BST_CHECKED) m_pItem->settings|=StdMenuItem::MENU_SPLIT_BUTTON; if (IsDlgButtonChecked(IDC_CHECKNOEXT)==BST_CHECKED) m_pItem->settings|=StdMenuItem::MENU_NOEXTENSIONS; + m_pItem->rows=IsPinnedPrograms()?(int)GetDlgItemInt(IDC_EDITROWS,NULL,FALSE):0; if (bForceMultiColumn) { // special handling of the Programs menu @@ -1712,10 +1725,18 @@ LRESULT CEditMenuDlg::OnCommandChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl CheckDlgButton(IDC_CHECKMULTICOLUMN,(m_pItem->settings&StdMenuItem::MENU_MULTICOLUMN)?BST_CHECKED:BST_UNCHECKED); GetDlgItem(IDC_CHECKMULTICOLUMN).EnableWindow(TRUE); } + EnableRows(); UpdateIcons(IDC_ICONN,0); return 0; } +// Rows per column can be set only for the Pinned programs item +void CEditMenuDlg::EnableRows( void ) +{ + GetDlgItem(IDC_STATICROWS).EnableWindow(IsPinnedPrograms()); + GetDlgItem(IDC_EDITROWS).EnableWindow(IsPinnedPrograms()); +} + LRESULT CEditMenuDlg::OnLinkChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ) { CString text=GetComboText(wNotifyCode,wID); @@ -1816,6 +1837,8 @@ LRESULT CEditMenuDlg::OnReset( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b CheckDlgButton(IDC_CHECKINLINE,(m_pItem->settings&StdMenuItem::MENU_INLINE)?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(IDC_CHECKSPLIT,(m_pItem->settings&StdMenuItem::MENU_SPLIT_BUTTON)?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(IDC_CHECKNOEXT,(m_pItem->settings&StdMenuItem::MENU_NOEXTENSIONS)?BST_CHECKED:BST_UNCHECKED); + m_pItem->rows=0; + SetDlgItemText(IDC_EDITROWS,L""); if (m_pItem->pStdCommand && (wcscmp(m_pItem->pStdCommand->name,L"programs")==0 || wcscmp(m_pItem->pStdCommand->name,L"apps")==0)) { CheckDlgButton(IDC_CHECKMULTICOLUMN,BST_CHECKED); @@ -1849,6 +1872,9 @@ void CCustomMenuDlg::ParseTreeItemExtra( CTreeItem *pItem, CSettingsParser &pars { pItem->settings=0; wchar_t text[256]; + Sprintf(text,_countof(text),L"%s.Rows",pItem->name); + const wchar_t *rows=parser.FindSetting(text); + pItem->rows=rows?_wtol(rows):0; Sprintf(text,_countof(text),L"%s.Settings",pItem->name); const wchar_t *str=parser.FindSetting(text); if (!str) return; @@ -1875,8 +1901,13 @@ void CCustomMenuDlg::ParseTreeItemExtra( CTreeItem *pItem, CSettingsParser &pars void CCustomMenuDlg::SerializeItemExtra( CTreeItem *pItem, std::vector &stringBuilder ) { - if (!pItem->settings) return; wchar_t text[256]; + if (pItem->rows>0) + { + Sprintf(text,_countof(text),L"%s.Rows=%d\n",pItem->name,pItem->rows); + AppendString(stringBuilder,text); + } + if (!pItem->settings) return; Sprintf(text,_countof(text),L"%s.Settings=",pItem->name); AppendString(stringBuilder,text); if (pItem->settings&StdMenuItem::MENU_OPENUP) AppendString(stringBuilder,L"OPEN_UP|"); diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc b/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc index 54a384219..314444123 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc @@ -144,6 +144,8 @@ BEGIN CONTROL "Don't track recent items",IDC_CHECKNOTRACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,155,97,10 CONTROL "Place items first",IDC_CHECKITEMSFIRST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,168,69,10 CONTROL "Hide extensions",IDC_CHECKNOEXT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,181,72,10 + LTEXT "Rows per column:",IDC_STATICROWS,130,195,60,8 + EDITTEXT IDC_EDITROWS,192,193,30,12,ES_AUTOHSCROLL | ES_NUMBER PUSHBUTTON "Restore Defaults",IDC_BUTTONRESET,7,215,90,14 DEFPUSHBUTTON "OK",IDOK,135,215,50,14 PUSHBUTTON "Cancel",IDCANCEL,192,215,50,14 @@ -1086,6 +1088,9 @@ BEGIN IDS_SECOND_PANE_FIRST "First column" IDS_SECOND_PANE_FIRST_TIP "The column before the first column break looks like the second pane and is drawn on the left" + IDS_PINNED_ITEM "Pinned programs" + IDS_PINNED_ITEM_TIP "Places the pinned programs here, as a list. Without this item they are at the top of the first column" + IDS_ROWS_TIP "After this many rows the list continues in the next column. Leave empty for no limit" END STRINGTABLE diff --git a/Src/StartMenu/StartMenuDLL/resource.h b/Src/StartMenu/StartMenuDLL/resource.h index 9e9b0a29b..a40e4b46d 100644 --- a/Src/StartMenu/StartMenuDLL/resource.h +++ b/Src/StartMenu/StartMenuDLL/resource.h @@ -101,6 +101,8 @@ #define IDC_SKIN_CLASSIC2 1087 #define IDC_SKIN_WIN7 1088 #define IDC_STATICEDGE2 1089 +#define IDC_STATICROWS 1090 +#define IDC_EDITROWS 1091 #define IDD_CUSTOMMENU 3001 #define IDS_APP_TITLE 3001 #define IDD_SKINSETTINGS 3002 @@ -796,6 +798,9 @@ #define IDS_SECOND_PANE_NONE_TIP 3697 #define IDS_SECOND_PANE_FIRST 3698 #define IDS_SECOND_PANE_FIRST_TIP 3699 +#define IDS_PINNED_ITEM 3700 +#define IDS_PINNED_ITEM_TIP 3701 +#define IDS_ROWS_TIP 3702 #define IDS_STRING7001 7001 #define IDS_STRING7002 7002 #define IDS_STRING7003 7003 @@ -860,7 +865,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 126 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1090 +#define _APS_NEXT_CONTROL_VALUE 1092 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif From 594bfa99c59da5371e8f433f2aa76da03f0064fc Mon Sep 17 00:00:00 2001 From: Emilio Heredia <60711791+emilioheredia-source@users.noreply.github.com> Date: Sun, 15 Nov 2026 18:05:49 -0600 Subject: [PATCH 6/6] Pinned Programs item: no automatic separator after the pinned programs AddStandardItems puts a separator between the pinned programs and the items that follow them, because in the default menu they share a column. With a Pinned Programs item the user places the pinned programs and everything around them, so that separator is no longer needed, and when a list follows in the same column it pushes the rows below it out of line with the column next to it. The separator now gets no height when a Pinned Programs item places the pinned programs. The item stays, so the bottom alignment it carries for COLUMN_PADDING and the pager's use of it are unchanged. A SEPARATOR item after the Pinned Programs item still draws a line. Menus without a Pinned Programs item are unchanged. --- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 9 +++++++++ Src/StartMenu/StartMenuDLL/MenuContainer.h | 1 + 2 files changed, 10 insertions(+) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index a2c590048..d42a21adb 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -1598,6 +1598,13 @@ int CMenuContainer::GetPinnedEnd( void ) return end; } +// Is the item the separator that AddStandardItems puts after the pinned programs, while a Pinned Programs item places them? +// That separator gets no height: with a Pinned Programs item the user adds separators where they want them +bool CMenuContainer::IsPinnedSeparator( int index ) +{ + return m_PinnedPosition>=0 && index==m_ScrollCount && m_Items[index].id==MENU_SEPARATOR; +} + // The SecondPane setting in effect TSecondPane CMenuContainer::GetSecondPaneMode( void ) { @@ -3642,6 +3649,8 @@ void CMenuContainer::InitWindowInternal( bool bDontShrink, const POINT &corner, h=0; // hide it for now else if (!s_bShowTopEmpty && m_Items.size()>1 && (m_Items[i].id==MENU_EMPTY_TOP || (i>0 && m_Items[i-1].id==MENU_EMPTY_TOP))) h=0; // this is the first (Empty) item in the top menu. hide it for now + else if (IsPinnedSeparator(i)) + h=0; else if (item.bInline) { h=iconSize+settings.iconPadding.top+settings.iconPadding.bottom; diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.h b/Src/StartMenu/StartMenuDLL/MenuContainer.h index a4371049c..b612b4c39 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.h +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.h @@ -720,6 +720,7 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub void MovePinnedPadding( void ); void GetLayoutOrder( std::vector &order ); int GetPinnedEnd( void ); + bool IsPinnedSeparator( int index ); static TSecondPane GetSecondPaneMode( void ); static int CountColumnBreaks( const StdMenuItem *pStdItem ); bool IsSecondPaneAfterBreaks( int breaks, int count );