smaller imgui impl improvements
This commit is contained in:
@@ -4,12 +4,16 @@
|
||||
|
||||
namespace gui {
|
||||
struct PopupWindow {
|
||||
PopupWindow(const std::string& title, std::function<void()>&& func = nullptr, bool opened = true) : title(title), exec(func), opened(opened) {}
|
||||
PopupWindow(const std::string& title, std::function<void()>&& func = nullptr, bool opened = false) : title(title), exec(func), opened(opened) {}
|
||||
void setFunc(std::function<void()>&& func) {
|
||||
exec = func;
|
||||
}
|
||||
|
||||
void setOpened(bool v) { opened = true; }
|
||||
|
||||
bool render() {
|
||||
if(!opened)
|
||||
return false;
|
||||
ImGui::OpenPopup(title.c_str());
|
||||
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
||||
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
@@ -28,6 +32,6 @@ struct PopupWindow {
|
||||
private:
|
||||
std::function<void()> exec;
|
||||
std::string title;
|
||||
bool opened = true;
|
||||
bool opened = false;
|
||||
};
|
||||
}
|
||||
@@ -5,6 +5,8 @@ namespace gui {
|
||||
struct StatusBar {
|
||||
StatusBar(std::function<void()>&& func = nullptr, bool enabled = true) : exec(func), enabled(enabled) {}
|
||||
|
||||
void setFunc(std::function<void()>&& func) { exec = func; }
|
||||
|
||||
bool render() {
|
||||
float statusWindowHeight = ImGui::GetFrameHeight() * 1.4f;
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
|
||||
@@ -12,6 +12,20 @@ KaizenGui::KaizenGui() noexcept : window(SDL_CreateWindow("Kaizen", 1280, 720, S
|
||||
}
|
||||
};
|
||||
|
||||
about.setFunc([&]() {
|
||||
ImGui::Text("Kaizen is a Nintendo 64 emulator that strives");
|
||||
ImGui::Text("to offer a friendly user experience and compatibility.");
|
||||
ImGui::Text("Kaizen is licensed under the BSD 3-clause license.");
|
||||
ImGui::Text("Nintendo 64 is a registered trademarks of Nintendo Co., Ltd.");
|
||||
if(ImGui::Button("OK")) {
|
||||
about.setOpened(false);
|
||||
}
|
||||
});
|
||||
|
||||
statusBar.setFunc([&]() {
|
||||
ImGui::Text("GUI FPS: %.2f, Emulation FPS: %.2f", ImGui::GetIO().Framerate, fpsCounter);
|
||||
});
|
||||
|
||||
menuBar.addMenu({"File",
|
||||
{
|
||||
{"Open", [&]() {
|
||||
@@ -43,12 +57,7 @@ KaizenGui::KaizenGui() noexcept : window(SDL_CreateWindow("Kaizen", 1280, 720, S
|
||||
menuBar.addMenu({"Help",
|
||||
{
|
||||
{"About", [&]() {
|
||||
gui::PopupWindow about{"About Kaizen", [&]() {
|
||||
ImGui::Text("Kaizen is a Nintendo 64 emulator that strives");
|
||||
ImGui::Text("to offer a friendly user experience and compatibility.");
|
||||
ImGui::Text("Kaizen is licensed under the BSD 3-clause license.");
|
||||
ImGui::Text("Nintendo 64 is a registered trademarks of Nintendo Co., Ltd.");
|
||||
}};
|
||||
about.setOpened(true);
|
||||
}},
|
||||
}
|
||||
});
|
||||
@@ -81,11 +90,7 @@ int KaizenGui::run() {
|
||||
|
||||
menuBar.render();
|
||||
|
||||
// TODO VULKAN CANVAS
|
||||
|
||||
gui::StatusBar statusBar{[&]() {
|
||||
ImGui::Text("GUI FPS: %.2f, Emulation FPS: %.2f", ImGui::GetIO().Framerate, fpsCounter);
|
||||
}};
|
||||
about.render();
|
||||
|
||||
statusBar.render();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ private:
|
||||
bool quit = false;
|
||||
void handleEvents();
|
||||
std::function<void()> emuExitFunc;
|
||||
|
||||
gui::PopupWindow about{"About Kaizen"};
|
||||
gui::StatusBar statusBar{};
|
||||
bool textPauseToggle = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user