Creando Stack viewer

This commit is contained in:
2025-06-28 18:12:04 -04:00
parent a477a21d7f
commit a1a52024c8
7 changed files with 69 additions and 3 deletions

34
src/UI/StackViewer.cpp Normal file
View File

@@ -0,0 +1,34 @@
#include "StackViewer.h"
#include "imgui.h"
StackViewer::StackViewer(
std::shared_ptr<Graphics> graphics,
std::shared_ptr<MachineState> machine_state,
std::shared_ptr<CallbackManager> callback_manager
) :
graphics{std::move(graphics)},
machine_state{std::move(machine_state)},
callback_manager{std::move(callback_manager)}
{
}
void StackViewer::render()
{
if (ImGui::Begin("Chip8 - Stack"))
{
if (ImGui::BeginTable("Stack", 2, ImGuiTableFlags_BordersV))
{
for (std::size_t i = 0; i < std::size(machine_state->stack); i++)
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("Depth %zu", i);
ImGui::TableSetColumnIndex(1);
ImGui::Text("0x%04X", machine_state->stack[i]);
}
}
ImGui::EndTable();
}
ImGui::End();
}