From ec4e6ead87c007181a5ef2a6f893a08a8d4ac079 Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Fri, 16 Nov 2018 13:08:17 +0100 Subject: [PATCH] Make dropdown filters expandable by clicking on the line (#1670 1/10) --- src/game/client/components/menus_browser.cpp | 37 +++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 741b7c64f..be7716e1e 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -642,25 +642,17 @@ bool CMenus::RenderFilterHeader(CUIRect View, int FilterIndex) float ButtonHeight = 20.0f; float Spacing = 3.0f; + bool Switch = false; RenderTools()->DrawUIRect(&View, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f); CUIRect Button, EditButtons; View.VSplitLeft(20.0f, &Button, &View); Button.Margin(2.0f, &Button); - if(DoButton_SpriteClean(IMAGE_MENUICONS, pFilter->Extended() ? SPRITE_MENU_EXPANDED : SPRITE_MENU_COLLAPSED, &Button)) + if(DoButton_SpriteClean(IMAGE_MENUICONS, pFilter->Extended() ? SPRITE_MENU_EXPANDED : SPRITE_MENU_COLLAPSED, &Button) + || (UI()->MouseInside(&View) && Input()->KeyPress(KEY_MOUSE_1))) { - pFilter->Switch(); - - // retract the other filters - if(pFilter->Extended()) - { - for(int i = 0; i < m_lFilters.size(); ++i) - { - if(i != FilterIndex && m_lFilters[i].Extended()) - m_lFilters[i].Switch(); - } - } + Switch = true; // switch later, to make sure we haven't clicked one of the filter buttons (edit...) } // split buttons from label @@ -714,6 +706,7 @@ bool CMenus::RenderFilterHeader(CUIRect View, int FilterIndex) static int s_EditPopupID = 0; m_SelectedFilter = FilterIndex; InvokePopupMenu(&s_EditPopupID, 0, UI()->MouseX(), UI()->MouseY(), 200.0f, 310.0f, PopupFilter); + Switch = false; } EditButtons.VSplitRight(Spacing, &EditButtons, 0); @@ -722,7 +715,10 @@ bool CMenus::RenderFilterHeader(CUIRect View, int FilterIndex) if(FilterIndex > 0 && (pFilter->Custom() > CBrowserFilter::FILTER_ALL || m_lFilters[FilterIndex-1].Custom() != CBrowserFilter::FILTER_STANDARD)) { if(DoButton_SpriteClean(IMAGE_TOOLICONS, SPRITE_TOOL_UP_A, &Button)) + { Move(true, FilterIndex); + Switch = false; + } } else DoIcon(IMAGE_TOOLICONS, SPRITE_TOOL_UP_B, &Button); @@ -733,11 +729,28 @@ bool CMenus::RenderFilterHeader(CUIRect View, int FilterIndex) if(FilterIndex >= 0 && FilterIndex < m_lFilters.size()-1 && (pFilter->Custom() != CBrowserFilter::FILTER_STANDARD || m_lFilters[FilterIndex+1].Custom() > CBrowserFilter::FILTER_ALL)) { if(DoButton_SpriteClean(IMAGE_TOOLICONS, SPRITE_TOOL_DOWN_A, &Button)) + { Move(false, FilterIndex); + Switch = false; + } } else DoIcon(IMAGE_TOOLICONS, SPRITE_TOOL_DOWN_B, &Button); + if(Switch) + { + pFilter->Switch(); + // retract the other filters + if(pFilter->Extended()) + { + for(int i = 0; i < m_lFilters.size(); ++i) + { + if(i != FilterIndex && m_lFilters[i].Extended()) + m_lFilters[i].Switch(); + } + } + } + return false; }