Style.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package imgui
  2. // #include "StyleWrapper.h"
  3. import "C"
  4. // StyleVarID identifies a style variable in the UI style.
  5. type StyleVarID int
  6. const (
  7. StyleVarAlpha StyleVarID = iota
  8. StyleVarDisabledAlpha
  9. StyleVarWindowPadding
  10. StyleVarWindowRounding
  11. StyleVarWindowBorderSize
  12. StyleVarWindowMinSize
  13. StyleVarWindowTitleAlign
  14. StyleVarChildRounding
  15. StyleVarChildBorderSize
  16. StyleVarPopupRounding
  17. StyleVarPopupBorderSize
  18. StyleVarFramePadding
  19. StyleVarFrameRounding
  20. StyleVarFrameBorderSize
  21. StyleVarItemSpacing
  22. StyleVarItemInnerSpacing
  23. StyleVarIndentSpacing
  24. StyleVarCellPadding
  25. StyleVarScrollbarSize
  26. StyleVarScrollbarRounding
  27. StyleVarGrabMinSize
  28. StyleVarGrabRounding
  29. StyleVarTabRounding
  30. StyleVarButtonTextAlign
  31. StyleVarSelectableTextAlign
  32. )
  33. // StyleColorID identifies a color in the UI style.
  34. type StyleColorID int
  35. // StyleColor identifier
  36. const (
  37. StyleColorText StyleColorID = iota
  38. StyleColorTextDisabled
  39. StyleColorWindowBg // Background of normal windows
  40. StyleColorChildBg // Background of child windows
  41. StyleColorPopupBg // Background of popups, menus, tooltips windows
  42. StyleColorBorder
  43. StyleColorBorderShadow
  44. StyleColorFrameBg // Background of checkbox, radio button, plot, slider, text input
  45. StyleColorFrameBgHovered
  46. StyleColorFrameBgActive
  47. StyleColorTitleBg
  48. StyleColorTitleBgActive
  49. StyleColorTitleBgCollapsed
  50. StyleColorMenuBarBg
  51. StyleColorScrollbarBg
  52. StyleColorScrollbarGrab
  53. StyleColorScrollbarGrabHovered
  54. StyleColorScrollbarGrabActive
  55. StyleColorCheckMark
  56. StyleColorSliderGrab
  57. StyleColorSliderGrabActive
  58. StyleColorButton
  59. StyleColorButtonHovered
  60. StyleColorButtonActive
  61. StyleColorHeader // Header* colors are used for CollapsingHeader, TreeNode, Selectable, MenuItem
  62. StyleColorHeaderHovered
  63. StyleColorHeaderActive
  64. StyleColorSeparator
  65. StyleColorSeparatorHovered
  66. StyleColorSeparatorActive
  67. StyleColorResizeGrip
  68. StyleColorResizeGripHovered
  69. StyleColorResizeGripActive
  70. StyleColorTab
  71. StyleColorTabHovered
  72. StyleColorTabActive
  73. StyleColorTabUnfocused
  74. StyleColorTabUnfocusedActive
  75. StyleColorPlotLines
  76. StyleColorPlotLinesHovered
  77. StyleColorPlotHistogram
  78. StyleColorPlotHistogramHovered
  79. StyleColorTableHeaderBg // Table header background
  80. StyleColorTableBorderStrong // Table outer and header borders (prefer using Alpha=1.0 here)
  81. StyleColorTableBorderLight // Table inner borders (prefer using Alpha=1.0 here)
  82. StyleColorTableRowBg // Table row background (even rows)
  83. StyleColorTableRowBgAlt // Table row background (odd rows)
  84. StyleColorTextSelectedBg
  85. StyleColorDragDropTarget
  86. StyleColorNavHighlight // Gamepad/keyboard: current highlighted item
  87. StyleColorNavWindowingHighlight // Highlight window when using CTRL+TAB
  88. StyleColorNavWindowingDimBg // Darken/colorize entire screen behind the CTRL+TAB window list, when active
  89. StyleColorModalWindowDimBg // Darken/colorize entire screen behind a modal window, when one is active
  90. )
  91. // Style describes the overall graphical representation of the user interface.
  92. type Style uintptr
  93. func (style Style) handle() C.IggGuiStyle {
  94. return C.IggGuiStyle(style)
  95. }
  96. // ItemSpacing is the horizontal and vertical spacing between widgets/lines.
  97. func (style Style) ItemSpacing() Vec2 {
  98. var value Vec2
  99. valueArg, valueFin := value.wrapped()
  100. C.iggStyleGetItemSpacing(style.handle(), valueArg)
  101. valueFin()
  102. return value
  103. }
  104. // ItemInnerSpacing is the horizontal and vertical spacing between elements of
  105. // a composed widget (e.g. a slider and its label).
  106. func (style Style) ItemInnerSpacing() Vec2 {
  107. var value Vec2
  108. valueArg, valueFin := value.wrapped()
  109. C.iggStyleGetItemInnerSpacing(style.handle(), valueArg)
  110. valueFin()
  111. return value
  112. }
  113. func (style Style) WindowPadding() Vec2 {
  114. var value Vec2
  115. valueArg, valueFin := value.wrapped()
  116. C.iggStyleGetWindowPadding(style.handle(), valueArg)
  117. valueFin()
  118. return value
  119. }
  120. func (style Style) FramePadding() Vec2 {
  121. var value Vec2
  122. valueArg, valueFin := value.wrapped()
  123. C.iggStyleGetFramePadding(style.handle(), valueArg)
  124. valueFin()
  125. return value
  126. }
  127. // SetColor sets a color value of the UI style.
  128. func (style Style) SetColor(id StyleColorID, value Vec4) {
  129. valueArg, _ := value.wrapped()
  130. C.iggStyleSetColor(style.handle(), C.int(id), valueArg)
  131. }
  132. func (style Style) GetColor(id StyleColorID) Vec4 {
  133. var col Vec4
  134. colArg, colFin := col.wrapped()
  135. C.iggStyleGetColor(style.handle(), C.int(id), colArg)
  136. colFin()
  137. return col
  138. }
  139. // ScaleAllSizes applies a scaling factor to all sizes.
  140. // To scale your entire UI (e.g. if you want your app to use High DPI or generally be DPI aware) you may use this helper function.
  141. // Scaling the fonts is done separately and is up to you.
  142. //
  143. // Important: This operation is lossy because all sizes are rounded to integer.
  144. // If you need to change your scale multiples, call this over a freshly initialized style rather than scaling multiple times.
  145. func (style Style) ScaleAllSizes(scale float32) {
  146. C.iggStyleScaleAllSizes(style.handle(), C.float(scale))
  147. }