yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
editor.cc
Go to the documentation of this file.
1#include "editor.h"
2
4#include "imgui/imgui.h"
5
6namespace yaze {
7namespace app {
8namespace editor {
9
10absl::Status DrawEditor(EditorLayoutParams *params) {
11 if (params->editor == nullptr) {
12 return absl::InternalError("Editor is not initialized");
13 }
14
15 // Draw the editors based on h_split and v_split in a recursive manner
16 if (params->v_split) {
17 ImGui::BeginTable("##VerticalSplitTable", 2);
18
19 ImGui::TableNextColumn();
20 if (params->left)
22
23 ImGui::TableNextColumn();
24 if (params->right)
26
27 ImGui::EndTable();
28 } else if (params->h_split) {
29 ImGui::BeginTable("##HorizontalSplitTable", 1);
30
31 ImGui::TableNextColumn();
32 if (params->top)
34
35 ImGui::TableNextColumn();
36 if (params->bottom)
38
39 ImGui::EndTable();
40 } else {
41 // No split, just draw the single editor
42 ImGui::Text("%s Editor",
43 kEditorNames[static_cast<int>(params->editor->type())]);
44 RETURN_IF_ERROR(params->editor->Update());
45 }
46
47 return absl::OkStatus();
48}
49
50} // namespace editor
51} // namespace app
52} // namespace yaze
virtual absl::Status Update()=0
EditorType type() const
Definition editor.h:70
#define RETURN_IF_ERROR(expression)
Definition constants.h:62
absl::Status DrawEditor(EditorLayoutParams *params)
Definition editor.cc:10
constexpr std::array< const char *, 10 > kEditorNames
Definition editor.h:43
Definition common.cc:22
Dynamic Editor Layout Parameters.
Definition editor.h:80
EditorLayoutParams * right
Definition editor.h:87
EditorLayoutParams * left
Definition editor.h:86
EditorLayoutParams * bottom
Definition editor.h:89