Tatooine
window.h
Go to the documentation of this file.
1#ifndef TATOOINE_FLOWEXPLORER_WINDOW_H
2#define TATOOINE_FLOWEXPLORER_WINDOW_H
3//==============================================================================
7//==============================================================================
9//==============================================================================
13 //----------------------------------------------------------------------------
14 // members
15 //----------------------------------------------------------------------------
16 float m_ui_scale_factor = 1.0f;
17 bool m_show_nodes_gui = true;
19 bool m_left_button_down = false;
21 std::unique_ptr<ImGui::FileBrowser> m_file_browser;
23 ImFont* m_font_regular = nullptr;
24 ImFont* m_font_header1 = nullptr;
25 ImFont* m_font_header2 = nullptr;
26 ImFont* m_font_bold = nullptr;
29 //============================================================================
30 auto ui_scale_factor() const { return m_ui_scale_factor; }
31 //----------------------------------------------------------------------------
32 auto aabb2d_icon_tex() const -> auto const& { return m_aabb2d_icon_tex; }
33 auto aabb3d_icon_tex() const -> auto const& { return m_aabb3d_icon_tex; }
34
35 //----------------------------------------------------------------------------
36 // ctor
37 //----------------------------------------------------------------------------
39 window(filesystem::path const& scene_path);
40 //----------------------------------------------------------------------------
42 //============================================================================
43 void on_key_pressed(gl::key k) override;
44 void on_button_pressed(gl::button b) override;
46 void on_cursor_moved(double /*x*/, double /*y*/) override;
47 void start();
48 //=============================================================================
49 auto push_regular_font() -> void { ImGui::PushFont(m_font_regular); }
50 auto push_header1_font() -> void { ImGui::PushFont(m_font_header1); }
51 auto push_header2_font() -> void { ImGui::PushFont(m_font_header2); }
52 auto push_bold_font() -> void { ImGui::PushFont(m_font_bold); }
53 auto pop_font() -> void { ImGui::PopFont(); }
54 //----------------------------------------------------------------------------
56 m_file_browser->ClearSelected();
57 m_file_browser->Close();
58 m_path_notifier = nullptr;
59 }
60 //----------------------------------------------------------------------------
61 private:
63 m_file_browser = std::make_unique<ImGui::FileBrowser>(0);
64 m_file_browser->Open();
65 }
66 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
67 auto open_file_explorer(std::string const& title) {
69 m_file_browser->SetTitle(title);
70 }
71 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
72 auto open_file_explorer(std::string const& title,
73 std::vector<std::string> const& extensions) {
74 open_file_explorer(title);
75 m_file_browser->SetTypeFilters(extensions);
76 }
77
78 //----------------------------------------------------------------------------
79 public:
81 m_file_browser = std::make_unique<ImGui::FileBrowser>(0);
82 m_path_notifier = &n;
83 m_file_browser->Open();
84 }
85 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
86 auto open_file_explorer(std::string const& title, ui::base::node& n) {
88 m_file_browser->SetTitle(title);
89 }
90 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
91 auto open_file_explorer(std::string const& title,
92 std::vector<std::string> const& extensions,
93 ui::base::node& n) {
94 open_file_explorer(title, n);
95 m_file_browser->SetTypeFilters(extensions);
96 }
97 //----------------------------------------------------------------------------
99 m_file_browser = std::make_unique<ImGui::FileBrowser>(ImGuiFileBrowserFlags_EnterNewFilename);
100 m_path_notifier = &n;
101 m_file_browser->Open();
102 }
103 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104 auto open_file_explorer_write(std::string const& title, ui::base::node& n) {
106 m_file_browser->SetTitle(title);
107 }
108 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
109 auto open_file_explorer_write(std::string const& title,
110 std::vector<std::string> const& extensions,
111 ui::base::node& n) {
112 open_file_explorer_write(title, n);
113 m_file_browser->SetTypeFilters(extensions);
114 }
115 //----------------------------------------------------------------------------
117 return m_file_browser != nullptr && m_file_browser->IsOpened();
118 }
119 //----------------------------------------------------------------------------
120 auto file_explorer() const -> auto const& { return *m_file_browser; }
121 auto file_explorer() -> auto& { return *m_file_browser; }
122};
123//==============================================================================
124} // namespace tatooine::flowexplorer
125//==============================================================================
126#endif
Definition: directories.h:6
button
Definition: mouse.h:8
key
Definition: keyboard.h:9
tex2rgba< GLfloat > tex2rgba32f
Definition: texture.h:957
Definition: scene.h:17
Definition: window.h:10
auto push_bold_font() -> void
Definition: window.h:52
auto pop_font() -> void
Definition: window.h:53
float m_ui_scale_factor
Definition: window.h:16
gl::tex2rgba32f m_aabb2d_icon_tex
Definition: window.h:27
auto open_file_explorer(ui::base::node &n)
Definition: window.h:80
gl::tex2rgba32f m_aabb3d_icon_tex
Definition: window.h:28
ImFont * m_font_regular
Definition: window.h:23
scene m_scene
Definition: window.h:20
auto open_file_explorer()
Definition: window.h:62
double m_mouse_x
Definition: window.h:18
std::unique_ptr< ImGui::FileBrowser > m_file_browser
Definition: window.h:21
void on_button_pressed(gl::button b) override
auto push_header1_font() -> void
Definition: window.h:50
auto file_explorer() const -> auto const &
Definition: window.h:120
auto file_explorer() -> auto &
Definition: window.h:121
auto close_file_explorer()
Definition: window.h:55
auto open_file_explorer_write(ui::base::node &n)
Definition: window.h:98
auto open_file_explorer(std::string const &title, std::vector< std::string > const &extensions, ui::base::node &n)
Definition: window.h:91
void on_key_pressed(gl::key k) override
auto aabb3d_icon_tex() const -> auto const &
Definition: window.h:33
void on_cursor_moved(double, double) override
auto open_file_explorer(std::string const &title, ui::base::node &n)
Definition: window.h:86
ImFont * m_font_header2
Definition: window.h:25
auto file_explorer_is_opened() const
Definition: window.h:116
double m_mouse_y
Definition: window.h:18
bool m_show_nodes_gui
Definition: window.h:17
auto push_regular_font() -> void
Definition: window.h:49
auto open_file_explorer(std::string const &title, std::vector< std::string > const &extensions)
Definition: window.h:72
ui::base::node * m_path_notifier
Definition: window.h:22
ImFont * m_font_header1
Definition: window.h:24
void on_button_released(gl::button b) override
window(filesystem::path const &scene_path)
bool m_left_button_down
Definition: window.h:19
ImFont * m_font_bold
Definition: window.h:26
auto open_file_explorer_write(std::string const &title, std::vector< std::string > const &extensions, ui::base::node &n)
Definition: window.h:109
auto open_file_explorer_write(std::string const &title, ui::base::node &n)
Definition: window.h:104
auto ui_scale_factor() const
Definition: window.h:30
auto aabb2d_icon_tex() const -> auto const &
Definition: window.h:32
auto open_file_explorer(std::string const &title)
Definition: window.h:67
auto push_header2_font() -> void
Definition: window.h:51
Definition: first_person_window.h:15