R-Type
imconfig.h
Go to the documentation of this file.
1 // Add this to your imconfig.h
2 
3 #include <SFML/Graphics/Color.hpp>
4 #include <SFML/System/Vector2.hpp>
5 
6 #include <cstdint>
7 
8 #include "imgui-SFML_export.h"
9 
10 #define IM_VEC2_CLASS_EXTRA \
11  template <typename T> \
12  ImVec2(const sf::Vector2<T> &v) \
13  { \
14  x = static_cast<float>(v.x); \
15  y = static_cast<float>(v.y); \
16  } \
17  \
18  template <typename T> \
19  operator sf::Vector2<T>() const \
20  { \
21  return sf::Vector2<T>(static_cast<T>(x), static_cast<T>(y)); \
22  }
23 
24 #define IM_VEC4_CLASS_EXTRA \
25  ImVec4(const sf::Color &c) : x(c.r / 255.f), y(c.g / 255.f), z(c.b / 255.f), w(c.a / 255.f) {} \
26  operator sf::Color() const \
27  { \
28  return sf::Color(static_cast<std::uint8_t>(x * 255.f), static_cast<std::uint8_t>(y * 255.f), \
29  static_cast<std::uint8_t>(z * 255.f), static_cast<std::uint8_t>(w * 255.f)); \
30  }