3#include <imgui/imgui_internal.h>
9#include "imgui/imgui.h"
16 auto color = ImGui::GetStyleColorVec4(idx);
17 color.x *= multiplier;
18 color.y *= multiplier;
19 color.z *= multiplier;
29std::vector<property_layout*> stack;
30void push_layout_to_stack(property_layout* l)
35void pop_layout_from_stack(property_layout* l)
70 push_layout_to_stack(
this);
75 push_layout_to_stack(
this);
84 push_layout_to_stack(
this);
93 push_layout_to_stack(
this);
102 push_layout_to_stack(
this);
111 push_layout_to_stack(
this);
113 callback_ = callback;
124 pop_layout_from_stack(
this);
153 auto avail = ImGui::GetContentRegionAvail();
155 columns_open_ = ImGui::BeginTable((
"properties##" + name_).c_str(), 2);
160 auto first_column = 0.325f;
161 ImGui::TableSetupColumn(
"##prop_column1", ImGuiTableColumnFlags_WidthFixed, avail.x * first_column);
162 ImGui::TableSetupColumn(
"##prop_column2", ImGuiTableColumnFlags_WidthFixed, avail.x * (1.0f - first_column));
164 ImGui::TableNextRow();
165 ImGui::TableNextColumn();
169 ImGui::AlignTextToFramePadding();
176 ImGui::TextUnformatted(name_.c_str());
181 if(ImGui::BeginPopupContextItem((
"Property Context Menu##" + name_).c_str()))
189 if(override_ctx.is_path_overridden())
191 if(ImGui::MenuItem(fmt::format(
"Reset {} to default", name_).c_str()))
193 override_ctx.reset_override();
200 if(!tooltip_.empty())
203 auto tooltip_callback = [&]()
205 ImGui::PushStyleColor(ImGuiCol_Separator, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled));
208 ImGui::Text(
"%s", name_.c_str());
214 ImGui::Text(
"%s", tooltip_.c_str());
215 ImGui::PopStyleColor();
217 ImGui::ItemTooltipEx(tooltip_callback);
220 ImGui::HelpMarker(
"(?)",
true, tooltip_callback);
223 if(auto_proceed_to_next_column)
233 ImGui::TableNextColumn();
236 ImGui::PushID(name_.c_str());
237 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().
x);
248 auto avail = ImGui::GetContentRegionAvail();
250 columns_open_ = ImGui::BeginTable((
"properties##" + name_).c_str(), 2);
254 auto first_column = 0.325f;
255 ImGui::TableSetupColumn(
"##prop_column1", ImGuiTableColumnFlags_WidthFixed, avail.x * first_column);
256 ImGui::TableSetupColumn(
"##prop_column2", ImGuiTableColumnFlags_WidthFixed, avail.x * (1.0f - first_column));
258 ImGui::TableNextRow();
259 ImGui::TableNextColumn();
263 ImGui::SetNextItemOpen(default_open, ImGuiCond_Appearing);
264 ImGui::AlignTextToFramePadding();
266 open_ = ImGui::TreeNodeEx(name_.c_str(), flags | ImGuiTreeNodeFlags_AllowOverlap);
270 if(ImGui::BeginPopupContextItem((
"Property Context Menu##" + name_).c_str()))
278 if(override_ctx.is_path_overridden())
280 if(ImGui::MenuItem(fmt::format(
"Reset {} to default", name_).c_str()))
282 override_ctx.reset_override();
289 if(!tooltip_.empty())
292 auto tooltip_callback = [&]()
294 ImGui::PushStyleColor(ImGuiCol_Separator, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled));
297 ImGui::Text(
"%s", name_.c_str());
303 ImGui::Text(
"%s", tooltip_.c_str());
304 ImGui::PopStyleColor();
306 ImGui::ItemTooltipEx(tooltip_callback);
309 ImGui::HelpMarker(
"(?)",
true, tooltip_callback);
325 ImGui::PopItemWidth();
336 if(columns_open_ && ImGui::TableGetColumnCount() > 1)
347 ImGui::PushTextWrapPos(ImGui::GetCursorPos().
x + ImGui::GetContentRegionAvail().
x);
348 ImGui::TextColored(ImVec4(1.0f, 0.62f, 0.0f, 1.0f),
"%s",hint_.c_str());
349 ImGui::PopTextWrapPos();
358 layout_ = std::make_unique<property_layout>(prop,
object);
370 proxy.
impl->parent =
nullptr;
373 proxy.
impl->resolver = [var](entt::meta_any& result)
mutable
378 proxy.
impl->getter = [var = var.as_ref()](entt::meta_any& result)
mutable
380 result = var.as_ref();
383 proxy.
impl->setter = [](
meta_any_proxy& proxy,
const entt::meta_any& value, uint64_t execution_count)
mutable
386 if(proxy.
impl->getter(var) && var)
388 return var.assign(value);
397 if(var.type() != entt::resolve<entt::uhandle>())
404 proxy.
impl->parent =
nullptr;
406 proxy.impl->name =
name;
407 proxy.impl->resolver = [
handle](entt::meta_any& result)
mutable ->
bool
412 proxy.impl->getter = [
handle](entt::meta_any& result)
mutable ->
bool
417 proxy.impl->setter = [](
meta_any_proxy& proxy,
const entt::meta_any& value, uint64_t execution_count)
mutable
419 entt::meta_any var_slot;
420 if(proxy.impl->getter(var_slot) && var_slot)
422 return var_slot.assign(value);
432 prop_proxy.
impl->parent = var_proxy.impl;
434 prop_proxy.
impl->name = [&]()
436 const auto&
name = var_proxy.impl->name;
443 prop_proxy.
impl->getter = [parent_proxy = var_proxy, prop](entt::meta_any& result)
446 if(parent_proxy.impl->getter(var) && var)
448 result = prop.get(var);
453 prop_proxy.
impl->setter = [parent_proxy = var_proxy, prop](
meta_any_proxy& proxy,
const entt::meta_any& value, uint64_t execution_count)
mutable
456 if(parent_proxy.impl->getter(var) && var)
458 prop.set(var, value);
459 return parent_proxy.impl->setter(parent_proxy, var, execution_count);
Manages ImGui layout for property inspection in the editor.
property_layout()
Default constructor that registers this layout in the global stack.
auto push_tree_layout(ImGuiTreeNodeFlags flags=0, bool default_open=true) -> bool
Creates a collapsible tree node layout for nested properties.
void push_layout(bool auto_proceed_to_next_column=true)
Initializes ImGui layout with tables and property label.
static auto get_current() -> property_layout *
Gets the currently active property layout from the global stack.
void set_data(const entt::meta_data &prop, const entt::meta_any &object, bool columns=true)
Updates layout data from meta property.
void pop_layout()
Cleans up ImGui state (IDs, tables, tree nodes)
void prepare_for_item()
Prepares ImGui for rendering the property value widget.
~property_layout()
Destructor that cleans up ImGui state and removes from stack.
void PushFont(Font::Enum _font)
auto GetTintedStyleColor(ImGuiCol idx, float multiplier=1.0f) -> ImVec4
void PopWindowFontScale()
void PushWindowFontScale(float scale)
auto get_property_hint(const entt::meta_any &object, const entt::meta_data &prop) -> std::string
auto get_pretty_name(const meta_type &t) -> std::string
auto get_attribute_as< std::string >(const meta_custom &custom, const char *name) -> std::string
auto capitalize(const std::string &word) -> std::string
auto make_entity_proxy(entt::meta_any &var, const std::string &name) -> meta_any_proxy
Like make_proxy, but for entt::handle roots resolved by id_component UUID each access.
auto make_property_proxy(const meta_any_proxy &var_proxy, const entt::meta_data &prop) -> meta_any_proxy
auto make_proxy(entt::meta_any &var, const std::string &name) -> meta_any_proxy
Creates a simple proxy for direct variable access.
std::vector< math::color > color
static auto context() -> rtti::context &
std::unique_ptr< property_layout > layout_
Layout manager for this inspector's UI.
virtual void after_inspect(const entt::meta_data &prop, const entt::meta_any &object)
Called after inspecting a property to clean up layout.
virtual void before_inspect(const entt::meta_data &prop, const entt::meta_any &object)
Called before inspecting a property to set up layout.
Global context for tracking prefab override changes during inspection.
property_layout_group(const std::string &name)