blendish.h 86 KB

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