Refactor editor UI components: streamline button handling in graphics and music editors, remove unused macros, and improve table setup in assembly editor.

This commit is contained in:
scawful
2025-03-08 00:58:47 -05:00
parent f31143f239
commit 9919677e43
5 changed files with 46 additions and 31 deletions

View File

@@ -54,19 +54,16 @@ class AssemblyEditor : public Editor {
private: private:
void DrawFileMenu(); void DrawFileMenu();
void DrawEditMenu(); void DrawEditMenu();
void SetEditorText(); void SetEditorText();
void DrawCurrentFolder(); void DrawCurrentFolder();
void DrawFileTabView(); void DrawFileTabView();
bool file_is_loaded_ = false; bool file_is_loaded_ = false;
int current_file_id_ = 0;
std::vector<std::string> files_; std::vector<std::string> files_;
std::vector<TextEditor> open_files_; std::vector<TextEditor> open_files_;
ImVector<int> active_files_; ImVector<int> active_files_;
int current_file_id_ = 0;
std::string current_file_; std::string current_file_;
FolderItem current_folder_; FolderItem current_folder_;

View File

@@ -499,16 +499,15 @@ absl::Status GraphicsEditor::UpdateScadView() {
absl::Status GraphicsEditor::DrawToolset() { absl::Status GraphicsEditor::DrawToolset() {
static constexpr absl::string_view kGfxToolsetColumnNames[] = { static constexpr absl::string_view kGfxToolsetColumnNames[] = {
"#memoryEditor", "#memoryEditor",
"##separator_gfx1",
}; };
if (ImGui::BeginTable("GraphicsToolset", 2, ImGuiTableFlags_SizingFixedFit, if (ImGui::BeginTable("GraphicsToolset", 1, ImGuiTableFlags_SizingFixedFit,
ImVec2(0, 0))) { ImVec2(0, 0))) {
for (const auto& name : kGfxToolsetColumnNames) for (const auto& name : kGfxToolsetColumnNames)
ImGui::TableSetupColumn(name.data()); ImGui::TableSetupColumn(name.data());
TableNextColumn(); TableNextColumn();
if (Button(ICON_MD_MEMORY)) { if (Button(absl::StrCat(ICON_MD_MEMORY, "Open Memory Editor").c_str())) {
if (!open_memory_editor_) { if (!open_memory_editor_) {
open_memory_editor_ = true; open_memory_editor_ = true;
} else { } else {
@@ -516,8 +515,6 @@ absl::Status GraphicsEditor::DrawToolset() {
} }
} }
TEXT_COLUMN("Open Memory Editor") // Separator
ImGui::EndTable(); ImGui::EndTable();
} }
return absl::OkStatus(); return absl::OkStatus();

View File

@@ -98,14 +98,34 @@ void ScreenEditor::DrawInventoryToolset() {
ImGui::TableSetupColumn("#bg3Tool"); ImGui::TableSetupColumn("#bg3Tool");
ImGui::TableSetupColumn("#itemTool"); ImGui::TableSetupColumn("#itemTool");
BUTTON_COLUMN(ICON_MD_UNDO) ImGui::TableNextColumn();
BUTTON_COLUMN(ICON_MD_REDO) if (ImGui::Button(ICON_MD_UNDO)) {
TEXT_COLUMN(ICON_MD_MORE_VERT) // status_ = inventory_.Undo();
BUTTON_COLUMN(ICON_MD_ZOOM_OUT) }
BUTTON_COLUMN(ICON_MD_ZOOM_IN) ImGui::TableNextColumn();
TEXT_COLUMN(ICON_MD_MORE_VERT) if (ImGui::Button(ICON_MD_REDO)) {
BUTTON_COLUMN(ICON_MD_DRAW) // status_ = inventory_.Redo();
BUTTON_COLUMN(ICON_MD_BUILD) }
ImGui::TableNextColumn();
ImGui::Text(ICON_MD_MORE_VERT);
ImGui::TableNextColumn();
if (ImGui::Button(ICON_MD_ZOOM_OUT)) {
screen_canvas_.ZoomOut();
}
ImGui::TableNextColumn();
if (ImGui::Button(ICON_MD_ZOOM_IN)) {
screen_canvas_.ZoomIn();
}
ImGui::TableNextColumn();
ImGui::Text(ICON_MD_MORE_VERT);
ImGui::TableNextColumn();
if (ImGui::Button(ICON_MD_DRAW)) {
current_mode_ = EditingMode::DRAW;
}
ImGui::TableNextColumn();
if (ImGui::Button(ICON_MD_BUILD)) {
// current_mode_ = EditingMode::BUILD;
}
ImGui::EndTable(); ImGui::EndTable();
} }

View File

@@ -194,9 +194,21 @@ void MusicEditor::DrawToolset() {
is_playing = !is_playing; is_playing = !is_playing;
} }
BUTTON_COLUMN(ICON_MD_FAST_REWIND) ImGui::TableNextColumn();
BUTTON_COLUMN(ICON_MD_FAST_FORWARD) if (ImGui::Button(ICON_MD_FAST_REWIND)) {
BUTTON_COLUMN(ICON_MD_VOLUME_UP) // Handle rewind button click
}
ImGui::TableNextColumn();
if (ImGui::Button(ICON_MD_FAST_FORWARD)) {
// Handle fast forward button click
}
ImGui::TableNextColumn();
if (ImGui::Button(ICON_MD_VOLUME_UP)) {
// Handle volume up button click
}
if (ImGui::Button(ICON_MD_ACCESS_TIME)) { if (ImGui::Button(ICON_MD_ACCESS_TIME)) {
music_tracker_.LoadSongs(*rom()); music_tracker_.LoadSongs(*rom());
} }

View File

@@ -6,17 +6,6 @@
ImGui::EndTabItem(); \ ImGui::EndTabItem(); \
} }
#define MENU_ITEM(w) if (ImGui::MenuItem(w))
#define MENU_ITEM2(w, v) if (ImGui::MenuItem(w, v))
#define BUTTON_COLUMN(w) \
ImGui::TableNextColumn(); \
ImGui::Button(w);
#define TEXT_COLUMN(w) \
ImGui::TableNextColumn(); \
ImGui::Text(w);
#define BEGIN_TABLE(l, n, f) if (ImGui::BeginTable(l, n, f, ImVec2(0, 0))) { #define BEGIN_TABLE(l, n, f) if (ImGui::BeginTable(l, n, f, ImVec2(0, 0))) {
#define SETUP_COLUMN(l) ImGui::TableSetupColumn(l); #define SETUP_COLUMN(l) ImGui::TableSetupColumn(l);