dbgui.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /** @addtogroup Debug
  2. @{*/
  3. /**
  4. * \defgroup DebugUI Debug UI API
  5. \brief Immediate mode debug UI API
  6. * @{
  7. Per frame usage example:
  8. @code
  9. bool m_ShowDbgUI = false;
  10. int m_DbgListSelection = 0;
  11. float m_DbgSliderValue = 0.0;
  12. autoptr array<string> m_DbgOptions = {"jedna", "dva", "tri"};
  13. void OnUpdate(float timeslice)
  14. {
  15. DbgUI.Begin("Test");
  16. DbgUI.Check("Show DbgUI", m_ShowDbgUI);
  17. if (m_ShowDbgUI)
  18. {
  19. DbgUI.Text("DbgUI Test");
  20. string name = "";
  21. DbgUI.InputText("name", name);
  22. if (DbgUI.Button("Print name"))
  23. {
  24. Print(name);
  25. }
  26. DbgUI.List("test list", m_DbgListSelection, m_DbgOptions);
  27. DbgUI.Text("Choice = " + m_DbgListSelection.ToString());
  28. DbgUI.Spacer(10);
  29. DbgUI.SliderFloat("slider", m_DbgSliderValue, 0, 100);
  30. DbgUI.Text("Slider value = " + ftoa(m_DbgSliderValue));
  31. }
  32. DbgUI.End();
  33. }
  34. @endcode
  35. For non-per frame usage example:
  36. @code
  37. int m_DbgEventCount = 0;
  38. void OnEvent(EventType eventTypeId, Param params)
  39. {
  40. m_DbgEventCount++;
  41. DbgUI.BeginCleanupScope();
  42. DbgUI.Begin("events", 300, 0);
  43. DbgUI.Text("Events count = " + m_DbgEventCount.ToString());
  44. DbgUI.End();
  45. DbgUI.EndCleanupScope();
  46. }
  47. @endcode
  48. */
  49. class DbgUI
  50. {
  51. private void DbgUI() {}
  52. private void ~DbgUI() {}
  53. static proto native void DoUnitTest(); ///< Creates all possible DbgUI widgets. Just for the testing purposes.
  54. static proto native void Text(string label);
  55. static proto native void ColoredText(int color, string label);
  56. static proto void Check(string label, out bool checked);
  57. static proto void Combo(string label, out int selection, TStringArray elems);
  58. static proto void List(string label, out int selection, TStringArray elems);
  59. static proto void SliderFloat(string label, out float value, float min, float max, int pxWidth = 150);
  60. static proto native void Spacer(int height);
  61. static proto native void Panel(string label, int width, int height, int color = 0xaa555555);
  62. static proto native bool Button(string txt, int minWidth = 0);
  63. static proto void InputText(string txt, out string value, int pxWidth = 150);
  64. static proto void InputInt(string txt, out int value, int pxWidth = 150);
  65. static proto void InputFloat(string txt, out float value, int pxWidth = 150);
  66. static proto native void PlotLive(string label, int sizeX, int sizeY, float val, int timeStep = 100, int historySize = 30, int color = 0xFFFFFFFF);
  67. static proto native void SameLine();
  68. static proto native void SameSpot();
  69. static proto native void PushID_Int(int int_id);
  70. static proto native void PushID_Str(string str_id);
  71. static proto native void PopID();
  72. static proto void BeginCleanupScope();
  73. static proto native void EndCleanupScope();
  74. static proto native void Begin(string windowTitle, float x = 0, float y = 0);
  75. static proto native void End();
  76. };
  77. //@}
  78. //@}