tb_debug.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // ================================================================================
  2. // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås ==
  3. // == See tb_core.h for more information. ==
  4. // ================================================================================
  5. #ifndef TB_DEBUG_H
  6. #define TB_DEBUG_H
  7. #include "tb_types.h"
  8. #ifdef TB_RUNTIME_DEBUG_INFO
  9. #define TB_IF_DEBUG(debug) debug
  10. #else
  11. #define TB_IF_DEBUG(debug)
  12. #endif
  13. namespace tb {
  14. #ifdef TB_RUNTIME_DEBUG_INFO
  15. class TBDebugInfo
  16. {
  17. public:
  18. TBDebugInfo();
  19. enum SETTING {
  20. /** Show widgets bounds */
  21. LAYOUT_BOUNDS,
  22. /** Show child widget clipping set by some widgets. */
  23. LAYOUT_CLIPPING,
  24. /** Show highlights on widgets that recalculate their preferred
  25. size, and those who recalculate their layout. */
  26. LAYOUT_PS_DEBUGGING,
  27. /** Show render batch info and log batch info in the debug
  28. output. It depends on the renderer backend if this is available. */
  29. RENDER_BATCHES,
  30. /** Render the bitmap fragments of the skin. */
  31. RENDER_SKIN_BITMAP_FRAGMENTS,
  32. /** Render the bitmap fragments of the font that's set on the hovered
  33. or focused widget. */
  34. RENDER_FONT_BITMAP_FRAGMENTS,
  35. NUM_SETTINGS
  36. };
  37. int settings[NUM_SETTINGS];
  38. };
  39. extern TBDebugInfo g_tb_debug;
  40. /** Show a window containing runtime debugging settings. */
  41. void ShowDebugInfoSettingsWindow(class TBWidget *root);
  42. #define TB_DEBUG_SETTING(setting) g_tb_debug.settings[TBDebugInfo::setting]
  43. #define TB_IF_DEBUG_SETTING(setting, code) if (TB_DEBUG_SETTING(setting)) { code; }
  44. #else // TB_RUNTIME_DEBUG_INFO
  45. /** Show a window containing runtime debugging settings. */
  46. #define ShowDebugInfoSettingsWindow(root) ((void)0)
  47. #define TB_DEBUG_SETTING(setting) false
  48. #define TB_IF_DEBUG_SETTING(setting, code)
  49. #endif // TB_RUNTIME_DEBUG_INFO
  50. }; // namespace tb
  51. #endif // TB_DEBUG_H