Skip to content

Fix 1656 ; Introduce ImGuiPlugin with list of ImGuiWidgets#1973

Merged
alecjacobson merged 1 commit intomainfrom
alecjacobson/imgui-refactor
Feb 14, 2022
Merged

Fix 1656 ; Introduce ImGuiPlugin with list of ImGuiWidgets#1973
alecjacobson merged 1 commit intomainfrom
alecjacobson/imgui-refactor

Conversation

@alecjacobson
Copy link
Copy Markdown
Contributor

Fixes #1656

Following Jeremie's idea #1656 (comment), I've introduced a new "parent" ImGuiPlugin which handles ImGui IO functions and converted the old ImGuiMenu, ImGuizmoPlugin, SelectionPlugin plugins to inherit from a new ImGuiWidget class. In this way, a single ImGuiPlugin can be registered to the viewer's plugins list and one or many widgets are registered to this plugin's widgets list.

For folks just using the menu, this incurs a few extra lines. To add the menu:

#include <igl/opengl/glfw/imgui/ImGuiPlugin.h>
#include <igl/opengl/glfw/imgui/ImGuiMenu.h>
…
igl::opengl::glfw::imgui::ImGuiPlugin plugin;
viewer.plugins.push_back(&plugin);
igl::opengl::glfw::imgui::ImGuiMenu menu;
plugin.widgets.push_back(&menu);

The reward is that now we can use all of these plugins (and any new user created plugins using ImGui subroutines) without conflict.

To highlight this, the updated 109_ImGuizmo successfully shows the Viewer menu and the ImGuizmo Widget

Screen Shot 2022-02-12 at 6 08 59 PM

(since this is a breaking change. I'd love to get it into the upcoming 2.4.0 release)

Copy link
Copy Markdown
Collaborator

@jdumas jdumas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm. When you merge it don't forget to update the changelog on the website.

@alecjacobson alecjacobson merged commit 29ac7b2 into main Feb 14, 2022
@alecjacobson alecjacobson deleted the alecjacobson/imgui-refactor branch February 14, 2022 17:37
@graphitical
Copy link
Copy Markdown

Quick note: The tutorial page still links to #1656 which got resolved here.

Don't mean to reopen anything, but I wasn't sure where else to put this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can only have one ImGuiMenu plugin at a time

3 participants