6#include <core/filesystem/file_dialog.hpp>
7#include <core/scene/components.hpp>
29 bool begin_popup_context_window(
const char* p_name,
30 ImGuiMouseButton p_mb,
40 void draw_vec3(
const std::string& p_name,
42 float p_reset_value = 0.f);
51 void draw_vec4(
const std::string& p_name,
53 float p_reset_value = 0.f);
62 void draw_float(
const std::string& p_tag,
64 float p_reset_value = 0.f);
73 void draw_input_text(std::string& p_dst, std::string& p_src);
80 void draw_text(
const std::string& p_value);
105 template<
typename UComponent,
typename UFunction>
106 static void draw_panel_component(
const std::string& p_name,
107 flecs::entity& p_entity,
108 const UFunction& p_callback) {
109 const ImGuiTreeNodeFlags tree_node_flags =
110 ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed |
111 ImGuiTreeNodeFlags_SpanAvailWidth |
112 ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_FramePadding;
114 ImVec2 content_region = ImGui::GetContentRegionAvail();
115 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2{ 4, 4 });
118 ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.y * 2.0f;
121 bool opened = ImGui::TreeNodeEx((
void*)
typeid(UComponent).hash_code(),
125 ImGui::PopStyleVar();
127 ImGui::SameLine(content_region.x - line_height * 0.05f);
129 if (ImGui::Button(
"+", ImVec2(line_height, line_height))) {
130 ImGui::OpenPopup(
"ComponentSettings");
133 bool remove_component =
false;
135 if (ImGui::BeginPopup(
"ComponentSettings")) {
136 if (ImGui::MenuItem(
"Remove Component")) {
137 remove_component =
true;
143 if (remove_component) {
144 p_entity.remove<UComponent>();
148 p_callback(p_entity.get_mut<UComponent>());
162 template<
typename T,
typename UFunction>
163 static void draw_component(
const std::string& p_tag,
164 flecs::entity& p_entity,
165 const UFunction& p_callable) {
166 const ImGuiTreeNodeFlags tree_node_flags =
167 ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed |
168 ImGuiTreeNodeFlags_SpanAvailWidth |
169 ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_FramePadding;
171 if (!p_entity.has<T>()) {
175 T* component = p_entity.get_mut<T>();
177 ImVec2 content_region = ImGui::GetContentRegionAvail();
178 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2{ 4, 4 });
181 ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.y * 2.0f;
184 bool opened = ImGui::TreeNodeEx(
185 (
void*)
typeid(T).hash_code(), tree_node_flags,
"%s", p_tag.c_str());
186 ImGui::PopStyleVar();
188 ImGui::SameLine(content_region.x - line_height * 0.05f);
190 if (ImGui::Button(
"+", ImVec2(line_height, line_height))) {
191 ImGui::OpenPopup(
"ComponentSettings");
194 bool remove_component =
false;
196 if (ImGui::BeginPopup(
"ComponentSettings")) {
197 if (ImGui::MenuItem(
"Remove Component")) {
198 remove_component =
true;
205 p_callable(component);
209 if (remove_component and !std::is_same_v<T, transform>) {
210 p_entity.remove<T>();
220 void dockspace_window(GLFWwindow* p_window);
234 void button_open_file_dialog(
const std::string& p_name,
235 std::string& p_filepath,
236 const std::string& p_filter =
"obj;glftf;fbx");