diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index 3337b66a8..43720ff65 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -2763,6 +2763,7 @@ bool CMenuContainer::InitSearchItems( void ) std::vector counts; int sepHeight=0, itemHeight=0, maxHeight=0, reservedHeight=0; int maxCount=0; + bool bPrioritySearch=(s_bWin7Style && GetSettingBool(L"SearchResultsPriority")); if (s_bWin7Style) { sepHeight=s_Skin.ItemSettings[s_Skin.More_bitmap_Size.cx?MenuSkin::LIST_SEPARATOR_SPLIT:MenuSkin::LIST_SEPARATOR].itemHeight; @@ -2787,6 +2788,8 @@ bool CMenuContainer::InitSearchItems( void ) } if (s_bWin7Style) { + if (!bPrioritySearch) + { // calculate the allowed counts per category int selectedCount=0; if (!s_SearchResults.programs.empty()) @@ -2845,9 +2848,12 @@ bool CMenuContainer::InitSearchItems( void ) if (reservedHeight>maxHeight) reservedHeight=maxHeight; maxHeight-=reservedHeight; } + } } // add categories + int resultsHeight=maxHeight; + int fitRows=0, fitH=0; // rows that fit in the results area (for the scrollbar page size) std::list::const_iterator it=s_SearchResults.indexed.begin(); for (size_t idx=0;idxmaxCount) - count=maxCount; + if (bPrioritySearch) + { + // always show the configured number of results per category, + // the list is made scrollable to fit the extra items + count=GetSettingInt(categoryHash==m_SearchCategoryHash?L"SearchResultsMax":L"SearchResults"); + } + else + { + int h=(categoryHash==m_SearchCategoryHash?reservedHeight:maxHeight); + count=(h-sepHeight)/itemHeight; + if (categoryHash!=m_SearchCategoryHash && count>maxCount) + count=maxCount; + // limit the number of results per category (same setting as the non-Win7 styles) + int limit=GetSettingInt(categoryHash==m_SearchCategoryHash?L"SearchResultsMax":L"SearchResults"); + if (count>limit) + count=limit; + } } else { @@ -2957,11 +2976,37 @@ bool CMenuContainer::InitSearchItems( void ) { count=AddSearchItems(items,name,categoryHash,originalCount); } - if (s_bWin7Style && categoryHash!=m_SearchCategoryHash && count>0) - maxHeight-=sepHeight+count*itemHeight; + if (s_bWin7Style && count>0) + { + if (bPrioritySearch) + { + // count how many rows fit in the visible area (headers are taller than items) + for (int r=0;r<1+count && fitH0 && m_SearchScrollCount==0) + { + // enable scrolling when the prioritized results don't fit + int total=(int)m_Items.size()-m_OriginalCount; + if (total>fitRows) + { + m_SearchScrollCount=total; + m_SearchScrollHeight=fitRows; + } + } UpdateAccelerators(m_OriginalCount,(int)m_Items.size()); MenuItem &item=m_Items[m_SearchIndex-m_SearchItemCount+1]; if (s_SearchResults.bSearching) @@ -4506,6 +4551,23 @@ HRESULT __stdcall CMenuContainer::ReleaseAccessible( ComCallData *pData ) return CoDisconnectContext(INFINITE); } +// Returns the pixel offset the scrollable search list is shifted by. +// The scroll position is in rows, but the rows have different heights +// (category headers are taller), so the offset is the sum of the heights +// of the rows scrolled out of view. +int CMenuContainer::SearchScrollOffset( void ) const +{ + if (m_SearchScrollPos<=0) + return 0; + int end=m_OriginalCount+m_SearchScrollPos; + if (end>(int)m_Items.size()) + end=(int)m_Items.size(); + int offset=0; + for (int i=m_OriginalCount;i=0 && index<(int)m_Items.size()) @@ -4521,7 +4583,7 @@ bool CMenuContainer::GetItemRect( int index, RECT &rc ) } if (m_SearchScrollCount>m_SearchScrollHeight && index>=m_OriginalCount) { - OffsetRect(&rc,0,-m_SearchScrollPos*(rc.bottom-rc.top)); + OffsetRect(&rc,0,-SearchScrollOffset()); } } return true; @@ -4549,7 +4611,7 @@ int CMenuContainer::HitTest( const POINT &pt, bool *bArrow, bool bDrop ) } else if (m_SearchScrollCount>m_SearchScrollHeight && i>=m_OriginalCount) { - OffsetRect(&rc,0,-m_SearchScrollPos*(rc.bottom-rc.top)); + OffsetRect(&rc,0,-SearchScrollOffset()); } else if (bDrop && m_bTwoColumns && i=m_SearchScrollPos+m_SearchScrollHeight) continue; - OffsetRect(&itemRect,0,-m_SearchScrollPos*(itemRect.bottom-itemRect.top)); + OffsetRect(&itemRect,0,-SearchScrollOffset()); } { RECT q; diff --git a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp index af9376103..84ff2f5ab 100644 --- a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp +++ b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp @@ -4382,8 +4382,9 @@ CSetting g_Settings[]={ {L"SearchHint",CSetting::TYPE_BOOL,IDS_SEARCH_HINT,IDS_SEARCH_HINT_TIP,0,0,L"SearchBox"}, {L"SearchHintText",CSetting::TYPE_STRING,IDS_NEW_SEARCH_HINT,IDS_NEW_SEARCH_HINT_TIP,L"",0,L"#SearchHint",L"SearchHint"}, {L"SearchTrack",CSetting::TYPE_BOOL,IDS_SEARCH_TRACK,IDS_SEARCH_TRACK_TIP,1,0,L"SearchBox"}, - {L"SearchResults",CSetting::TYPE_INT,IDS_SEARCH_MAX2,IDS_SEARCH_MAX_TIP2,5,CSetting::FLAG_MENU_CLASSIC_BOTH,L"SearchBox"}, - {L"SearchResultsMax",CSetting::TYPE_INT,IDS_SEARCH_MAX3,IDS_SEARCH_MAX_TIP3,20,CSetting::FLAG_MENU_CLASSIC_BOTH,L"SearchBox"}, + {L"SearchResults",CSetting::TYPE_INT,IDS_SEARCH_MAX2,IDS_SEARCH_MAX_TIP2,5,CSetting::FLAG_MENU_CLASSIC_BOTH|CSetting::FLAG_MENU_WIN7,L"SearchBox"}, + {L"SearchResultsMax",CSetting::TYPE_INT,IDS_SEARCH_MAX3,IDS_SEARCH_MAX_TIP3,20,CSetting::FLAG_MENU_CLASSIC_BOTH|CSetting::FLAG_MENU_WIN7,L"SearchBox"}, + {L"SearchResultsPriority",CSetting::TYPE_BOOL,IDS_SEARCH_PRIORITY,IDS_SEARCH_PRIORITY_TIP,0,CSetting::FLAG_MENU_WIN7,L"SearchBox"}, {L"SearchAutoComplete",CSetting::TYPE_BOOL,IDS_SEARCH_AUTO,IDS_SEARCH_AUTO_TIP,1,0,L"SearchBox"}, {L"SearchPrograms",CSetting::TYPE_BOOL,IDS_SEARCH_PROGRAMS,IDS_SEARCH_PROGRAMS_TIP,1,0,L"SearchBox"}, {L"SearchPath",CSetting::TYPE_BOOL,IDS_SEARCH_PATH,IDS_SEARCH_PATH_TIP,1,0,L"#SearchPrograms",L"SearchPrograms"}, diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc b/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc index d65ffce32..2e0cb8875 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc @@ -1045,6 +1045,8 @@ BEGIN IDS_SEARCH_MAX_TIP2 "Limit the number of results shown per category" IDS_SEARCH_MAX3 "Results per maximized category" IDS_SEARCH_MAX_TIP3 "Limit the number of results shown for the maximized category" + IDS_SEARCH_PRIORITY "Prioritize results per category" + IDS_SEARCH_PRIORITY_TIP "Always show the specified number of results per category instead of dividing the available space equally. The search list becomes scrollable when the results don't fit" IDS_SHOW_APPS "Show Metro apps" IDS_SHOW_APPS_TIP "When this is checked, the programs tree will include a folder for the Metro apps" IDS_FOLDERS_FIRST "Show folders first" diff --git a/Src/StartMenu/StartMenuDLL/resource.h b/Src/StartMenu/StartMenuDLL/resource.h index 81acb7478..8cc0ecf0f 100644 --- a/Src/StartMenu/StartMenuDLL/resource.h +++ b/Src/StartMenu/StartMenuDLL/resource.h @@ -846,6 +846,9 @@ #define IDS_STRING7110 7110 #define IDS_STRING7111 7111 +#define IDS_SEARCH_PRIORITY 3297 +#define IDS_SEARCH_PRIORITY_TIP 3298 + // Next default values for new objects // #ifdef APSTUDIO_INVOKED