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.

2401 lines
85KB

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