DebuggerPlugin.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #pragma once
  2. #include "../../Include/RmlUi/Core/EventListener.h"
  3. #include "../../Include/RmlUi/Core/Plugin.h"
  4. namespace Rml {
  5. class ElementDocument;
  6. class SystemInterface;
  7. namespace Debugger {
  8. class ElementLog;
  9. class ElementInfo;
  10. class ElementContextHook;
  11. class ElementDataModels;
  12. class DebuggerSystemInterface;
  13. /**
  14. RmlUi plugin interface for the debugger.
  15. */
  16. class DebuggerPlugin : public Rml::Plugin, public Rml::EventListener {
  17. public:
  18. DebuggerPlugin();
  19. ~DebuggerPlugin();
  20. /// Initialises the debugging tools into the given context.
  21. /// @param[in] context The context to load the tools into.
  22. /// @return True on success, false if an error occured.
  23. bool Initialise(Context* context);
  24. /// Sets the context to be debugged.
  25. /// @param[in] context The context to be debugged.
  26. /// @return True if the debugger is initialised and the context was switched, false otherwise.
  27. bool SetContext(Context* context);
  28. /// Sets the visibility of the debugger.
  29. /// @param[in] visibility True to show the debugger, false to hide it.
  30. void SetVisible(bool visibility);
  31. /// Returns the visibility of the debugger.
  32. /// @return True if the debugger is visible, false if not.
  33. bool IsVisible();
  34. /// Renders any debug elements in the debug context.
  35. void Render();
  36. /// Called when RmlUi shuts down.
  37. void OnShutdown() override;
  38. /// Called whenever a RmlUi context is destroyed.
  39. /// @param[in] context The destroyed context.
  40. void OnContextDestroy(Context* context) override;
  41. /// Called whenever an element is destroyed.
  42. /// @param[in] element The destroyed element.
  43. void OnElementDestroy(Element* element) override;
  44. /// Event handler for events from the debugger elements.
  45. /// @param[in] event The event to process.
  46. void ProcessEvent(Event& event) override;
  47. /// Access the singleton instance of the debugger
  48. /// @return nullptr or an instance of the plugin
  49. static DebuggerPlugin* GetInstance();
  50. private:
  51. bool LoadFont();
  52. bool LoadMenuElement();
  53. bool LoadInfoElement();
  54. bool LoadLogElement();
  55. bool LoadDataExplorerElement();
  56. void SetupInfoListeners(Rml::Context* new_context);
  57. // Release all loaded elements
  58. void ReleaseElements();
  59. // The context hosting the debug documents.
  60. Context* host_context;
  61. // The context we're debugging.
  62. Context* debug_context;
  63. // The debug elements.
  64. ElementDocument* menu_element;
  65. ElementInfo* info_element;
  66. ElementLog* log_element;
  67. ElementDataModels* data_explorer_element;
  68. ElementContextHook* hook_element;
  69. Rml::SystemInterface* application_interface;
  70. UniquePtr<DebuggerSystemInterface> log_interface;
  71. UniquePtr<ElementInstancer> hook_element_instancer, debug_document_instancer, info_element_instancer, log_element_instancer,
  72. data_explorer_element_instancer;
  73. bool render_outlines;
  74. // Singleton instance
  75. static DebuggerPlugin* instance;
  76. };
  77. } // namespace Debugger
  78. } // namespace Rml