Add parameter to force showing scrollbar with listbox

This commit is contained in:
Robert Müller 2023-07-02 23:13:05 +02:00
parent b376fbb331
commit 9efab4964b
2 changed files with 3 additions and 2 deletions

View file

@ -60,7 +60,7 @@ void CListBox::DoFooter(const char *pBottomText, float FooterHeight)
m_FooterHeight = 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; CUIRect View;
if(pRect) if(pRect)
@ -119,6 +119,7 @@ void CListBox::DoStart(float RowHeight, int NumItems, int ItemsPerRow, int RowsP
ScrollParams.m_Active = m_Active; ScrollParams.m_Active = m_Active;
ScrollParams.m_ScrollbarWidth = ScrollbarWidthMax(); ScrollParams.m_ScrollbarWidth = ScrollbarWidthMax();
ScrollParams.m_ScrollUnit = (m_ListBoxRowHeight + m_AutoSpacing) * RowsPerScroll; 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_ScrollRegion.Begin(&m_ListBoxView, &m_ScrollOffset, &ScrollParams);
m_ListBoxView.y += m_ScrollOffset.y; m_ListBoxView.y += m_ScrollOffset.y;
} }

View file

@ -51,7 +51,7 @@ public:
void DoAutoSpacing(float Spacing = 20.0f) { m_AutoSpacing = Spacing; } void DoAutoSpacing(float Spacing = 20.0f) { m_AutoSpacing = Spacing; }
void DoSpacing(float Spacing = 20.0f); void DoSpacing(float Spacing = 20.0f);
void DoFooter(const char *pBottomText, float FooterHeight = 20.0f); // call before DoStart to create a footer 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; } void ScrollToSelected() { m_ListBoxUpdateScroll = true; }
CListboxItem DoNextItem(const void *pID, bool Selected = false); CListboxItem DoNextItem(const void *pID, bool Selected = false);
CListboxItem DoSubheader(); CListboxItem DoSubheader();