From 5ddc50458f38d9682e05995272ba014c6b36e622 Mon Sep 17 00:00:00 2001 From: Ignacio Sanchez Gines <863613+drhelius@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:28:54 +0200 Subject: [PATCH] Disassembler tool bar --- platforms/shared/desktop/gui.cpp | 11 +++ platforms/shared/desktop/gui.h | 1 + .../shared/desktop/gui_debug_disassembler.cpp | 77 +++++++++++++++---- platforms/shared/desktop/gui_menus.cpp | 4 +- 4 files changed, 74 insertions(+), 19 deletions(-) diff --git a/platforms/shared/desktop/gui.cpp b/platforms/shared/desktop/gui.cpp index 30c2bb3..54843c4 100644 --- a/platforms/shared/desktop/gui.cpp +++ b/platforms/shared/desktop/gui.cpp @@ -21,6 +21,8 @@ #include "imgui/imgui.h" #include "imgui/implot.h" #include "imgui/fonts/RobotoMedium.h" +#include "imgui/fonts/MaterialIcons.h" +#include "imgui/fonts/IconsMaterialDesign.h" #include "nfd/nfd.h" #include "config.h" #include "application.h" @@ -73,6 +75,15 @@ void gui_init(void) gui_roboto_font = io.Fonts->AddFontFromMemoryCompressedTTF(RobotoMedium_compressed_data, RobotoMedium_compressed_size, 17.0f * application_display_scale, NULL, io.Fonts->GetGlyphRangesCyrillic()); + float iconFontSize = 20.0f; + static const ImWchar icons_ranges[] = { ICON_MIN_MD, ICON_MAX_16_MD, 0 }; + ImFontConfig icons_config; + icons_config.MergeMode = true; + icons_config.PixelSnapH = true; + icons_config.GlyphMinAdvanceX = iconFontSize; + icons_config.GlyphOffset = { 0.0f, 5.0f }; + gui_material_icons_font = io.Fonts->AddFontFromMemoryCompressedTTF(MaterialIcons_compressed_data, MaterialIcons_compressed_size, iconFontSize, &icons_config, icons_ranges); + ImFontConfig font_cfg; for (int i = 0; i < 4; i++) diff --git a/platforms/shared/desktop/gui.h b/platforms/shared/desktop/gui.h index d8c71aa..61f57a1 100644 --- a/platforms/shared/desktop/gui.h +++ b/platforms/shared/desktop/gui.h @@ -59,6 +59,7 @@ EXTERN bool gui_main_menu_hovered; EXTERN ImFont* gui_default_font; EXTERN ImFont* gui_default_fonts[4]; EXTERN ImFont* gui_roboto_font; +EXTERN ImFont* gui_material_icons_font; EXTERN int gui_main_window_width; EXTERN int gui_main_window_height; EXTERN int gui_main_menu_height; diff --git a/platforms/shared/desktop/gui_debug_disassembler.cpp b/platforms/shared/desktop/gui_debug_disassembler.cpp index 8ea8878..27aa597 100644 --- a/platforms/shared/desktop/gui_debug_disassembler.cpp +++ b/platforms/shared/desktop/gui_debug_disassembler.cpp @@ -21,6 +21,7 @@ #include "gui_debug_disassembler.h" #include "imgui/imgui.h" +#include "imgui/fonts/IconsMaterialDesign.h" #include "../../../src/geargrafx.h" #include "gui_debug_constants.h" #include "gui.h" @@ -178,44 +179,88 @@ void gui_debug_window_disassembler(void) static void show_controls(void) { - if (ImGui::Button("Step Over")) + ImGui::PushFont(gui_material_icons_font); + + if (ImGui::Button(ICON_MD_PLAY_ARROW)) + { + emu_debug_continue(); + } + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) + { + ImGui::SetTooltip("Continue (F5)"); + } + + ImGui::SameLine(); + if (ImGui::Button(ICON_MD_STOP)) + { + emu_debug_break(); + } + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) + { + ImGui::SetTooltip("Break (F7)"); + } + + ImGui::SameLine(); + if (ImGui::Button(ICON_MD_REDO)) { emu_debug_step_over(); } + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) + { + ImGui::SetTooltip("Step Over (F10)"); + } + ImGui::SameLine(); - if (ImGui::Button("Step Into")) + if (ImGui::Button(ICON_MD_FILE_DOWNLOAD)) { emu_debug_step_into(); } + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) + { + ImGui::SetTooltip("Step Into (F11)"); + } + ImGui::SameLine(); - if (ImGui::Button("Step Out")) + if (ImGui::Button(ICON_MD_FILE_UPLOAD)) { emu_debug_step_out(); } + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) + { + ImGui::SetTooltip("Step Out (Shift+F11)"); + } + ImGui::SameLine(); - if (ImGui::Button("Step Frame")) + if (ImGui::Button(ICON_MD_KEYBOARD_TAB)) { - emu_debug_step_frame(); + gui_debug_runtocursor(); } - if (ImGui::Button("Break")) + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) { - emu_debug_break(); + ImGui::SetTooltip("Run to Cursor (F8)"); } + ImGui::SameLine(); - if (ImGui::Button("Continue")) + if (ImGui::Button(ICON_MD_INPUT)) { - emu_debug_continue(); + emu_debug_step_frame(); } - ImGui::SameLine(); - if (ImGui::Button("Run To Cursor")) + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) { - gui_debug_runtocursor(); + ImGui::SetTooltip("Step Frame (F6)"); } + ImGui::SameLine(); - if (ImGui::Button("Reset")) + if (ImGui::Button(ICON_MD_REPLAY)) { emu_reset(); } + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) + { + ImGui::SetTooltip("Reset (CTRL+R)"); + } + + ImGui::PopFont(); ImGui::Checkbox("Opcodes", &show_mem); ImGui::SameLine(); ImGui::Checkbox("Symbols", &show_symbols); ImGui::SameLine(); @@ -224,8 +269,6 @@ static void show_controls(void) ImGui::Separator(); - ImGui::Text("Go To Address: "); - ImGui::SameLine(); ImGui::PushItemWidth(45); if (ImGui::InputTextWithHint("##goto_address", "XXXX", goto_address, IM_ARRAYSIZE(goto_address), ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue)) { @@ -240,7 +283,7 @@ static void show_controls(void) } ImGui::PopItemWidth(); ImGui::SameLine(); - if (ImGui::Button("Go", ImVec2(30, 0))) + if (ImGui::Button("Go To Address", ImVec2(120, 0))) { try { @@ -253,7 +296,7 @@ static void show_controls(void) } ImGui::SameLine(); - if (ImGui::Button("Back", ImVec2(50, 0))) + if (ImGui::Button("Go Back", ImVec2(80, 0))) { goto_back_requested = true; } diff --git a/platforms/shared/desktop/gui_menus.cpp b/platforms/shared/desktop/gui_menus.cpp index d4a74ba..a66ca46 100644 --- a/platforms/shared/desktop/gui_menus.cpp +++ b/platforms/shared/desktop/gui_menus.cpp @@ -502,7 +502,7 @@ static void menu_debug(void) emu_debug_step_into(); } - if (ImGui::MenuItem("Step Out", "SHIFT + F11", (void*)0, config_debug.debug)) + if (ImGui::MenuItem("Step Out", "SHIFT+F11", (void*)0, config_debug.debug)) { emu_debug_step_out(); } @@ -529,7 +529,7 @@ static void menu_debug(void) ImGui::Separator(); - if (ImGui::MenuItem("Go Back", "CTRL + BACKSPACE", (void*)0, config_debug.debug)) + if (ImGui::MenuItem("Go Back", "CTRL+BACKSPACE", (void*)0, config_debug.debug)) { gui_debug_go_back(); }