2#include <imgui/imgui_internal.h>
10std::vector<property_layout*> stack;
11void push_layout_to_stack(property_layout* l)
16void pop_layout_from_stack(property_layout* l)
28 push_layout_to_stack(
this);
33 push_layout_to_stack(
this);
42 push_layout_to_stack(
this);
51 push_layout_to_stack(
this);
60 push_layout_to_stack(
this);
73 pop_layout_from_stack(
this);
99 auto avail = ImGui::GetContentRegionAvail();
101 columns_open_ = ImGui::BeginTable((
"properties##" + name_).c_str(), 2);
106 auto first_column = 0.325f;
107 ImGui::TableSetupColumn(
"##prop_column1", ImGuiTableColumnFlags_WidthFixed, avail.x * first_column);
108 ImGui::TableSetupColumn(
"##prop_column2", ImGuiTableColumnFlags_WidthFixed, avail.x * (1.0f - first_column));
110 ImGui::TableNextRow();
111 ImGui::TableNextColumn();
115 ImGui::AlignTextToFramePadding();
122 ImGui::TextUnformatted(name_.c_str());
127 if(ImGui::BeginPopupContextItem(
"Property Context Menu"))
129 if(ImGui::MenuItem(fmt::format(
"Reset {} to default", name_).c_str()))
137 if(!tooltip_.empty())
139 ImGui::SetItemTooltipEx(
"%s", tooltip_.c_str());
141 ImGui::HelpMarker(tooltip_.c_str());
146 if(auto_proceed_to_next_column)
156 ImGui::TableNextColumn();
159 ImGui::PushID(name_.c_str());
160 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().
x);
169 auto avail = ImGui::GetContentRegionAvail();
171 columns_open_ = ImGui::BeginTable((
"properties##" + name_).c_str(), 2);
175 auto first_column = 0.325f;
176 ImGui::TableSetupColumn(
"##prop_column1", ImGuiTableColumnFlags_WidthFixed, avail.x * first_column);
177 ImGui::TableSetupColumn(
"##prop_column2", ImGuiTableColumnFlags_WidthFixed, avail.x * (1.0f - first_column));
179 ImGui::TableNextRow();
180 ImGui::TableNextColumn();
184 ImGui::SetNextItemOpen(
true, ImGuiCond_Appearing);
185 ImGui::AlignTextToFramePadding();
186 open_ = ImGui::TreeNodeEx(name_.c_str(), flags | ImGuiTreeNodeFlags_AllowOverlap);
190 if(ImGui::BeginPopupContextItem(
"Property Context Menu"))
192 if(ImGui::MenuItem(fmt::format(
"Reset {} to default", name_).c_str()))
200 if(!tooltip_.empty())
202 ImGui::SetItemTooltipEx(
"%s", tooltip_.c_str());
204 ImGui::HelpMarker(tooltip_.c_str());
220 ImGui::PopItemWidth();
231 if(columns_open_ && ImGui::TableGetColumnCount() > 1)
242 layout_ = std::make_unique<property_layout>(prop);
258 proxy.
impl->getter = [var](entt::meta_any& result)
263 proxy.
impl->setter = [var](
meta_any_proxy& proxy,
const entt::meta_any& value, uint64_t execution_count)
266 if(proxy.
impl->getter(var) && var)
268 return var.assign(value);
278 prop_proxy.
impl->get_name = [var_proxy, prop]()
280 auto name = var_proxy.impl->get_name();
287 prop_proxy.
impl->getter = [parent_proxy = var_proxy, prop](entt::meta_any& result)
290 if(parent_proxy.impl->getter(var) && var)
292 result = prop.get(var);
297 prop_proxy.
impl->setter = [parent_proxy = var_proxy, prop](
meta_any_proxy& proxy,
const entt::meta_any& value, uint64_t execution_count)
mutable
300 if(parent_proxy.impl->getter(var) && var)
302 prop.set(var, value);
303 return parent_proxy.impl->setter(parent_proxy, var, execution_count);
Manages ImGui layout for property inspection in the editor.
void set_data(const entt::meta_data &prop, bool columns=true)
Updates layout data from meta property.
property_layout()
Default constructor that registers this layout in the global stack.
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 pop_layout()
Cleans up ImGui state (IDs, tables, tree nodes)
void prepare_for_item()
Prepares ImGui for rendering the property value widget.
auto push_tree_layout(ImGuiTreeNodeFlags flags=0) -> bool
Creates a collapsible tree node layout for nested properties.
~property_layout()
Destructor that cleans up ImGui state and removes from stack.
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_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::unique_ptr< property_layout > layout_
Layout manager for this inspector's UI.
virtual void before_inspect(const entt::meta_data &prop)
Called before inspecting a property to set up layout.
virtual void after_inspect(const entt::meta_data &prop)
Called after inspecting a property to clean up layout.