emilib
imgui_sdl.hpp
1 // By Emil Ernerfeldt 2015-2016
2 // LICENSE:
3 // This software is dual-licensed to the public domain and under the following
4 // license: you are granted a perpetual, irrevocable license to copy, modify,
5 // publish, and distribute this file as you see fit.
6 
7 #pragma once
8 
9 union SDL_Event;
10 
11 namespace emilib {
12 
53 class ImGui_SDL
54 {
55 public:
56  ImGui_SDL(float width_points, float height_points, float pixels_per_point);
57  ~ImGui_SDL();
58 
60  bool visible() const { return _visible; }
61  void set_visible(bool v) { _visible = v; }
62 
64  bool interactive() const { return _interactive; }
65  void set_interactive(bool v) { _interactive = v; }
66 
67  void new_frame();
68  void paint();
69 
71  void on_event(const SDL_Event& e);
72 
74  bool mod_command() const;
75  bool mod_shift() const;
76 
77  float width_points() const { return _width_points; }
78  float height_points() const { return _height_points; }
79  float width_pixels() const { return _pixels_per_point * _width_points; }
80  float height_pixels() const { return _pixels_per_point * _height_points; }
81  float pixels_per_point() const { return _pixels_per_point; }
82 
83 private:
84  bool _visible = true;
85  bool _interactive = true;
86  float _width_points;
87  float _height_points;
88  float _pixels_per_point;
89 };
90 
91 } // namespace emilib
bool visible() const
When invisible, you can still call ImGui functions, but you cannot see or interact any widgets...
Definition: imgui_sdl.hpp:60
bool interactive() const
When not interactive, any ImGui widgets are passive (you can't click them).
Definition: imgui_sdl.hpp:64
bool mod_command() const
Key modifiers:
void on_event(const SDL_Event &e)
You must call this yourself!
~ImGui_SDL()
Will call ImGui::Shutdown.
Definition: imgui_sdl.hpp:53
Definition: coroutine.hpp:18