Unravel Engine C++ Reference
Loading...
Searching...
No Matches
panel.cpp
Go to the documentation of this file.
1#include "panel.h"
2#include "panels_defs.h"
3
5
6#include <imgui/imgui.h>
7#include <imgui/imgui_internal.h>
10
11#include <logging/logging.h>
12
13namespace unravel
14{
15
17{
18 console_log_panel_ = std::make_shared<console_log_panel>(CONSOLE_VIEW);
19 console_log_panel_->set_level(spdlog::level::trace);
20 get_mutable_logging_container()->add_sink(console_log_panel_);
21
22 header_panel_ = std::make_unique<header_panel>(this);
23 footer_panel_ = std::make_unique<footer_panel>();
24 cenral_dockspace_ = std::make_unique<dockspace>();
25
26 content_browser_panel_ = std::make_unique<content_browser_panel>(this, CONTENT_VIEW);
27 hierarchy_panel_ = std::make_unique<hierarchy_panel>(this, HIERARCHY_VIEW);
28 inspector_panel_ = std::make_unique<inspector_panel>(this, INSPECTOR_VIEW);
29 scene_panel_ = std::make_unique<scene_panel>(this, SCENE_VIEW);
30 game_panel_ = std::make_unique<game_panel>(this, GAME_VIEW);
31 profiler_timeline_panel_ = std::make_unique<profiler_timeline_panel>(this, PROFILER_VIEW);
32 animation_panel_ = std::make_unique<animation_panel>(this);
33 mcp_panel_ = std::make_unique<mcp_panel>(this);
34
35 deploy_panel_ = std::make_unique<deploy_panel>(this);
36 project_settings_panel_ = std::make_unique<project_settings_panel>(this);
37 editor_settings_panel_ = std::make_unique<editor_settings_panel>(this);
38 style_panel_ = std::make_unique<style_panel>(this);
39 layout_panel_ = std::make_unique<layout_panel>(this, LAYOUTS_VIEW);
40 undo_redo_panel_ = std::make_unique<undo_redo_panel>(this);
41}
42
44{
45 get_mutable_logging_container()->remove_sink(console_log_panel_);
46}
47
49{
50 style_panel_->init(ctx);
51
52 content_browser_panel_->init(ctx);
53 hierarchy_panel_->init(ctx);
54 inspector_panel_->init(ctx);
55 scene_panel_->init(ctx);
56 game_panel_->init(ctx);
57 animation_panel_->init(ctx);
58 mcp_panel_->init(ctx);
59
60 auto layouts_dir = fs::resolve_protocol("editor:/settings/layouts");
61 layout_manager_.init(layouts_dir);
62}
63
65{
66 content_browser_panel_->deinit(ctx);
67 scene_panel_->deinit(ctx);
68 game_panel_->deinit(ctx);
69 inspector_panel_->deinit(ctx);
70 animation_panel_->deinit(ctx);
71 mcp_panel_->deinit(ctx);
72}
73
75{
76 scene_panel_->on_frame_update(ctx, dt);
77 game_panel_->on_frame_update(ctx, dt);
78}
79
81{
82 scene_panel_->on_frame_before_render(ctx, dt);
83 game_panel_->on_frame_before_render(ctx, dt);
84}
85
87{
88 scene_panel_->on_frame_render(ctx, dt);
89 game_panel_->on_frame_render(ctx, dt);
90}
91
93{
94 auto footer_size = ImGui::GetFrameHeightWithSpacing();
95 auto header_size = ImGui::GetFrameHeightWithSpacing() * 2;
96
97 if(ImGui::IsCombinationKeyPressed(shortcuts::scene_fullscreen_toggle))
98 {
99 std::vector<panel_base*> panels =
100 {
101 scene_panel_.get(),
102 game_panel_.get()
103 };
104 for(const auto& panel : panels)
105 {
106 if(panel->is_focused())
107 {
108 panel->toggle_fullscreen();
109
110 if(panel->is_fullscreen())
111 {
112 full_screen_panel_ = panel;
113 }
114 else
115 {
116 full_screen_panel_ = nullptr;
117 }
118 panel->focus();
119 }
120 }
121
122 }
123
124 header_panel_->on_frame_ui_render(ctx, header_size);
125
126 if(full_screen_panel_ && full_screen_panel_->is_fullscreen())
127 {
128 const ImGuiViewport* viewport = ImGui::GetMainViewport();
129 const ImVec2 fullscreen_pos(viewport->WorkPos.x, viewport->WorkPos.y + header_size);
130 const ImVec2 fullscreen_size(viewport->WorkSize.x, viewport->WorkSize.y - header_size - footer_size);
131 ImGui::SetNextWindowPos(fullscreen_pos);
132 ImGui::SetNextWindowSize(fullscreen_size);
133 full_screen_panel_->on_frame_ui_render(ctx);
134 }
135 else
136 {
137
138
139 cenral_dockspace_->on_frame_ui_render(header_size, footer_size);
140
141 hierarchy_panel_->on_frame_ui_render(ctx);
142
143 inspector_panel_->on_frame_ui_render(ctx);
144
145 profiler_timeline_panel_->on_frame_ui_render(ctx, PROFILER_VIEW);
146
147 console_log_panel_->on_frame_ui_render(ctx);
148
149 content_browser_panel_->on_frame_ui_render(ctx);
150
151 scene_panel_->on_frame_ui_render(ctx);
152
153 game_panel_->on_frame_ui_render(ctx);
154
155 layout_panel_->on_frame_ui_render(ctx);
156
157 animation_panel_->on_frame_ui_render(ctx, ANIMATION_VIEW);
158
159 mcp_panel_->on_frame_ui_render(ctx, MCP_VIEW);
160
161 deploy_panel_->on_frame_ui_render(ctx, DEPLOY_VIEW);
162
163 project_settings_panel_->on_frame_ui_render(ctx, PROJECT_SETTINGS_VIEW);
164
165 editor_settings_panel_->on_frame_ui_render(ctx, EDITOR_SETTINGS_VIEW);
166 }
167
168 footer_panel_->on_frame_ui_render(ctx,
169 footer_size,
170 [&]()
171 {
172 console_log_panel_->draw_last_log_button();
173 });
174 cenral_dockspace_->execute_dock_builder_order_and_focus_workaround();
175
176
177 // Draw the style picker window if visible
178 style_panel_->on_frame_ui_render();
179
180 // Draw the undo/redo panel if visible
181 undo_redo_panel_->on_frame_ui_render(ctx);
182
183
184}
185
187{
188 return *deploy_panel_;
189}
190
192{
193 return *project_settings_panel_;
194}
195
197{
198 return *editor_settings_panel_;
199}
200
202{
203 return *scene_panel_;
204}
205
207{
208 return *game_panel_;
209}
210
212{
213 return *console_log_panel_;
214}
215
217{
218 return *style_panel_;
219}
220
222{
223 return *cenral_dockspace_;
224}
225
227{
228 return *animation_panel_;
229}
230
232{
233 return *mcp_panel_;
234}
235
237{
238 return *profiler_timeline_panel_;
239}
240
242{
243 return *undo_redo_panel_;
244}
245
247{
248 external_drop_data_.drop_in_progress = in_progress;
249}
250
252{
253 return external_drop_data_.drop_in_progress;
254}
255
257{
258 external_drop_data_.drop_position = pos;
259}
260
261auto imgui_panels::get_external_drop_position() const -> const ImVec2&
262{
263 return external_drop_data_.drop_position;
264}
265
266void imgui_panels::add_external_drop_file(const std::string& file)
267{
268 external_drop_data_.drop_files.emplace_back(file);
269}
270
272{
273 external_drop_data_.drop_files.clear();
274}
275
276auto imgui_panels::get_external_drop_files() const -> const std::vector<std::string>&
277{
278 return external_drop_data_.drop_files;
279}
280
282{
283 return layout_manager_;
284}
285
287{
288 return *layout_panel_;
289}
290
291} // namespace unravel
auto get_profiler_timeline_panel() -> profiler_timeline_panel &
Definition panel.cpp:236
void set_external_drop_in_progress(bool in_progress)
Definition panel.cpp:246
void add_external_drop_file(const std::string &file)
Definition panel.cpp:266
void on_frame_ui_render(rtti::context &ctx)
Definition panel.cpp:92
auto get_project_settings_panel() -> project_settings_panel &
Definition panel.cpp:191
auto get_external_drop_position() const -> const ImVec2 &
Definition panel.cpp:261
auto get_scene_panel() -> scene_panel &
Definition panel.cpp:201
void on_frame_update(rtti::context &ctx, delta_t dt)
Definition panel.cpp:74
void on_frame_render(rtti::context &ctx, delta_t dt)
Definition panel.cpp:86
auto get_game_panel() -> game_panel &
Definition panel.cpp:206
auto get_dockspace() -> dockspace &
Definition panel.cpp:221
void on_frame_before_render(rtti::context &ctx, delta_t dt)
Definition panel.cpp:80
void clear_external_drop_files()
Definition panel.cpp:271
auto get_deploy_panel() -> deploy_panel &
Definition panel.cpp:186
auto get_console_log_panel() -> console_log_panel &
Definition panel.cpp:211
auto get_external_drop_files() const -> const std::vector< std::string > &
Definition panel.cpp:276
auto get_external_drop_in_progress() const -> bool
Definition panel.cpp:251
void deinit(rtti::context &ctx)
Definition panel.cpp:64
auto get_editor_settings_panel() -> editor_settings_panel &
Definition panel.cpp:196
auto get_layout_panel() -> layout_panel &
Definition panel.cpp:286
auto get_style_panel() -> style_panel &
Definition panel.cpp:216
void set_external_drop_position(ImVec2 pos)
Definition panel.cpp:256
auto get_animation_panel() -> animation_panel &
Definition panel.cpp:226
auto get_layout_manager() -> layout_manager &
Definition panel.cpp:281
void init(rtti::context &ctx)
Definition panel.cpp:48
auto get_mcp_panel() -> mcp_panel &
Definition panel.cpp:231
auto get_undo_redo_panel() -> undo_redo_panel &
Definition panel.cpp:241
void init(const fs::path &layouts_directory)
void on_frame_ui_render(rtti::context &ctx)
auto is_fullscreen() const -> bool
Definition panel_base.h:22
std::chrono::duration< float > delta_t
path resolve_protocol(const path &_path)
Given the specified path/filename, resolve the final full filename. This will be based on either the ...
Hash specialization for batch_key to enable use in std::unordered_map.
const ImGuiKeyCombination scene_fullscreen_toggle
Definition shortcuts.h:65
auto get_mutable_logging_container() -> std::shared_ptr< spdlog::sinks::dist_sink_mt >
Definition logging.cpp:31
#define CONTENT_VIEW
Definition panels_defs.h:8
#define DEPLOY_VIEW
Definition panels_defs.h:11
#define HIERARCHY_VIEW
Definition panels_defs.h:9
#define ANIMATION_VIEW
Definition panels_defs.h:17
#define MCP_VIEW
Definition panels_defs.h:18
#define SCENE_VIEW
Definition panels_defs.h:5
#define INSPECTOR_VIEW
Definition panels_defs.h:10
#define CONSOLE_VIEW
Definition panels_defs.h:4
#define PROFILER_VIEW
Definition panels_defs.h:19
#define PROJECT_SETTINGS_VIEW
Definition panels_defs.h:12
#define EDITOR_SETTINGS_VIEW
Definition panels_defs.h:13
#define GAME_VIEW
Definition panels_defs.h:7
#define LAYOUTS_VIEW
Definition panels_defs.h:15