You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2331 lines
83KB

  1. /*
  2. Blendish - Blender 2.5 UI based theming functions for NanoVG
  3. Copyright (c) 2014 Leonard Ritter <leonard.ritter@duangle.com>
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. */
  20. #ifndef BLENDISH_H
  21. #define BLENDISH_H
  22. #ifndef NANOVG_H
  23. #error "nanovg.h must be included first."
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /*
  29. Revision 6 (2014-09-21)
  30. Summary
  31. -------
  32. Blendish is a small collection of drawing functions for NanoVG, designed to
  33. replicate the look of the Blender 2.5+ User Interface. You can use these
  34. functions to theme your UI library. Several metric constants for faithful
  35. reproduction are also included.
  36. Blendish supports the original Blender icon sheet; As the licensing of Blenders
  37. icons is unclear, they are not included in Blendishes repository, but a SVG
  38. template, "icons_template.svg" is provided, which you can use to build your own
  39. icon sheet.
  40. To use icons, you must first load the icon sheet using one of the
  41. nvgCreateImage*() functions and then pass the image handle to bndSetIconImage();
  42. otherwise, no icons will be drawn. See bndSetIconImage() for more information.
  43. Blendish will not render text until a suitable UI font has been passed to
  44. bndSetFont() has been called. See bndSetFont() for more information.
  45. Drawbacks
  46. ---------
  47. There is no support for varying dpi resolutions yet. The library is hardcoded
  48. to the equivalent of 72 dpi in the Blender system settings.
  49. Support for label truncation is missing. Text rendering breaks when widgets are
  50. too short to contain their labels.
  51. Usage
  52. -----
  53. To use this header file in implementation mode, define BLENDISH_IMPLEMENTATION
  54. before including blendish.h, otherwise the file will be in header-only mode.
  55. */
  56. // you can override this from the outside to pick
  57. // the export level you need
  58. #ifndef BND_EXPORT
  59. #define BND_EXPORT
  60. #endif
  61. // if that typedef is provided elsewhere, you may define
  62. // BLENDISH_NO_NVG_TYPEDEFS before including the header.
  63. #ifndef BLENDISH_NO_NVG_TYPEDEFS
  64. typedef struct NVGcontext NVGcontext;
  65. typedef struct NVGcolor NVGcolor;
  66. typedef struct NVGglyphPosition NVGglyphPosition;
  67. #endif
  68. // describes the theme used to draw a single widget or widget box;
  69. // these values correspond to the same values that can be retrieved from
  70. // the Theme panel in the Blender preferences
  71. typedef struct BNDwidgetTheme {
  72. // color of widget box outline
  73. NVGcolor outlineColor;
  74. // color of widget item (meaning changes depending on class)
  75. NVGcolor itemColor;
  76. // fill color of widget box
  77. NVGcolor innerColor;
  78. // fill color of widget box when active
  79. NVGcolor innerSelectedColor;
  80. // color of text label
  81. NVGcolor textColor;
  82. // color of text label when active
  83. NVGcolor textSelectedColor;
  84. // delta modifier for upper part of gradient (-100 to 100)
  85. int shadeTop;
  86. // delta modifier for lower part of gradient (-100 to 100)
  87. int shadeDown;
  88. } BNDwidgetTheme;
  89. // describes the theme used to draw nodes
  90. typedef struct BNDnodeTheme {
  91. // inner color of selected node (and downarrow)
  92. NVGcolor nodeSelectedColor;
  93. // outline of wires
  94. NVGcolor wiresColor;
  95. // color of text label when active
  96. NVGcolor textSelectedColor;
  97. // inner color of active node (and dragged wire)
  98. NVGcolor activeNodeColor;
  99. // color of selected wire
  100. NVGcolor wireSelectColor;
  101. // color of background of node
  102. NVGcolor nodeBackdropColor;
  103. // how much a noodle curves (0 to 10)
  104. int noodleCurving;
  105. } BNDnodeTheme;
  106. // describes the theme used to draw widgets
  107. typedef struct BNDtheme {
  108. // the background color of panels and windows
  109. NVGcolor backgroundColor;
  110. // theme for labels
  111. BNDwidgetTheme regularTheme;
  112. // theme for tool buttons
  113. BNDwidgetTheme toolTheme;
  114. // theme for radio buttons
  115. BNDwidgetTheme radioTheme;
  116. // theme for text fields
  117. BNDwidgetTheme textFieldTheme;
  118. // theme for option buttons (checkboxes)
  119. BNDwidgetTheme optionTheme;
  120. // theme for choice buttons (comboboxes)
  121. // Blender calls them "menu buttons"
  122. BNDwidgetTheme choiceTheme;
  123. // theme for number fields
  124. BNDwidgetTheme numberFieldTheme;
  125. // theme for slider controls
  126. BNDwidgetTheme sliderTheme;
  127. // theme for scrollbars
  128. BNDwidgetTheme scrollBarTheme;
  129. // theme for tooltips
  130. BNDwidgetTheme tooltipTheme;
  131. // theme for menu backgrounds
  132. BNDwidgetTheme menuTheme;
  133. // theme for menu items
  134. BNDwidgetTheme menuItemTheme;
  135. // theme for nodes
  136. BNDnodeTheme nodeTheme;
  137. } BNDtheme;
  138. // how text on a control is aligned
  139. typedef enum BNDtextAlignment {
  140. BND_LEFT = 0,
  141. BND_CENTER,
  142. } BNDtextAlignment;
  143. // states altering the styling of a widget
  144. typedef enum BNDwidgetState {
  145. // not interacting
  146. BND_DEFAULT = 0,
  147. // the mouse is hovering over the control
  148. BND_HOVER,
  149. // the widget is activated (pressed) or in an active state (toggled)
  150. BND_ACTIVE
  151. } BNDwidgetState;
  152. // flags indicating which corners are sharp (for grouping widgets)
  153. typedef enum BNDcornerFlags {
  154. // all corners are round
  155. BND_CORNER_NONE = 0,
  156. // sharp top left corner
  157. BND_CORNER_TOP_LEFT = 1,
  158. // sharp top right corner
  159. BND_CORNER_TOP_RIGHT = 2,
  160. // sharp bottom right corner
  161. BND_CORNER_DOWN_RIGHT = 4,
  162. // sharp bottom left corner
  163. BND_CORNER_DOWN_LEFT = 8,
  164. // all corners are sharp;
  165. // you can invert a set of flags using ^= BND_CORNER_ALL
  166. BND_CORNER_ALL = 0xF,
  167. // top border is sharp
  168. BND_CORNER_TOP = 3,
  169. // bottom border is sharp
  170. BND_CORNER_DOWN = 0xC,
  171. // left border is sharp
  172. BND_CORNER_LEFT = 9,
  173. // right border is sharp
  174. BND_CORNER_RIGHT = 6
  175. } BNDcornerFlags;
  176. // build an icon ID from two coordinates into the icon sheet, where
  177. // (0,0) designates the upper-leftmost icon, (1,0) the one right next to it,
  178. // and so on.
  179. #define BND_ICONID(x,y) ((x)|((y)<<8))
  180. // alpha of disabled widget groups
  181. // can be used in conjunction with nvgGlobalAlpha()
  182. #define BND_DISABLED_ALPHA 0.5
  183. enum {
  184. // default widget height
  185. BND_WIDGET_HEIGHT = 21,
  186. // default toolbutton width (if icon only)
  187. BND_TOOL_WIDTH = 20,
  188. // default radius of node ports
  189. BND_NODE_PORT_RADIUS = 5,
  190. // top margin of node content
  191. BND_NODE_MARGIN_TOP = 25,
  192. // bottom margin of node content
  193. BND_NODE_MARGIN_DOWN = 5,
  194. // left and right margin of node content
  195. BND_NODE_MARGIN_SIDE = 10,
  196. // height of node title bar
  197. BND_NODE_TITLE_HEIGHT = 20,
  198. // width of node title arrow click area
  199. BND_NODE_ARROW_AREA_WIDTH = 20,
  200. // size of splitter corner click area
  201. BND_SPLITTER_AREA_SIZE = 12,
  202. // width of vertical scrollbar
  203. BND_SCROLLBAR_WIDTH = 13,
  204. // height of horizontal scrollbar
  205. BND_SCROLLBAR_HEIGHT = 14,
  206. // default vertical spacing
  207. BND_VSPACING = 1,
  208. // default vertical spacing between groups
  209. BND_VSPACING_GROUP = 8,
  210. // default horizontal spacing
  211. BND_HSPACING = 8,
  212. };
  213. typedef enum BNDicon {
  214. BND_ICON_NONE = BND_ICONID(0,29),
  215. BND_ICON_QUESTION = BND_ICONID(1,29),
  216. BND_ICON_ERROR = BND_ICONID(2,29),
  217. BND_ICON_CANCEL = BND_ICONID(3,29),
  218. BND_ICON_TRIA_RIGHT = BND_ICONID(4,29),
  219. BND_ICON_TRIA_DOWN = BND_ICONID(5,29),
  220. BND_ICON_TRIA_LEFT = BND_ICONID(6,29),
  221. BND_ICON_TRIA_UP = BND_ICONID(7,29),
  222. BND_ICON_ARROW_LEFTRIGHT = BND_ICONID(8,29),
  223. BND_ICON_PLUS = BND_ICONID(9,29),
  224. BND_ICON_DISCLOSURE_TRI_DOWN = BND_ICONID(10,29),
  225. BND_ICON_DISCLOSURE_TRI_RIGHT = BND_ICONID(11,29),
  226. BND_ICON_RADIOBUT_OFF = BND_ICONID(12,29),
  227. BND_ICON_RADIOBUT_ON = BND_ICONID(13,29),
  228. BND_ICON_MENU_PANEL = BND_ICONID(14,29),
  229. BND_ICON_BLENDER = BND_ICONID(15,29),
  230. BND_ICON_GRIP = BND_ICONID(16,29),
  231. BND_ICON_DOT = BND_ICONID(17,29),
  232. BND_ICON_COLLAPSEMENU = BND_ICONID(18,29),
  233. BND_ICON_X = BND_ICONID(19,29),
  234. BND_ICON_GO_LEFT = BND_ICONID(21,29),
  235. BND_ICON_PLUG = BND_ICONID(22,29),
  236. BND_ICON_UI = BND_ICONID(23,29),
  237. BND_ICON_NODE = BND_ICONID(24,29),
  238. BND_ICON_NODE_SEL = BND_ICONID(25,29),
  239. BND_ICON_FULLSCREEN = BND_ICONID(0,28),
  240. BND_ICON_SPLITSCREEN = BND_ICONID(1,28),
  241. BND_ICON_RIGHTARROW_THIN = BND_ICONID(2,28),
  242. BND_ICON_BORDERMOVE = BND_ICONID(3,28),
  243. BND_ICON_VIEWZOOM = BND_ICONID(4,28),
  244. BND_ICON_ZOOMIN = BND_ICONID(5,28),
  245. BND_ICON_ZOOMOUT = BND_ICONID(6,28),
  246. BND_ICON_PANEL_CLOSE = BND_ICONID(7,28),
  247. BND_ICON_COPY_ID = BND_ICONID(8,28),
  248. BND_ICON_EYEDROPPER = BND_ICONID(9,28),
  249. BND_ICON_LINK_AREA = BND_ICONID(10,28),
  250. BND_ICON_AUTO = BND_ICONID(11,28),
  251. BND_ICON_CHECKBOX_DEHLT = BND_ICONID(12,28),
  252. BND_ICON_CHECKBOX_HLT = BND_ICONID(13,28),
  253. BND_ICON_UNLOCKED = BND_ICONID(14,28),
  254. BND_ICON_LOCKED = BND_ICONID(15,28),
  255. BND_ICON_UNPINNED = BND_ICONID(16,28),
  256. BND_ICON_PINNED = BND_ICONID(17,28),
  257. BND_ICON_SCREEN_BACK = BND_ICONID(18,28),
  258. BND_ICON_RIGHTARROW = BND_ICONID(19,28),
  259. BND_ICON_DOWNARROW_HLT = BND_ICONID(20,28),
  260. BND_ICON_DOTSUP = BND_ICONID(21,28),
  261. BND_ICON_DOTSDOWN = BND_ICONID(22,28),
  262. BND_ICON_LINK = BND_ICONID(23,28),
  263. BND_ICON_INLINK = BND_ICONID(24,28),
  264. BND_ICON_PLUGIN = BND_ICONID(25,28),
  265. BND_ICON_HELP = BND_ICONID(0,27),
  266. BND_ICON_GHOST_ENABLED = BND_ICONID(1,27),
  267. BND_ICON_COLOR = BND_ICONID(2,27),
  268. BND_ICON_LINKED = BND_ICONID(3,27),
  269. BND_ICON_UNLINKED = BND_ICONID(4,27),
  270. BND_ICON_HAND = BND_ICONID(5,27),
  271. BND_ICON_ZOOM_ALL = BND_ICONID(6,27),
  272. BND_ICON_ZOOM_SELECTED = BND_ICONID(7,27),
  273. BND_ICON_ZOOM_PREVIOUS = BND_ICONID(8,27),
  274. BND_ICON_ZOOM_IN = BND_ICONID(9,27),
  275. BND_ICON_ZOOM_OUT = BND_ICONID(10,27),
  276. BND_ICON_RENDER_REGION = BND_ICONID(11,27),
  277. BND_ICON_BORDER_RECT = BND_ICONID(12,27),
  278. BND_ICON_BORDER_LASSO = BND_ICONID(13,27),
  279. BND_ICON_FREEZE = BND_ICONID(14,27),
  280. BND_ICON_STYLUS_PRESSURE = BND_ICONID(15,27),
  281. BND_ICON_GHOST_DISABLED = BND_ICONID(16,27),
  282. BND_ICON_NEW = BND_ICONID(17,27),
  283. BND_ICON_FILE_TICK = BND_ICONID(18,27),
  284. BND_ICON_QUIT = BND_ICONID(19,27),
  285. BND_ICON_URL = BND_ICONID(20,27),
  286. BND_ICON_RECOVER_LAST = BND_ICONID(21,27),
  287. BND_ICON_FULLSCREEN_ENTER = BND_ICONID(23,27),
  288. BND_ICON_FULLSCREEN_EXIT = BND_ICONID(24,27),
  289. BND_ICON_BLANK1 = BND_ICONID(25,27),
  290. BND_ICON_LAMP = BND_ICONID(0,26),
  291. BND_ICON_MATERIAL = BND_ICONID(1,26),
  292. BND_ICON_TEXTURE = BND_ICONID(2,26),
  293. BND_ICON_ANIM = BND_ICONID(3,26),
  294. BND_ICON_WORLD = BND_ICONID(4,26),
  295. BND_ICON_SCENE = BND_ICONID(5,26),
  296. BND_ICON_EDIT = BND_ICONID(6,26),
  297. BND_ICON_GAME = BND_ICONID(7,26),
  298. BND_ICON_RADIO = BND_ICONID(8,26),
  299. BND_ICON_SCRIPT = BND_ICONID(9,26),
  300. BND_ICON_PARTICLES = BND_ICONID(10,26),
  301. BND_ICON_PHYSICS = BND_ICONID(11,26),
  302. BND_ICON_SPEAKER = BND_ICONID(12,26),
  303. BND_ICON_TEXTURE_SHADED = BND_ICONID(13,26),
  304. BND_ICON_VIEW3D = BND_ICONID(0,25),
  305. BND_ICON_IPO = BND_ICONID(1,25),
  306. BND_ICON_OOPS = BND_ICONID(2,25),
  307. BND_ICON_BUTS = BND_ICONID(3,25),
  308. BND_ICON_FILESEL = BND_ICONID(4,25),
  309. BND_ICON_IMAGE_COL = BND_ICONID(5,25),
  310. BND_ICON_INFO = BND_ICONID(6,25),
  311. BND_ICON_SEQUENCE = BND_ICONID(7,25),
  312. BND_ICON_TEXT = BND_ICONID(8,25),
  313. BND_ICON_IMASEL = BND_ICONID(9,25),
  314. BND_ICON_SOUND = BND_ICONID(10,25),
  315. BND_ICON_ACTION = BND_ICONID(11,25),
  316. BND_ICON_NLA = BND_ICONID(12,25),
  317. BND_ICON_SCRIPTWIN = BND_ICONID(13,25),
  318. BND_ICON_TIME = BND_ICONID(14,25),
  319. BND_ICON_NODETREE = BND_ICONID(15,25),
  320. BND_ICON_LOGIC = BND_ICONID(16,25),
  321. BND_ICON_CONSOLE = BND_ICONID(17,25),
  322. BND_ICON_PREFERENCES = BND_ICONID(18,25),
  323. BND_ICON_CLIP = BND_ICONID(19,25),
  324. BND_ICON_ASSET_MANAGER = BND_ICONID(20,25),
  325. BND_ICON_OBJECT_DATAMODE = BND_ICONID(0,24),
  326. BND_ICON_EDITMODE_HLT = BND_ICONID(1,24),
  327. BND_ICON_FACESEL_HLT = BND_ICONID(2,24),
  328. BND_ICON_VPAINT_HLT = BND_ICONID(3,24),
  329. BND_ICON_TPAINT_HLT = BND_ICONID(4,24),
  330. BND_ICON_WPAINT_HLT = BND_ICONID(5,24),
  331. BND_ICON_SCULPTMODE_HLT = BND_ICONID(6,24),
  332. BND_ICON_POSE_HLT = BND_ICONID(7,24),
  333. BND_ICON_PARTICLEMODE = BND_ICONID(8,24),
  334. BND_ICON_LIGHTPAINT = BND_ICONID(9,24),
  335. BND_ICON_SCENE_DATA = BND_ICONID(0,23),
  336. BND_ICON_RENDERLAYERS = BND_ICONID(1,23),
  337. BND_ICON_WORLD_DATA = BND_ICONID(2,23),
  338. BND_ICON_OBJECT_DATA = BND_ICONID(3,23),
  339. BND_ICON_MESH_DATA = BND_ICONID(4,23),
  340. BND_ICON_CURVE_DATA = BND_ICONID(5,23),
  341. BND_ICON_META_DATA = BND_ICONID(6,23),
  342. BND_ICON_LATTICE_DATA = BND_ICONID(7,23),
  343. BND_ICON_LAMP_DATA = BND_ICONID(8,23),
  344. BND_ICON_MATERIAL_DATA = BND_ICONID(9,23),
  345. BND_ICON_TEXTURE_DATA = BND_ICONID(10,23),
  346. BND_ICON_ANIM_DATA = BND_ICONID(11,23),
  347. BND_ICON_CAMERA_DATA = BND_ICONID(12,23),
  348. BND_ICON_PARTICLE_DATA = BND_ICONID(13,23),
  349. BND_ICON_LIBRARY_DATA_DIRECT = BND_ICONID(14,23),
  350. BND_ICON_GROUP = BND_ICONID(15,23),
  351. BND_ICON_ARMATURE_DATA = BND_ICONID(16,23),
  352. BND_ICON_POSE_DATA = BND_ICONID(17,23),
  353. BND_ICON_BONE_DATA = BND_ICONID(18,23),
  354. BND_ICON_CONSTRAINT = BND_ICONID(19,23),
  355. BND_ICON_SHAPEKEY_DATA = BND_ICONID(20,23),
  356. BND_ICON_CONSTRAINT_BONE = BND_ICONID(21,23),
  357. BND_ICON_CAMERA_STEREO = BND_ICONID(22,23),
  358. BND_ICON_PACKAGE = BND_ICONID(23,23),
  359. BND_ICON_UGLYPACKAGE = BND_ICONID(24,23),
  360. BND_ICON_BRUSH_DATA = BND_ICONID(0,22),
  361. BND_ICON_IMAGE_DATA = BND_ICONID(1,22),
  362. BND_ICON_FILE = BND_ICONID(2,22),
  363. BND_ICON_FCURVE = BND_ICONID(3,22),
  364. BND_ICON_FONT_DATA = BND_ICONID(4,22),
  365. BND_ICON_RENDER_RESULT = BND_ICONID(5,22),
  366. BND_ICON_SURFACE_DATA = BND_ICONID(6,22),
  367. BND_ICON_EMPTY_DATA = BND_ICONID(7,22),
  368. BND_ICON_SETTINGS = BND_ICONID(8,22),
  369. BND_ICON_RENDER_ANIMATION = BND_ICONID(9,22),
  370. BND_ICON_RENDER_STILL = BND_ICONID(10,22),
  371. BND_ICON_BOIDS = BND_ICONID(12,22),
  372. BND_ICON_STRANDS = BND_ICONID(13,22),
  373. BND_ICON_LIBRARY_DATA_INDIRECT = BND_ICONID(14,22),
  374. BND_ICON_GREASEPENCIL = BND_ICONID(15,22),
  375. BND_ICON_LINE_DATA = BND_ICONID(16,22),
  376. BND_ICON_GROUP_BONE = BND_ICONID(18,22),
  377. BND_ICON_GROUP_VERTEX = BND_ICONID(19,22),
  378. BND_ICON_GROUP_VCOL = BND_ICONID(20,22),
  379. BND_ICON_GROUP_UVS = BND_ICONID(21,22),
  380. BND_ICON_RNA = BND_ICONID(24,22),
  381. BND_ICON_RNA_ADD = BND_ICONID(25,22),
  382. BND_ICON_OUTLINER_OB_EMPTY = BND_ICONID(0,20),
  383. BND_ICON_OUTLINER_OB_MESH = BND_ICONID(1,20),
  384. BND_ICON_OUTLINER_OB_CURVE = BND_ICONID(2,20),
  385. BND_ICON_OUTLINER_OB_LATTICE = BND_ICONID(3,20),
  386. BND_ICON_OUTLINER_OB_META = BND_ICONID(4,20),
  387. BND_ICON_OUTLINER_OB_LAMP = BND_ICONID(5,20),
  388. BND_ICON_OUTLINER_OB_CAMERA = BND_ICONID(6,20),
  389. BND_ICON_OUTLINER_OB_ARMATURE = BND_ICONID(7,20),
  390. BND_ICON_OUTLINER_OB_FONT = BND_ICONID(8,20),
  391. BND_ICON_OUTLINER_OB_SURFACE = BND_ICONID(9,20),
  392. BND_ICON_OUTLINER_OB_SPEAKER = BND_ICONID(10,20),
  393. BND_ICON_RESTRICT_VIEW_OFF = BND_ICONID(19,20),
  394. BND_ICON_RESTRICT_VIEW_ON = BND_ICONID(20,20),
  395. BND_ICON_RESTRICT_SELECT_OFF = BND_ICONID(21,20),
  396. BND_ICON_RESTRICT_SELECT_ON = BND_ICONID(22,20),
  397. BND_ICON_RESTRICT_RENDER_OFF = BND_ICONID(23,20),
  398. BND_ICON_RESTRICT_RENDER_ON = BND_ICONID(24,20),
  399. BND_ICON_OUTLINER_DATA_EMPTY = BND_ICONID(0,19),
  400. BND_ICON_OUTLINER_DATA_MESH = BND_ICONID(1,19),
  401. BND_ICON_OUTLINER_DATA_CURVE = BND_ICONID(2,19),
  402. BND_ICON_OUTLINER_DATA_LATTICE = BND_ICONID(3,19),
  403. BND_ICON_OUTLINER_DATA_META = BND_ICONID(4,19),
  404. BND_ICON_OUTLINER_DATA_LAMP = BND_ICONID(5,19),
  405. BND_ICON_OUTLINER_DATA_CAMERA = BND_ICONID(6,19),
  406. BND_ICON_OUTLINER_DATA_ARMATURE = BND_ICONID(7,19),
  407. BND_ICON_OUTLINER_DATA_FONT = BND_ICONID(8,19),
  408. BND_ICON_OUTLINER_DATA_SURFACE = BND_ICONID(9,19),
  409. BND_ICON_OUTLINER_DATA_SPEAKER = BND_ICONID(10,19),
  410. BND_ICON_OUTLINER_DATA_POSE = BND_ICONID(11,19),
  411. BND_ICON_MESH_PLANE = BND_ICONID(0,18),
  412. BND_ICON_MESH_CUBE = BND_ICONID(1,18),
  413. BND_ICON_MESH_CIRCLE = BND_ICONID(2,18),
  414. BND_ICON_MESH_UVSPHERE = BND_ICONID(3,18),
  415. BND_ICON_MESH_ICOSPHERE = BND_ICONID(4,18),
  416. BND_ICON_MESH_GRID = BND_ICONID(5,18),
  417. BND_ICON_MESH_MONKEY = BND_ICONID(6,18),
  418. BND_ICON_MESH_CYLINDER = BND_ICONID(7,18),
  419. BND_ICON_MESH_TORUS = BND_ICONID(8,18),
  420. BND_ICON_MESH_CONE = BND_ICONID(9,18),
  421. BND_ICON_LAMP_POINT = BND_ICONID(12,18),
  422. BND_ICON_LAMP_SUN = BND_ICONID(13,18),
  423. BND_ICON_LAMP_SPOT = BND_ICONID(14,18),
  424. BND_ICON_LAMP_HEMI = BND_ICONID(15,18),
  425. BND_ICON_LAMP_AREA = BND_ICONID(16,18),
  426. BND_ICON_META_EMPTY = BND_ICONID(19,18),
  427. BND_ICON_META_PLANE = BND_ICONID(20,18),
  428. BND_ICON_META_CUBE = BND_ICONID(21,18),
  429. BND_ICON_META_BALL = BND_ICONID(22,18),
  430. BND_ICON_META_ELLIPSOID = BND_ICONID(23,18),
  431. BND_ICON_META_CAPSULE = BND_ICONID(24,18),
  432. BND_ICON_SURFACE_NCURVE = BND_ICONID(0,17),
  433. BND_ICON_SURFACE_NCIRCLE = BND_ICONID(1,17),
  434. BND_ICON_SURFACE_NSURFACE = BND_ICONID(2,17),
  435. BND_ICON_SURFACE_NCYLINDER = BND_ICONID(3,17),
  436. BND_ICON_SURFACE_NSPHERE = BND_ICONID(4,17),
  437. BND_ICON_SURFACE_NTORUS = BND_ICONID(5,17),
  438. BND_ICON_CURVE_BEZCURVE = BND_ICONID(9,17),
  439. BND_ICON_CURVE_BEZCIRCLE = BND_ICONID(10,17),
  440. BND_ICON_CURVE_NCURVE = BND_ICONID(11,17),
  441. BND_ICON_CURVE_NCIRCLE = BND_ICONID(12,17),
  442. BND_ICON_CURVE_PATH = BND_ICONID(13,17),
  443. BND_ICON_COLOR_RED = BND_ICONID(19,17),
  444. BND_ICON_COLOR_GREEN = BND_ICONID(20,17),
  445. BND_ICON_COLOR_BLUE = BND_ICONID(21,17),
  446. BND_ICON_FORCE_FORCE = BND_ICONID(0,16),
  447. BND_ICON_FORCE_WIND = BND_ICONID(1,16),
  448. BND_ICON_FORCE_VORTEX = BND_ICONID(2,16),
  449. BND_ICON_FORCE_MAGNETIC = BND_ICONID(3,16),
  450. BND_ICON_FORCE_HARMONIC = BND_ICONID(4,16),
  451. BND_ICON_FORCE_CHARGE = BND_ICONID(5,16),
  452. BND_ICON_FORCE_LENNARDJONES = BND_ICONID(6,16),
  453. BND_ICON_FORCE_TEXTURE = BND_ICONID(7,16),
  454. BND_ICON_FORCE_CURVE = BND_ICONID(8,16),
  455. BND_ICON_FORCE_BOID = BND_ICONID(9,16),
  456. BND_ICON_FORCE_TURBULENCE = BND_ICONID(10,16),
  457. BND_ICON_FORCE_DRAG = BND_ICONID(11,16),
  458. BND_ICON_FORCE_SMOKEFLOW = BND_ICONID(12,16),
  459. BND_ICON_MODIFIER = BND_ICONID(0,12),
  460. BND_ICON_MOD_WAVE = BND_ICONID(1,12),
  461. BND_ICON_MOD_BUILD = BND_ICONID(2,12),
  462. BND_ICON_MOD_DECIM = BND_ICONID(3,12),
  463. BND_ICON_MOD_MIRROR = BND_ICONID(4,12),
  464. BND_ICON_MOD_SOFT = BND_ICONID(5,12),
  465. BND_ICON_MOD_SUBSURF = BND_ICONID(6,12),
  466. BND_ICON_HOOK = BND_ICONID(7,12),
  467. BND_ICON_MOD_PHYSICS = BND_ICONID(8,12),
  468. BND_ICON_MOD_PARTICLES = BND_ICONID(9,12),
  469. BND_ICON_MOD_BOOLEAN = BND_ICONID(10,12),
  470. BND_ICON_MOD_EDGESPLIT = BND_ICONID(11,12),
  471. BND_ICON_MOD_ARRAY = BND_ICONID(12,12),
  472. BND_ICON_MOD_UVPROJECT = BND_ICONID(13,12),
  473. BND_ICON_MOD_DISPLACE = BND_ICONID(14,12),
  474. BND_ICON_MOD_CURVE = BND_ICONID(15,12),
  475. BND_ICON_MOD_LATTICE = BND_ICONID(16,12),
  476. BND_ICON_CONSTRAINT_DATA = BND_ICONID(17,12),
  477. BND_ICON_MOD_ARMATURE = BND_ICONID(18,12),
  478. BND_ICON_MOD_SHRINKWRAP = BND_ICONID(19,12),
  479. BND_ICON_MOD_CAST = BND_ICONID(20,12),
  480. BND_ICON_MOD_MESHDEFORM = BND_ICONID(21,12),
  481. BND_ICON_MOD_BEVEL = BND_ICONID(22,12),
  482. BND_ICON_MOD_SMOOTH = BND_ICONID(23,12),
  483. BND_ICON_MOD_SIMPLEDEFORM = BND_ICONID(24,12),
  484. BND_ICON_MOD_MASK = BND_ICONID(25,12),
  485. BND_ICON_MOD_CLOTH = BND_ICONID(0,11),
  486. BND_ICON_MOD_EXPLODE = BND_ICONID(1,11),
  487. BND_ICON_MOD_FLUIDSIM = BND_ICONID(2,11),
  488. BND_ICON_MOD_MULTIRES = BND_ICONID(3,11),
  489. BND_ICON_MOD_SMOKE = BND_ICONID(4,11),
  490. BND_ICON_MOD_SOLIDIFY = BND_ICONID(5,11),
  491. BND_ICON_MOD_SCREW = BND_ICONID(6,11),
  492. BND_ICON_MOD_VERTEX_WEIGHT = BND_ICONID(7,11),
  493. BND_ICON_MOD_DYNAMICPAINT = BND_ICONID(8,11),
  494. BND_ICON_MOD_REMESH = BND_ICONID(9,11),
  495. BND_ICON_MOD_OCEAN = BND_ICONID(10,11),
  496. BND_ICON_MOD_WARP = BND_ICONID(11,11),
  497. BND_ICON_MOD_SKIN = BND_ICONID(12,11),
  498. BND_ICON_MOD_TRIANGULATE = BND_ICONID(13,11),
  499. BND_ICON_MOD_WIREFRAME = BND_ICONID(14,11),
  500. BND_ICON_REC = BND_ICONID(0,10),
  501. BND_ICON_PLAY = BND_ICONID(1,10),
  502. BND_ICON_FF = BND_ICONID(2,10),
  503. BND_ICON_REW = BND_ICONID(3,10),
  504. BND_ICON_PAUSE = BND_ICONID(4,10),
  505. BND_ICON_PREV_KEYFRAME = BND_ICONID(5,10),
  506. BND_ICON_NEXT_KEYFRAME = BND_ICONID(6,10),
  507. BND_ICON_PLAY_AUDIO = BND_ICONID(7,10),
  508. BND_ICON_PLAY_REVERSE = BND_ICONID(8,10),
  509. BND_ICON_PREVIEW_RANGE = BND_ICONID(9,10),
  510. BND_ICON_ACTION_TWEAK = BND_ICONID(10,10),
  511. BND_ICON_PMARKER_ACT = BND_ICONID(11,10),
  512. BND_ICON_PMARKER_SEL = BND_ICONID(12,10),
  513. BND_ICON_PMARKER = BND_ICONID(13,10),
  514. BND_ICON_MARKER_HLT = BND_ICONID(14,10),
  515. BND_ICON_MARKER = BND_ICONID(15,10),
  516. BND_ICON_SPACE2 = BND_ICONID(16,10),
  517. BND_ICON_SPACE3 = BND_ICONID(17,10),
  518. BND_ICON_KEYINGSET = BND_ICONID(18,10),
  519. BND_ICON_KEY_DEHLT = BND_ICONID(19,10),
  520. BND_ICON_KEY_HLT = BND_ICONID(20,10),
  521. BND_ICON_MUTE_IPO_OFF = BND_ICONID(21,10),
  522. BND_ICON_MUTE_IPO_ON = BND_ICONID(22,10),
  523. BND_ICON_VISIBLE_IPO_OFF = BND_ICONID(23,10),
  524. BND_ICON_VISIBLE_IPO_ON = BND_ICONID(24,10),
  525. BND_ICON_DRIVER = BND_ICONID(25,10),
  526. BND_ICON_SOLO_OFF = BND_ICONID(0,9),
  527. BND_ICON_SOLO_ON = BND_ICONID(1,9),
  528. BND_ICON_FRAME_PREV = BND_ICONID(2,9),
  529. BND_ICON_FRAME_NEXT = BND_ICONID(3,9),
  530. BND_ICON_NLA_PUSHDOWN = BND_ICONID(4,9),
  531. BND_ICON_IPO_CONSTANT = BND_ICONID(5,9),
  532. BND_ICON_IPO_LINEAR = BND_ICONID(6,9),
  533. BND_ICON_IPO_BEZIER = BND_ICONID(7,9),
  534. BND_ICON_IPO_SINE = BND_ICONID(8,9),
  535. BND_ICON_IPO_QUAD = BND_ICONID(9,9),
  536. BND_ICON_IPO_CUBIC = BND_ICONID(10,9),
  537. BND_ICON_IPO_QUART = BND_ICONID(11,9),
  538. BND_ICON_IPO_QUINT = BND_ICONID(12,9),
  539. BND_ICON_IPO_EXPO = BND_ICONID(13,9),
  540. BND_ICON_IPO_CIRC = BND_ICONID(14,9),
  541. BND_ICON_IPO_BOUNCE = BND_ICONID(15,9),
  542. BND_ICON_IPO_ELASTIC = BND_ICONID(16,9),
  543. BND_ICON_IPO_BACK = BND_ICONID(17,9),
  544. BND_ICON_IPO_EASE_IN = BND_ICONID(18,9),
  545. BND_ICON_IPO_EASE_OUT = BND_ICONID(19,9),
  546. BND_ICON_IPO_EASE_IN_OUT = BND_ICONID(20,9),
  547. BND_ICON_VERTEXSEL = BND_ICONID(0,8),
  548. BND_ICON_EDGESEL = BND_ICONID(1,8),
  549. BND_ICON_FACESEL = BND_ICONID(2,8),
  550. BND_ICON_LOOPSEL = BND_ICONID(3,8),
  551. BND_ICON_ROTATE = BND_ICONID(5,8),
  552. BND_ICON_CURSOR = BND_ICONID(6,8),
  553. BND_ICON_ROTATECOLLECTION = BND_ICONID(7,8),
  554. BND_ICON_ROTATECENTER = BND_ICONID(8,8),
  555. BND_ICON_ROTACTIVE = BND_ICONID(9,8),
  556. BND_ICON_ALIGN = BND_ICONID(10,8),
  557. BND_ICON_SMOOTHCURVE = BND_ICONID(12,8),
  558. BND_ICON_SPHERECURVE = BND_ICONID(13,8),
  559. BND_ICON_ROOTCURVE = BND_ICONID(14,8),
  560. BND_ICON_SHARPCURVE = BND_ICONID(15,8),
  561. BND_ICON_LINCURVE = BND_ICONID(16,8),
  562. BND_ICON_NOCURVE = BND_ICONID(17,8),
  563. BND_ICON_RNDCURVE = BND_ICONID(18,8),
  564. BND_ICON_PROP_OFF = BND_ICONID(19,8),
  565. BND_ICON_PROP_ON = BND_ICONID(20,8),
  566. BND_ICON_PROP_CON = BND_ICONID(21,8),
  567. BND_ICON_SCULPT_DYNTOPO = BND_ICONID(22,8),
  568. BND_ICON_PARTICLE_POINT = BND_ICONID(23,8),
  569. BND_ICON_PARTICLE_TIP = BND_ICONID(24,8),
  570. BND_ICON_PARTICLE_PATH = BND_ICONID(25,8),
  571. BND_ICON_MAN_TRANS = BND_ICONID(0,7),
  572. BND_ICON_MAN_ROT = BND_ICONID(1,7),
  573. BND_ICON_MAN_SCALE = BND_ICONID(2,7),
  574. BND_ICON_MANIPUL = BND_ICONID(3,7),
  575. BND_ICON_SNAP_OFF = BND_ICONID(4,7),
  576. BND_ICON_SNAP_ON = BND_ICONID(5,7),
  577. BND_ICON_SNAP_NORMAL = BND_ICONID(6,7),
  578. BND_ICON_SNAP_INCREMENT = BND_ICONID(7,7),
  579. BND_ICON_SNAP_VERTEX = BND_ICONID(8,7),
  580. BND_ICON_SNAP_EDGE = BND_ICONID(9,7),
  581. BND_ICON_SNAP_FACE = BND_ICONID(10,7),
  582. BND_ICON_SNAP_VOLUME = BND_ICONID(11,7),
  583. BND_ICON_STICKY_UVS_LOC = BND_ICONID(13,7),
  584. BND_ICON_STICKY_UVS_DISABLE = BND_ICONID(14,7),
  585. BND_ICON_STICKY_UVS_VERT = BND_ICONID(15,7),
  586. BND_ICON_CLIPUV_DEHLT = BND_ICONID(16,7),
  587. BND_ICON_CLIPUV_HLT = BND_ICONID(17,7),
  588. BND_ICON_SNAP_PEEL_OBJECT = BND_ICONID(18,7),
  589. BND_ICON_GRID = BND_ICONID(19,7),
  590. BND_ICON_PASTEDOWN = BND_ICONID(0,6),
  591. BND_ICON_COPYDOWN = BND_ICONID(1,6),
  592. BND_ICON_PASTEFLIPUP = BND_ICONID(2,6),
  593. BND_ICON_PASTEFLIPDOWN = BND_ICONID(3,6),
  594. BND_ICON_SNAP_SURFACE = BND_ICONID(8,6),
  595. BND_ICON_AUTOMERGE_ON = BND_ICONID(9,6),
  596. BND_ICON_AUTOMERGE_OFF = BND_ICONID(10,6),
  597. BND_ICON_RETOPO = BND_ICONID(11,6),
  598. BND_ICON_UV_VERTEXSEL = BND_ICONID(12,6),
  599. BND_ICON_UV_EDGESEL = BND_ICONID(13,6),
  600. BND_ICON_UV_FACESEL = BND_ICONID(14,6),
  601. BND_ICON_UV_ISLANDSEL = BND_ICONID(15,6),
  602. BND_ICON_UV_SYNC_SELECT = BND_ICONID(16,6),
  603. BND_ICON_BBOX = BND_ICONID(0,5),
  604. BND_ICON_WIRE = BND_ICONID(1,5),
  605. BND_ICON_SOLID = BND_ICONID(2,5),
  606. BND_ICON_SMOOTH = BND_ICONID(3,5),
  607. BND_ICON_POTATO = BND_ICONID(4,5),
  608. BND_ICON_ORTHO = BND_ICONID(6,5),
  609. BND_ICON_LOCKVIEW_OFF = BND_ICONID(9,5),
  610. BND_ICON_LOCKVIEW_ON = BND_ICONID(10,5),
  611. BND_ICON_AXIS_SIDE = BND_ICONID(12,5),
  612. BND_ICON_AXIS_FRONT = BND_ICONID(13,5),
  613. BND_ICON_AXIS_TOP = BND_ICONID(14,5),
  614. BND_ICON_NDOF_DOM = BND_ICONID(15,5),
  615. BND_ICON_NDOF_TURN = BND_ICONID(16,5),
  616. BND_ICON_NDOF_FLY = BND_ICONID(17,5),
  617. BND_ICON_NDOF_TRANS = BND_ICONID(18,5),
  618. BND_ICON_LAYER_USED = BND_ICONID(19,5),
  619. BND_ICON_LAYER_ACTIVE = BND_ICONID(20,5),
  620. BND_ICON_SORTALPHA = BND_ICONID(0,3),
  621. BND_ICON_SORTBYEXT = BND_ICONID(1,3),
  622. BND_ICON_SORTTIME = BND_ICONID(2,3),
  623. BND_ICON_SORTSIZE = BND_ICONID(3,3),
  624. BND_ICON_LONGDISPLAY = BND_ICONID(4,3),
  625. BND_ICON_SHORTDISPLAY = BND_ICONID(5,3),
  626. BND_ICON_GHOST = BND_ICONID(6,3),
  627. BND_ICON_IMGDISPLAY = BND_ICONID(7,3),
  628. BND_ICON_SAVE_AS = BND_ICONID(8,3),
  629. BND_ICON_SAVE_COPY = BND_ICONID(9,3),
  630. BND_ICON_BOOKMARKS = BND_ICONID(10,3),
  631. BND_ICON_FONTPREVIEW = BND_ICONID(11,3),
  632. BND_ICON_FILTER = BND_ICONID(12,3),
  633. BND_ICON_NEWFOLDER = BND_ICONID(13,3),
  634. BND_ICON_OPEN_RECENT = BND_ICONID(14,3),
  635. BND_ICON_FILE_PARENT = BND_ICONID(15,3),
  636. BND_ICON_FILE_REFRESH = BND_ICONID(16,3),
  637. BND_ICON_FILE_FOLDER = BND_ICONID(17,3),
  638. BND_ICON_FILE_BLANK = BND_ICONID(18,3),
  639. BND_ICON_FILE_BLEND = BND_ICONID(19,3),
  640. BND_ICON_FILE_IMAGE = BND_ICONID(20,3),
  641. BND_ICON_FILE_MOVIE = BND_ICONID(21,3),
  642. BND_ICON_FILE_SCRIPT = BND_ICONID(22,3),
  643. BND_ICON_FILE_SOUND = BND_ICONID(23,3),
  644. BND_ICON_FILE_FONT = BND_ICONID(24,3),
  645. BND_ICON_FILE_TEXT = BND_ICONID(25,3),
  646. BND_ICON_RECOVER_AUTO = BND_ICONID(0,2),
  647. BND_ICON_SAVE_PREFS = BND_ICONID(1,2),
  648. BND_ICON_LINK_BLEND = BND_ICONID(2,2),
  649. BND_ICON_APPEND_BLEND = BND_ICONID(3,2),
  650. BND_ICON_IMPORT = BND_ICONID(4,2),
  651. BND_ICON_EXPORT = BND_ICONID(5,2),
  652. BND_ICON_EXTERNAL_DATA = BND_ICONID(6,2),
  653. BND_ICON_LOAD_FACTORY = BND_ICONID(7,2),
  654. BND_ICON_LOOP_BACK = BND_ICONID(13,2),
  655. BND_ICON_LOOP_FORWARDS = BND_ICONID(14,2),
  656. BND_ICON_BACK = BND_ICONID(15,2),
  657. BND_ICON_FORWARD = BND_ICONID(16,2),
  658. BND_ICON_FILE_BACKUP = BND_ICONID(24,2),
  659. BND_ICON_DISK_DRIVE = BND_ICONID(25,2),
  660. BND_ICON_MATPLANE = BND_ICONID(0,1),
  661. BND_ICON_MATSPHERE = BND_ICONID(1,1),
  662. BND_ICON_MATCUBE = BND_ICONID(2,1),
  663. BND_ICON_MONKEY = BND_ICONID(3,1),
  664. BND_ICON_HAIR = BND_ICONID(4,1),
  665. BND_ICON_ALIASED = BND_ICONID(5,1),
  666. BND_ICON_ANTIALIASED = BND_ICONID(6,1),
  667. BND_ICON_MAT_SPHERE_SKY = BND_ICONID(7,1),
  668. BND_ICON_WORDWRAP_OFF = BND_ICONID(12,1),
  669. BND_ICON_WORDWRAP_ON = BND_ICONID(13,1),
  670. BND_ICON_SYNTAX_OFF = BND_ICONID(14,1),
  671. BND_ICON_SYNTAX_ON = BND_ICONID(15,1),
  672. BND_ICON_LINENUMBERS_OFF = BND_ICONID(16,1),
  673. BND_ICON_LINENUMBERS_ON = BND_ICONID(17,1),
  674. BND_ICON_SCRIPTPLUGINS = BND_ICONID(18,1),
  675. BND_ICON_SEQ_SEQUENCER = BND_ICONID(0,0),
  676. BND_ICON_SEQ_PREVIEW = BND_ICONID(1,0),
  677. BND_ICON_SEQ_LUMA_WAVEFORM = BND_ICONID(2,0),
  678. BND_ICON_SEQ_CHROMA_SCOPE = BND_ICONID(3,0),
  679. BND_ICON_SEQ_HISTOGRAM = BND_ICONID(4,0),
  680. BND_ICON_SEQ_SPLITVIEW = BND_ICONID(5,0),
  681. BND_ICON_IMAGE_RGB = BND_ICONID(9,0),
  682. BND_ICON_IMAGE_RGB_ALPHA = BND_ICONID(10,0),
  683. BND_ICON_IMAGE_ALPHA = BND_ICONID(11,0),
  684. BND_ICON_IMAGE_ZDEPTH = BND_ICONID(12,0),
  685. BND_ICON_IMAGEFILE = BND_ICONID(13,0),
  686. } BNDicon;
  687. ////////////////////////////////////////////////////////////////////////////////
  688. // set the current theme all widgets will be drawn with.
  689. // the default Blender 2.6 theme is set by default.
  690. BND_EXPORT void bndSetTheme(BNDtheme theme);
  691. // Returns the currently set theme
  692. BND_EXPORT const BNDtheme *bndGetTheme();
  693. // designates an image handle as returned by nvgCreateImage*() as the themes'
  694. // icon sheet. The icon sheet format must be compatible to Blender 2.6's icon
  695. // sheet; the order of icons does not matter.
  696. // A valid icon sheet is e.g. shown at
  697. // http://wiki.blender.org/index.php/Dev:2.5/Doc/How_to/Add_an_icon
  698. BND_EXPORT void bndSetIconImage(int image);
  699. // designates an image handle as returned by nvgCreateFont*() as the themes'
  700. // UI font. Blender's original UI font Droid Sans is perfectly suited and
  701. // available here:
  702. // https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/datafiles/fonts/
  703. BND_EXPORT void bndSetFont(int font);
  704. ////////////////////////////////////////////////////////////////////////////////
  705. // High Level Functions
  706. // --------------------
  707. // Use these functions to draw themed widgets with your NVGcontext.
  708. // Draw a label with its lower left origin at (x,y) and size of (w,h).
  709. // if iconid >= 0, an icon will be added to the widget
  710. // if label is not NULL, a label will be added to the widget
  711. // widget looks best when height is BND_WIDGET_HEIGHT
  712. BND_EXPORT void bndLabel(NVGcontext *ctx,
  713. float x, float y, float w, float h, int iconid, const char *label);
  714. // Draw a tool button with its lower left origin at (x,y) and size of (w,h),
  715. // where flags is one or multiple flags from BNDcornerFlags and state denotes
  716. // the widgets current UI state.
  717. // if iconid >= 0, an icon will be added to the widget
  718. // if label is not NULL, a label will be added to the widget
  719. // widget looks best when height is BND_WIDGET_HEIGHT
  720. BND_EXPORT void bndToolButton(NVGcontext *ctx,
  721. float x, float y, float w, float h, int flags, BNDwidgetState state,
  722. int iconid, const char *label);
  723. // Draw a radio button with its lower left origin at (x,y) and size of (w,h),
  724. // where flags is one or multiple flags from BNDcornerFlags and state denotes
  725. // the widgets current UI state.
  726. // if iconid >= 0, an icon will be added to the widget
  727. // if label is not NULL, a label will be added to the widget
  728. // widget looks best when height is BND_WIDGET_HEIGHT
  729. BND_EXPORT void bndRadioButton(NVGcontext *ctx,
  730. float x, float y, float w, float h, int flags, BNDwidgetState state,
  731. int iconid, const char *label);
  732. // Draw a text field with its lower left origin at (x,y) and size of (w,h),
  733. // where flags is one or multiple flags from BNDcornerFlags and state denotes
  734. // the widgets current UI state.
  735. // if iconid >= 0, an icon will be added to the widget
  736. // if text is not NULL, text will be printed to the widget
  737. // cbegin must be >= 0 and <= strlen(text) and denotes the beginning of the caret
  738. // cend must be >= cbegin and <= strlen(text) and denotes the end of the caret
  739. // if cend < cbegin, then no caret will be drawn
  740. // widget looks best when height is BND_WIDGET_HEIGHT
  741. BND_EXPORT void bndTextField(NVGcontext *ctx,
  742. float x, float y, float w, float h, int flags, BNDwidgetState state,
  743. int iconid, const char *text, int cbegin, int cend);
  744. // Draw an option button with its lower left origin at (x,y) and size of (w,h),
  745. // where flags is one or multiple flags from BNDcornerFlags and state denotes
  746. // the widgets current UI state.
  747. // if label is not NULL, a label will be added to the widget
  748. // widget looks best when height is BND_WIDGET_HEIGHT
  749. BND_EXPORT void bndOptionButton(NVGcontext *ctx,
  750. float x, float y, float w, float h, BNDwidgetState state,
  751. const char *label);
  752. // Draw a choice button with its lower left origin at (x,y) and size of (w,h),
  753. // where flags is one or multiple flags from BNDcornerFlags and state denotes
  754. // the widgets current UI state.
  755. // if iconid >= 0, an icon will be added to the widget
  756. // if label is not NULL, a label will be added to the widget
  757. // widget looks best when height is BND_WIDGET_HEIGHT
  758. BND_EXPORT void bndChoiceButton(NVGcontext *ctx,
  759. float x, float y, float w, float h, int flags, BNDwidgetState state,
  760. int iconid, const char *label);
  761. // Draw a color button with its lower left origin at (x,y) and size of (w,h),
  762. // where flags is one or multiple flags from BNDcornerFlags and state denotes
  763. // the widgets current UI state.
  764. // widget looks best when height is BND_WIDGET_HEIGHT
  765. BND_EXPORT void bndColorButton(NVGcontext *ctx,
  766. float x, float y, float w, float h, int flags, NVGcolor color);
  767. // Draw a number field with its lower left origin at (x,y) and size of (w,h),
  768. // where flags is one or multiple flags from BNDcornerFlags and state denotes
  769. // the widgets current UI state.
  770. // if label is not NULL, a label will be added to the widget
  771. // if value is not NULL, a value will be added to the widget, along with
  772. // a ":" separator
  773. // widget looks best when height is BND_WIDGET_HEIGHT
  774. BND_EXPORT void bndNumberField(NVGcontext *ctx,
  775. float x, float y, float w, float h, int flags, BNDwidgetState state,
  776. const char *label, const char *value);
  777. // Draw slider control with its lower left origin at (x,y) and size of (w,h),
  778. // where flags is one or multiple flags from BNDcornerFlags and state denotes
  779. // the widgets current UI state.
  780. // progress must be in the range 0..1 and controls the size of the slider bar
  781. // if label is not NULL, a label will be added to the widget
  782. // if value is not NULL, a value will be added to the widget, along with
  783. // a ":" separator
  784. // widget looks best when height is BND_WIDGET_HEIGHT
  785. BND_EXPORT void bndSlider(NVGcontext *ctx,
  786. float x, float y, float w, float h, int flags, BNDwidgetState state,
  787. float progress, const char *label, const char *value);
  788. // Draw scrollbar with its lower left origin at (x,y) and size of (w,h),
  789. // where state denotes the widgets current UI state.
  790. // offset is in the range 0..1 and controls the position of the scroll handle
  791. // size is in the range 0..1 and controls the size of the scroll handle
  792. // horizontal widget looks best when height is BND_SCROLLBAR_HEIGHT,
  793. // vertical looks best when width is BND_SCROLLBAR_WIDTH
  794. BND_EXPORT void bndScrollBar(NVGcontext *ctx,
  795. float x, float y, float w, float h, BNDwidgetState state,
  796. float offset, float size);
  797. // Draw a menu background with its lower left origin at (x,y) and size of (w,h),
  798. // where flags is one or multiple flags from BNDcornerFlags.
  799. BND_EXPORT void bndMenuBackground(NVGcontext *ctx,
  800. float x, float y, float w, float h, int flags);
  801. // Draw a menu label with its lower left origin at (x,y) and size of (w,h).
  802. // if iconid >= 0, an icon will be added to the widget
  803. // if label is not NULL, a label will be added to the widget
  804. // widget looks best when height is BND_WIDGET_HEIGHT
  805. BND_EXPORT void bndMenuLabel(NVGcontext *ctx,
  806. float x, float y, float w, float h, int iconid, const char *label);
  807. // Draw a menu item with its lower left origin at (x,y) and size of (w,h),
  808. // where state denotes the widgets current UI state.
  809. // if iconid >= 0, an icon will be added to the widget
  810. // if label is not NULL, a label will be added to the widget
  811. // widget looks best when height is BND_WIDGET_HEIGHT
  812. BND_EXPORT void bndMenuItem(NVGcontext *ctx,
  813. float x, float y, float w, float h, BNDwidgetState state,
  814. int iconid, const char *label);
  815. // Draw a tooltip background with its lower left origin at (x,y) and size of (w,h)
  816. BND_EXPORT void bndTooltipBackground(NVGcontext *ctx, float x, float y, float w, float h);
  817. // Draw a node port at the given position filled with the given color
  818. BND_EXPORT void bndNodePort(NVGcontext *ctx, float x, float y, BNDwidgetState state,
  819. NVGcolor color);
  820. // Draw a node wire originating at (x0,y0) and floating to (x1,y1), with
  821. // a colored gradient based on the states state0 and state1:
  822. // BND_DEFAULT: default wire color
  823. // BND_HOVER: selected wire color
  824. // BND_ACTIVE: dragged wire color
  825. BND_EXPORT void bndNodeWire(NVGcontext *ctx, float x0, float y0, float x1, float y1,
  826. BNDwidgetState state0, BNDwidgetState state1);
  827. // Draw a node background with its upper left origin at (x,y) and size of (w,h)
  828. // where titleColor provides the base color for the title bar
  829. BND_EXPORT void bndNodeBackground(NVGcontext *ctx, float x, float y, float w, float h,
  830. BNDwidgetState state, int iconid, const char *label, NVGcolor titleColor);
  831. // Draw a window with the upper right and lower left splitter widgets into
  832. // the rectangle at origin (x,y) and size (w, h)
  833. BND_EXPORT void bndSplitterWidgets(NVGcontext *ctx, float x, float y, float w, float h);
  834. // Draw the join area overlay stencil into the rectangle
  835. // at origin (x,y) and size (w,h)
  836. // vertical is 0 or 1 and designates the arrow orientation,
  837. // mirror is 0 or 1 and flips the arrow side
  838. BND_EXPORT void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h,
  839. int vertical, int mirror);
  840. ////////////////////////////////////////////////////////////////////////////////
  841. // Estimator Functions
  842. // -------------------
  843. // Use these functions to estimate sizes for widgets with your NVGcontext.
  844. // returns the ideal width for a label with given icon and text
  845. BND_EXPORT float bndLabelWidth(NVGcontext *ctx, int iconid, const char *label);
  846. // returns the height for a label with given icon, text and width; this
  847. // function is primarily useful in conjunction with multiline labels and textboxes
  848. BND_EXPORT float bndLabelHeight(NVGcontext *ctx, int iconid, const char *label,
  849. float width);
  850. ////////////////////////////////////////////////////////////////////////////////
  851. // Low Level Functions
  852. // -------------------
  853. // these are part of the implementation detail and can be used to theme
  854. // new kinds of controls in a similar fashion.
  855. // make color transparent using the default alpha value
  856. BND_EXPORT NVGcolor bndTransparent(NVGcolor color);
  857. // offset a color by a given integer delta in the range -100 to 100
  858. BND_EXPORT NVGcolor bndOffsetColor(NVGcolor color, int delta);
  859. // assigns radius r to the four entries of array radiuses depending on whether
  860. // the corner is marked as sharp or not; see BNDcornerFlags for possible
  861. // flag values.
  862. BND_EXPORT void bndSelectCorners(float *radiuses, float r, int flags);
  863. // computes the upper and lower gradient colors for the inner box from a widget
  864. // theme and the widgets state. If flipActive is set and the state is
  865. // BND_ACTIVE, the upper and lower colors will be swapped.
  866. BND_EXPORT void bndInnerColors(NVGcolor *shade_top, NVGcolor *shade_down,
  867. const BNDwidgetTheme *theme, BNDwidgetState state, int flipActive);
  868. // computes the text color for a widget label from a widget theme and the
  869. // widgets state.
  870. BND_EXPORT NVGcolor bndTextColor(const BNDwidgetTheme *theme, BNDwidgetState state);
  871. // computes the bounds of the scrollbar handle from the scrollbar size
  872. // and the handles offset and size.
  873. // offset is in the range 0..1 and defines the position of the scroll handle
  874. // size is in the range 0..1 and defines the size of the scroll handle
  875. BND_EXPORT void bndScrollHandleRect(float *x, float *y, float *w, float *h,
  876. float offset, float size);
  877. // Add a rounded box path at position (x,y) with size (w,h) and a separate
  878. // radius for each corner listed in clockwise order, so that cr0 = top left,
  879. // cr1 = top right, cr2 = bottom right, cr3 = bottom left;
  880. // this is a low level drawing function: the path must be stroked or filled
  881. // to become visible.
  882. BND_EXPORT void bndRoundedBox(NVGcontext *ctx, float x, float y, float w, float h,
  883. float cr0, float cr1, float cr2, float cr3);
  884. // Draw a flat panel without any decorations at position (x,y) with size (w,h)
  885. // and fills it with backgroundColor
  886. BND_EXPORT void bndBackground(NVGcontext *ctx, float x, float y, float w, float h);
  887. // Draw a beveled border at position (x,y) with size (w,h) shaded with
  888. // lighter and darker versions of backgroundColor
  889. BND_EXPORT void bndBevel(NVGcontext *ctx, float x, float y, float w, float h);
  890. // Draw a lower inset for a rounded box at position (x,y) with size (w,h)
  891. // that gives the impression the surface has been pushed in.
  892. // cr2 and cr3 contain the radiuses of the bottom right and bottom left
  893. // corners of the rounded box.
  894. BND_EXPORT void bndBevelInset(NVGcontext *ctx, float x, float y, float w, float h,
  895. float cr2, float cr3);
  896. // Draw an icon with (x,y) as its upper left coordinate; the iconid selects
  897. // the icon from the sheet; use the BND_ICONID macro to build icon IDs.
  898. BND_EXPORT void bndIcon(NVGcontext *ctx, float x, float y, int iconid);
  899. // Draw a drop shadow around the rounded box at (x,y) with size (w,h) and
  900. // radius r, with feather as its maximum range in pixels.
  901. // No shadow will be painted inside the rounded box.
  902. BND_EXPORT void bndDropShadow(NVGcontext *ctx, float x, float y, float w, float h,
  903. float r, float feather, float alpha);
  904. // Draw the inner part of a widget box, with a gradient from shade_top to
  905. // shade_down. If h>w, the gradient will be horizontal instead of
  906. // vertical.
  907. BND_EXPORT void bndInnerBox(NVGcontext *ctx, float x, float y, float w, float h,
  908. float cr0, float cr1, float cr2, float cr3,
  909. NVGcolor shade_top, NVGcolor shade_down);
  910. // Draw the outline part of a widget box with the given color
  911. BND_EXPORT void bndOutlineBox(NVGcontext *ctx, float x, float y, float w, float h,
  912. float cr0, float cr1, float cr2, float cr3, NVGcolor color);
  913. // Draw an optional icon specified by <iconid> and an optional label with
  914. // given alignment (BNDtextAlignment), fontsize and color within a widget box.
  915. // if iconid is >= 0, an icon will be drawn and the labels remaining space
  916. // will be adjusted.
  917. // if label is not NULL, it will be drawn with the specified alignment, fontsize
  918. // and color.
  919. // if value is not NULL, label and value will be drawn with a ":" separator
  920. // inbetween.
  921. BND_EXPORT void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h,
  922. int iconid, NVGcolor color, int align, float fontsize, const char *label,
  923. const char *value);
  924. // Draw an optional icon specified by <iconid> and an optional label with
  925. // given alignment (BNDtextAlignment), fontsize and color within a node title bar
  926. // if iconid is >= 0, an icon will be drawn
  927. // if label is not NULL, it will be drawn with the specified alignment, fontsize
  928. // and color.
  929. BND_EXPORT void bndNodeIconLabel(NVGcontext *ctx, float x, float y, float w, float h,
  930. int iconid, NVGcolor color, NVGcolor shadowColor, int align,
  931. float fontsize, const char *label);
  932. // Draw an optional icon specified by <iconid>, an optional label and
  933. // a caret with given fontsize and color within a widget box.
  934. // if iconid is >= 0, an icon will be drawn and the labels remaining space
  935. // will be adjusted.
  936. // if label is not NULL, it will be drawn with the specified alignment, fontsize
  937. // and color.
  938. // cbegin must be >= 0 and <= strlen(text) and denotes the beginning of the caret
  939. // cend must be >= cbegin and <= strlen(text) and denotes the end of the caret
  940. // if cend < cbegin, then no caret will be drawn
  941. BND_EXPORT void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h,
  942. int iconid, NVGcolor color, float fontsize, const char *label,
  943. NVGcolor caretcolor, int cbegin, int cend);
  944. // Draw a checkmark for an option box with the given upper left coordinates
  945. // (ox,oy) with the specified color.
  946. BND_EXPORT void bndCheck(NVGcontext *ctx, float ox, float oy, NVGcolor color);
  947. // Draw a horizontal arrow for a number field with its center at (x,y) and
  948. // size s; if s is negative, the arrow points to the left.
  949. BND_EXPORT void bndArrow(NVGcontext *ctx, float x, float y, float s, NVGcolor color);
  950. // Draw an up/down arrow for a choice box with its center at (x,y) and size s
  951. BND_EXPORT void bndUpDownArrow(NVGcontext *ctx, float x, float y, float s, NVGcolor color);
  952. // Draw a node down-arrow with its tip at (x,y) and size s
  953. BND_EXPORT void bndNodeArrowDown(NVGcontext *ctx, float x, float y, float s, NVGcolor color);
  954. // return the color of a node wire based on state
  955. // BND_HOVER indicates selected state,
  956. // BND_ACTIVE indicates dragged state
  957. BND_EXPORT NVGcolor bndNodeWireColor(const BNDnodeTheme *theme, BNDwidgetState state);
  958. #ifdef __cplusplus
  959. };
  960. #endif
  961. #endif // BLENDISH_H
  962. ////////////////////////////////////////////////////////////////////////////////
  963. ////////////////////////////////////////////////////////////////////////////////
  964. #ifdef BLENDISH_IMPLEMENTATION
  965. #include <memory.h>
  966. #include <math.h>
  967. #ifdef _MSC_VER
  968. #pragma warning (disable: 4996) // Switch off security warnings
  969. #pragma warning (disable: 4100) // Switch off unreferenced formal parameter warnings
  970. #ifdef __cplusplus
  971. #define BND_INLINE inline
  972. #else
  973. #define BND_INLINE
  974. #endif
  975. #include <float.h>
  976. static float bnd_fminf ( float a, float b )
  977. {
  978. return _isnan(a) ? b : ( _isnan(b) ? a : ((a < b) ? a : b));
  979. }
  980. static float bnd_fmaxf ( float a, float b )
  981. {
  982. return _isnan(a) ? b : ( _isnan(b) ? a : ((a > b) ? a : b));
  983. }
  984. static double bnd_fmin ( double a, double b )
  985. {
  986. return _isnan(a) ? b : ( _isnan(b) ? a : ((a < b) ? a : b));
  987. }
  988. static double bnd_fmax ( double a, double b )
  989. {
  990. return _isnan(a) ? b : ( _isnan(b) ? a : ((a > b) ? a : b));
  991. }
  992. #else
  993. #define BND_INLINE inline
  994. #define bnd_fminf(a, b) fminf(a, b)
  995. #define bnd_fmaxf(a, b) fmaxf(a, b)
  996. #define bnd_fmin(a, b) fmin(a, b)
  997. #define bnd_fmax(a, b) fmax(a, b)
  998. #endif
  999. ////////////////////////////////////////////////////////////////////////////////
  1000. // default text size
  1001. #define BND_LABEL_FONT_SIZE 13
  1002. // default text padding in inner box
  1003. #define BND_PAD_LEFT 8
  1004. #define BND_PAD_RIGHT 8
  1005. // label: value separator string
  1006. #define BND_LABEL_SEPARATOR ": "
  1007. // alpha intensity of transparent items (0xa4)
  1008. #define BND_TRANSPARENT_ALPHA 0.643
  1009. // shade intensity of beveled panels
  1010. #define BND_BEVEL_SHADE 30
  1011. // shade intensity of beveled insets
  1012. #define BND_INSET_BEVEL_SHADE 30
  1013. // shade intensity of hovered inner boxes
  1014. #define BND_HOVER_SHADE 15
  1015. // shade intensity of splitter bevels
  1016. #define BND_SPLITTER_SHADE 100
  1017. // width of icon sheet
  1018. #define BND_ICON_SHEET_WIDTH 602
  1019. // height of icon sheet
  1020. #define BND_ICON_SHEET_HEIGHT 640
  1021. // gridsize of icon sheet in both dimensions
  1022. #define BND_ICON_SHEET_GRID 21
  1023. // offset of first icon tile relative to left border
  1024. #define BND_ICON_SHEET_OFFSET_X 5
  1025. // offset of first icon tile relative to top border
  1026. #define BND_ICON_SHEET_OFFSET_Y 10
  1027. // resolution of single icon
  1028. #define BND_ICON_SHEET_RES 16
  1029. // size of number field arrow
  1030. #define BND_NUMBER_ARROW_SIZE 4
  1031. // default text color
  1032. #define BND_COLOR_TEXT {{{ 0,0,0,1 }}}
  1033. // default highlighted text color
  1034. #define BND_COLOR_TEXT_SELECTED {{{ 1,1,1,1 }}}
  1035. // radius of tool button
  1036. #define BND_TOOL_RADIUS 4
  1037. // radius of option button
  1038. #define BND_OPTION_RADIUS 4
  1039. // width of option button checkbox
  1040. #define BND_OPTION_WIDTH 14
  1041. // height of option button checkbox
  1042. #define BND_OPTION_HEIGHT 15
  1043. // radius of text field
  1044. #define BND_TEXT_RADIUS 4
  1045. // radius of number button
  1046. #define BND_NUMBER_RADIUS 10
  1047. // radius of menu popup
  1048. #define BND_MENU_RADIUS 3
  1049. // feather of menu popup shadow
  1050. #define BND_SHADOW_FEATHER 12
  1051. // alpha of menu popup shadow
  1052. #define BND_SHADOW_ALPHA 0.5
  1053. // radius of scrollbar
  1054. #define BND_SCROLLBAR_RADIUS 7
  1055. // shade intensity of active scrollbar
  1056. #define BND_SCROLLBAR_ACTIVE_SHADE 15
  1057. // max glyphs for position testing
  1058. #define BND_MAX_GLYPHS 1024
  1059. // text distance from bottom
  1060. #define BND_TEXT_PAD_DOWN 7
  1061. // stroke width of wire outline
  1062. #define BND_NODE_WIRE_OUTLINE_WIDTH 4
  1063. // stroke width of wire
  1064. #define BND_NODE_WIRE_WIDTH 2
  1065. // radius of node box
  1066. #define BND_NODE_RADIUS 8
  1067. // feather of node title text
  1068. #define BND_NODE_TITLE_FEATHER 1
  1069. // size of node title arrow
  1070. #define BND_NODE_ARROW_SIZE 9
  1071. ////////////////////////////////////////////////////////////////////////////////
  1072. BND_INLINE float bnd_clamp(float v, float mn, float mx) {
  1073. return (v > mx)?mx:(v < mn)?mn:v;
  1074. }
  1075. ////////////////////////////////////////////////////////////////////////////////
  1076. // the initial theme
  1077. static BNDtheme bnd_theme = {
  1078. // backgroundColor
  1079. {{{ 0.447, 0.447, 0.447, 1.0 }}},
  1080. // regularTheme
  1081. {
  1082. {{{ 0.098,0.098,0.098,1 }}}, // color_outline
  1083. {{{ 0.098,0.098,0.098,1 }}}, // color_item
  1084. {{{ 0.6,0.6,0.6,1 }}}, // color_inner
  1085. {{{ 0.392,0.392,0.392,1 }}}, // color_inner_selected
  1086. BND_COLOR_TEXT, // color_text
  1087. BND_COLOR_TEXT_SELECTED, // color_text_selected
  1088. 0, // shade_top
  1089. 0, // shade_down
  1090. },
  1091. // toolTheme
  1092. {
  1093. {{{ 0.098,0.098,0.098,1 }}}, // color_outline
  1094. {{{ 0.098,0.098,0.098,1 }}}, // color_item
  1095. {{{ 0.6,0.6,0.6,1 }}}, // color_inner
  1096. {{{ 0.392,0.392,0.392,1 }}}, // color_inner_selected
  1097. BND_COLOR_TEXT, // color_text
  1098. BND_COLOR_TEXT_SELECTED, // color_text_selected
  1099. 15, // shade_top
  1100. -15, // shade_down
  1101. },
  1102. // radioTheme
  1103. {
  1104. {{{ 0,0,0,1 }}}, // color_outline
  1105. {{{ 1,1,1,1 }}}, // color_item
  1106. {{{ 0.275,0.275,0.275,1 }}}, // color_inner
  1107. {{{ 0.337,0.502,0.761,1 }}}, // color_inner_selected
  1108. BND_COLOR_TEXT_SELECTED, // color_text
  1109. BND_COLOR_TEXT, // color_text_selected
  1110. 15, // shade_top
  1111. -15, // shade_down
  1112. },
  1113. // textFieldTheme
  1114. {
  1115. {{{ 0.098,0.098,0.098,1 }}}, // color_outline
  1116. {{{ 0.353, 0.353, 0.353,1 }}}, // color_item
  1117. {{{ 0.6, 0.6, 0.6,1 }}}, // color_inner
  1118. {{{ 0.6, 0.6, 0.6,1 }}}, // color_inner_selected
  1119. BND_COLOR_TEXT, // color_text
  1120. BND_COLOR_TEXT_SELECTED, // color_text_selected
  1121. 0, // shade_top
  1122. 25, // shade_down
  1123. },
  1124. // optionTheme
  1125. {
  1126. {{{ 0,0,0,1 }}}, // color_outline
  1127. {{{ 1,1,1,1 }}}, // color_item
  1128. {{{ 0.275,0.275,0.275,1 }}}, // color_inner
  1129. {{{ 0.275,0.275,0.275,1 }}}, // color_inner_selected
  1130. BND_COLOR_TEXT, // color_text
  1131. BND_COLOR_TEXT_SELECTED, // color_text_selected
  1132. 15, // shade_top
  1133. -15, // shade_down
  1134. },
  1135. // choiceTheme
  1136. {
  1137. {{{ 0,0,0,1 }}}, // color_outline
  1138. {{{ 1,1,1,1 }}}, // color_item
  1139. {{{ 0.275,0.275,0.275,1 }}}, // color_inner
  1140. {{{ 0.275,0.275,0.275,1 }}}, // color_inner_selected
  1141. BND_COLOR_TEXT_SELECTED, // color_text
  1142. {{{ 0.8,0.8,0.8,1 }}}, // color_text_selected
  1143. 15, // shade_top
  1144. -15, // shade_down
  1145. },
  1146. // numberFieldTheme
  1147. {
  1148. {{{ 0.098,0.098,0.098,1 }}}, // color_outline
  1149. {{{ 0.353, 0.353, 0.353,1 }}}, // color_item
  1150. {{{ 0.706, 0.706, 0.706,1 }}}, // color_inner
  1151. {{{ 0.6, 0.6, 0.6,1 }}}, // color_inner_selected
  1152. BND_COLOR_TEXT, // color_text
  1153. BND_COLOR_TEXT_SELECTED, // color_text_selected
  1154. -20, // shade_top
  1155. 0, // shade_down
  1156. },
  1157. // sliderTheme
  1158. {
  1159. {{{ 0.098,0.098,0.098,1 }}}, // color_outline
  1160. {{{ 0.502,0.502,0.502,1 }}}, // color_item
  1161. {{{ 0.706, 0.706, 0.706,1 }}}, // color_inner
  1162. {{{ 0.6, 0.6, 0.6,1 }}}, // color_inner_selected
  1163. BND_COLOR_TEXT, // color_text
  1164. BND_COLOR_TEXT_SELECTED, // color_text_selected
  1165. -20, // shade_top
  1166. 0, // shade_down
  1167. },
  1168. // scrollBarTheme
  1169. {
  1170. {{{ 0.196,0.196,0.196,1 }}}, // color_outline
  1171. {{{ 0.502,0.502,0.502,1 }}}, // color_item
  1172. {{{ 0.314, 0.314, 0.314,0.706 }}}, // color_inner
  1173. {{{ 0.392, 0.392, 0.392,0.706 }}}, // color_inner_selected
  1174. BND_COLOR_TEXT, // color_text
  1175. BND_COLOR_TEXT_SELECTED, // color_text_selected
  1176. 5, // shade_top
  1177. -5, // shade_down
  1178. },
  1179. // tooltipTheme
  1180. {
  1181. {{{ 0,0,0,1 }}}, // color_outline
  1182. {{{ 0.392,0.392,0.392,1 }}}, // color_item
  1183. {{{ 0.098, 0.098, 0.098, 0.902 }}}, // color_inner
  1184. {{{ 0.176, 0.176, 0.176, 0.902 }}}, // color_inner_selected
  1185. {{{ 0.627, 0.627, 0.627, 1 }}}, // color_text
  1186. BND_COLOR_TEXT_SELECTED, // color_text_selected
  1187. 0, // shade_top
  1188. 0, // shade_down
  1189. },
  1190. // menuTheme
  1191. {
  1192. {{{ 0,0,0,1 }}}, // color_outline
  1193. {{{ 0.392,0.392,0.392,1 }}}, // color_item
  1194. {{{ 0.098, 0.098, 0.098, 0.902 }}}, // color_inner
  1195. {{{ 0.176, 0.176, 0.176, 0.902 }}}, // color_inner_selected
  1196. {{{ 0.627, 0.627, 0.627, 1 }}}, // color_text
  1197. BND_COLOR_TEXT_SELECTED, // color_text_selected
  1198. 0, // shade_top
  1199. 0, // shade_down
  1200. },
  1201. // menuItemTheme
  1202. {
  1203. {{{ 0,0,0,1 }}}, // color_outline
  1204. {{{ 0.675,0.675,0.675,0.502 }}}, // color_item
  1205. {{{ 0,0,0,0 }}}, // color_inner
  1206. {{{ 0.337,0.502,0.761,1 }}}, // color_inner_selected
  1207. BND_COLOR_TEXT_SELECTED, // color_text
  1208. BND_COLOR_TEXT, // color_text_selected
  1209. 38, // shade_top
  1210. 0, // shade_down
  1211. },
  1212. // nodeTheme
  1213. {
  1214. {{{ 0.945,0.345,0,1 }}}, // nodeSelectedColor
  1215. {{{ 0,0,0,1 }}}, // wiresColor
  1216. {{{ 0.498,0.439,0.439,1 }}}, // textSelectedColor
  1217. {{{ 1,0.667,0.251,1 }}}, // activeNodeColor
  1218. {{{ 1,1,1,1 }}}, // wireSelectColor
  1219. {{{ 0.608,0.608,0.608,0.627 }}}, // nodeBackdropColor
  1220. 5, // noodleCurving
  1221. },
  1222. };
  1223. ////////////////////////////////////////////////////////////////////////////////
  1224. void bndSetTheme(BNDtheme theme) {
  1225. bnd_theme = theme;
  1226. }
  1227. const BNDtheme *bndGetTheme() {
  1228. return &bnd_theme;
  1229. }
  1230. // the handle to the image containing the icon sheet
  1231. static int bnd_icon_image = -1;
  1232. void bndSetIconImage(int image) {
  1233. bnd_icon_image = image;
  1234. }
  1235. // the handle to the UI font
  1236. static int bnd_font = -1;
  1237. void bndSetFont(int font) {
  1238. bnd_font = font;
  1239. }
  1240. ////////////////////////////////////////////////////////////////////////////////
  1241. void bndLabel(NVGcontext *ctx,
  1242. float x, float y, float w, float h, int iconid, const char *label) {
  1243. bndIconLabelValue(ctx,x,y,w,h,iconid,
  1244. bnd_theme.regularTheme.textColor, BND_LEFT,
  1245. BND_LABEL_FONT_SIZE, label, NULL);
  1246. }
  1247. void bndToolButton(NVGcontext *ctx,
  1248. float x, float y, float w, float h, int flags, BNDwidgetState state,
  1249. int iconid, const char *label) {
  1250. float cr[4];
  1251. NVGcolor shade_top, shade_down;
  1252. bndSelectCorners(cr, BND_TOOL_RADIUS, flags);
  1253. bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
  1254. bndInnerColors(&shade_top, &shade_down, &bnd_theme.toolTheme, state, 1);
  1255. bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
  1256. bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
  1257. bndTransparent(bnd_theme.toolTheme.outlineColor));
  1258. bndIconLabelValue(ctx,x,y,w,h,iconid,
  1259. bndTextColor(&bnd_theme.toolTheme, state), BND_CENTER,
  1260. BND_LABEL_FONT_SIZE, label, NULL);
  1261. }
  1262. void bndRadioButton(NVGcontext *ctx,
  1263. float x, float y, float w, float h, int flags, BNDwidgetState state,
  1264. int iconid, const char *label) {
  1265. float cr[4];
  1266. NVGcolor shade_top, shade_down;
  1267. bndSelectCorners(cr, BND_OPTION_RADIUS, flags);
  1268. bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
  1269. bndInnerColors(&shade_top, &shade_down, &bnd_theme.radioTheme, state, 1);
  1270. bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
  1271. bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
  1272. bndTransparent(bnd_theme.radioTheme.outlineColor));
  1273. bndIconLabelValue(ctx,x,y,w,h,iconid,
  1274. bndTextColor(&bnd_theme.radioTheme, state), BND_CENTER,
  1275. BND_LABEL_FONT_SIZE, label, NULL);
  1276. }
  1277. void bndTextField(NVGcontext *ctx,
  1278. float x, float y, float w, float h, int flags, BNDwidgetState state,
  1279. int iconid, const char *text, int cbegin, int cend) {
  1280. float cr[4];
  1281. NVGcolor shade_top, shade_down;
  1282. bndSelectCorners(cr, BND_TEXT_RADIUS, flags);
  1283. bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
  1284. bndInnerColors(&shade_top, &shade_down, &bnd_theme.textFieldTheme, state, 0);
  1285. bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
  1286. bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
  1287. bndTransparent(bnd_theme.textFieldTheme.outlineColor));
  1288. if (state != BND_ACTIVE) {
  1289. cend = -1;
  1290. }
  1291. bndIconLabelCaret(ctx,x,y,w,h,iconid,
  1292. bndTextColor(&bnd_theme.textFieldTheme, state), BND_LABEL_FONT_SIZE,
  1293. text, bnd_theme.textFieldTheme.itemColor, cbegin, cend);
  1294. }
  1295. void bndOptionButton(NVGcontext *ctx,
  1296. float x, float y, float w, float h, BNDwidgetState state,
  1297. const char *label) {
  1298. float ox, oy;
  1299. NVGcolor shade_top, shade_down;
  1300. ox = x;
  1301. oy = y+h-BND_OPTION_HEIGHT-3;
  1302. bndBevelInset(ctx,ox,oy,
  1303. BND_OPTION_WIDTH,BND_OPTION_HEIGHT,
  1304. BND_OPTION_RADIUS,BND_OPTION_RADIUS);
  1305. bndInnerColors(&shade_top, &shade_down, &bnd_theme.optionTheme, state, 1);
  1306. bndInnerBox(ctx,ox,oy,
  1307. BND_OPTION_WIDTH,BND_OPTION_HEIGHT,
  1308. BND_OPTION_RADIUS,BND_OPTION_RADIUS,BND_OPTION_RADIUS,BND_OPTION_RADIUS,
  1309. shade_top, shade_down);
  1310. bndOutlineBox(ctx,ox,oy,
  1311. BND_OPTION_WIDTH,BND_OPTION_HEIGHT,
  1312. BND_OPTION_RADIUS,BND_OPTION_RADIUS,BND_OPTION_RADIUS,BND_OPTION_RADIUS,
  1313. bndTransparent(bnd_theme.optionTheme.outlineColor));
  1314. if (state == BND_ACTIVE) {
  1315. bndCheck(ctx,ox,oy, bndTransparent(bnd_theme.optionTheme.itemColor));
  1316. }
  1317. bndIconLabelValue(ctx,x+12,y,w-12,h,-1,
  1318. bndTextColor(&bnd_theme.optionTheme, state), BND_LEFT,
  1319. BND_LABEL_FONT_SIZE, label, NULL);
  1320. }
  1321. void bndChoiceButton(NVGcontext *ctx,
  1322. float x, float y, float w, float h, int flags, BNDwidgetState state,
  1323. int iconid, const char *label) {
  1324. float cr[4];
  1325. NVGcolor shade_top, shade_down;
  1326. bndSelectCorners(cr, BND_OPTION_RADIUS, flags);
  1327. bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
  1328. bndInnerColors(&shade_top, &shade_down, &bnd_theme.choiceTheme, state, 1);
  1329. bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
  1330. bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
  1331. bndTransparent(bnd_theme.choiceTheme.outlineColor));
  1332. bndIconLabelValue(ctx,x,y,w,h,iconid,
  1333. bndTextColor(&bnd_theme.choiceTheme, state), BND_LEFT,
  1334. BND_LABEL_FONT_SIZE, label, NULL);
  1335. bndUpDownArrow(ctx,x+w-10,y+10,5,
  1336. bndTransparent(bnd_theme.choiceTheme.itemColor));
  1337. }
  1338. void bndColorButton(NVGcontext *ctx,
  1339. float x, float y, float w, float h, int flags, NVGcolor color) {
  1340. float cr[4];
  1341. bndSelectCorners(cr, BND_TOOL_RADIUS, flags);
  1342. bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
  1343. bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], color, color);
  1344. bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
  1345. bndTransparent(bnd_theme.toolTheme.outlineColor));
  1346. }
  1347. void bndNumberField(NVGcontext *ctx,
  1348. float x, float y, float w, float h, int flags, BNDwidgetState state,
  1349. const char *label, const char *value) {
  1350. float cr[4];
  1351. NVGcolor shade_top, shade_down;
  1352. bndSelectCorners(cr, BND_NUMBER_RADIUS, flags);
  1353. bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
  1354. bndInnerColors(&shade_top, &shade_down, &bnd_theme.numberFieldTheme, state, 0);
  1355. bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
  1356. bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
  1357. bndTransparent(bnd_theme.numberFieldTheme.outlineColor));
  1358. bndIconLabelValue(ctx,x,y,w,h,-1,
  1359. bndTextColor(&bnd_theme.numberFieldTheme, state), BND_CENTER,
  1360. BND_LABEL_FONT_SIZE, label, value);
  1361. bndArrow(ctx,x+8,y+10,-BND_NUMBER_ARROW_SIZE,
  1362. bndTransparent(bnd_theme.numberFieldTheme.itemColor));
  1363. bndArrow(ctx,x+w-8,y+10,BND_NUMBER_ARROW_SIZE,
  1364. bndTransparent(bnd_theme.numberFieldTheme.itemColor));
  1365. }
  1366. void bndSlider(NVGcontext *ctx,
  1367. float x, float y, float w, float h, int flags, BNDwidgetState state,
  1368. float progress, const char *label, const char *value) {
  1369. float cr[4];
  1370. NVGcolor shade_top, shade_down;
  1371. bndSelectCorners(cr, BND_NUMBER_RADIUS, flags);
  1372. bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
  1373. bndInnerColors(&shade_top, &shade_down, &bnd_theme.sliderTheme, state, 0);
  1374. bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
  1375. if (state == BND_ACTIVE) {
  1376. shade_top = bndOffsetColor(
  1377. bnd_theme.sliderTheme.itemColor, bnd_theme.sliderTheme.shadeTop);
  1378. shade_down = bndOffsetColor(
  1379. bnd_theme.sliderTheme.itemColor, bnd_theme.sliderTheme.shadeDown);
  1380. } else {
  1381. shade_top = bndOffsetColor(
  1382. bnd_theme.sliderTheme.itemColor, bnd_theme.sliderTheme.shadeDown);
  1383. shade_down = bndOffsetColor(
  1384. bnd_theme.sliderTheme.itemColor, bnd_theme.sliderTheme.shadeTop);
  1385. }
  1386. nvgScissor(ctx,x,y,8+(w-8)*bnd_clamp(progress,0,1),h);
  1387. bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
  1388. nvgResetScissor(ctx);
  1389. bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
  1390. bndTransparent(bnd_theme.sliderTheme.outlineColor));
  1391. bndIconLabelValue(ctx,x,y,w,h,-1,
  1392. bndTextColor(&bnd_theme.sliderTheme, state), BND_CENTER,
  1393. BND_LABEL_FONT_SIZE, label, value);
  1394. }
  1395. void bndScrollBar(NVGcontext *ctx,
  1396. float x, float y, float w, float h, BNDwidgetState state,
  1397. float offset, float size) {
  1398. bndBevelInset(ctx,x,y,w,h,
  1399. BND_SCROLLBAR_RADIUS, BND_SCROLLBAR_RADIUS);
  1400. bndInnerBox(ctx,x,y,w,h,
  1401. BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
  1402. BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
  1403. bndOffsetColor(
  1404. bnd_theme.scrollBarTheme.innerColor, 3*bnd_theme.scrollBarTheme.shadeDown),
  1405. bndOffsetColor(
  1406. bnd_theme.scrollBarTheme.innerColor, 3*bnd_theme.scrollBarTheme.shadeTop));
  1407. bndOutlineBox(ctx,x,y,w,h,
  1408. BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
  1409. BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
  1410. bndTransparent(bnd_theme.scrollBarTheme.outlineColor));
  1411. NVGcolor itemColor = bndOffsetColor(
  1412. bnd_theme.scrollBarTheme.itemColor,
  1413. (state == BND_ACTIVE)?BND_SCROLLBAR_ACTIVE_SHADE:0);
  1414. bndScrollHandleRect(&x,&y,&w,&h,offset,size);
  1415. bndInnerBox(ctx,x,y,w,h,
  1416. BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
  1417. BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
  1418. bndOffsetColor(
  1419. itemColor, 3*bnd_theme.scrollBarTheme.shadeTop),
  1420. bndOffsetColor(
  1421. itemColor, 3*bnd_theme.scrollBarTheme.shadeDown));
  1422. bndOutlineBox(ctx,x,y,w,h,
  1423. BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
  1424. BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
  1425. bndTransparent(bnd_theme.scrollBarTheme.outlineColor));
  1426. }
  1427. void bndMenuBackground(NVGcontext *ctx,
  1428. float x, float y, float w, float h, int flags) {
  1429. float cr[4];
  1430. NVGcolor shade_top, shade_down;
  1431. bndSelectCorners(cr, BND_MENU_RADIUS, flags);
  1432. bndInnerColors(&shade_top, &shade_down, &bnd_theme.menuTheme,
  1433. BND_DEFAULT, 0);
  1434. bndInnerBox(ctx,x,y,w,h+1,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
  1435. bndOutlineBox(ctx,x,y,w,h+1,cr[0],cr[1],cr[2],cr[3],
  1436. bndTransparent(bnd_theme.menuTheme.outlineColor));
  1437. bndDropShadow(ctx,x,y,w,h,BND_MENU_RADIUS,
  1438. BND_SHADOW_FEATHER,BND_SHADOW_ALPHA);
  1439. }
  1440. void bndTooltipBackground(NVGcontext *ctx, float x, float y, float w, float h) {
  1441. NVGcolor shade_top, shade_down;
  1442. bndInnerColors(&shade_top, &shade_down, &bnd_theme.tooltipTheme,
  1443. BND_DEFAULT, 0);
  1444. bndInnerBox(ctx,x,y,w,h+1,
  1445. BND_MENU_RADIUS,BND_MENU_RADIUS,BND_MENU_RADIUS,BND_MENU_RADIUS,
  1446. shade_top, shade_down);
  1447. bndOutlineBox(ctx,x,y,w,h+1,
  1448. BND_MENU_RADIUS,BND_MENU_RADIUS,BND_MENU_RADIUS,BND_MENU_RADIUS,
  1449. bndTransparent(bnd_theme.tooltipTheme.outlineColor));
  1450. bndDropShadow(ctx,x,y,w,h,BND_MENU_RADIUS,
  1451. BND_SHADOW_FEATHER,BND_SHADOW_ALPHA);
  1452. }
  1453. void bndMenuLabel(NVGcontext *ctx,
  1454. float x, float y, float w, float h, int iconid, const char *label) {
  1455. bndIconLabelValue(ctx,x,y,w,h,iconid,
  1456. bnd_theme.menuTheme.textColor, BND_LEFT,
  1457. BND_LABEL_FONT_SIZE, label, NULL);
  1458. }
  1459. void bndMenuItem(NVGcontext *ctx,
  1460. float x, float y, float w, float h, BNDwidgetState state,
  1461. int iconid, const char *label) {
  1462. if (state != BND_DEFAULT) {
  1463. bndInnerBox(ctx,x,y,w,h,0,0,0,0,
  1464. bndOffsetColor(bnd_theme.menuItemTheme.innerSelectedColor,
  1465. bnd_theme.menuItemTheme.shadeTop),
  1466. bndOffsetColor(bnd_theme.menuItemTheme.innerSelectedColor,
  1467. bnd_theme.menuItemTheme.shadeDown));
  1468. state = BND_ACTIVE;
  1469. }
  1470. bndIconLabelValue(ctx,x,y,w,h,iconid,
  1471. bndTextColor(&bnd_theme.menuItemTheme, state), BND_LEFT,
  1472. BND_LABEL_FONT_SIZE, label, NULL);
  1473. }
  1474. void bndNodePort(NVGcontext *ctx, float x, float y, BNDwidgetState state,
  1475. NVGcolor color) {
  1476. nvgBeginPath(ctx);
  1477. nvgCircle(ctx, x, y, BND_NODE_PORT_RADIUS);
  1478. nvgStrokeColor(ctx,bnd_theme.nodeTheme.wiresColor);
  1479. nvgStrokeWidth(ctx,1.0f);
  1480. nvgStroke(ctx);
  1481. nvgFillColor(ctx,(state != BND_DEFAULT)?
  1482. bndOffsetColor(color, BND_HOVER_SHADE):color);
  1483. nvgFill(ctx);
  1484. }
  1485. void bndNodeWire(NVGcontext *ctx, float x0, float y0, float x1, float y1,
  1486. BNDwidgetState state0, BNDwidgetState state1) {
  1487. float delta = fabsf(x1 - x0)*(float)bnd_theme.nodeTheme.noodleCurving/10.0f;
  1488. nvgBeginPath(ctx);
  1489. nvgMoveTo(ctx, x0, y0);
  1490. nvgBezierTo(ctx,
  1491. x0 + delta, y0,
  1492. x1 - delta, y1,
  1493. x1, y1);
  1494. nvgStrokeColor(ctx, bnd_theme.nodeTheme.wiresColor);
  1495. nvgStrokeWidth(ctx, BND_NODE_WIRE_OUTLINE_WIDTH);
  1496. nvgStroke(ctx);
  1497. nvgStrokePaint(ctx, nvgLinearGradient(ctx,
  1498. x0, y0, x1, y1,
  1499. bndNodeWireColor(&bnd_theme.nodeTheme, state0),
  1500. bndNodeWireColor(&bnd_theme.nodeTheme, state1)));
  1501. nvgStrokeWidth(ctx,BND_NODE_WIRE_WIDTH);
  1502. nvgStroke(ctx);
  1503. }
  1504. void bndNodeBackground(NVGcontext *ctx, float x, float y, float w, float h,
  1505. BNDwidgetState state, int iconid, const char *label, NVGcolor titleColor) {
  1506. bndInnerBox(ctx,x,y,w,BND_NODE_TITLE_HEIGHT+2,
  1507. BND_NODE_RADIUS,BND_NODE_RADIUS,0,0,
  1508. bndTransparent(bndOffsetColor(titleColor, BND_BEVEL_SHADE)),
  1509. bndTransparent(titleColor));
  1510. bndInnerBox(ctx,x,y+BND_NODE_TITLE_HEIGHT-1,w,h+2-BND_NODE_TITLE_HEIGHT,
  1511. 0,0,BND_NODE_RADIUS,BND_NODE_RADIUS,
  1512. bndTransparent(bnd_theme.nodeTheme.nodeBackdropColor),
  1513. bndTransparent(bnd_theme.nodeTheme.nodeBackdropColor));
  1514. bndNodeIconLabel(ctx,
  1515. x+BND_NODE_ARROW_AREA_WIDTH,y,
  1516. w-BND_NODE_ARROW_AREA_WIDTH-BND_NODE_MARGIN_SIDE,BND_NODE_TITLE_HEIGHT,
  1517. iconid, bnd_theme.regularTheme.textColor,
  1518. bndOffsetColor(titleColor, BND_BEVEL_SHADE),
  1519. BND_LEFT, BND_LABEL_FONT_SIZE, label);
  1520. NVGcolor arrowColor;
  1521. NVGcolor borderColor;
  1522. switch(state) {
  1523. default:
  1524. case BND_DEFAULT: {
  1525. borderColor = nvgRGBf(0,0,0);
  1526. arrowColor = bndOffsetColor(titleColor, -BND_BEVEL_SHADE);
  1527. } break;
  1528. case BND_HOVER: {
  1529. borderColor = bnd_theme.nodeTheme.nodeSelectedColor;
  1530. arrowColor = bnd_theme.nodeTheme.nodeSelectedColor;
  1531. } break;
  1532. case BND_ACTIVE: {
  1533. borderColor = bnd_theme.nodeTheme.activeNodeColor;
  1534. arrowColor = bnd_theme.nodeTheme.nodeSelectedColor;
  1535. } break;
  1536. }
  1537. bndOutlineBox(ctx,x,y,w,h+1,
  1538. BND_NODE_RADIUS,BND_NODE_RADIUS,BND_NODE_RADIUS,BND_NODE_RADIUS,
  1539. bndTransparent(borderColor));
  1540. bndNodeArrowDown(ctx,
  1541. x + BND_NODE_MARGIN_SIDE, y + BND_NODE_TITLE_HEIGHT-4,
  1542. BND_NODE_ARROW_SIZE, arrowColor);
  1543. bndDropShadow(ctx,x,y,w,h,BND_NODE_RADIUS,
  1544. BND_SHADOW_FEATHER,BND_SHADOW_ALPHA);
  1545. }
  1546. void bndSplitterWidgets(NVGcontext *ctx, float x, float y, float w, float h) {
  1547. NVGcolor insetLight = bndTransparent(
  1548. bndOffsetColor(bnd_theme.backgroundColor, BND_SPLITTER_SHADE));
  1549. NVGcolor insetDark = bndTransparent(
  1550. bndOffsetColor(bnd_theme.backgroundColor, -BND_SPLITTER_SHADE));
  1551. NVGcolor inset = bndTransparent(bnd_theme.backgroundColor);
  1552. float x2 = x+w;
  1553. float y2 = y+h;
  1554. nvgBeginPath(ctx);
  1555. nvgMoveTo(ctx, x, y2-13);
  1556. nvgLineTo(ctx, x+13, y2);
  1557. nvgMoveTo(ctx, x, y2-9);
  1558. nvgLineTo(ctx, x+9, y2);
  1559. nvgMoveTo(ctx, x, y2-5);
  1560. nvgLineTo(ctx, x+5, y2);
  1561. nvgMoveTo(ctx, x2-11, y);
  1562. nvgLineTo(ctx, x2, y+11);
  1563. nvgMoveTo(ctx, x2-7, y);
  1564. nvgLineTo(ctx, x2, y+7);
  1565. nvgMoveTo(ctx, x2-3, y);
  1566. nvgLineTo(ctx, x2, y+3);
  1567. nvgStrokeColor(ctx, insetDark);
  1568. nvgStroke(ctx);
  1569. nvgBeginPath(ctx);
  1570. nvgMoveTo(ctx, x, y2-11);
  1571. nvgLineTo(ctx, x+11, y2);
  1572. nvgMoveTo(ctx, x, y2-7);
  1573. nvgLineTo(ctx, x+7, y2);
  1574. nvgMoveTo(ctx, x, y2-3);
  1575. nvgLineTo(ctx, x+3, y2);
  1576. nvgMoveTo(ctx, x2-13, y);
  1577. nvgLineTo(ctx, x2, y+13);
  1578. nvgMoveTo(ctx, x2-9, y);
  1579. nvgLineTo(ctx, x2, y+9);
  1580. nvgMoveTo(ctx, x2-5, y);
  1581. nvgLineTo(ctx, x2, y+5);
  1582. nvgStrokeColor(ctx, insetLight);
  1583. nvgStroke(ctx);
  1584. nvgBeginPath(ctx);
  1585. nvgMoveTo(ctx, x, y2-12);
  1586. nvgLineTo(ctx, x+12, y2);
  1587. nvgMoveTo(ctx, x, y2-8);
  1588. nvgLineTo(ctx, x+8, y2);
  1589. nvgMoveTo(ctx, x, y2-4);
  1590. nvgLineTo(ctx, x+4, y2);
  1591. nvgMoveTo(ctx, x2-12, y);
  1592. nvgLineTo(ctx, x2, y+12);
  1593. nvgMoveTo(ctx, x2-8, y);
  1594. nvgLineTo(ctx, x2, y+8);
  1595. nvgMoveTo(ctx, x2-4, y);
  1596. nvgLineTo(ctx, x2, y+4);
  1597. nvgStrokeColor(ctx, inset);
  1598. nvgStroke(ctx);
  1599. }
  1600. void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h,
  1601. int vertical, int mirror) {
  1602. if (vertical) {
  1603. float u = w;
  1604. w = h; h = u;
  1605. }
  1606. float s = (w<h)?w:h;
  1607. float x0,y0,x1,y1;
  1608. if (mirror) {
  1609. x0 = w;
  1610. y0 = h;
  1611. x1 = 0;
  1612. y1 = 0;
  1613. s = -s;
  1614. } else {
  1615. x0 = 0;
  1616. y0 = 0;
  1617. x1 = w;
  1618. y1 = h;
  1619. }
  1620. float yc = (y0+y1)*0.5f;
  1621. float s2 = s/2.0f;
  1622. float s4 = s/4.0f;
  1623. float s8 = s/8.0f;
  1624. float x4 = x0+s4;
  1625. float points[][2] = {
  1626. { x0,y0 },
  1627. { x1,y0 },
  1628. { x1,y1 },
  1629. { x0,y1 },
  1630. { x0,yc+s8 },
  1631. { x4,yc+s8 },
  1632. { x4,yc+s4 },
  1633. { x0+s2,yc },
  1634. { x4,yc-s4 },
  1635. { x4,yc-s8 },
  1636. { x0,yc-s8 }
  1637. };
  1638. nvgBeginPath(ctx);
  1639. int count = sizeof(points) / (sizeof(float)*2);
  1640. nvgMoveTo(ctx,x+points[0][vertical&1],y+points[0][(vertical&1)^1]);
  1641. for (int i = 1; i < count; ++i) {
  1642. nvgLineTo(ctx,x+points[i][vertical&1],y+points[i][(vertical&1)^1]);
  1643. }
  1644. nvgFillColor(ctx, nvgRGBAf(0,0,0,0.3));
  1645. nvgFill(ctx);
  1646. }
  1647. ////////////////////////////////////////////////////////////////////////////////
  1648. float bndLabelWidth(NVGcontext *ctx, int iconid, const char *label) {
  1649. int w = BND_PAD_LEFT + BND_PAD_RIGHT;
  1650. if (iconid >= 0) {
  1651. w += BND_ICON_SHEET_RES;
  1652. }
  1653. if (label && (bnd_font >= 0)) {
  1654. nvgFontFaceId(ctx, bnd_font);
  1655. nvgFontSize(ctx, BND_LABEL_FONT_SIZE);
  1656. w += nvgTextBounds(ctx, 1, 1, label, NULL, NULL);
  1657. }
  1658. return w;
  1659. }
  1660. float bndLabelHeight(NVGcontext *ctx, int iconid, const char *label, float width) {
  1661. int h = BND_WIDGET_HEIGHT;
  1662. width -= BND_TEXT_RADIUS*2;
  1663. if (iconid >= 0) {
  1664. width -= BND_ICON_SHEET_RES;
  1665. }
  1666. if (label && (bnd_font >= 0)) {
  1667. nvgFontFaceId(ctx, bnd_font);
  1668. nvgFontSize(ctx, BND_LABEL_FONT_SIZE);
  1669. float bounds[4];
  1670. nvgTextBoxBounds(ctx, 1, 1, width, label, NULL, bounds);
  1671. int bh = int(bounds[3] - bounds[1]) + BND_TEXT_PAD_DOWN;
  1672. if (bh > h)
  1673. h = bh;
  1674. }
  1675. return h;
  1676. }
  1677. ////////////////////////////////////////////////////////////////////////////////
  1678. void bndRoundedBox(NVGcontext *ctx, float x, float y, float w, float h,
  1679. float cr0, float cr1, float cr2, float cr3) {
  1680. float d;
  1681. w = bnd_fmaxf(0, w);
  1682. h = bnd_fmaxf(0, h);
  1683. d = bnd_fminf(w, h);
  1684. nvgMoveTo(ctx, x,y+h*0.5f);
  1685. nvgArcTo(ctx, x,y, x+w,y, bnd_fminf(cr0, d/2));
  1686. nvgArcTo(ctx, x+w,y, x+w,y+h, bnd_fminf(cr1, d/2));
  1687. nvgArcTo(ctx, x+w,y+h, x,y+h, bnd_fminf(cr2, d/2));
  1688. nvgArcTo(ctx, x,y+h, x,y, bnd_fminf(cr3, d/2));
  1689. nvgClosePath(ctx);
  1690. }
  1691. NVGcolor bndTransparent(NVGcolor color) {
  1692. color.a *= BND_TRANSPARENT_ALPHA;
  1693. return color;
  1694. }
  1695. NVGcolor bndOffsetColor(NVGcolor color, int delta) {
  1696. float offset = (float)delta / 255.0f;
  1697. return delta?(
  1698. nvgRGBAf(
  1699. bnd_clamp(color.r+offset,0,1),
  1700. bnd_clamp(color.g+offset,0,1),
  1701. bnd_clamp(color.b+offset,0,1),
  1702. color.a)
  1703. ):color;
  1704. }
  1705. void bndBevel(NVGcontext *ctx, float x, float y, float w, float h) {
  1706. nvgStrokeWidth(ctx, 1);
  1707. x += 0.5f;
  1708. y += 0.5f;
  1709. w -= 1;
  1710. h -= 1;
  1711. nvgBeginPath(ctx);
  1712. nvgMoveTo(ctx, x, y+h);
  1713. nvgLineTo(ctx, x+w, y+h);
  1714. nvgLineTo(ctx, x+w, y);
  1715. nvgStrokeColor(ctx, bndTransparent(
  1716. bndOffsetColor(bnd_theme.backgroundColor, -BND_BEVEL_SHADE)));
  1717. nvgStroke(ctx);
  1718. nvgBeginPath(ctx);
  1719. nvgMoveTo(ctx, x, y+h);
  1720. nvgLineTo(ctx, x, y);
  1721. nvgLineTo(ctx, x+w, y);
  1722. nvgStrokeColor(ctx, bndTransparent(
  1723. bndOffsetColor(bnd_theme.backgroundColor, BND_BEVEL_SHADE)));
  1724. nvgStroke(ctx);
  1725. }
  1726. void bndBevelInset(NVGcontext *ctx, float x, float y, float w, float h,
  1727. float cr2, float cr3) {
  1728. float d;
  1729. y -= 0.5f;
  1730. d = bnd_fminf(w, h);
  1731. cr2 = bnd_fminf(cr2, d/2);
  1732. cr3 = bnd_fminf(cr3, d/2);
  1733. nvgBeginPath(ctx);
  1734. nvgMoveTo(ctx, x+w,y+h-cr2);
  1735. nvgArcTo(ctx, x+w,y+h, x,y+h, cr2);
  1736. nvgArcTo(ctx, x,y+h, x,y, cr3);
  1737. NVGcolor bevelColor = bndOffsetColor(bnd_theme.backgroundColor,
  1738. BND_INSET_BEVEL_SHADE);
  1739. nvgStrokeWidth(ctx, 1);
  1740. nvgStrokePaint(ctx,
  1741. nvgLinearGradient(ctx,
  1742. x,y+h-bnd_fmaxf(cr2,cr3)-1,
  1743. x,y+h-1,
  1744. nvgRGBAf(bevelColor.r, bevelColor.g, bevelColor.b, 0),
  1745. bevelColor));
  1746. nvgStroke(ctx);
  1747. }
  1748. void bndBackground(NVGcontext *ctx, float x, float y, float w, float h) {
  1749. nvgBeginPath(ctx);
  1750. nvgRect(ctx, x, y, w, h);
  1751. nvgFillColor(ctx, bnd_theme.backgroundColor);
  1752. nvgFill(ctx);
  1753. }
  1754. void bndIcon(NVGcontext *ctx, float x, float y, int iconid) {
  1755. int ix, iy, u, v;
  1756. if (bnd_icon_image < 0) return; // no icons loaded
  1757. ix = iconid & 0xff;
  1758. iy = (iconid>>8) & 0xff;
  1759. u = BND_ICON_SHEET_OFFSET_X + ix*BND_ICON_SHEET_GRID;
  1760. v = BND_ICON_SHEET_OFFSET_Y + iy*BND_ICON_SHEET_GRID;
  1761. nvgBeginPath(ctx);
  1762. nvgRect(ctx,x,y,BND_ICON_SHEET_RES,BND_ICON_SHEET_RES);
  1763. nvgFillPaint(ctx,
  1764. nvgImagePattern(ctx,x-u,y-v,
  1765. BND_ICON_SHEET_WIDTH,
  1766. BND_ICON_SHEET_HEIGHT,
  1767. 0,bnd_icon_image,1));
  1768. nvgFill(ctx);
  1769. }
  1770. void bndDropShadow(NVGcontext *ctx, float x, float y, float w, float h,
  1771. float r, float feather, float alpha) {
  1772. nvgBeginPath(ctx);
  1773. y += feather;
  1774. h -= feather;
  1775. nvgMoveTo(ctx, x-feather, y-feather);
  1776. nvgLineTo(ctx, x, y-feather);
  1777. nvgLineTo(ctx, x, y+h-feather);
  1778. nvgArcTo(ctx, x,y+h,x+r,y+h,r);
  1779. nvgArcTo(ctx, x+w,y+h,x+w,y+h-r,r);
  1780. nvgLineTo(ctx, x+w, y-feather);
  1781. nvgLineTo(ctx, x+w+feather, y-feather);
  1782. nvgLineTo(ctx, x+w+feather, y+h+feather);
  1783. nvgLineTo(ctx, x-feather, y+h+feather);
  1784. nvgClosePath(ctx);
  1785. nvgFillPaint(ctx, nvgBoxGradient(ctx,
  1786. x - feather*0.5f,y - feather*0.5f,
  1787. w + feather,h+feather,
  1788. r+feather*0.5f,
  1789. feather,
  1790. nvgRGBAf(0,0,0,alpha*alpha),
  1791. nvgRGBAf(0,0,0,0)));
  1792. nvgFill(ctx);
  1793. }
  1794. void bndInnerBox(NVGcontext *ctx, float x, float y, float w, float h,
  1795. float cr0, float cr1, float cr2, float cr3,
  1796. NVGcolor shade_top, NVGcolor shade_down) {
  1797. nvgBeginPath(ctx);
  1798. bndRoundedBox(ctx,x+1,y+1,w-2,h-3,bnd_fmaxf(0,cr0-1),
  1799. bnd_fmaxf(0,cr1-1),bnd_fmaxf(0,cr2-1),bnd_fmaxf(0,cr3-1));
  1800. nvgFillPaint(ctx,((h-2)>w)?
  1801. nvgLinearGradient(ctx,x,y,x+w,y,shade_top,shade_down):
  1802. nvgLinearGradient(ctx,x,y,x,y+h,shade_top,shade_down));
  1803. nvgFill(ctx);
  1804. }
  1805. void bndOutlineBox(NVGcontext *ctx, float x, float y, float w, float h,
  1806. float cr0, float cr1, float cr2, float cr3, NVGcolor color) {
  1807. nvgBeginPath(ctx);
  1808. bndRoundedBox(ctx,x+0.5f,y+0.5f,w-1,h-2,cr0,cr1,cr2,cr3);
  1809. nvgStrokeColor(ctx,color);
  1810. nvgStrokeWidth(ctx,1);
  1811. nvgStroke(ctx);
  1812. }
  1813. void bndSelectCorners(float *radiuses, float r, int flags) {
  1814. radiuses[0] = (flags & BND_CORNER_TOP_LEFT)?0:r;
  1815. radiuses[1] = (flags & BND_CORNER_TOP_RIGHT)?0:r;
  1816. radiuses[2] = (flags & BND_CORNER_DOWN_RIGHT)?0:r;
  1817. radiuses[3] = (flags & BND_CORNER_DOWN_LEFT)?0:r;
  1818. }
  1819. void bndInnerColors(
  1820. NVGcolor *shade_top, NVGcolor *shade_down,
  1821. const BNDwidgetTheme *theme, BNDwidgetState state, int flipActive) {
  1822. switch(state) {
  1823. default:
  1824. case BND_DEFAULT: {
  1825. *shade_top = bndOffsetColor(theme->innerColor, theme->shadeTop);
  1826. *shade_down = bndOffsetColor(theme->innerColor, theme->shadeDown);
  1827. } break;
  1828. case BND_HOVER: {
  1829. NVGcolor color = bndOffsetColor(theme->innerColor, BND_HOVER_SHADE);
  1830. *shade_top = bndOffsetColor(color, theme->shadeTop);
  1831. *shade_down = bndOffsetColor(color, theme->shadeDown);
  1832. } break;
  1833. case BND_ACTIVE: {
  1834. *shade_top = bndOffsetColor(theme->innerSelectedColor,
  1835. flipActive?theme->shadeDown:theme->shadeTop);
  1836. *shade_down = bndOffsetColor(theme->innerSelectedColor,
  1837. flipActive?theme->shadeTop:theme->shadeDown);
  1838. } break;
  1839. }
  1840. }
  1841. NVGcolor bndTextColor(const BNDwidgetTheme *theme, BNDwidgetState state) {
  1842. return (state == BND_ACTIVE)?theme->textSelectedColor:theme->textColor;
  1843. }
  1844. void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h,
  1845. int iconid, NVGcolor color, int align, float fontsize, const char *label,
  1846. const char *value) {
  1847. float pleft = BND_PAD_LEFT;
  1848. if (label) {
  1849. if (iconid >= 0) {
  1850. bndIcon(ctx,x+4,y+2,iconid);
  1851. pleft += BND_ICON_SHEET_RES;
  1852. }
  1853. if (bnd_font < 0) return;
  1854. nvgFontFaceId(ctx, bnd_font);
  1855. nvgFontSize(ctx, fontsize);
  1856. nvgBeginPath(ctx);
  1857. nvgFillColor(ctx, color);
  1858. if (value) {
  1859. float label_width = nvgTextBounds(ctx, 1, 1, label, NULL, NULL);
  1860. float sep_width = nvgTextBounds(ctx, 1, 1,
  1861. BND_LABEL_SEPARATOR, NULL, NULL);
  1862. nvgTextAlign(ctx, NVG_ALIGN_LEFT|NVG_ALIGN_BASELINE);
  1863. x += pleft;
  1864. if (align == BND_CENTER) {
  1865. float width = label_width + sep_width
  1866. + nvgTextBounds(ctx, 1, 1, value, NULL, NULL);
  1867. x += ((w-BND_PAD_RIGHT-pleft)-width)*0.5f;
  1868. }
  1869. y += h-BND_TEXT_PAD_DOWN;
  1870. nvgText(ctx, x, y, label, NULL);
  1871. x += label_width;
  1872. nvgText(ctx, x, y, BND_LABEL_SEPARATOR, NULL);
  1873. x += sep_width;
  1874. nvgText(ctx, x, y, value, NULL);
  1875. } else {
  1876. nvgTextAlign(ctx,
  1877. (align==BND_LEFT)?(NVG_ALIGN_LEFT|NVG_ALIGN_BASELINE):
  1878. (NVG_ALIGN_CENTER|NVG_ALIGN_BASELINE));
  1879. nvgTextBox(ctx,x+pleft,y+h-BND_TEXT_PAD_DOWN,
  1880. w-BND_PAD_RIGHT-pleft,label, NULL);
  1881. }
  1882. } else if (iconid >= 0) {
  1883. bndIcon(ctx,x+2,y+2,iconid);
  1884. }
  1885. }
  1886. void bndNodeIconLabel(NVGcontext *ctx, float x, float y, float w, float h,
  1887. int iconid, NVGcolor color, NVGcolor shadowColor,
  1888. int align, float fontsize, const char *label) {
  1889. if (label && (bnd_font >= 0)) {
  1890. nvgFontFaceId(ctx, bnd_font);
  1891. nvgFontSize(ctx, fontsize);
  1892. nvgBeginPath(ctx);
  1893. nvgTextAlign(ctx, NVG_ALIGN_LEFT|NVG_ALIGN_BASELINE);
  1894. nvgFillColor(ctx, shadowColor);
  1895. nvgFontBlur(ctx, BND_NODE_TITLE_FEATHER);
  1896. nvgTextBox(ctx,x+1,y+h+3-BND_TEXT_PAD_DOWN,
  1897. w,label, NULL);
  1898. nvgFillColor(ctx, color);
  1899. nvgFontBlur(ctx, 0);
  1900. nvgTextBox(ctx,x,y+h+2-BND_TEXT_PAD_DOWN,
  1901. w,label, NULL);
  1902. }
  1903. if (iconid >= 0) {
  1904. bndIcon(ctx,x+w-BND_ICON_SHEET_RES,y+3,iconid);
  1905. }
  1906. }
  1907. void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h,
  1908. int iconid, NVGcolor color, float fontsize, const char *label,
  1909. NVGcolor caretcolor, int cbegin, int cend) {
  1910. float bounds[4];
  1911. float pleft = BND_TEXT_RADIUS;
  1912. if (!label) return;
  1913. if (iconid >= 0) {
  1914. bndIcon(ctx,x+4,y+2,iconid);
  1915. pleft += BND_ICON_SHEET_RES;
  1916. }
  1917. if (bnd_font < 0) return;
  1918. x+=pleft;
  1919. y+=BND_WIDGET_HEIGHT-BND_TEXT_PAD_DOWN;
  1920. nvgFontFaceId(ctx, bnd_font);
  1921. nvgFontSize(ctx, fontsize);
  1922. nvgTextAlign(ctx, NVG_ALIGN_LEFT|NVG_ALIGN_BASELINE);
  1923. w -= BND_TEXT_RADIUS+pleft;
  1924. if (cend >= cbegin) {
  1925. #if 1
  1926. float c0,c1;
  1927. const char *cb;const char *ce;
  1928. static NVGglyphPosition glyphs[BND_MAX_GLYPHS];
  1929. int nglyphs = nvgTextGlyphPositions(
  1930. ctx, x, y, label, label+cend+1, glyphs, BND_MAX_GLYPHS);
  1931. c0=glyphs[0].x;
  1932. c1=glyphs[nglyphs-1].x;
  1933. cb = label+cbegin; ce = label+cend;
  1934. // TODO: this is slow
  1935. for (int i=0; i < nglyphs; ++i) {
  1936. if (glyphs[i].str == cb)
  1937. c0 = glyphs[i].x;
  1938. if (glyphs[i].str == ce)
  1939. c1 = glyphs[i].x;
  1940. }
  1941. nvgTextBounds(ctx,x,y,label,NULL, bounds);
  1942. nvgBeginPath(ctx);
  1943. if (cbegin == cend) {
  1944. nvgFillColor(ctx, nvgRGBf(0.337,0.502,0.761));
  1945. nvgRect(ctx, c0-1, bounds[1], 2, bounds[3]-bounds[1]);
  1946. } else {
  1947. nvgFillColor(ctx, caretcolor);
  1948. nvgRect(ctx, c0-1, bounds[1], c1-c0+1, bounds[3]-bounds[1]);
  1949. }
  1950. nvgFill(ctx);
  1951. #else
  1952. float c0,c1;
  1953. const char *cb;
  1954. const char *ce;
  1955. const char *line;
  1956. int numlines;
  1957. cb = label+cbegin; ce = label+cend;
  1958. line = label;
  1959. NVGtextRow rows[2];
  1960. numlines = nvgTextBreakLines(ctx, line, NULL, w, rows, 2);
  1961. /*
  1962. int nglyphs = nvgTextGlyphPositions(
  1963. ctx, x, y, label, label+cend+1, glyphs, BND_MAX_GLYPHS);
  1964. c0=glyphs[0].x;
  1965. c1=glyphs[nglyphs-1].x;
  1966. // TODO: this is slow
  1967. for (int i=0; i < nglyphs; ++i) {
  1968. if (glyphs[i].str == cb)
  1969. c0 = glyphs[i].x;
  1970. if (glyphs[i].str == ce)
  1971. c1 = glyphs[i].x;
  1972. }
  1973. nvgTextBounds(ctx,x,y,label,NULL, bounds);
  1974. nvgBeginPath(ctx);
  1975. if (cbegin == cend) {
  1976. nvgFillColor(ctx, nvgRGBf(0.337,0.502,0.761));
  1977. nvgRect(ctx, c0-1, bounds[1], 2, bounds[3]-bounds[1]);
  1978. } else {
  1979. nvgFillColor(ctx, caretcolor);
  1980. nvgRect(ctx, c0-1, bounds[1], c1-c0+1, bounds[3]-bounds[1]);
  1981. }
  1982. nvgFill(ctx);
  1983. */
  1984. #endif
  1985. }
  1986. nvgBeginPath(ctx);
  1987. nvgFillColor(ctx, color);
  1988. nvgTextBox(ctx,x,y,w,label, NULL);
  1989. }
  1990. void bndCheck(NVGcontext *ctx, float ox, float oy, NVGcolor color) {
  1991. nvgBeginPath(ctx);
  1992. nvgStrokeWidth(ctx,2);
  1993. nvgStrokeColor(ctx,color);
  1994. nvgLineCap(ctx,NVG_BUTT);
  1995. nvgLineJoin(ctx,NVG_MITER);
  1996. nvgMoveTo(ctx,ox+4,oy+5);
  1997. nvgLineTo(ctx,ox+7,oy+8);
  1998. nvgLineTo(ctx,ox+14,oy+1);
  1999. nvgStroke(ctx);
  2000. }
  2001. void bndArrow(NVGcontext *ctx, float x, float y, float s, NVGcolor color) {
  2002. nvgBeginPath(ctx);
  2003. nvgMoveTo(ctx,x,y);
  2004. nvgLineTo(ctx,x-s,y+s);
  2005. nvgLineTo(ctx,x-s,y-s);
  2006. nvgClosePath(ctx);
  2007. nvgFillColor(ctx,color);
  2008. nvgFill(ctx);
  2009. }
  2010. void bndUpDownArrow(NVGcontext *ctx, float x, float y, float s, NVGcolor color) {
  2011. float w;
  2012. nvgBeginPath(ctx);
  2013. w = 1.1f*s;
  2014. nvgMoveTo(ctx,x,y-1);
  2015. nvgLineTo(ctx,x+0.5*w,y-s-1);
  2016. nvgLineTo(ctx,x+w,y-1);
  2017. nvgClosePath(ctx);
  2018. nvgMoveTo(ctx,x,y+1);
  2019. nvgLineTo(ctx,x+0.5*w,y+s+1);
  2020. nvgLineTo(ctx,x+w,y+1);
  2021. nvgClosePath(ctx);
  2022. nvgFillColor(ctx,color);
  2023. nvgFill(ctx);
  2024. }
  2025. void bndNodeArrowDown(NVGcontext *ctx, float x, float y, float s, NVGcolor color) {
  2026. float w;
  2027. nvgBeginPath(ctx);
  2028. w = 1.0f*s;
  2029. nvgMoveTo(ctx,x,y);
  2030. nvgLineTo(ctx,x+0.5*w,y-s);
  2031. nvgLineTo(ctx,x-0.5*w,y-s);
  2032. nvgClosePath(ctx);
  2033. nvgFillColor(ctx,color);
  2034. nvgFill(ctx);
  2035. }
  2036. void bndScrollHandleRect(float *x, float *y, float *w, float *h,
  2037. float offset, float size) {
  2038. size = bnd_clamp(size,0,1);
  2039. offset = bnd_clamp(offset,0,1);
  2040. if ((*h) > (*w)) {
  2041. float hs = bnd_fmaxf(size*(*h), (*w)+1);
  2042. *y = (*y) + ((*h)-hs)*offset;
  2043. *h = hs;
  2044. } else {
  2045. float ws = bnd_fmaxf(size*(*w), (*h)-1);
  2046. *x = (*x) + ((*w)-ws)*offset;
  2047. *w = ws;
  2048. }
  2049. }
  2050. NVGcolor bndNodeWireColor(const BNDnodeTheme *theme, BNDwidgetState state) {
  2051. switch(state) {
  2052. default:
  2053. case BND_DEFAULT: return nvgRGBf(0.5f,0.5f,0.5f);
  2054. case BND_HOVER: return theme->wireSelectColor;
  2055. case BND_ACTIVE: return theme->activeNodeColor;
  2056. }
  2057. }
  2058. ////////////////////////////////////////////////////////////////////////////////
  2059. #ifdef BND_INLINE
  2060. #undef BND_INLINE
  2061. #endif
  2062. #endif // BLENDISH_IMPLEMENTATION