76 std::string indent(indent_level * 2,
' ');
79 auto* label_prop =
const_cast<WidgetDefinition&
>(widget).GetProperty(
"label");
80 std::string label = label_prop ? label_prop->string_value :
"Widget";
84 code += indent + absl::StrFormat(
"if (gui::ThemedButton(\"%s\")) {\n", label);
86 code += indent + absl::StrFormat(
" %s();\n", widget.
callback_name);
88 code += indent +
"}\n";
92 code += indent + absl::StrFormat(
"if (gui::PrimaryButton(\"%s\")) {\n", label);
94 code += indent + absl::StrFormat(
" %s();\n", widget.
callback_name);
96 code += indent +
"}\n";
100 code += indent + absl::StrFormat(
"if (gui::DangerButton(\"%s\")) {\n", label);
102 code += indent + absl::StrFormat(
" %s();\n", widget.
callback_name);
104 code += indent +
"}\n";
108 auto* icon_prop =
const_cast<WidgetDefinition&
>(widget).GetProperty(
"icon");
109 std::string icon = icon_prop ? icon_prop->string_value :
ICON_MD_LABEL;
110 code += indent + absl::StrFormat(
"gui::SectionHeader(\"%s\", \"%s\");\n",
116 code += indent +
"if (gui::BeginPropertyTable(\"props\")) {\n";
117 code += indent +
" // Add property rows here\n";
118 code += indent +
" gui::EndPropertyTable();\n";
119 code += indent +
"}\n";
123 auto* value_prop =
const_cast<WidgetDefinition&
>(widget).GetProperty(
"value");
124 std::string value = value_prop ? value_prop->string_value :
"Value";
125 code += indent + absl::StrFormat(
"gui::PropertyRow(\"%s\", \"%s\");\n",
131 auto* columns_prop =
const_cast<WidgetDefinition&
>(widget).GetProperty(
"columns");
132 int columns = columns_prop ? columns_prop->int_value : 2;
133 code += indent + absl::StrFormat(
134 "if (gui::LayoutHelpers::BeginTableWithTheming(\"table\", %d)) {\n",
136 code += indent +
" // Table contents\n";
137 code += indent +
" gui::LayoutHelpers::EndTableWithTheming();\n";
138 code += indent +
"}\n";
143 code += indent + absl::StrFormat(
"if (gui::AutoButton(\"%s\")) {\n", label);
145 code += indent + absl::StrFormat(
" %s();\n", widget.
callback_name);
147 code += indent +
"}\n";
151 auto* size_prop =
const_cast<WidgetDefinition&
>(widget).GetProperty(
"size");
152 ImVec2 size = size_prop ? size_prop->vec2_value : ImVec2(300, 200);
153 code += indent +
"ImVec2 canvas_size;\n";
154 code += indent +
"gui::LayoutHelpers::BeginCanvasPanel(\"canvas\", &canvas_size);\n";
155 code += indent +
"// Custom drawing code here\n";
156 code += indent +
"gui::LayoutHelpers::EndCanvasPanel();\n";
161 auto* icon_prop =
const_cast<WidgetDefinition&
>(widget).GetProperty(
"icon");
162 std::string icon = icon_prop ? icon_prop->string_value :
ICON_MD_WINDOW;
163 code += indent + absl::StrFormat(
"gui::PanelHeader(\"%s\", \"%s\");\n",
169 code += indent + absl::StrFormat(
"// TODO: Yaze widget: %s\n",