The scrollbar element

All of that support for interface scrolling and control elements implies the existence of the scrollbar element. Its purpose is to move around the visible area of the content texture in order to reveal elements that are positioned further out than its size allows, which could be along any axis. With that knowledge, let's take a stab at working out the basic class definition of the scrollbar element:

enum class SliderType{ Horizontal, Vertical }; class GUI_Scrollbar : public GUI_Element{ public: ... void SetPosition(const sf::Vector2f& l_pos); void ApplyStyle(); void UpdateStyle(const GUI_ElementState& l_state, const GUI_Style& l_style); private: SliderType m_sliderType; sf::RectangleShape m_slider; sf::Vector2f m_moveMouseLast; ...

Get SFML Game Development By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.