ux-window.h
Go to the documentation of this file.
1 #pragma once
2 
3 #define GLFW_INCLUDE_GLU
4 #include <GLFW/glfw3.h>
5 
6 #include "imgui.h"
7 #include <string>
8 #include <functional>
9 #include <thread>
10 #include "rendering.h"
11 #include <atomic>
12 #include <memory>
13 
14 namespace rs2
15 {
16  class visualizer_2d;
17  class context;
18 
20  {
21  public:
22  const static int control_panel_width = 280;
23  const static int control_panel_height = 40;
24  const static int metrics_panel_width = 250;
25  const static int default_log_h = 80;
26  // Flags for pop-up window - no window resize, move or collaps
30  };
31 
32  class ux_window
33  {
34  public:
35  std::function<void(std::string)> on_file_drop = [](std::string) {};
36  std::function<bool()> on_load = []() { return false; };
37  std::function<void()> on_reload_complete = []() { };
38 
39  ux_window(const char* title, context &ctx);
40 
41  float width() const { return float(_width); }
42  float height() const { return float(_height); }
43 
44  float framebuf_width() const { return float(_fb_width); }
45  float framebuf_height() const { return float(_fb_height); }
46 
47  // Check that the graphic subsystem is valid and start a new frame
48  operator bool();
49 
50  ~ux_window();
51 
52  operator GLFWwindow*() const { return _win; }
53 
54  void begin_frame();
55 
56  void begin_viewport();
57 
58  void end_frame();
59 
60  void reset();
61 
62  ImFont* get_large_font() const { return _font_18; }
63  ImFont* get_monofont() const { return _monofont; }
64  ImFont* get_font() const { return _font_14; }
65 
66  rs2::mouse_info& get_mouse() { return _mouse; }
67  float get_scale_factor() const { return _scale_factor; }
68 
69  void add_on_load_message(const std::string& msg);
70 
71  bool is_ui_aligned() { return _is_ui_aligned; }
72  bool is_fullscreen() { return _fullscreen; }
73 
74  texture_buffer& get_splash() { return _splash_tex; }
75 
76  void reload();
77  void refresh();
78 
79  void link_hovered();
80  void cross_hovered();
81 
82  void set_hovered_over_input() { _hovers_any_input_window = true; }
83  bool get_hovered_over_input() const { return _hovers_any_input_window; }
84 
85  double time() const { return glfwGetTime(); }
86  private:
87  void open_window();
88 
89  void setup_icon();
90 
91  void imgui_config_push();
92  void imgui_config_pop();
93 
95  int _width, _height, _output_height;
96  int _fb_width = 0;
97  int _fb_height = 0;
99 
100  ImFont *_font_14, *_font_18, *_monofont;
101  rs2::mouse_info _mouse{};
104 
105  std::thread _first_load;
107  std::atomic<bool> _app_ready;
108  std::atomic<bool> _keep_alive;
112  std::vector<std::string> _on_load_message;
114 
115  bool _hovers_any_input_window = false;
116  bool _query_devices = true;
117  bool _missing_device = false;
118  int _hourglass_index = 0;
120  bool _fullscreen_pressed = false;
121  bool _fullscreen = false;
122  bool _reload = false;
123  bool _show_fps = false;
124  bool _vsync = true;
125  bool _use_glsl_proc = false;
126  bool _use_glsl_render = false;
127  bool _enable_msaa = false;
128  int _msaa_samples = 0;
129 
130  bool _link_hovered = false;
131  GLFWcursor* _hand_cursor = nullptr;
132  bool _cross_hovered = false;
133  GLFWcursor* _cross_cursor = nullptr;
134 
136  std::shared_ptr<visualizer_2d> _2d_vis;
138 
139  bool _is_ui_aligned = false;
140  };
141 }
static const auto imgui_flags
Definition: ux-window.h:27
std::string _error_message
Definition: ux-window.h:102
The header of the GLFW 3 API.
GLboolean reset
static const int metrics_panel_width
Definition: ux-window.h:24
context & _ctx
Definition: ux-window.h:137
ImFont * get_monofont() const
Definition: ux-window.h:63
float _scale_factor
Definition: ux-window.h:103
std::mutex _on_load_message_mtx
Definition: ux-window.h:113
Definition: cah-model.h:10
static const int control_panel_width
Definition: ux-window.h:22
GLsizei const GLchar *const * string
std::shared_ptr< visualizer_2d > _2d_vis
Definition: ux-window.h:136
ImFont * get_font() const
Definition: ux-window.h:64
static const textual_icon refresh
Definition: model-views.h:217
float framebuf_width() const
Definition: ux-window.h:44
double time() const
Definition: ux-window.h:85
std::vector< std::string > _on_load_message
Definition: ux-window.h:112
static const int control_panel_height
Definition: ux-window.h:23
bool get_hovered_over_input() const
Definition: ux-window.h:83
bool is_ui_aligned()
Definition: ux-window.h:71
std::atomic< bool > _keep_alive
Definition: ux-window.h:108
float framebuf_height() const
Definition: ux-window.h:45
std::string _dev_stat_message
Definition: ux-window.h:119
GLFWAPI double glfwGetTime(void)
Returns the value of the GLFW timer.
Definition: input.c:1275
ImFont * _monofont
Definition: ux-window.h:100
bool _first_frame
Definition: ux-window.h:106
void set_hovered_over_input()
Definition: ux-window.h:82
Definition: imgui.h:1392
std::thread _first_load
Definition: ux-window.h:105
struct GLFWcursor GLFWcursor
Opaque cursor object.
Definition: glfw3.h:1149
GLFWwindow * _win
Definition: ux-window.h:94
float width() const
Definition: ux-window.h:41
texture_buffer & get_splash()
Definition: ux-window.h:74
std::string _title
Definition: ux-window.h:135
bool is_fullscreen()
Definition: ux-window.h:72
rs2::rect _viewer_rect
Definition: ux-window.h:98
ImFont * get_large_font() const
Definition: ux-window.h:62
std::string _title_str
Definition: ux-window.h:111
float get_scale_factor() const
Definition: ux-window.h:67
std::atomic< bool > _app_ready
Definition: ux-window.h:107
texture_buffer _splash_tex
Definition: ux-window.h:109
struct GLFWwindow GLFWwindow
static const int default_log_h
Definition: ux-window.h:25
utilities::time::stopwatch _splash_timer
Definition: ux-window.h:110
float height() const
Definition: ux-window.h:42
rs2::mouse_info & get_mouse()
Definition: ux-window.h:66


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:14