NasNas
An intuitive and beginner friendly 2D game framework for C++
Style.hpp
1 // Created by Modar Nasser on 26/11/2021.
2 
3 #pragma once
4 
5 #include <memory>
6 
7 #include <SFML/Graphics/Drawable.hpp>
8 #include <SFML/System/Vector2.hpp>
9 
10 #include <NasNas/ui/Region.hpp>
11 
12 
13 namespace ns::ui {
14  namespace internal {
15  template <typename T>
16  struct shared_ptr : private std::shared_ptr<T> {
17  shared_ptr() = default;
18 
19  shared_ptr(T* ptr) {
20  this->reset(ptr);
21  }
22 
23  auto operator=(T* ptr) -> shared_ptr<T>& {
24  this->reset(ptr);
25  return *this;
26  }
27 
28  using std::shared_ptr<T>::operator bool;
29  using std::shared_ptr<T>::operator->;
30  using std::shared_ptr<T>::operator*;
31  };
32  }
33 
34  namespace style {
35  struct Basic {
36  private:
37  struct Padding {
38  float left = 0.f;
39  float top = 0.f;
40  float right = 0.f;
41  float bottom = 0.f;
42  auto topleft() const -> sf::Vector2f { return {left, top}; }
43  auto bottomright() const -> sf::Vector2f { return {right, bottom}; }
44  };
45  public:
46  Padding padding{};
47  sf::Drawable* drawable = nullptr;
48  };
49 
50  struct Button : Basic {
51  sf::Drawable* drawable_hovered = nullptr;
52  sf::Drawable* drawable_focused = nullptr;
54  };
55  }
56 
57  enum class TextAlign {
58  Left,
59  Center,
60  Right
61  };
62 }