ImGuiWidget.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2022 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_OPENGL_GLFW_IMGUI_IMGUIWIDGET_H
  9. #define IGL_OPENGL_GLFW_IMGUI_IMGUIWIDGET_H
  10. #include "ImGuiPlugin.h"
  11. #include "ImGuiWidget.h"
  12. #include "../../../igl_inline.h"
  13. #include <memory>
  14. namespace igl
  15. {
  16. namespace opengl
  17. {
  18. namespace glfw
  19. {
  20. class Viewer;
  21. namespace imgui
  22. {
  23. // Forward declaration of the parent plugin
  24. class ImGuiPlugin;
  25. /// Abstract class for imgui "widgets". A widget is something that uses
  26. /// imgui, but doesn't own the entire imgui IO stack: the single
  27. /// ImGuiPlugin owns that and widgets are registered with it.
  28. class ImGuiWidget
  29. {
  30. public:
  31. IGL_INLINE ImGuiWidget(){ name = "dummy"; }
  32. virtual ~ImGuiWidget(){}
  33. IGL_INLINE virtual void init(Viewer *_viewer, ImGuiPlugin *_plugin)
  34. { viewer = _viewer; plugin = _plugin; }
  35. IGL_INLINE virtual void shutdown() {}
  36. IGL_INLINE virtual void draw() {}
  37. IGL_INLINE virtual bool mouse_down(int /*button*/, int /*modifier*/)
  38. { return false;}
  39. IGL_INLINE virtual bool mouse_up(int /*button*/, int /*modifier*/)
  40. { return false;}
  41. IGL_INLINE virtual bool mouse_move(int /*mouse_x*/, int /*mouse_y*/)
  42. { return false;}
  43. IGL_INLINE virtual bool key_pressed(unsigned int /*key*/, int /*modifiers*/)
  44. { return false;}
  45. IGL_INLINE virtual bool key_down(int /*key*/, int /*modifiers*/)
  46. { return false;}
  47. IGL_INLINE virtual bool key_up(int /*key*/, int /*modifiers*/)
  48. { return false;}
  49. std::string name;
  50. protected:
  51. // Pointer to ImGuiPlugin's parent viewer
  52. Viewer *viewer;
  53. // Pointer to parent ImGuiPlugin class
  54. ImGuiPlugin *plugin;
  55. };
  56. }
  57. }
  58. }
  59. }
  60. #endif