From 9efab4964bfafcff65181a6f02f3009eb2afdd15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 2 Jul 2023 23:13:05 +0200 Subject: [PATCH] Add parameter to force showing scrollbar with listbox --- src/game/client/ui_listbox.cpp | 3 ++- src/game/client/ui_listbox.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game/client/ui_listbox.cpp b/src/game/client/ui_listbox.cpp index b73611809..8014a23dd 100644 --- a/src/game/client/ui_listbox.cpp +++ b/src/game/client/ui_listbox.cpp @@ -60,7 +60,7 @@ void CListBox::DoFooter(const char *pBottomText, float FooterHeight) m_FooterHeight = FooterHeight; } -void CListBox::DoStart(float RowHeight, int NumItems, int ItemsPerRow, int RowsPerScroll, int SelectedIndex, const CUIRect *pRect, bool Background, int BackgroundCorners) +void CListBox::DoStart(float RowHeight, int NumItems, int ItemsPerRow, int RowsPerScroll, int SelectedIndex, const CUIRect *pRect, bool Background, int BackgroundCorners, bool ForceShowScrollbar) { CUIRect View; if(pRect) @@ -119,6 +119,7 @@ void CListBox::DoStart(float RowHeight, int NumItems, int ItemsPerRow, int RowsP ScrollParams.m_Active = m_Active; ScrollParams.m_ScrollbarWidth = ScrollbarWidthMax(); ScrollParams.m_ScrollUnit = (m_ListBoxRowHeight + m_AutoSpacing) * RowsPerScroll; + ScrollParams.m_Flags = ForceShowScrollbar ? CScrollRegionParams::FLAG_CONTENT_STATIC_WIDTH : 0; m_ScrollRegion.Begin(&m_ListBoxView, &m_ScrollOffset, &ScrollParams); m_ListBoxView.y += m_ScrollOffset.y; } diff --git a/src/game/client/ui_listbox.h b/src/game/client/ui_listbox.h index fff29f26a..e50aa246a 100644 --- a/src/game/client/ui_listbox.h +++ b/src/game/client/ui_listbox.h @@ -51,7 +51,7 @@ public: void DoAutoSpacing(float Spacing = 20.0f) { m_AutoSpacing = Spacing; } void DoSpacing(float Spacing = 20.0f); void DoFooter(const char *pBottomText, float FooterHeight = 20.0f); // call before DoStart to create a footer - void DoStart(float RowHeight, int NumItems, int ItemsPerRow, int RowsPerScroll, int SelectedIndex, const CUIRect *pRect = nullptr, bool Background = true, int BackgroundCorners = IGraphics::CORNER_ALL); + void DoStart(float RowHeight, int NumItems, int ItemsPerRow, int RowsPerScroll, int SelectedIndex, const CUIRect *pRect = nullptr, bool Background = true, int BackgroundCorners = IGraphics::CORNER_ALL, bool ForceShowScrollbar = false); void ScrollToSelected() { m_ListBoxUpdateScroll = true; } CListboxItem DoNextItem(const void *pID, bool Selected = false); CListboxItem DoSubheader();