Simple GUI Library
slider.h
Go to the documentation of this file.
1/**
2 * @author Nikita Mochalov (github.com/tralf-strues)
3 * @file slider.h
4 * @date 2021-11-28
5 *
6 * @copyright Copyright (c) 2021
7 */
8
9#pragma once
10
11#include "control.h"
12#include "../containers/box_container.h"
13#include "../shapes/text.h"
14
15namespace Sgl
16{
17 class Slider : public Control
18 {
19 public:
20 Slider(float rangeMin, float rangeMax);
21 Slider(BaseSkin<Slider>* skin, float rangeMin, float rangeMax);
22
23 Orientation getOrientation() const;
24 void setOrientation(Orientation orientation);
25
26 float getRangeMin() const;
27 void setRangeMin(float min);
28
29 float getRangeMax() const;
30 void setRangeMax(float max);
31
32 float getValue() const;
33 void setValue(float value);
34
35 void addOnPropertyChange(Sml::PropertyChangeListener<float>* listener);
36 const std::list<Sml::PropertyChangeListener<float>*>& getOnPropertyChange(); // TODO: get rid of
37
38 private:
39 Orientation m_Orientation = Orientation::HORIZONTAL;
40
41 float m_RangeMin = 0;
42 float m_RangeMax = 0;
43 float m_Value = 0;
44
45 std::list<Sml::PropertyChangeListener<float>*> m_PropertyChangeListeners;
46 };
47
48 class SliderWithLabel : public HBox
49 {
50 public:
51 static const int32_t DEFAULT_SPACING;
52
53 public:
54 SliderWithLabel(float rangeMin, float rangeMax, const char* format = "%lg");
55 SliderWithLabel(BaseSkin<Slider>* skin, float rangeMin, float rangeMax, const char* format = "%lg");
56
57 Slider* getSlider();
58 Text* getLabel();
59
60 private:
61 Slider* m_Slider = nullptr;
62 Text* m_Label = nullptr;
63 const char* m_Format = nullptr;
64
65 void attach();
66 };
67}
Definition: text.h:17