ImGuiMenu.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2022 Alec Jacobson <[email protected]>
  4. // Copyright (C) 2018 Jérémie Dumas <[email protected]>
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla Public License
  7. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  8. // obtain one at http://mozilla.org/MPL/2.0/.
  9. #ifndef IGL_OPENGL_GLFW_IMGUI_IMGUIMENU_H
  10. #define IGL_OPENGL_GLFW_IMGUI_IMGUIMENU_H
  11. #include "ImGuiPlugin.h"
  12. #include "ImGuiWidget.h"
  13. #include "../../../igl_inline.h"
  14. #include <memory>
  15. namespace igl
  16. {
  17. namespace opengl
  18. {
  19. namespace glfw
  20. {
  21. namespace imgui
  22. {
  23. /// Widget for a menu bar and a viewer window.
  24. class ImGuiMenu : public ImGuiWidget
  25. {
  26. public:
  27. IGL_INLINE virtual void init(Viewer *_viewer, ImGuiPlugin *_plugin) override;
  28. IGL_INLINE virtual void shutdown() override;
  29. IGL_INLINE virtual void draw() override;
  30. // Can be overwritten by `callback_draw_viewer_window`
  31. IGL_INLINE virtual void draw_viewer_window();
  32. // Can be overwritten by `callback_draw_viewer_menu`
  33. IGL_INLINE virtual void draw_viewer_menu();
  34. // Can be overwritten by `callback_draw_custom_window`
  35. IGL_INLINE virtual void draw_custom_window() { }
  36. // Customizable callbacks
  37. std::function<void(void)> callback_draw_viewer_window;
  38. std::function<void(void)> callback_draw_viewer_menu;
  39. std::function<void(void)> callback_draw_custom_window;
  40. float menu_scaling()
  41. { return plugin->hidpi_scaling() / plugin->pixel_ratio(); }
  42. };
  43. }
  44. }
  45. }
  46. }
  47. #ifndef IGL_STATIC_LIBRARY
  48. # include "ImGuiMenu.cpp"
  49. #endif
  50. #endif