First-pass of a plugin system for GUI elements.
Refactor filament's debug drawing to be one such plugin. PiperOrigin-RevId: 859002002 Change-Id: Ibe9000dec19fce648eef6d57170ce435b9a8c6ff
This commit is contained in:
committed by
Copybara-Service
parent
bf05bb1885
commit
e2180ff744
@@ -37,6 +37,7 @@
|
||||
#include "experimental/platform/imgui_widgets.h"
|
||||
#include "experimental/platform/interaction.h"
|
||||
#include "experimental/platform/picture_gui.h"
|
||||
#include "experimental/platform/plugin.h"
|
||||
#include "experimental/platform/renderer.h"
|
||||
#include "experimental/platform/step_control.h"
|
||||
#include "experimental/platform/window.h"
|
||||
@@ -854,6 +855,26 @@ void App::BuildGui() {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
platform::ForEachGuiPlugin([](platform::GuiPlugin* plugin) {
|
||||
if (!plugin->update) {
|
||||
return;
|
||||
}
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
if (ImGui::BeginMenu("Plugins")) {
|
||||
if (ImGui::MenuItem(plugin->name, "", plugin->active)) {
|
||||
plugin->active = !plugin->active;
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
if (plugin->active) {
|
||||
ImGui::Begin(plugin->name);
|
||||
plugin->update(plugin);
|
||||
ImGui::End();
|
||||
}
|
||||
});
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (tmp_.first_frame) {
|
||||
LoadSettings();
|
||||
@@ -1534,6 +1555,11 @@ void App::MainMenuGui() {
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Plugins")) {
|
||||
// Placeholder menu item that will be populated by plugins later on. We
|
||||
// do this now in so that the menu is present at the right place.
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Help")) {
|
||||
if (ImGui::MenuItem("Help", "F1", tmp_.help)) {
|
||||
ToggleWindow(tmp_.help);
|
||||
|
||||
Reference in New Issue
Block a user