1
1
forked from 0ad/0ad

Fix #3415. Removes 'ghost' scrollbar bounding to enable extreme-right hover and selection in dropdowns. Patch by elexis.

This was SVN commit r17149.
This commit is contained in:
JoshuaJB 2015-10-31 05:40:43 +00:00
parent 230654f6ca
commit 108633affd
4 changed files with 16 additions and 8 deletions

View File

@ -113,8 +113,9 @@ void CDropDown::HandleMessage(SGUIMessage& Message)
if (mouse.y >= rect.top + m_ItemsYPositions[i] &&
mouse.y < rect.top + m_ItemsYPositions[i+1] &&
// mouse is not over scroll-bar
!(mouse.x >= GetScrollBar(0).GetOuterRect().left &&
mouse.x <= GetScrollBar(0).GetOuterRect().right))
(m_HideScrollBar ||
mouse.x < GetScrollBar(0).GetOuterRect().left ||
mouse.x > GetScrollBar(0).GetOuterRect().right))
{
set = i;
}
@ -208,9 +209,10 @@ void CDropDown::HandleMessage(SGUIMessage& Message)
return; // overshadow
}
if (!(mouse.x >= GetScrollBar(0).GetOuterRect().left &&
mouse.x <= GetScrollBar(0).GetOuterRect().right) &&
mouse.y >= GetListRect().top)
if (m_HideScrollBar ||
mouse.x < GetScrollBar(0).GetOuterRect().left ||
mouse.x > GetScrollBar(0).GetOuterRect().right ||
mouse.y < GetListRect().top)
{
m_Open = false;
GetScrollBar(0).SetZ(GetBufferedZ());

View File

@ -54,7 +54,7 @@ void CGUIScrollBarVertical::Draw()
return;
}
if (GetGUI() && GetMaxPos() != 1)
if (GetGUI() && IsVisible())
{
CRect outline = GetOuterRect();

View File

@ -200,8 +200,9 @@ void CList::HandleMessage(SGUIMessage& Message)
if (mouse.y >= rect.top + m_ItemsYPositions[i] &&
mouse.y < rect.top + m_ItemsYPositions[i+1] &&
// mouse is not over scroll-bar
!(mouse.x >= GetScrollBar(0).GetOuterRect().left &&
mouse.x <= GetScrollBar(0).GetOuterRect().right))
(!scrollbar || !GetScrollBar(0).IsVisible() ||
mouse.x < GetScrollBar(0).GetOuterRect().left ||
mouse.x > GetScrollBar(0).GetOuterRect().right))
{
set = i;
}

View File

@ -209,6 +209,11 @@ public:
*/
float GetMaxPos() const { return std::max(1.f, m_ScrollRange - m_ScrollSpace); }
/**
* Get the value of m_Pos that corresponds to the bottom of the scrollable region
*/
float IsVisible() const { return GetMaxPos() != 1.f; }
/**
* Increase scroll one step
*/