From cf13c4faf4077751a5d88190b472811505162b41 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Wed, 1 Apr 2020 12:24:07 +0200 Subject: [PATCH] Menu: Make the scrollbar not appear with too few entries. --- src/menu-fn/w_scrollbar.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/menu-fn/w_scrollbar.cpp b/src/menu-fn/w_scrollbar.cpp index 49a1c274..d5e13f0c 100644 --- a/src/menu-fn/w_scrollbar.cpp +++ b/src/menu-fn/w_scrollbar.cpp @@ -81,6 +81,12 @@ void CScrollbar::Draw(void) barheight = 20 /*m_theight * (m_theight / (m_max * m_itemheight))*/; barstep = (m_scroll * m_itemheight) * (m_theight / (m_max * m_itemheight)); + /* too few entries? don't even bother */ + if (m_max * m_itemheight < m_height) { + drawfill([g_menuofs[0]+m_x,g_menuofs[1]+m_y+16], [16,m_theight+20], [0.25,0.25,0.25], 1.0f); + return; + } + if (!m_hold) { drawfill([g_menuofs[0]+m_x,g_menuofs[1]+m_y+16], [16,m_theight+20], [0.25,0.25,0.25], 1.0f); if (!m_hover) { @@ -99,6 +105,11 @@ void CScrollbar::Input(float type, float x, float y, float devid) int barheight = 0; int barstep = 0; + /* too few entries? don't even bother */ + if (m_max * m_itemheight < m_height) { + return; + } + /* Up Arrow */ if (Util_CheckMouse(m_x, m_y, 16, 16)) { m_up_hover = TRUE;