ElementLog.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. * Copyright (c) 2019 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #ifndef RMLUIDEBUGGERELEMENTLOG_H
  29. #define RMLUIDEBUGGERELEMENTLOG_H
  30. #include "../../Include/RmlUi/Core/ElementDocument.h"
  31. #include "../../Include/RmlUi/Core/EventListener.h"
  32. #include <deque>
  33. namespace Rml {
  34. namespace Debugger {
  35. class SystemInterface;
  36. /**
  37. @author Robert Curry
  38. */
  39. class ElementLog : public Core::ElementDocument, public Core::EventListener
  40. {
  41. public:
  42. ElementLog(const Core::String& tag);
  43. ~ElementLog();
  44. /// Initialises the log element.
  45. /// @return True if the element initialised successfully, false otherwise.
  46. bool Initialise();
  47. /// Adds a log message to the debug log.
  48. void AddLogMessage(Core::Log::Type type, const Core::String& message);
  49. protected:
  50. void OnUpdate() override;
  51. void ProcessEvent(Core::Event& event) override;
  52. private:
  53. struct LogMessage
  54. {
  55. unsigned int index;
  56. Core::String message;
  57. };
  58. typedef std::deque< LogMessage > LogMessageList;
  59. struct LogType
  60. {
  61. bool visible;
  62. Core::String class_name;
  63. Core::String alert_contents;
  64. Core::String button_name;
  65. LogMessageList log_messages;
  66. };
  67. LogType log_types[Core::Log::LT_MAX];
  68. int FindNextEarliestLogType(unsigned int log_pointers[Core::Log::LT_MAX]);
  69. unsigned int current_index;
  70. bool dirty_logs;
  71. bool auto_scroll;
  72. Core::Element* message_content;
  73. Core::ElementDocument* beacon;
  74. int current_beacon_level;
  75. };
  76. }
  77. }
  78. #endif