2#include <imgui/imgui_internal.h>
9std::vector<property_layout*> stack;
10void push_layout_to_stack(property_layout* l)
15void pop_layout_from_stack(property_layout* l)
27 push_layout_to_stack(
this);
32 push_layout_to_stack(
this);
41 push_layout_to_stack(
this);
50 push_layout_to_stack(
this);
59 push_layout_to_stack(
this);
72 pop_layout_from_stack(
this);
98 auto avail = ImGui::GetContentRegionAvail();
100 columns_open_ = ImGui::BeginTable((
"properties##" + name_).c_str(), 2);
105 auto first_column = 0.325f;
106 ImGui::TableSetupColumn(
"##prop_column1", ImGuiTableColumnFlags_WidthFixed, avail.x * first_column);
107 ImGui::TableSetupColumn(
"##prop_column2", ImGuiTableColumnFlags_WidthFixed, avail.x * (1.0f - first_column));
109 ImGui::TableNextRow();
110 ImGui::TableNextColumn();
114 ImGui::AlignTextToFramePadding();
121 ImGui::TextUnformatted(name_.c_str());
126 if(ImGui::BeginPopupContextItem(
"Property Context Menu"))
128 if(ImGui::MenuItem(fmt::format(
"Reset {} to default", name_).c_str()))
136 if(!tooltip_.empty())
138 ImGui::SetItemTooltipEx(
"%s", tooltip_.c_str());
140 ImGui::HelpMarker(tooltip_.c_str());
145 if(auto_proceed_to_next_column)
155 ImGui::TableNextColumn();
158 ImGui::PushID(name_.c_str());
159 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().
x);
168 auto avail = ImGui::GetContentRegionAvail();
170 columns_open_ = ImGui::BeginTable((
"properties##" + name_).c_str(), 2);
174 auto first_column = 0.325f;
175 ImGui::TableSetupColumn(
"##prop_column1", ImGuiTableColumnFlags_WidthFixed, avail.x * first_column);
176 ImGui::TableSetupColumn(
"##prop_column2", ImGuiTableColumnFlags_WidthFixed, avail.x * (1.0f - first_column));
178 ImGui::TableNextRow();
179 ImGui::TableNextColumn();
183 ImGui::SetNextItemOpen(
true, ImGuiCond_Appearing);
184 ImGui::AlignTextToFramePadding();
185 open_ = ImGui::TreeNodeEx(name_.c_str(), flags | ImGuiTreeNodeFlags_AllowOverlap);
189 if(ImGui::BeginPopupContextItem(
"Property Context Menu"))
191 if(ImGui::MenuItem(fmt::format(
"Reset {} to default", name_).c_str()))
199 if(!tooltip_.empty())
201 ImGui::SetItemTooltipEx(
"%s", tooltip_.c_str());
203 ImGui::HelpMarker(tooltip_.c_str());
219 ImGui::PopItemWidth();
230 if(columns_open_ && ImGui::TableGetColumnCount() > 1)
241 layout_ = std::make_unique<property_layout>(prop);
257 proxy.
impl->getter = [var](entt::meta_any& result)
262 proxy.
impl->setter = [var](
meta_any_proxy& proxy,
const entt::meta_any& value, uint64_t execution_count)
265 if(proxy.
impl->getter(var) && var)
267 return var.assign(value);
277 prop_proxy.
impl->get_name = [var_proxy, prop]()
279 auto name = var_proxy.impl->get_name();
286 prop_proxy.
impl->getter = [parent_proxy = var_proxy, prop](entt::meta_any& result)
289 if(parent_proxy.impl->getter(var) && var)
291 result = prop.get(var);
296 prop_proxy.
impl->setter = [parent_proxy = var_proxy, prop](
meta_any_proxy& proxy,
const entt::meta_any& value, uint64_t execution_count)
mutable
299 if(parent_proxy.impl->getter(var) && var)
301 prop.set(var, value);
302 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 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.