yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
zeml.cc
Go to the documentation of this file.
1
2#include "app/gui/zeml.h"
3
4#include "imgui/imgui.h"
5
6#include <cctype>
7#include <fstream>
8#include <functional>
9#include <map>
10#include <sstream>
11#include <string>
12#include <vector>
13
14#include "app/gui/canvas.h"
15#include "app/gui/input.h"
17
18namespace yaze {
19namespace app {
20namespace gui {
21namespace zeml {
22
23std::vector<Token> Tokenize(const std::string& input) {
24 std::vector<Token> tokens;
25 std::istringstream stream(input);
26 char ch;
27
28 while (stream.get(ch)) {
29 if (isspace(ch)) continue;
30
31 if (ch == '{') {
32 tokens.push_back({TokenType::OpenBrace, "{"});
33 } else if (ch == '}') {
34 tokens.push_back({TokenType::CloseBrace, "}"});
35 } else if (ch == ',') {
36 tokens.push_back({TokenType::Comma, ","});
37 } else if (std::isalnum(ch) || ch == '_') {
38 std::string ident(1, ch);
39 while (stream.get(ch) && (std::isalnum(ch) || ch == '_')) {
40 ident += ch;
41 }
42 stream.unget();
43 tokens.push_back({TokenType::Identifier, ident});
44 } else if (ch == '"' || ch == '\'') {
45 std::string str;
46 char quoteType = ch;
47 while (stream.get(ch) && ch != quoteType) {
48 str += ch;
49 }
50 tokens.push_back({TokenType::String, str});
51 }
52 }
53
54 tokens.push_back({TokenType::EndOfStream, ""});
55 return tokens;
56}
57
58WidgetType MapType(const std::string& type) {
59 static std::map<std::string, WidgetType> typeMap = {
60 {"Window", WidgetType::Window},
61 {"Button", WidgetType::Button},
62 {"Slider", WidgetType::Slider},
63 {"Text", WidgetType::Text},
64 {"CollapsingHeader", WidgetType::CollapsingHeader},
65 {"Columns", WidgetType::Columns},
66 {"Checkbox", WidgetType::Checkbox},
67 {"HexInputByte", WidgetType::HexInputByte},
68 {"HexInputWord", WidgetType::HexInputWord},
69 {"Table", WidgetType::Table},
70 {"Selectable", WidgetType::Selectable},
71 {"TableSetupColumn", WidgetType::TableSetupColumn},
72 {"TableHeadersRow", WidgetType::TableHeadersRow},
73 {"TableNextColumn", WidgetType::TableNextColumn},
74 {"Function", WidgetType::Function},
75 {"BeginChild", WidgetType::BeginChild},
76 {"BeginMenu", WidgetType::BeginMenu},
77 {"MenuItem", WidgetType::MenuItem},
78 {"BeginMenuBar", WidgetType::BeginMenuBar},
79 {"Separator", WidgetType::Separator},
80 {"BeginTabBar", WidgetType::BeginTabBar},
81 {"BeginTabItem", WidgetType::BeginTabItem},
82 {"Canvas", WidgetType::Canvas},
84 };
85 return typeMap[type];
86}
87
88Node ParseNode(const std::vector<Token>& tokens, size_t& index,
89 const std::map<std::string, void*>& data_bindings,
90 const std::map<std::string, Node>& definitions) {
91 Node node;
92 if (index >= tokens.size() || tokens[index].type == TokenType::EndOfStream) {
93 return node;
94 }
95
96 while (index < tokens.size() &&
97 tokens[index].type != TokenType::EndOfStream) {
98 Token token = tokens[index];
99 if (token.type == TokenType::Identifier) {
100 node.type = MapType(token.value);
101 index++; // Move to the next token for attributes
102 if (node.type == WidgetType::Definition) {
103 if (definitions.find(token.value) != definitions.end()) {
104 node = definitions.at(token.value);
105 }
106 } else {
107 node.attributes =
108 ParseAttributes(tokens, index, node.type, data_bindings);
109 }
110 }
111
112 // Handle the opening brace indicating the start of child nodes
113 if (index < tokens.size() && tokens[index].type == TokenType::OpenBrace) {
114 index++; // Skip the opening brace
115
116 while (index < tokens.size() &&
117 tokens[index].type != TokenType::CloseBrace) {
118 if (tokens[index].type == TokenType::Comma) {
119 index++; // Skip commas
120 } else {
121 node.children.push_back(ParseNode(tokens, index, data_bindings));
122 }
123 }
124
125 if (index < tokens.size() &&
126 tokens[index].type == TokenType::CloseBrace) {
127 index++; // Ensure closing brace is skipped before returning
128 }
129 }
130
131 break; // Exit after processing one complete node
132 }
133 return node;
134}
135
136void ParseFlags(const WidgetType& type, const std::string& flags,
137 WidgetAttributes& attributes) {
138 // Parse the flags for the `|` character
139 std::vector<std::string> flag_tokens;
140 std::string token;
141 std::istringstream tokenStream(flags);
142 while (std::getline(tokenStream, token, '|')) {
143 flag_tokens.push_back(token);
144 }
145
146 switch (type) {
148 static std::map<std::string, ImGuiWindowFlags> flagMap = {
149 {"None", ImGuiWindowFlags_None},
150 {"NoTitleBar", ImGuiWindowFlags_NoTitleBar},
151 {"NoResize", ImGuiWindowFlags_NoResize},
152 {"NoMove", ImGuiWindowFlags_NoMove},
153 {"NoScrollbar", ImGuiWindowFlags_NoScrollbar},
154 {"NoScrollWithMouse", ImGuiWindowFlags_NoScrollWithMouse},
155 {"NoCollapse", ImGuiWindowFlags_NoCollapse},
156 {"AlwaysAutoResize", ImGuiWindowFlags_AlwaysAutoResize},
157 {"NoSavedSettings", ImGuiWindowFlags_NoSavedSettings},
158 {"NoInputs", ImGuiWindowFlags_NoInputs},
159 {"MenuBar", ImGuiWindowFlags_MenuBar},
160 {"HorizontalScrollbar", ImGuiWindowFlags_HorizontalScrollbar},
161 {"NoFocusOnAppearing", ImGuiWindowFlags_NoFocusOnAppearing},
162 {"NoBringToFrontOnFocus", ImGuiWindowFlags_NoBringToFrontOnFocus},
163 {"AlwaysVerticalScrollbar", ImGuiWindowFlags_AlwaysVerticalScrollbar},
164 {"AlwaysHorizontalScrollbar",
165 ImGuiWindowFlags_AlwaysHorizontalScrollbar},
166 {"AlwaysUseWindowPadding", ImGuiWindowFlags_AlwaysUseWindowPadding},
167 {"NoNavInputs", ImGuiWindowFlags_NoNavInputs},
168 {"NoNavFocus", ImGuiWindowFlags_NoNavFocus},
169 {"UnsavedDocument", ImGuiWindowFlags_UnsavedDocument},
170 {"NoNav", ImGuiWindowFlags_NoNav},
171 {"NoDecoration", ImGuiWindowFlags_NoDecoration},
172 {"NoInputs", ImGuiWindowFlags_NoInputs},
173 {"NoFocusOnAppearing", ImGuiWindowFlags_NoFocusOnAppearing},
174 {"NoBringToFrontOnFocus", ImGuiWindowFlags_NoBringToFrontOnFocus},
175 {"AlwaysAutoResize", ImGuiWindowFlags_AlwaysAutoResize},
176 {"NoSavedSettings", ImGuiWindowFlags_NoSavedSettings},
177 {"NoMouseInputs", ImGuiWindowFlags_NoMouseInputs},
178 {"NoMouseInputs", ImGuiWindowFlags_NoMouseInputs},
179 {"NoTitleBar", ImGuiWindowFlags_NoTitleBar},
180 {"NoResize", ImGuiWindowFlags_NoResize},
181 {"NoMove", ImGuiWindowFlags_NoMove},
182 {"NoScrollbar", ImGuiWindowFlags_NoScrollbar},
183 {"NoScrollWithMouse", ImGuiWindowFlags_NoScrollWithMouse},
184 {"NoCollapse", ImGuiWindowFlags_NoCollapse},
185 {"AlwaysVerticalScrollbar", ImGuiWindowFlags_AlwaysVerticalScrollbar},
186 {"AlwaysHorizontalScrollbar",
187 ImGuiWindowFlags_AlwaysHorizontalScrollbar}};
188 ImGuiWindowFlags windowFlags = ImGuiWindowFlags_None;
189 for (const auto& flag : flag_tokens) {
190 if (flagMap.find(flag) != flagMap.end()) {
191 windowFlags |= flagMap[flag];
192 }
193 }
194 attributes.flags = std::make_unique<ImGuiWindowFlags>(windowFlags);
195 break;
196 }
198 // Create a flag map using the tree node flags
199 static std::map<std::string, ImGuiTreeNodeFlags> flagMap = {
200 {"None", ImGuiTreeNodeFlags_None},
201 {"Selected", ImGuiTreeNodeFlags_Selected},
202 {"Framed", ImGuiTreeNodeFlags_Framed},
203 {"AllowItemOverlap", ImGuiTreeNodeFlags_AllowItemOverlap},
204 {"NoTreePushOnOpen", ImGuiTreeNodeFlags_NoTreePushOnOpen},
205 {"NoAutoOpenOnLog", ImGuiTreeNodeFlags_NoAutoOpenOnLog},
206 {"DefaultOpen", ImGuiTreeNodeFlags_DefaultOpen},
207 {"OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick},
208 {"OpenOnArrow", ImGuiTreeNodeFlags_OpenOnArrow},
209 {"Leaf", ImGuiTreeNodeFlags_Leaf},
210 {"Bullet", ImGuiTreeNodeFlags_Bullet},
211 {"FramePadding", ImGuiTreeNodeFlags_FramePadding},
212 {"NavLeftJumpsBackHere", ImGuiTreeNodeFlags_NavLeftJumpsBackHere},
213 {"CollapsingHeader", ImGuiTreeNodeFlags_CollapsingHeader}};
214 ImGuiTreeNodeFlags treeFlags = ImGuiTreeNodeFlags_None;
215 for (const auto& flag : flag_tokens) {
216 if (flagMap.find(flag) != flagMap.end()) {
217 treeFlags |= flagMap[flag];
218 }
219 }
220 attributes.flags = std::make_unique<ImGuiTreeNodeFlags>(treeFlags);
221 break;
222 }
223 case WidgetType::Table: {
224 // Create a flag map
225 static std::map<std::string, ImGuiTableFlags> flagMap = {
226 {"None", ImGuiTableFlags_None},
227 {"Resizable", ImGuiTableFlags_Resizable},
228 {"Reorderable", ImGuiTableFlags_Reorderable},
229 {"Hideable", ImGuiTableFlags_Hideable},
230 {"Sortable", ImGuiTableFlags_Sortable},
231 {"NoSavedSettings", ImGuiTableFlags_NoSavedSettings},
232 {"ContextMenuInBody", ImGuiTableFlags_ContextMenuInBody},
233 {"RowBg", ImGuiTableFlags_RowBg},
234 {"BordersInnerH", ImGuiTableFlags_BordersInnerH},
235 {"BordersOuterH", ImGuiTableFlags_BordersOuterH},
236 {"BordersInnerV", ImGuiTableFlags_BordersInnerV},
237 {"BordersOuterV", ImGuiTableFlags_BordersOuterV},
238 {"BordersH", ImGuiTableFlags_BordersH},
239 {"BordersV", ImGuiTableFlags_BordersV},
240 {"Borders", ImGuiTableFlags_Borders},
241 {"NoBordersInBody", ImGuiTableFlags_NoBordersInBody},
242 {"NoBordersInBodyUntilResize",
243 ImGuiTableFlags_NoBordersInBodyUntilResize},
244 {"SizingFixedFit", ImGuiTableFlags_SizingFixedFit},
245 {"SizingFixedSame", ImGuiTableFlags_SizingFixedSame},
246 {"SizingStretchProp", ImGuiTableFlags_SizingStretchProp},
247 {"SizingStretchSame", ImGuiTableFlags_SizingStretchSame},
248 {"NoHostExtendX", ImGuiTableFlags_NoHostExtendX},
249 {"NoHostExtendY", ImGuiTableFlags_NoHostExtendY},
250 {"NoKeepColumnsVisible", ImGuiTableFlags_NoKeepColumnsVisible},
251 {"PreciseWidths", ImGuiTableFlags_PreciseWidths},
252 {"NoClip", ImGuiTableFlags_NoClip},
253 {"PadOuterX", ImGuiTableFlags_PadOuterX},
254 {"NoPadOuterX", ImGuiTableFlags_NoPadOuterX},
255 {"NoPadInnerX", ImGuiTableFlags_NoPadInnerX},
256 {"ScrollX", ImGuiTableFlags_ScrollX},
257 {"ScrollY", ImGuiTableFlags_ScrollY},
258 {"SortMulti", ImGuiTableFlags_SortMulti},
259 {"SortTristate", ImGuiTableFlags_SortTristate}};
260 ImGuiTableFlags tableFlags = ImGuiTableFlags_None;
261 for (const auto& flag : flag_tokens) {
262 if (flagMap.find(flag) != flagMap.end()) {
263 tableFlags |= flagMap[flag];
264 }
265 }
266 // Reserve data to the void* pointer and assign flags
267 attributes.flags = std::make_unique<ImGuiTableFlags>(tableFlags);
268 } break;
270 static std::map<std::string, ImGuiTableColumnFlags> flagMap = {
271 {"None", ImGuiTableColumnFlags_None},
272 {"DefaultHide", ImGuiTableColumnFlags_DefaultHide},
273 {"DefaultSort", ImGuiTableColumnFlags_DefaultSort},
274 {"WidthStretch", ImGuiTableColumnFlags_WidthStretch},
275 {"WidthFixed", ImGuiTableColumnFlags_WidthFixed},
276 {"NoResize", ImGuiTableColumnFlags_NoResize},
277 {"NoReorder", ImGuiTableColumnFlags_NoReorder},
278 {"NoHide", ImGuiTableColumnFlags_NoHide},
279 {"NoClip", ImGuiTableColumnFlags_NoClip},
280 {"NoSort", ImGuiTableColumnFlags_NoSort},
281 {"NoSortAscending", ImGuiTableColumnFlags_NoSortAscending},
282 {"NoSortDescending", ImGuiTableColumnFlags_NoSortDescending},
283 {"NoHeaderWidth", ImGuiTableColumnFlags_NoHeaderWidth},
284 {"PreferSortAscending", ImGuiTableColumnFlags_PreferSortAscending},
285 {"PreferSortDescending", ImGuiTableColumnFlags_PreferSortDescending},
286 {"IndentEnable", ImGuiTableColumnFlags_IndentEnable},
287 {"IndentDisable", ImGuiTableColumnFlags_IndentDisable},
288 {"IsEnabled", ImGuiTableColumnFlags_IsEnabled},
289 {"IsVisible", ImGuiTableColumnFlags_IsVisible},
290 {"IsSorted", ImGuiTableColumnFlags_IsSorted},
291 {"IsHovered", ImGuiTableColumnFlags_IsHovered}};
292 ImGuiTableColumnFlags columnFlags = ImGuiTableColumnFlags_None;
293 for (const auto& flag : flag_tokens) {
294 if (flagMap.find(flag) != flagMap.end()) {
295 columnFlags |= flagMap[flag];
296 }
297 }
298 // Reserve data to the void* pointer and assign flags
299 attributes.flags = std::make_unique<ImGuiTableColumnFlags>(columnFlags);
300 }
301 default:
302 break;
303 }
304}
305
307 const std::vector<Token>& tokens, size_t& index, const WidgetType& type,
308 const std::map<std::string, void*>& data_bindings) {
309 WidgetAttributes attributes;
310
311 while (index < tokens.size() && tokens[index].type != TokenType::CloseBrace) {
312 if (tokens[index].type == TokenType::Identifier) {
313 Token keyToken = tokens[index];
314 index++; // Move to the value token.
315 if (index < tokens.size() && tokens[index].type == TokenType::String) {
316 std::string value = tokens[index].value;
317 index++; // Move past the value.
318
319 if (keyToken.value == "id")
320 attributes.id = value;
321 else if (keyToken.value == "title")
322 attributes.title = value;
323 else if (keyToken.value == "min")
324 attributes.min = std::stod(value);
325 else if (keyToken.value == "max")
326 attributes.max = std::stod(value);
327 else if (keyToken.value == "value")
328 attributes.value = std::stod(value);
329 else if (keyToken.value == "width")
330 if (value == "autox")
331 attributes.width = ImGui::GetContentRegionAvail().x;
332 else if (value == "autoy")
333 attributes.width = ImGui::GetContentRegionAvail().y;
334 else
335 attributes.width = std::stod(value);
336 else if (keyToken.value == "text")
337 attributes.text = value;
338 else if (keyToken.value == "data" &&
339 data_bindings.find(value) != data_bindings.end()) {
340 attributes.data = data_bindings.at(value);
341 } else if (keyToken.value == "count") {
342 attributes.count = std::stoi(value);
343 } else if (keyToken.value == "flags") {
344 ParseFlags(type, value, attributes);
345 } else if (keyToken.value == "size") {
346 std::string sizeX, sizeY;
347 std::istringstream sizeStream(value);
348 std::getline(sizeStream, sizeX, ',');
349 std::getline(sizeStream, sizeY, ',');
350 attributes.size = ImVec2(std::stod(sizeX), std::stod(sizeY));
351 }
352 }
353 } else {
354 // If it's not an identifier or we encounter an open brace, break out.
355 break;
356 }
357 }
358 return attributes;
359}
360
361Node Parse(const std::string& yazon_input,
362 const std::map<std::string, void*>& data_bindings) {
363 size_t index = 0;
364 auto tokens = Tokenize(yazon_input);
365
366 std::map<std::string, Node> definitions;
367 if (tokens[index].value == "Definitions") {
368 index++; // Skip the "Definitions" token
369 while (index < tokens.size() &&
370 tokens[index].value != "Layout") { // Skip the definitions
371 // Get the definition name and parse the node
372 std::string definition_name = tokens[index].value;
373 index++; // Move to the definition node
374 definitions[definition_name] = ParseNode(tokens, index, data_bindings);
375 index++;
376 }
377 }
378
379 return ParseNode(tokens, index, data_bindings);
380}
381
382void Render(Node& node) {
383 switch (node.type) {
384 case WidgetType::Window: {
385 ImGuiWindowFlags flags = ImGuiWindowFlags_None;
386 if (node.attributes.flags) {
387 flags = *(ImGuiWindowFlags*)node.attributes.flags.get();
388 }
389 if (ImGui::Begin(node.attributes.title.c_str(), nullptr, flags)) {
390 for (auto& child : node.children) {
391 Render(child);
392 }
393 ImGui::End();
394 }
395 } break;
397 if (node.attributes.data) {
398 // Format the text with the data value
399 char formattedText[256];
400 snprintf(formattedText, sizeof(formattedText),
401 node.attributes.text.c_str(), *(int*)node.attributes.data);
402 if (ImGui::Button(formattedText)) {
404 }
405 } else {
406 if (ImGui::Button(node.attributes.text.c_str())) {
408 }
409 }
410 break;
412 ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_None;
413 if (node.attributes.flags) {
414 flags = *(ImGuiTreeNodeFlags*)node.attributes.flags.get();
415 }
416 if (ImGui::CollapsingHeader(node.attributes.title.c_str(), flags)) {
417 for (auto& child : node.children) {
418 Render(child);
419 }
420 }
421 } break;
423 ImGui::Columns(node.attributes.count, node.attributes.title.c_str());
424 ImGui::Separator();
425 for (auto& child : node.children) {
426 Render(child);
427 ImGui::NextColumn();
428 }
429 ImGui::Columns(1);
430 ImGui::Separator();
431 break;
433 if (ImGui::Checkbox(node.attributes.title.c_str(),
434 (bool*)node.attributes.data)) {
436 }
437 break;
438 case WidgetType::Table: {
439 ImGuiTableFlags flags = ImGuiTableFlags_None;
440 if (node.attributes.flags) {
441 flags = *(ImGuiTableFlags*)node.attributes.flags.get();
442 }
443 if (ImGui::BeginTable(node.attributes.id.c_str(), node.attributes.count,
444 flags)) {
445 for (auto& child : node.children) {
446 Render(child);
447 }
448 }
449 ImGui::EndTable();
450 } break;
452 ImGuiTableColumnFlags flags = ImGuiTableColumnFlags_None;
453 if (node.attributes.flags) {
454 flags = *(ImGuiTableColumnFlags*)node.attributes.flags.get();
455 }
456 ImGui::TableSetupColumn(node.attributes.title.c_str(), flags);
457 } break;
459 ImGui::TableHeadersRow();
460 break;
462 ImGui::TableNextColumn();
463 break;
464 case WidgetType::Text:
465 if (node.attributes.data) {
466 // Assuming all data-bound Text widgets use string formatting
467 char formattedText[128];
468 snprintf(formattedText, sizeof(formattedText),
469 node.attributes.text.c_str(),
470 *(int*)node.attributes.data & 0xFFFF);
471 ImGui::Text("%s", formattedText);
472 } else {
473 ImGui::Text("%s", node.attributes.text.c_str());
474 }
475 break;
477 node.actions[0].callback();
478 break;
479 }
481 if (ImGui::BeginChild(node.attributes.id.c_str(), node.attributes.size)) {
482 for (auto& child : node.children) {
483 Render(child);
484 }
485 ImGui::EndChild();
486 }
487 break;
489 if (ImGui::BeginMenuBar()) {
490 for (auto& child : node.children) {
491 Render(child);
492 }
493 ImGui::EndMenuBar();
494 }
495 break;
497 if (ImGui::BeginMenu(node.attributes.title.c_str())) {
498 for (auto& child : node.children) {
499 Render(child);
500 }
501 ImGui::EndMenu();
502 }
503 break;
504 }
506 if (ImGui::MenuItem(node.attributes.title.c_str())) {
508 }
509 break;
510 }
512 ImGui::Separator();
513 break;
515 if (ImGui::Selectable(node.attributes.title.c_str(),
516 (bool*)node.attributes.selected)) {
518 }
519 break;
521 if (ImGui::BeginTabBar(node.attributes.title.c_str())) {
522 for (auto& child : node.children) {
523 Render(child);
524 }
525 ImGui::EndTabBar();
526 }
527 break;
529 if (ImGui::BeginTabItem(node.attributes.title.c_str())) {
530 for (auto& child : node.children) {
531 Render(child);
532 }
533 ImGui::EndTabItem();
534 }
535 break;
537 gui::InputHexByte(node.attributes.id.c_str(),
538 (uint8_t*)node.attributes.data);
539 break;
541 gui::InputHexWord(node.attributes.id.c_str(),
542 (uint16_t*)node.attributes.data);
543 break;
544 case WidgetType::Canvas: {
545 gui::Canvas* canvas = (gui::Canvas*)node.attributes.data;
546 if (canvas) {
547 canvas->DrawBackground();
548 canvas->DrawContextMenu();
549
550 canvas->DrawGrid();
551 canvas->DrawOverlay();
552 }
553 break;
554 }
555 default:
556 break;
557 }
558}
559
560void ExecuteActions(const std::vector<Action>& actions, ActionType type) {
561 for (const auto& action : actions) {
562 if (action.type == type) {
563 action.callback(); // Execute the callback associated with the action
564 }
565 }
566}
567
568void Bind(Node* node, std::function<void()> callback) {
569 if (node) {
570 Action action = {ActionType::Click, callback};
571 node->actions.push_back(action);
572 }
573}
574
575void BindAction(Node* node, ActionType type, std::function<void()> callback) {
576 if (node) {
577 Action action = {type, callback};
578 node->actions.push_back(action);
579 }
580}
581
582void BindSelectable(Node* node, bool* selected,
583 std::function<void()> callback) {
584 if (node) {
585 Action action = {ActionType::Click, callback};
586 node->actions.push_back(action);
587 node->attributes.selected = selected;
588 }
589}
590
591std::string LoadFile(const std::string& filename) {
592 std::string fileContents;
593 const std::string kPath = "assets/layouts/";
594
595 #ifdef __APPLE__
596 #if TARGET_OS_IOS == 1
597 const std::string kBundlePath = core::GetBundleResourcePath();
598 std::ifstream file(kBundlePath + filename);
599 #else
600 std::ifstream file(kPath + filename);
601 #endif
602 #else
603 std::ifstream file(kPath + filename);
604 #endif
605
606 if (file.is_open()) {
607 std::string line;
608 while (std::getline(file, line)) {
609 fileContents += line;
610 }
611 file.close();
612 } else {
613 fileContents = "File not found: " + filename;
614 std::cout << fileContents << std::endl;
615 }
616 return fileContents;
617}
618
619} // namespace zeml
620} // namespace gui
621} // namespace app
622} // namespace yaze
Represents a canvas for drawing and manipulating graphics.
Definition canvas.h:36
void DrawBackground(ImVec2 canvas_size=ImVec2(0, 0), bool drag=false)
Definition canvas.cc:69
void DrawGrid(float grid_step=64.0f, int tile_id_offset=8)
Definition canvas.cc:689
void DrawContextMenu(gfx::Bitmap *bitmap=nullptr)
Definition canvas.cc:104
std::string GetBundleResourcePath()
WidgetAttributes ParseAttributes(const std::vector< Token > &tokens, size_t &index, const WidgetType &type, const std::map< std::string, void * > &data_bindings)
ParseNode attributes for a widget.
Definition zeml.cc:306
Node Parse(const std::string &yazon_input, const std::map< std::string, void * > &data_bindings)
Parse a zeml string.
Definition zeml.cc:361
void BindAction(Node *node, ActionType type, std::function< void()> callback)
Bind an action to a node.
Definition zeml.cc:575
void ExecuteActions(const std::vector< Action > &actions, ActionType type)
Execute actions for a node.
Definition zeml.cc:560
void Bind(Node *node, std::function< void()> callback)
Bind a callback to a node.
Definition zeml.cc:568
void BindSelectable(Node *node, bool *selected, std::function< void()> callback)
Bind a selectable node.
Definition zeml.cc:582
void Render(Node &node)
Render a zeml tree.
Definition zeml.cc:382
Node ParseNode(const std::vector< Token > &tokens, size_t &index, const std::map< std::string, void * > &data_bindings, const std::map< std::string, Node > &definitions)
Parse a zeml node.
Definition zeml.cc:88
std::string LoadFile(const std::string &filename)
Definition zeml.cc:591
WidgetType MapType(const std::string &type)
Map a string to a widget type.
Definition zeml.cc:58
void ParseFlags(const WidgetType &type, const std::string &flags, WidgetAttributes &attributes)
Definition zeml.cc:136
std::vector< Token > Tokenize(const std::string &input)
Tokenize a zeml string.
Definition zeml.cc:23
bool InputHexByte(const char *label, uint8_t *data, float input_width, bool no_step)
Definition input.cc:176
bool InputHexWord(const char *label, uint16_t *data, float input_width, bool no_step)
Definition input.cc:162
Definition common.cc:21
Node for a zeml tree.
Definition zeml.h:127
std::vector< Action > actions
Definition zeml.h:130
std::vector< Node > children
Definition zeml.h:131
WidgetAttributes attributes
Definition zeml.h:129
Attributes for a widget.
Definition zeml.h:90
std::shared_ptr< void > flags
Definition zeml.h:101