Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 70 additions & 8 deletions Src/StartMenu/StartMenuDLL/MenuContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2763,6 +2763,7 @@ bool CMenuContainer::InitSearchItems( void )
std::vector<int> 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;
Expand All @@ -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())
Expand Down Expand Up @@ -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<CSearchManager::SearchCategory>::const_iterator it=s_SearchResults.indexed.begin();
for (size_t idx=0;idx<s_SearchResults.indexed.size()+3;idx++)
{
Expand All @@ -2865,10 +2871,23 @@ bool CMenuContainer::InitSearchItems( void )
int count=0;
if (s_bWin7Style)
{
int h=(categoryHash==m_SearchCategoryHash?reservedHeight:maxHeight);
count=(h-sepHeight)/itemHeight;
if (categoryHash!=m_SearchCategoryHash && count>maxCount)
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
{
Expand Down Expand Up @@ -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 && fitH<resultsHeight;r++)
{
int rh=(r==0)?sepHeight:itemHeight;
if (fitH+rh<=resultsHeight || fitRows==0)
{
fitH+=rh;
fitRows++;
}
}
}
if (categoryHash!=m_SearchCategoryHash)
maxHeight-=sepHeight+count*itemHeight;
}
}
if (s_bWin7Style)
{
if (bPrioritySearch && fitRows>0 && 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)
Expand Down Expand Up @@ -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<end;i++)
offset+=m_Items[i].itemRect.bottom-m_Items[i].itemRect.top;
return offset;
}

bool CMenuContainer::GetItemRect( int index, RECT &rc )
{
if (index>=0 && index<(int)m_Items.size())
Expand All @@ -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;
Expand Down Expand Up @@ -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<n-1 && m_Items[i+1].column==0 && m_Items[i+1].bAlignBottom)
rc.bottom=m_Items[i+1].itemRect.top; // when dropping on the padding of the first column, assume the item above the padding was hit
Expand Down
1 change: 1 addition & 0 deletions Src/StartMenu/StartMenuDLL/MenuContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub
void RemoveMFUShortcut( unsigned int hash, bool bAppId );
void FadeOutItem( int index );
bool GetItemRect( int index, RECT &rc );
int SearchScrollOffset( void ) const; // pixel offset of the scrollable search list
int HitTest( const POINT &pt, bool *bArrow, bool bDrop=false );
bool DragOut( int index, bool bApp );
bool DragOutApps( const CItemManager::ItemInfo *pInfo );
Expand Down
2 changes: 1 addition & 1 deletion Src/StartMenu/StartMenuDLL/MenuPaint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,7 @@ void CMenuContainer::DrawBackground( HDC hdc, const RECT &drawRect )
{
if (index-m_OriginalCount<m_SearchScrollPos || index-m_OriginalCount>=m_SearchScrollPos+m_SearchScrollHeight)
continue;
OffsetRect(&itemRect,0,-m_SearchScrollPos*(itemRect.bottom-itemRect.top));
OffsetRect(&itemRect,0,-SearchScrollOffset());
}
{
RECT q;
Expand Down
5 changes: 3 additions & 2 deletions Src/StartMenu/StartMenuDLL/SettingsUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
2 changes: 2 additions & 0 deletions Src/StartMenu/StartMenuDLL/StartMenuDLL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions Src/StartMenu/StartMenuDLL/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down