Game Development Reference
In-Depth Information
m_delta = input - edge;
}
else
{
edge = input - m_delta;
math::Clamp(edge, minimal, maximal);
}
return true;
}
else
{
if ( m_state == Pressed )
{
m_state = Default;
}
}
}
if ( m_rectangle.Contains( mouse->GetPosition() ) )
{
if ( mouse->ButtonPressed(input::mouse::Left) )
{
edge = input - ( cursorSize / 2 );
return true;
}
}
}
return false;
}
The first part can be somewhat confusing and the syntax is less than ideal. The goal is to
get a reference to the coordinate we will work on depending on whether we are using a
vertical or horizontal scroll bar. We need it to be a reference to apply the movement of the
cursor by actually changing its value.
If the mouse button is not pressed and our scroll bar's state is currently set to Pressed , then
we will reset the state to indicate the scroll bar is at its Default state.
Next, we will handle the case in which a single mouse click is done somewhere within the
scroll bar's boundaries, but outside of the mouse cursor.
else
if ( m_rectangle.Contains( mouse->GetPosition() ) )
{
if ( mouse->ButtonPressed(input::mouse::Left) )
{
m_cursor.Top() = mouse->GetPosition().y() - ( m_cursor.Height() / 2 );
return true;
}
}
Search WWH ::




Custom Search