O'Reilly logo

SFML Game Development By Example by Raimondas Pupius

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required