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; int m_percentage; };
Firstly, we enumerate both possible types of sliders: horizontal and vertical. The actual GUI_Scrollbar
class overwrites three of the original methods the parent class provides, in addition...