imgui.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
  3. //
  4. // This software is provided 'as-is', without any express or implied
  5. // warranty. In no event will the authors be held liable for any damages
  6. // arising from the use of this software.
  7. // Permission is granted to anyone to use this software for any purpose,
  8. // including commercial applications, and to alter it and redistribute it
  9. // freely, subject to the following restrictions:
  10. // 1. The origin of this software must not be misrepresented; you must not
  11. // claim that you wrote the original software. If you use this software
  12. // in a product, an acknowledgment in the product documentation would be
  13. // appreciated but is not required.
  14. // 2. Altered source versions must be plainly marked as such, and must not be
  15. // misrepresented as being the original software.
  16. // 3. This notice may not be removed or altered from any source distribution.
  17. //
  18. #ifndef IMGUI_H
  19. #define IMGUI_H
  20. enum imguiMouseButton
  21. {
  22. IMGUI_MBUT_LEFT = 0x01,
  23. IMGUI_MBUT_RIGHT = 0x02,
  24. };
  25. enum imguiTextAlign
  26. {
  27. IMGUI_ALIGN_LEFT,
  28. IMGUI_ALIGN_CENTER,
  29. IMGUI_ALIGN_RIGHT,
  30. };
  31. inline unsigned int imguiRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
  32. {
  33. return (r) | (g << 8) | (b << 16) | (a << 24);
  34. }
  35. void imguiBeginFrame(int mx, int my, unsigned char mbut, int scroll);
  36. void imguiEndFrame();
  37. bool imguiBeginScrollArea(const char* name, int x, int y, int w, int h, int* scroll);
  38. void imguiEndScrollArea();
  39. void imguiIndent();
  40. void imguiUnindent();
  41. void imguiSeparator();
  42. void imguiSeparatorLine();
  43. bool imguiButton(const char* text, bool enabled = true);
  44. bool imguiItem(const char* text, bool enabled = true);
  45. bool imguiCheck(const char* text, bool checked, bool enabled = true);
  46. bool imguiCollapse(const char* text, const char* subtext, bool checked, bool enabled = true);
  47. void imguiLabel(const char* text);
  48. void imguiValue(const char* text);
  49. bool imguiSlider(const char* text, float* val, float vmin, float vmax, float vinc, bool enabled = true);
  50. void imguiDrawText(int x, int y, int align, const char* text, unsigned int color);
  51. void imguiDrawLine(float x0, float y0, float x1, float y1, float r, unsigned int color);
  52. void imguiDrawRoundedRect(float x, float y, float w, float h, float r, unsigned int color);
  53. void imguiDrawRect(float x, float y, float w, float h, unsigned int color);
  54. // Pull render interface.
  55. enum imguiGfxCmdType
  56. {
  57. IMGUI_GFXCMD_RECT,
  58. IMGUI_GFXCMD_TRIANGLE,
  59. IMGUI_GFXCMD_LINE,
  60. IMGUI_GFXCMD_TEXT,
  61. IMGUI_GFXCMD_SCISSOR,
  62. };
  63. struct imguiGfxRect
  64. {
  65. short x,y,w,h,r;
  66. };
  67. struct imguiGfxText
  68. {
  69. short x,y,align;
  70. const char* text;
  71. };
  72. struct imguiGfxLine
  73. {
  74. short x0,y0,x1,y1,r;
  75. };
  76. struct imguiGfxCmd
  77. {
  78. char type;
  79. char flags;
  80. char pad[2];
  81. unsigned int col;
  82. union
  83. {
  84. imguiGfxLine line;
  85. imguiGfxRect rect;
  86. imguiGfxText text;
  87. };
  88. };
  89. const imguiGfxCmd* imguiGetRenderQueue();
  90. int imguiGetRenderQueueSize();
  91. #endif // IMGUI_H