More config options, menu bar and global getter for QuickApp.

This commit is contained in:
2025-03-02 19:33:52 +01:00
parent 7a18cce60c
commit 75773778e9
3 changed files with 50 additions and 7 deletions

View File

@@ -20,6 +20,7 @@ namespace
{
constexpr int GL_COLOR_BUFFER_BIT = 0x00004000;
const char* IMGUI_GLSL_VERSION = "#version 130";
QuickApp* gAppInstance = nullptr;
}
int Application::run(int argc, char** argv)
@@ -93,7 +94,7 @@ int Application::run(int argc, char** argv)
ImGui::SetNextWindowPos({0, 0});
ImGui::SetNextWindowSize(imguiIO.DisplaySize);
ImGui::Begin("##main", nullptr, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration);
ImGui::Begin("##main", nullptr, mMainWindowFlags);
render();
ImGui::End();
@@ -304,22 +305,31 @@ void Application::saveImGuiConfig()
void QuickApp::init(QuickAppOptions options)
{
MIJIN_ASSERT_FATAL(options.callbacks.render, "Missing render callback.");
mOptions = std::move(options);
mRenderCallback = std::move(options.callbacks.render);
mFolderName = std::move(options.folderName);
setMainWindowFlags(options.mainWindowFlags);
}
QuickApp& QuickApp::get()
{
MIJIN_ASSERT_FATAL(gAppInstance != nullptr, "No QuickApp is running.");
return *gAppInstance;
}
void QuickApp::render()
{
mOptions.callbacks.render();
mRenderCallback();
}
std::string QuickApp::getFolderName()
{
return mOptions.folderName;
return mFolderName;
}
int runQuick(int argc, char* argv[], QuickAppOptions options)
{
QuickApp app;
gAppInstance = &app;
app.init(std::move(options));
return app.run(argc, argv);
}