ShishGL  1.0
A simple modular cross-platform graphics library
UISlider.hpp
Go to the documentation of this file.
1 /*============================================================================*/
2 #ifndef SHISHGL_UISLIDER_HPP
3 #define SHISHGL_UISLIDER_HPP
4 /*============================================================================*/
5 #include <variant>
6 
7 #include "UIWindow.hpp"
8 #include "Slidable.hpp"
9 /*============================================================================*/
10 namespace Sh {
11 
12  template <typename Behavior>
13  class UIVerticalSlider : public UIWindow {
14  public:
15 
16  template <typename... Args>
17  explicit UIVerticalSlider(const Frame& frame,
18  double slider_len,
19  Args&&... args)
20  : UIWindow(frame) {
21 
22  slider = attach<UIWindow>(Frame{
23  {0, 0},
24  {frame.size.x, std::min(frame.size.y, slider_len)}
25  });
26 
27  slider->setBehavior<Behavior>(Frame{ {0, 0}, frame.size },
28  std::forward<Args>(args)...);
29  }
30 
32  };
33 
34  template <typename Behavior>
35  class UIHorizontalSlider : public UIWindow {
36  public:
37 
38  template <typename... Args>
39  explicit UIHorizontalSlider(const Frame& frame,
40  double slider_len,
41  Args&&... args)
42  : UIWindow(frame) {
43 
44  slider = attach<UIWindow>(Frame{
45  {0, 0},
46  {std::min(frame.size.x, slider_len), frame.size.y}
47  });
48 
49  slider->setBehavior<Behavior>(Frame{ {0, 0}, frame.size },
50  std::forward<Args>(args)...);
51  }
52 
54  };
55 
56 
57  template <typename Behavior>
58  class UIFreeSlider : public UIWindow {
59  public:
60 
61  template <typename... Args>
62  explicit UIFreeSlider(const Frame& frame,
63  const Vector2<double>& size,
64  Args&&... args)
65  : UIWindow(frame) {
66 
67  slider = attach<UIWindow>(Frame{
68  {0, 0},
69  {std::min(frame.size.x, size.x), std::min(frame.size.y, size.y)}
70  });
71 
72  slider->setBehavior<Behavior>(Frame{ {0, 0}, frame.size },
73  std::forward<Args>(args)...);
74  }
75 
77  };
78 
79 }
80 /*============================================================================*/
81 #endif //SHISHGL_UISLIDER_HPP
82 /*============================================================================*/
Sh::UIHorizontalSlider::UIHorizontalSlider
UIHorizontalSlider(const Frame &frame, double slider_len, Args &&... args)
Definition: UISlider.hpp:39
Sh::Vector2::x
T x
Definition: Vector2.hpp:10
Slidable.hpp
Sh::Frame
Definition: Frame.hpp:9
Sh::Vector2< double >
Sh::Vector2::y
T y
Definition: Vector2.hpp:10
Sh::UIWindow
Definition: UIWindow.hpp:16
Sh::UIFreeSlider::UIFreeSlider
UIFreeSlider(const Frame &frame, const Vector2< double > &size, Args &&... args)
Definition: UISlider.hpp:62
Sh::UIVerticalSlider::UIVerticalSlider
UIVerticalSlider(const Frame &frame, double slider_len, Args &&... args)
Definition: UISlider.hpp:17
Sh
Definition: CoreApplication.hpp:10
Sh::Behavior
Definition: Behavior.hpp:9
Sh::UIFreeSlider::slider
UIWindow * slider
Definition: UISlider.hpp:76
Sh::UIVerticalSlider::slider
UIWindow * slider
Definition: UISlider.hpp:31
Sh::UIHorizontalSlider
Definition: UISlider.hpp:35
Sh::UIHorizontalSlider::slider
UIWindow * slider
Definition: UISlider.hpp:53
UIWindow.hpp
Sh::UIVerticalSlider
Definition: UISlider.hpp:13
Sh::Frame::size
Vector2< double > size
Definition: Frame.hpp:12
Sh::UIWindow::setBehavior
UIWindow * setBehavior(Args &&... args)
Definition: UIWindow.ipp:28
Sh::UIFreeSlider
Definition: UISlider.hpp:58