mirror of
https://github.com/pound-emu/pound.git
synced 2025-12-13 04:36:57 +00:00
Revert "feat(gui): Enhance CPU panel with state management and GUI improvements"
This commit is contained in:
parent
5b432dbb0c
commit
f69c918186
9 changed files with 307 additions and 345 deletions
|
|
@ -34,7 +34,6 @@ namespace Pound::GUI
|
|||
ImGui::CreateContext();
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||
// io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||
|
||||
// Setup style
|
||||
ApplyTheme();
|
||||
|
|
@ -70,8 +69,11 @@ namespace Pound::GUI
|
|||
window->ProcessEvents();
|
||||
|
||||
BeginFrame();
|
||||
RenderTabBars();
|
||||
|
||||
// Render menu bar
|
||||
RenderMainMenuBar();
|
||||
|
||||
// Render all panels
|
||||
for (auto &panel : panels)
|
||||
{
|
||||
if (panel->IsVisible())
|
||||
|
|
@ -80,6 +82,7 @@ namespace Pound::GUI
|
|||
}
|
||||
}
|
||||
|
||||
// Demo window for debugging
|
||||
if (show_demo_window)
|
||||
{
|
||||
ImGui::ShowDemoWindow(&show_demo_window);
|
||||
|
|
@ -109,6 +112,85 @@ namespace Pound::GUI
|
|||
window->SwapBuffers();
|
||||
}
|
||||
|
||||
void GUIManager::RenderMainMenuBar()
|
||||
{
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("File"))
|
||||
{
|
||||
if (ImGui::MenuItem("Load ROM...", "Ctrl+O"))
|
||||
{
|
||||
// TODO: Implement ROM loading
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Exit", "Alt+F4"))
|
||||
{
|
||||
window->SetShouldClose(true);
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Emulation"))
|
||||
{
|
||||
if (ImGui::MenuItem("Run CPU Test"))
|
||||
{
|
||||
if (cpu_test_callback)
|
||||
{
|
||||
cpu_test_callback();
|
||||
}
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Pause", "F5"))
|
||||
{
|
||||
// TODO: Implement pause
|
||||
}
|
||||
if (ImGui::MenuItem("Reset", "F6"))
|
||||
{
|
||||
// TODO: Implement reset
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("View"))
|
||||
{
|
||||
for (auto &panel : panels)
|
||||
{
|
||||
bool visible = panel->IsVisible();
|
||||
if (ImGui::MenuItem(panel->GetName().c_str(), nullptr, &visible))
|
||||
{
|
||||
panel->SetVisible(visible);
|
||||
}
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("ImGui Demo", nullptr, &show_demo_window))
|
||||
{
|
||||
// Toggle handled by flag
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Tools"))
|
||||
{
|
||||
if (ImGui::MenuItem("Settings", "Ctrl+,"))
|
||||
{
|
||||
// TODO: Open settings panel
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Help"))
|
||||
{
|
||||
if (ImGui::MenuItem("About"))
|
||||
{
|
||||
// TODO: Show about dialog
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
void GUIManager::ApplyTheme()
|
||||
{
|
||||
ImGuiStyle &style = ImGui::GetStyle();
|
||||
|
|
@ -190,114 +272,4 @@ namespace Pound::GUI
|
|||
}),
|
||||
panels.end());
|
||||
}
|
||||
|
||||
TabBar *GUIManager::AddTabs(const std::string &name)
|
||||
{
|
||||
auto new_bar = std::make_unique<TabBar>();
|
||||
new_bar->id = name;
|
||||
m_tab_bars.push_back(std::move(new_bar));
|
||||
return m_tab_bars.back().get();
|
||||
}
|
||||
|
||||
void GUIManager::AddSubTab(TabBar *parent_bar, const std::string &name, std::function<void()> callback)
|
||||
{
|
||||
if (!parent_bar)
|
||||
{
|
||||
LOG_WARNING(Render, "Trying to add a sub-tab to a null TabBar.");
|
||||
return;
|
||||
}
|
||||
|
||||
TabItem new_item;
|
||||
new_item.name = name;
|
||||
new_item.render_callback = std::move(callback);
|
||||
parent_bar->items.push_back(std::move(new_item));
|
||||
}
|
||||
|
||||
void GUIManager::AddSubTab(TabBar *parent_bar, const std::string &name, const std::string &shortcut, std::function<void()> callback)
|
||||
{
|
||||
if (!parent_bar)
|
||||
{
|
||||
LOG_WARNING(Render, "Trying to add a sub-tab to a null TabBar.");
|
||||
return;
|
||||
}
|
||||
|
||||
TabItem new_item;
|
||||
new_item.name = name;
|
||||
new_item.shortcut = shortcut;
|
||||
new_item.render_callback = std::move(callback);
|
||||
parent_bar->items.push_back(std::move(new_item));
|
||||
}
|
||||
|
||||
void GUIManager::AddSubTab(TabBar *parent_bar, const std::string &name, bool *p_selected, std::function<void(bool)> callback)
|
||||
{
|
||||
if (!parent_bar)
|
||||
{
|
||||
LOG_WARNING(Render, "Trying to add a sub-tab to a null TabBar.");
|
||||
return;
|
||||
}
|
||||
|
||||
TabItem new_item;
|
||||
new_item.name = name;
|
||||
new_item.p_selected = p_selected;
|
||||
new_item.checked_callback = std::move(callback);
|
||||
parent_bar->items.push_back(std::move(new_item));
|
||||
}
|
||||
|
||||
void GUIManager::AddSubTab(TabBar *parent_bar, const std::string &name, bool *p_selected, const std::string &shortcut, std::function<void(bool)> callback)
|
||||
{
|
||||
if (!parent_bar)
|
||||
{
|
||||
LOG_WARNING(Render, "Trying to add a sub-tab to a null TabBar.");
|
||||
return;
|
||||
}
|
||||
|
||||
TabItem new_item;
|
||||
new_item.name = name;
|
||||
new_item.shortcut = shortcut;
|
||||
new_item.p_selected = p_selected;
|
||||
new_item.checked_callback = std::move(callback);
|
||||
parent_bar->items.push_back(std::move(new_item));
|
||||
}
|
||||
|
||||
void GUIManager::RenderTabBarContents(TabBar &bar)
|
||||
{
|
||||
for (const auto &item : bar.items)
|
||||
{
|
||||
if (item.nested_tabs)
|
||||
{
|
||||
if (ImGui::BeginMenu(item.name.c_str()))
|
||||
{
|
||||
RenderTabBarContents(*item.nested_tabs);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *shortcut = item.shortcut.empty() ? nullptr : item.shortcut.c_str();
|
||||
if (ImGui::MenuItem(item.name.c_str(), shortcut, item.p_selected))
|
||||
{
|
||||
if (item.p_selected && item.checked_callback)
|
||||
{
|
||||
item.checked_callback(*item.p_selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GUIManager::RenderTabBars()
|
||||
{
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
for (const auto &bar_ptr : m_tab_bars)
|
||||
{
|
||||
if (ImGui::BeginMenu(bar_ptr->id.c_str()))
|
||||
{
|
||||
RenderTabBarContents(*bar_ptr);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue