2 Blendish - Blender 2.5 UI based theming functions for NanoVega
4 Copyright (c) 2014 Leonard Ritter <leonard.ritter@duangle.com>
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 /* Invisible Vector Library
25 * ported by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
26 * Understanding is not required. Only obedience.
27 * yes, this D port is GPLed.
29 * This program is free software: you can redistribute it and/or modify
30 * it under the terms of the GNU General Public License as published by
31 * the Free Software Foundation, version 3 of the License ONLY.
33 * This program is distributed in the hope that it will be useful,
34 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 * GNU General Public License for more details.
38 * You should have received a copy of the GNU General Public License
39 * along with this program. If not, see <http://www.gnu.org/licenses/>.
43 Revision 6 (2014-09-21)
47 Blendish is a small collection of drawing functions for NanoVega, designed to
48 replicate the look of the Blender 2.5+ User Interface. You can use these
49 functions to theme your UI library. Several metric constants for faithful
50 reproduction are also included.
52 Blendish supports the original Blender icon sheet; As the licensing of Blenders
53 icons is unclear, they are not included in Blendishes repository, but a SVG
54 template, "icons_template.svg" is provided, which you can use to build your own
57 To use icons, you must first load the icon sheet using one of the
58 `nvgCreateImage*()` functions and then pass the image handle to `bndSetIconImage()`;
59 otherwise, no icons will be drawn. See `bndSetIconImage()` for more information.
61 Blendish will not render text until a suitable UI font has been passed to
62 `bndSetFont()` has been called. See `bndSetFont()` for more information.
67 There is no support for varying dpi resolutions yet. The library is hardcoded
68 to the equivalent of 72 dpi in the Blender system settings.
70 Support for label truncation is missing. Text rendering breaks when widgets are
71 too short to contain their labels.
73 module iv
.nanovega
.blendish
;
76 import iv
.nanovega
.nanovega
;
80 private alias usize
= size_t
;
82 private template Unqual(T
) {
83 static if (is(T U
== immutable U
)) alias Unqual
= U
;
84 else static if (is(T U
== shared inout const U
)) alias Unqual
= U
;
85 else static if (is(T U
== shared inout U
)) alias Unqual
= U
;
86 else static if (is(T U
== shared const U
)) alias Unqual
= U
;
87 else static if (is(T U
== shared U
)) alias Unqual
= U
;
88 else static if (is(T U
== inout const U
)) alias Unqual
= U
;
89 else static if (is(T U
== inout U
)) alias Unqual
= U
;
90 else static if (is(T U
== const U
)) alias Unqual
= U
;
91 else alias Unqual
= T
;
93 private template isAnyCharType(T
, bool unqual
=false) {
94 static if (unqual
) private alias UT
= Unqual
!T
; else private alias UT
= T
;
95 enum isAnyCharType
= is(UT
== char) ||
is(UT
== wchar) ||
is(UT
== dchar);
97 private template isWideCharType(T
, bool unqual
=false) {
98 static if (unqual
) private alias UT
= Unqual
!T
; else private alias UT
= T
;
99 enum isWideCharType
= is(UT
== wchar) ||
is(UT
== dchar);
103 nothrow @trusted @nogc:
106 /** describes the theme used to draw a single widget or widget box;
107 * these values correspond to the same values that can be retrieved from
108 * the Theme panel in the Blender preferences */
109 public struct BNDwidgetTheme
{
112 /// color of widget box outline
113 NVGColor outlineColor
;
114 /// color of widget item (meaning changes depending on class)
116 /// fill color of widget box
118 /// fill color of widget box when active
119 NVGColor innerSelectedColor
;
120 /// color of text label
122 /// color of text label when active
123 NVGColor textSelectedColor
;
124 /// delta modifier for upper part of gradient (-100 to 100)
126 /// delta modifier for lower part of gradient (-100 to 100)
128 /// color of hovered text (if transparent, use `textSelectedColor`)
129 NVGColor textHoverColor
;
130 /// color of caret for text field (if transparent, use `textColor`)
131 NVGColor textCaretColor
;
134 /// describes the theme used to draw nodes
135 public struct BNDnodeTheme
{
138 /// inner color of selected node (and downarrow)
139 NVGColor nodeSelectedColor
;
142 /// color of text label when active
143 NVGColor textSelectedColor
;
145 /// inner color of active node (and dragged wire)
146 NVGColor activeNodeColor
;
147 /// color of selected wire
148 NVGColor wireSelectColor
;
149 /// color of background of node
150 NVGColor nodeBackdropColor
;
152 /// how much a noodle curves (0 to 10)
156 /// describes the theme used to draw widgets
157 public struct BNDtheme
{
160 /// the background color of panels and windows
161 NVGColor backgroundColor
;
163 BNDwidgetTheme regularTheme
;
164 /// theme for tool buttons
165 BNDwidgetTheme toolTheme
;
166 /// theme for radio buttons
167 BNDwidgetTheme radioTheme
;
168 /// theme for text fields
169 BNDwidgetTheme textFieldTheme
;
170 /// theme for option buttons (checkboxes)
171 BNDwidgetTheme optionTheme
;
172 /// theme for choice buttons (comboboxes)
173 /// Blender calls them "menu buttons"
174 BNDwidgetTheme choiceTheme
;
175 /// theme for number fields
176 BNDwidgetTheme numberFieldTheme
;
177 /// theme for slider controls
178 BNDwidgetTheme sliderTheme
;
179 /// theme for scrollbars
180 BNDwidgetTheme scrollBarTheme
;
181 /// theme for tooltips
182 BNDwidgetTheme tooltipTheme
;
183 /// theme for menu backgrounds
184 BNDwidgetTheme menuTheme
;
185 /// theme for menu items
186 BNDwidgetTheme menuItemTheme
;
188 BNDnodeTheme nodeTheme
;
191 /// how text on a control is aligned
192 public alias BNDtextAlignment
= int;
193 /// how text on a control is aligned (values)
194 public enum /*BNDtextAlignment*/ : int {
195 BND_LEFT
= 0, /// left
196 BND_CENTER
, /// center
200 /// states altering the styling of a widget
201 public alias BNDwidgetState
= int;
202 /// states altering the styling of a widget (values)
203 public enum /*BNDwidgetState*/ : int {
206 /// the mouse is hovering over the control
208 /// the widget is activated (pressed) or in an active state (toggled)
212 /// flags indicating which corners are sharp (for grouping widgets)
213 public alias BNDcornerFlags
= int;
214 public enum /*BNDcornerFlags*/ : int {
215 /// all corners are round
217 /// sharp top left corner
218 BND_CORNER_TOP_LEFT
= 1,
219 /// sharp top right corner
220 BND_CORNER_TOP_RIGHT
= 2,
221 /// sharp bottom right corner
222 BND_CORNER_DOWN_RIGHT
= 4,
223 /// sharp bottom left corner
224 BND_CORNER_DOWN_LEFT
= 8,
225 /// all corners are sharp; you can invert a set of flags using ^= BND_CORNER_ALL
226 BND_CORNER_ALL
= 0xF,
227 /// top border is sharp
229 /// bottom border is sharp
230 BND_CORNER_DOWN
= 0xC,
231 /// left border is sharp
233 /// right border is sharp
234 BND_CORNER_RIGHT
= 6,
237 /** build an icon ID from two coordinates into the icon sheet, where
238 * (0, 0) designates the upper-leftmost icon, (1, 0) the one right next to it,
240 public enum BND_ICONID(int x
, int y
) = ((x
)|
((y
)<<8));
242 /// alpha of disabled widget groups; can be used in conjunction with nvgGlobalAlpha()
243 public __gshared
float BND_DISABLED_ALPHA
= 0.5;
246 /// default widget height
247 int BND_WIDGET_HEIGHT
= 21;
248 /// default toolbutton width (if icon only)
249 int BND_TOOL_WIDTH
= 20;
251 /// default radius of node ports
252 int BND_NODE_PORT_RADIUS
= 5;
253 /// top margin of node content
254 int BND_NODE_MARGIN_TOP
= 25;
255 /// bottom margin of node content
256 int BND_NODE_MARGIN_DOWN
= 5;
257 /// left and right margin of node content
258 int BND_NODE_MARGIN_SIDE
= 10;
259 /// height of node title bar
260 int BND_NODE_TITLE_HEIGHT
= 20;
261 /// width of node title arrow click area
262 int BND_NODE_ARROW_AREA_WIDTH
= 20;
264 /// size of splitter corner click area
265 int BND_SPLITTER_AREA_SIZE
= 12;
267 /// width of vertical scrollbar
268 int BND_SCROLLBAR_WIDTH
= 13;
269 /// height of horizontal scrollbar
270 int BND_SCROLLBAR_HEIGHT
= 14;
272 /// default vertical spacing
273 int BND_VSPACING
= 1;
274 /// default vertical spacing between groups
275 int BND_VSPACING_GROUP
= 8;
276 /// default horizontal spacing
277 int BND_HSPACING
= 8;
280 public alias BNDicon
= int;
281 public enum /*BNDicon*/ {
282 BND_ICON_NONE
= BND_ICONID
!(0, 29),
283 BND_ICON_QUESTION
= BND_ICONID
!(1, 29),
284 BND_ICON_ERROR
= BND_ICONID
!(2, 29),
285 BND_ICON_CANCEL
= BND_ICONID
!(3, 29),
286 BND_ICON_TRIA_RIGHT
= BND_ICONID
!(4, 29),
287 BND_ICON_TRIA_DOWN
= BND_ICONID
!(5, 29),
288 BND_ICON_TRIA_LEFT
= BND_ICONID
!(6, 29),
289 BND_ICON_TRIA_UP
= BND_ICONID
!(7, 29),
290 BND_ICON_ARROW_LEFTRIGHT
= BND_ICONID
!(8, 29),
291 BND_ICON_PLUS
= BND_ICONID
!(9, 29),
292 BND_ICON_DISCLOSURE_TRI_DOWN
= BND_ICONID
!(10, 29),
293 BND_ICON_DISCLOSURE_TRI_RIGHT
= BND_ICONID
!(11, 29),
294 BND_ICON_RADIOBUT_OFF
= BND_ICONID
!(12, 29),
295 BND_ICON_RADIOBUT_ON
= BND_ICONID
!(13, 29),
296 BND_ICON_MENU_PANEL
= BND_ICONID
!(14, 29),
297 BND_ICON_BLENDER
= BND_ICONID
!(15, 29),
298 BND_ICON_GRIP
= BND_ICONID
!(16, 29),
299 BND_ICON_DOT
= BND_ICONID
!(17, 29),
300 BND_ICON_COLLAPSEMENU
= BND_ICONID
!(18, 29),
301 BND_ICON_X
= BND_ICONID
!(19, 29),
302 BND_ICON_GO_LEFT
= BND_ICONID
!(21, 29),
303 BND_ICON_PLUG
= BND_ICONID
!(22, 29),
304 BND_ICON_UI
= BND_ICONID
!(23, 29),
305 BND_ICON_NODE
= BND_ICONID
!(24, 29),
306 BND_ICON_NODE_SEL
= BND_ICONID
!(25, 29),
308 public enum /*BNDicon*/ {
309 BND_ICON_FULLSCREEN
= BND_ICONID
!(0, 28),
310 BND_ICON_SPLITSCREEN
= BND_ICONID
!(1, 28),
311 BND_ICON_RIGHTARROW_THIN
= BND_ICONID
!(2, 28),
312 BND_ICON_BORDERMOVE
= BND_ICONID
!(3, 28),
313 BND_ICON_VIEWZOOM
= BND_ICONID
!(4, 28),
314 BND_ICON_ZOOMIN
= BND_ICONID
!(5, 28),
315 BND_ICON_ZOOMOUT
= BND_ICONID
!(6, 28),
316 BND_ICON_PANEL_CLOSE
= BND_ICONID
!(7, 28),
317 BND_ICON_COPY_ID
= BND_ICONID
!(8, 28),
318 BND_ICON_EYEDROPPER
= BND_ICONID
!(9, 28),
319 BND_ICON_LINK_AREA
= BND_ICONID
!(10, 28),
320 BND_ICON_AUTO
= BND_ICONID
!(11, 28),
321 BND_ICON_CHECKBOX_DEHLT
= BND_ICONID
!(12, 28),
322 BND_ICON_CHECKBOX_HLT
= BND_ICONID
!(13, 28),
323 BND_ICON_UNLOCKED
= BND_ICONID
!(14, 28),
324 BND_ICON_LOCKED
= BND_ICONID
!(15, 28),
325 BND_ICON_UNPINNED
= BND_ICONID
!(16, 28),
326 BND_ICON_PINNED
= BND_ICONID
!(17, 28),
327 BND_ICON_SCREEN_BACK
= BND_ICONID
!(18, 28),
328 BND_ICON_RIGHTARROW
= BND_ICONID
!(19, 28),
329 BND_ICON_DOWNARROW_HLT
= BND_ICONID
!(20, 28),
330 BND_ICON_DOTSUP
= BND_ICONID
!(21, 28),
331 BND_ICON_DOTSDOWN
= BND_ICONID
!(22, 28),
332 BND_ICON_LINK
= BND_ICONID
!(23, 28),
333 BND_ICON_INLINK
= BND_ICONID
!(24, 28),
334 BND_ICON_PLUGIN
= BND_ICONID
!(25, 28),
336 public enum /*BNDicon*/ {
337 BND_ICON_HELP
= BND_ICONID
!(0, 27),
338 BND_ICON_GHOST_ENABLED
= BND_ICONID
!(1, 27),
339 BND_ICON_COLOR
= BND_ICONID
!(2, 27),
340 BND_ICON_LINKED
= BND_ICONID
!(3, 27),
341 BND_ICON_UNLINKED
= BND_ICONID
!(4, 27),
342 BND_ICON_HAND
= BND_ICONID
!(5, 27),
343 BND_ICON_ZOOM_ALL
= BND_ICONID
!(6, 27),
344 BND_ICON_ZOOM_SELECTED
= BND_ICONID
!(7, 27),
345 BND_ICON_ZOOM_PREVIOUS
= BND_ICONID
!(8, 27),
346 BND_ICON_ZOOM_IN
= BND_ICONID
!(9, 27),
347 BND_ICON_ZOOM_OUT
= BND_ICONID
!(10, 27),
348 BND_ICON_RENDER_REGION
= BND_ICONID
!(11, 27),
349 BND_ICON_BORDER_RECT
= BND_ICONID
!(12, 27),
350 BND_ICON_BORDER_LASSO
= BND_ICONID
!(13, 27),
351 BND_ICON_FREEZE
= BND_ICONID
!(14, 27),
352 BND_ICON_STYLUS_PRESSURE
= BND_ICONID
!(15, 27),
353 BND_ICON_GHOST_DISABLED
= BND_ICONID
!(16, 27),
354 BND_ICON_NEW
= BND_ICONID
!(17, 27),
355 BND_ICON_FILE_TICK
= BND_ICONID
!(18, 27),
356 BND_ICON_QUIT
= BND_ICONID
!(19, 27),
357 BND_ICON_URL
= BND_ICONID
!(20, 27),
358 BND_ICON_RECOVER_LAST
= BND_ICONID
!(21, 27),
359 BND_ICON_FULLSCREEN_ENTER
= BND_ICONID
!(23, 27),
360 BND_ICON_FULLSCREEN_EXIT
= BND_ICONID
!(24, 27),
361 BND_ICON_BLANK1
= BND_ICONID
!(25, 27),
363 public enum /*BNDicon*/ {
364 BND_ICON_LAMP
= BND_ICONID
!(0, 26),
365 BND_ICON_MATERIAL
= BND_ICONID
!(1, 26),
366 BND_ICON_TEXTURE
= BND_ICONID
!(2, 26),
367 BND_ICON_ANIM
= BND_ICONID
!(3, 26),
368 BND_ICON_WORLD
= BND_ICONID
!(4, 26),
369 BND_ICON_SCENE
= BND_ICONID
!(5, 26),
370 BND_ICON_EDIT
= BND_ICONID
!(6, 26),
371 BND_ICON_GAME
= BND_ICONID
!(7, 26),
372 BND_ICON_RADIO
= BND_ICONID
!(8, 26),
373 BND_ICON_SCRIPT
= BND_ICONID
!(9, 26),
374 BND_ICON_PARTICLES
= BND_ICONID
!(10, 26),
375 BND_ICON_PHYSICS
= BND_ICONID
!(11, 26),
376 BND_ICON_SPEAKER
= BND_ICONID
!(12, 26),
377 BND_ICON_TEXTURE_SHADED
= BND_ICONID
!(13, 26),
379 public enum /*BNDicon*/ {
380 BND_ICON_VIEW3D
= BND_ICONID
!(0, 25),
381 BND_ICON_IPO
= BND_ICONID
!(1, 25),
382 BND_ICON_OOPS
= BND_ICONID
!(2, 25),
383 BND_ICON_BUTS
= BND_ICONID
!(3, 25),
384 BND_ICON_FILESEL
= BND_ICONID
!(4, 25),
385 BND_ICON_IMAGE_COL
= BND_ICONID
!(5, 25),
386 BND_ICON_INFO
= BND_ICONID
!(6, 25),
387 BND_ICON_SEQUENCE
= BND_ICONID
!(7, 25),
388 BND_ICON_TEXT
= BND_ICONID
!(8, 25),
389 BND_ICON_IMASEL
= BND_ICONID
!(9, 25),
390 BND_ICON_SOUND
= BND_ICONID
!(10, 25),
391 BND_ICON_ACTION
= BND_ICONID
!(11, 25),
392 BND_ICON_NLA
= BND_ICONID
!(12, 25),
393 BND_ICON_SCRIPTWIN
= BND_ICONID
!(13, 25),
394 BND_ICON_TIME
= BND_ICONID
!(14, 25),
395 BND_ICON_NODETREE
= BND_ICONID
!(15, 25),
396 BND_ICON_LOGIC
= BND_ICONID
!(16, 25),
397 BND_ICON_CONSOLE
= BND_ICONID
!(17, 25),
398 BND_ICON_PREFERENCES
= BND_ICONID
!(18, 25),
399 BND_ICON_CLIP
= BND_ICONID
!(19, 25),
400 BND_ICON_ASSET_MANAGER
= BND_ICONID
!(20, 25),
402 public enum /*BNDicon*/ {
403 BND_ICON_OBJECT_DATAMODE
= BND_ICONID
!(0, 24),
404 BND_ICON_EDITMODE_HLT
= BND_ICONID
!(1, 24),
405 BND_ICON_FACESEL_HLT
= BND_ICONID
!(2, 24),
406 BND_ICON_VPAINT_HLT
= BND_ICONID
!(3, 24),
407 BND_ICON_TPAINT_HLT
= BND_ICONID
!(4, 24),
408 BND_ICON_WPAINT_HLT
= BND_ICONID
!(5, 24),
409 BND_ICON_SCULPTMODE_HLT
= BND_ICONID
!(6, 24),
410 BND_ICON_POSE_HLT
= BND_ICONID
!(7, 24),
411 BND_ICON_PARTICLEMODE
= BND_ICONID
!(8, 24),
412 BND_ICON_LIGHTPAINT
= BND_ICONID
!(9, 24),
414 public enum /*BNDicon*/ {
415 BND_ICON_SCENE_DATA
= BND_ICONID
!(0, 23),
416 BND_ICON_RENDERLAYERS
= BND_ICONID
!(1, 23),
417 BND_ICON_WORLD_DATA
= BND_ICONID
!(2, 23),
418 BND_ICON_OBJECT_DATA
= BND_ICONID
!(3, 23),
419 BND_ICON_MESH_DATA
= BND_ICONID
!(4, 23),
420 BND_ICON_CURVE_DATA
= BND_ICONID
!(5, 23),
421 BND_ICON_META_DATA
= BND_ICONID
!(6, 23),
422 BND_ICON_LATTICE_DATA
= BND_ICONID
!(7, 23),
423 BND_ICON_LAMP_DATA
= BND_ICONID
!(8, 23),
424 BND_ICON_MATERIAL_DATA
= BND_ICONID
!(9, 23),
425 BND_ICON_TEXTURE_DATA
= BND_ICONID
!(10, 23),
426 BND_ICON_ANIM_DATA
= BND_ICONID
!(11, 23),
427 BND_ICON_CAMERA_DATA
= BND_ICONID
!(12, 23),
428 BND_ICON_PARTICLE_DATA
= BND_ICONID
!(13, 23),
429 BND_ICON_LIBRARY_DATA_DIRECT
= BND_ICONID
!(14, 23),
430 BND_ICON_GROUP
= BND_ICONID
!(15, 23),
431 BND_ICON_ARMATURE_DATA
= BND_ICONID
!(16, 23),
432 BND_ICON_POSE_DATA
= BND_ICONID
!(17, 23),
433 BND_ICON_BONE_DATA
= BND_ICONID
!(18, 23),
434 BND_ICON_CONSTRAINT
= BND_ICONID
!(19, 23),
435 BND_ICON_SHAPEKEY_DATA
= BND_ICONID
!(20, 23),
436 BND_ICON_CONSTRAINT_BONE
= BND_ICONID
!(21, 23),
437 BND_ICON_CAMERA_STEREO
= BND_ICONID
!(22, 23),
438 BND_ICON_PACKAGE
= BND_ICONID
!(23, 23),
439 BND_ICON_UGLYPACKAGE
= BND_ICONID
!(24, 23),
441 public enum /*BNDicon*/ {
442 BND_ICON_BRUSH_DATA
= BND_ICONID
!(0, 22),
443 BND_ICON_IMAGE_DATA
= BND_ICONID
!(1, 22),
444 BND_ICON_FILE
= BND_ICONID
!(2, 22),
445 BND_ICON_FCURVE
= BND_ICONID
!(3, 22),
446 BND_ICON_FONT_DATA
= BND_ICONID
!(4, 22),
447 BND_ICON_RENDER_RESULT
= BND_ICONID
!(5, 22),
448 BND_ICON_SURFACE_DATA
= BND_ICONID
!(6, 22),
449 BND_ICON_EMPTY_DATA
= BND_ICONID
!(7, 22),
450 BND_ICON_SETTINGS
= BND_ICONID
!(8, 22),
451 BND_ICON_RENDER_ANIMATION
= BND_ICONID
!(9, 22),
452 BND_ICON_RENDER_STILL
= BND_ICONID
!(10, 22),
453 BND_ICON_BOIDS
= BND_ICONID
!(12, 22),
454 BND_ICON_STRANDS
= BND_ICONID
!(13, 22),
455 BND_ICON_LIBRARY_DATA_INDIRECT
= BND_ICONID
!(14, 22),
456 BND_ICON_GREASEPENCIL
= BND_ICONID
!(15, 22),
457 BND_ICON_LINE_DATA
= BND_ICONID
!(16, 22),
458 BND_ICON_GROUP_BONE
= BND_ICONID
!(18, 22),
459 BND_ICON_GROUP_VERTEX
= BND_ICONID
!(19, 22),
460 BND_ICON_GROUP_VCOL
= BND_ICONID
!(20, 22),
461 BND_ICON_GROUP_UVS
= BND_ICONID
!(21, 22),
462 BND_ICON_RNA
= BND_ICONID
!(24, 22),
463 BND_ICON_RNA_ADD
= BND_ICONID
!(25, 22),
465 public enum /*BNDicon*/ {
466 BND_ICON_OUTLINER_OB_EMPTY
= BND_ICONID
!(0, 20),
467 BND_ICON_OUTLINER_OB_MESH
= BND_ICONID
!(1, 20),
468 BND_ICON_OUTLINER_OB_CURVE
= BND_ICONID
!(2, 20),
469 BND_ICON_OUTLINER_OB_LATTICE
= BND_ICONID
!(3, 20),
470 BND_ICON_OUTLINER_OB_META
= BND_ICONID
!(4, 20),
471 BND_ICON_OUTLINER_OB_LAMP
= BND_ICONID
!(5, 20),
472 BND_ICON_OUTLINER_OB_CAMERA
= BND_ICONID
!(6, 20),
473 BND_ICON_OUTLINER_OB_ARMATURE
= BND_ICONID
!(7, 20),
474 BND_ICON_OUTLINER_OB_FONT
= BND_ICONID
!(8, 20),
475 BND_ICON_OUTLINER_OB_SURFACE
= BND_ICONID
!(9, 20),
476 BND_ICON_OUTLINER_OB_SPEAKER
= BND_ICONID
!(10, 20),
477 BND_ICON_RESTRICT_VIEW_OFF
= BND_ICONID
!(19, 20),
478 BND_ICON_RESTRICT_VIEW_ON
= BND_ICONID
!(20, 20),
479 BND_ICON_RESTRICT_SELECT_OFF
= BND_ICONID
!(21, 20),
480 BND_ICON_RESTRICT_SELECT_ON
= BND_ICONID
!(22, 20),
481 BND_ICON_RESTRICT_RENDER_OFF
= BND_ICONID
!(23, 20),
482 BND_ICON_RESTRICT_RENDER_ON
= BND_ICONID
!(24, 20),
484 public enum /*BNDicon*/ {
485 BND_ICON_OUTLINER_DATA_EMPTY
= BND_ICONID
!(0, 19),
486 BND_ICON_OUTLINER_DATA_MESH
= BND_ICONID
!(1, 19),
487 BND_ICON_OUTLINER_DATA_CURVE
= BND_ICONID
!(2, 19),
488 BND_ICON_OUTLINER_DATA_LATTICE
= BND_ICONID
!(3, 19),
489 BND_ICON_OUTLINER_DATA_META
= BND_ICONID
!(4, 19),
490 BND_ICON_OUTLINER_DATA_LAMP
= BND_ICONID
!(5, 19),
491 BND_ICON_OUTLINER_DATA_CAMERA
= BND_ICONID
!(6, 19),
492 BND_ICON_OUTLINER_DATA_ARMATURE
= BND_ICONID
!(7, 19),
493 BND_ICON_OUTLINER_DATA_FONT
= BND_ICONID
!(8, 19),
494 BND_ICON_OUTLINER_DATA_SURFACE
= BND_ICONID
!(9, 19),
495 BND_ICON_OUTLINER_DATA_SPEAKER
= BND_ICONID
!(10, 19),
496 BND_ICON_OUTLINER_DATA_POSE
= BND_ICONID
!(11, 19),
498 public enum /*BNDicon*/ {
499 BND_ICON_MESH_PLANE
= BND_ICONID
!(0, 18),
500 BND_ICON_MESH_CUBE
= BND_ICONID
!(1, 18),
501 BND_ICON_MESH_CIRCLE
= BND_ICONID
!(2, 18),
502 BND_ICON_MESH_UVSPHERE
= BND_ICONID
!(3, 18),
503 BND_ICON_MESH_ICOSPHERE
= BND_ICONID
!(4, 18),
504 BND_ICON_MESH_GRID
= BND_ICONID
!(5, 18),
505 BND_ICON_MESH_MONKEY
= BND_ICONID
!(6, 18),
506 BND_ICON_MESH_CYLINDER
= BND_ICONID
!(7, 18),
507 BND_ICON_MESH_TORUS
= BND_ICONID
!(8, 18),
508 BND_ICON_MESH_CONE
= BND_ICONID
!(9, 18),
509 BND_ICON_LAMP_POINT
= BND_ICONID
!(12, 18),
510 BND_ICON_LAMP_SUN
= BND_ICONID
!(13, 18),
511 BND_ICON_LAMP_SPOT
= BND_ICONID
!(14, 18),
512 BND_ICON_LAMP_HEMI
= BND_ICONID
!(15, 18),
513 BND_ICON_LAMP_AREA
= BND_ICONID
!(16, 18),
514 BND_ICON_META_EMPTY
= BND_ICONID
!(19, 18),
515 BND_ICON_META_PLANE
= BND_ICONID
!(20, 18),
516 BND_ICON_META_CUBE
= BND_ICONID
!(21, 18),
517 BND_ICON_META_BALL
= BND_ICONID
!(22, 18),
518 BND_ICON_META_ELLIPSOID
= BND_ICONID
!(23, 18),
519 BND_ICON_META_CAPSULE
= BND_ICONID
!(24, 18),
521 public enum /*BNDicon*/ {
522 BND_ICON_SURFACE_NCURVE
= BND_ICONID
!(0, 17),
523 BND_ICON_SURFACE_NCIRCLE
= BND_ICONID
!(1, 17),
524 BND_ICON_SURFACE_NSURFACE
= BND_ICONID
!(2, 17),
525 BND_ICON_SURFACE_NCYLINDER
= BND_ICONID
!(3, 17),
526 BND_ICON_SURFACE_NSPHERE
= BND_ICONID
!(4, 17),
527 BND_ICON_SURFACE_NTORUS
= BND_ICONID
!(5, 17),
528 BND_ICON_CURVE_BEZCURVE
= BND_ICONID
!(9, 17),
529 BND_ICON_CURVE_BEZCIRCLE
= BND_ICONID
!(10, 17),
530 BND_ICON_CURVE_NCURVE
= BND_ICONID
!(11, 17),
531 BND_ICON_CURVE_NCIRCLE
= BND_ICONID
!(12, 17),
532 BND_ICON_CURVE_PATH
= BND_ICONID
!(13, 17),
533 BND_ICON_COLOR_RED
= BND_ICONID
!(19, 17),
534 BND_ICON_COLOR_GREEN
= BND_ICONID
!(20, 17),
535 BND_ICON_COLOR_BLUE
= BND_ICONID
!(21, 17),
537 public enum /*BNDicon*/ {
538 BND_ICON_FORCE_FORCE
= BND_ICONID
!(0, 16),
539 BND_ICON_FORCE_WIND
= BND_ICONID
!(1, 16),
540 BND_ICON_FORCE_VORTEX
= BND_ICONID
!(2, 16),
541 BND_ICON_FORCE_MAGNETIC
= BND_ICONID
!(3, 16),
542 BND_ICON_FORCE_HARMONIC
= BND_ICONID
!(4, 16),
543 BND_ICON_FORCE_CHARGE
= BND_ICONID
!(5, 16),
544 BND_ICON_FORCE_LENNARDJONES
= BND_ICONID
!(6, 16),
545 BND_ICON_FORCE_TEXTURE
= BND_ICONID
!(7, 16),
546 BND_ICON_FORCE_CURVE
= BND_ICONID
!(8, 16),
547 BND_ICON_FORCE_BOID
= BND_ICONID
!(9, 16),
548 BND_ICON_FORCE_TURBULENCE
= BND_ICONID
!(10, 16),
549 BND_ICON_FORCE_DRAG
= BND_ICONID
!(11, 16),
550 BND_ICON_FORCE_SMOKEFLOW
= BND_ICONID
!(12, 16),
552 public enum /*BNDicon*/ {
553 BND_ICON_MODIFIER
= BND_ICONID
!(0, 12),
554 BND_ICON_MOD_WAVE
= BND_ICONID
!(1, 12),
555 BND_ICON_MOD_BUILD
= BND_ICONID
!(2, 12),
556 BND_ICON_MOD_DECIM
= BND_ICONID
!(3, 12),
557 BND_ICON_MOD_MIRROR
= BND_ICONID
!(4, 12),
558 BND_ICON_MOD_SOFT
= BND_ICONID
!(5, 12),
559 BND_ICON_MOD_SUBSURF
= BND_ICONID
!(6, 12),
560 BND_ICON_HOOK
= BND_ICONID
!(7, 12),
561 BND_ICON_MOD_PHYSICS
= BND_ICONID
!(8, 12),
562 BND_ICON_MOD_PARTICLES
= BND_ICONID
!(9, 12),
563 BND_ICON_MOD_BOOLEAN
= BND_ICONID
!(10, 12),
564 BND_ICON_MOD_EDGESPLIT
= BND_ICONID
!(11, 12),
565 BND_ICON_MOD_ARRAY
= BND_ICONID
!(12, 12),
566 BND_ICON_MOD_UVPROJECT
= BND_ICONID
!(13, 12),
567 BND_ICON_MOD_DISPLACE
= BND_ICONID
!(14, 12),
568 BND_ICON_MOD_CURVE
= BND_ICONID
!(15, 12),
569 BND_ICON_MOD_LATTICE
= BND_ICONID
!(16, 12),
570 BND_ICON_CONSTRAINT_DATA
= BND_ICONID
!(17, 12),
571 BND_ICON_MOD_ARMATURE
= BND_ICONID
!(18, 12),
572 BND_ICON_MOD_SHRINKWRAP
= BND_ICONID
!(19, 12),
573 BND_ICON_MOD_CAST
= BND_ICONID
!(20, 12),
574 BND_ICON_MOD_MESHDEFORM
= BND_ICONID
!(21, 12),
575 BND_ICON_MOD_BEVEL
= BND_ICONID
!(22, 12),
576 BND_ICON_MOD_SMOOTH
= BND_ICONID
!(23, 12),
577 BND_ICON_MOD_SIMPLEDEFORM
= BND_ICONID
!(24, 12),
578 BND_ICON_MOD_MASK
= BND_ICONID
!(25, 12),
580 public enum /*BNDicon*/ {
581 BND_ICON_MOD_CLOTH
= BND_ICONID
!(0, 11),
582 BND_ICON_MOD_EXPLODE
= BND_ICONID
!(1, 11),
583 BND_ICON_MOD_FLUIDSIM
= BND_ICONID
!(2, 11),
584 BND_ICON_MOD_MULTIRES
= BND_ICONID
!(3, 11),
585 BND_ICON_MOD_SMOKE
= BND_ICONID
!(4, 11),
586 BND_ICON_MOD_SOLIDIFY
= BND_ICONID
!(5, 11),
587 BND_ICON_MOD_SCREW
= BND_ICONID
!(6, 11),
588 BND_ICON_MOD_VERTEX_WEIGHT
= BND_ICONID
!(7, 11),
589 BND_ICON_MOD_DYNAMICPAINT
= BND_ICONID
!(8, 11),
590 BND_ICON_MOD_REMESH
= BND_ICONID
!(9, 11),
591 BND_ICON_MOD_OCEAN
= BND_ICONID
!(10, 11),
592 BND_ICON_MOD_WARP
= BND_ICONID
!(11, 11),
593 BND_ICON_MOD_SKIN
= BND_ICONID
!(12, 11),
594 BND_ICON_MOD_TRIANGULATE
= BND_ICONID
!(13, 11),
595 BND_ICON_MOD_WIREFRAME
= BND_ICONID
!(14, 11),
597 public enum /*BNDicon*/ {
598 BND_ICON_REC
= BND_ICONID
!(0, 10),
599 BND_ICON_PLAY
= BND_ICONID
!(1, 10),
600 BND_ICON_FF
= BND_ICONID
!(2, 10),
601 BND_ICON_REW
= BND_ICONID
!(3, 10),
602 BND_ICON_PAUSE
= BND_ICONID
!(4, 10),
603 BND_ICON_PREV_KEYFRAME
= BND_ICONID
!(5, 10),
604 BND_ICON_NEXT_KEYFRAME
= BND_ICONID
!(6, 10),
605 BND_ICON_PLAY_AUDIO
= BND_ICONID
!(7, 10),
606 BND_ICON_PLAY_REVERSE
= BND_ICONID
!(8, 10),
607 BND_ICON_PREVIEW_RANGE
= BND_ICONID
!(9, 10),
608 BND_ICON_ACTION_TWEAK
= BND_ICONID
!(10, 10),
609 BND_ICON_PMARKER_ACT
= BND_ICONID
!(11, 10),
610 BND_ICON_PMARKER_SEL
= BND_ICONID
!(12, 10),
611 BND_ICON_PMARKER
= BND_ICONID
!(13, 10),
612 BND_ICON_MARKER_HLT
= BND_ICONID
!(14, 10),
613 BND_ICON_MARKER
= BND_ICONID
!(15, 10),
614 BND_ICON_SPACE2
= BND_ICONID
!(16, 10),
615 BND_ICON_SPACE3
= BND_ICONID
!(17, 10),
616 BND_ICON_KEYINGSET
= BND_ICONID
!(18, 10),
617 BND_ICON_KEY_DEHLT
= BND_ICONID
!(19, 10),
618 BND_ICON_KEY_HLT
= BND_ICONID
!(20, 10),
619 BND_ICON_MUTE_IPO_OFF
= BND_ICONID
!(21, 10),
620 BND_ICON_MUTE_IPO_ON
= BND_ICONID
!(22, 10),
621 BND_ICON_VISIBLE_IPO_OFF
= BND_ICONID
!(23, 10),
622 BND_ICON_VISIBLE_IPO_ON
= BND_ICONID
!(24, 10),
623 BND_ICON_DRIVER
= BND_ICONID
!(25, 10),
625 public enum /*BNDicon*/ {
626 BND_ICON_SOLO_OFF
= BND_ICONID
!(0, 9),
627 BND_ICON_SOLO_ON
= BND_ICONID
!(1, 9),
628 BND_ICON_FRAME_PREV
= BND_ICONID
!(2, 9),
629 BND_ICON_FRAME_NEXT
= BND_ICONID
!(3, 9),
630 BND_ICON_NLA_PUSHDOWN
= BND_ICONID
!(4, 9),
631 BND_ICON_IPO_CONSTANT
= BND_ICONID
!(5, 9),
632 BND_ICON_IPO_LINEAR
= BND_ICONID
!(6, 9),
633 BND_ICON_IPO_BEZIER
= BND_ICONID
!(7, 9),
634 BND_ICON_IPO_SINE
= BND_ICONID
!(8, 9),
635 BND_ICON_IPO_QUAD
= BND_ICONID
!(9, 9),
636 BND_ICON_IPO_CUBIC
= BND_ICONID
!(10, 9),
637 BND_ICON_IPO_QUART
= BND_ICONID
!(11, 9),
638 BND_ICON_IPO_QUINT
= BND_ICONID
!(12, 9),
639 BND_ICON_IPO_EXPO
= BND_ICONID
!(13, 9),
640 BND_ICON_IPO_CIRC
= BND_ICONID
!(14, 9),
641 BND_ICON_IPO_BOUNCE
= BND_ICONID
!(15, 9),
642 BND_ICON_IPO_ELASTIC
= BND_ICONID
!(16, 9),
643 BND_ICON_IPO_BACK
= BND_ICONID
!(17, 9),
644 BND_ICON_IPO_EASE_IN
= BND_ICONID
!(18, 9),
645 BND_ICON_IPO_EASE_OUT
= BND_ICONID
!(19, 9),
646 BND_ICON_IPO_EASE_IN_OUT
= BND_ICONID
!(20, 9),
648 public enum /*BNDicon*/ {
649 BND_ICON_VERTEXSEL
= BND_ICONID
!(0, 8),
650 BND_ICON_EDGESEL
= BND_ICONID
!(1, 8),
651 BND_ICON_FACESEL
= BND_ICONID
!(2, 8),
652 BND_ICON_LOOPSEL
= BND_ICONID
!(3, 8),
653 BND_ICON_ROTATE
= BND_ICONID
!(5, 8),
654 BND_ICON_CURSOR
= BND_ICONID
!(6, 8),
655 BND_ICON_ROTATECOLLECTION
= BND_ICONID
!(7, 8),
656 BND_ICON_ROTATECENTER
= BND_ICONID
!(8, 8),
657 BND_ICON_ROTACTIVE
= BND_ICONID
!(9, 8),
658 BND_ICON_ALIGN
= BND_ICONID
!(10, 8),
659 BND_ICON_SMOOTHCURVE
= BND_ICONID
!(12, 8),
660 BND_ICON_SPHERECURVE
= BND_ICONID
!(13, 8),
661 BND_ICON_ROOTCURVE
= BND_ICONID
!(14, 8),
662 BND_ICON_SHARPCURVE
= BND_ICONID
!(15, 8),
663 BND_ICON_LINCURVE
= BND_ICONID
!(16, 8),
664 BND_ICON_NOCURVE
= BND_ICONID
!(17, 8),
665 BND_ICON_RNDCURVE
= BND_ICONID
!(18, 8),
666 BND_ICON_PROP_OFF
= BND_ICONID
!(19, 8),
667 BND_ICON_PROP_ON
= BND_ICONID
!(20, 8),
668 BND_ICON_PROP_CON
= BND_ICONID
!(21, 8),
669 BND_ICON_SCULPT_DYNTOPO
= BND_ICONID
!(22, 8),
670 BND_ICON_PARTICLE_POINT
= BND_ICONID
!(23, 8),
671 BND_ICON_PARTICLE_TIP
= BND_ICONID
!(24, 8),
672 BND_ICON_PARTICLE_PATH
= BND_ICONID
!(25, 8),
674 public enum /*BNDicon*/ {
675 BND_ICON_MAN_TRANS
= BND_ICONID
!(0, 7),
676 BND_ICON_MAN_ROT
= BND_ICONID
!(1, 7),
677 BND_ICON_MAN_SCALE
= BND_ICONID
!(2, 7),
678 BND_ICON_MANIPUL
= BND_ICONID
!(3, 7),
679 BND_ICON_SNAP_OFF
= BND_ICONID
!(4, 7),
680 BND_ICON_SNAP_ON
= BND_ICONID
!(5, 7),
681 BND_ICON_SNAP_NORMAL
= BND_ICONID
!(6, 7),
682 BND_ICON_SNAP_INCREMENT
= BND_ICONID
!(7, 7),
683 BND_ICON_SNAP_VERTEX
= BND_ICONID
!(8, 7),
684 BND_ICON_SNAP_EDGE
= BND_ICONID
!(9, 7),
685 BND_ICON_SNAP_FACE
= BND_ICONID
!(10, 7),
686 BND_ICON_SNAP_VOLUME
= BND_ICONID
!(11, 7),
687 BND_ICON_STICKY_UVS_LOC
= BND_ICONID
!(13, 7),
688 BND_ICON_STICKY_UVS_DISABLE
= BND_ICONID
!(14, 7),
689 BND_ICON_STICKY_UVS_VERT
= BND_ICONID
!(15, 7),
690 BND_ICON_CLIPUV_DEHLT
= BND_ICONID
!(16, 7),
691 BND_ICON_CLIPUV_HLT
= BND_ICONID
!(17, 7),
692 BND_ICON_SNAP_PEEL_OBJECT
= BND_ICONID
!(18, 7),
693 BND_ICON_GRID
= BND_ICONID
!(19, 7),
695 public enum /*BNDicon*/ {
696 BND_ICON_PASTEDOWN
= BND_ICONID
!(0, 6),
697 BND_ICON_COPYDOWN
= BND_ICONID
!(1, 6),
698 BND_ICON_PASTEFLIPUP
= BND_ICONID
!(2, 6),
699 BND_ICON_PASTEFLIPDOWN
= BND_ICONID
!(3, 6),
700 BND_ICON_SNAP_SURFACE
= BND_ICONID
!(8, 6),
701 BND_ICON_AUTOMERGE_ON
= BND_ICONID
!(9, 6),
702 BND_ICON_AUTOMERGE_OFF
= BND_ICONID
!(10, 6),
703 BND_ICON_RETOPO
= BND_ICONID
!(11, 6),
704 BND_ICON_UV_VERTEXSEL
= BND_ICONID
!(12, 6),
705 BND_ICON_UV_EDGESEL
= BND_ICONID
!(13, 6),
706 BND_ICON_UV_FACESEL
= BND_ICONID
!(14, 6),
707 BND_ICON_UV_ISLANDSEL
= BND_ICONID
!(15, 6),
708 BND_ICON_UV_SYNC_SELECT
= BND_ICONID
!(16, 6),
710 public enum /*BNDicon*/ {
711 BND_ICON_BBOX
= BND_ICONID
!(0, 5),
712 BND_ICON_WIRE
= BND_ICONID
!(1, 5),
713 BND_ICON_SOLID
= BND_ICONID
!(2, 5),
714 BND_ICON_SMOOTH
= BND_ICONID
!(3, 5),
715 BND_ICON_POTATO
= BND_ICONID
!(4, 5),
716 BND_ICON_ORTHO
= BND_ICONID
!(6, 5),
717 BND_ICON_LOCKVIEW_OFF
= BND_ICONID
!(9, 5),
718 BND_ICON_LOCKVIEW_ON
= BND_ICONID
!(10, 5),
719 BND_ICON_AXIS_SIDE
= BND_ICONID
!(12, 5),
720 BND_ICON_AXIS_FRONT
= BND_ICONID
!(13, 5),
721 BND_ICON_AXIS_TOP
= BND_ICONID
!(14, 5),
722 BND_ICON_NDOF_DOM
= BND_ICONID
!(15, 5),
723 BND_ICON_NDOF_TURN
= BND_ICONID
!(16, 5),
724 BND_ICON_NDOF_FLY
= BND_ICONID
!(17, 5),
725 BND_ICON_NDOF_TRANS
= BND_ICONID
!(18, 5),
726 BND_ICON_LAYER_USED
= BND_ICONID
!(19, 5),
727 BND_ICON_LAYER_ACTIVE
= BND_ICONID
!(20, 5),
729 public enum /*BNDicon*/ {
730 BND_ICON_SORTALPHA
= BND_ICONID
!(0, 3),
731 BND_ICON_SORTBYEXT
= BND_ICONID
!(1, 3),
732 BND_ICON_SORTTIME
= BND_ICONID
!(2, 3),
733 BND_ICON_SORTSIZE
= BND_ICONID
!(3, 3),
734 BND_ICON_LONGDISPLAY
= BND_ICONID
!(4, 3),
735 BND_ICON_SHORTDISPLAY
= BND_ICONID
!(5, 3),
736 BND_ICON_GHOST
= BND_ICONID
!(6, 3),
737 BND_ICON_IMGDISPLAY
= BND_ICONID
!(7, 3),
738 BND_ICON_SAVE_AS
= BND_ICONID
!(8, 3),
739 BND_ICON_SAVE_COPY
= BND_ICONID
!(9, 3),
740 BND_ICON_BOOKMARKS
= BND_ICONID
!(10, 3),
741 BND_ICON_FONTPREVIEW
= BND_ICONID
!(11, 3),
742 BND_ICON_FILTER
= BND_ICONID
!(12, 3),
743 BND_ICON_NEWFOLDER
= BND_ICONID
!(13, 3),
744 BND_ICON_OPEN_RECENT
= BND_ICONID
!(14, 3),
745 BND_ICON_FILE_PARENT
= BND_ICONID
!(15, 3),
746 BND_ICON_FILE_REFRESH
= BND_ICONID
!(16, 3),
747 BND_ICON_FILE_FOLDER
= BND_ICONID
!(17, 3),
748 BND_ICON_FILE_BLANK
= BND_ICONID
!(18, 3),
749 BND_ICON_FILE_BLEND
= BND_ICONID
!(19, 3),
750 BND_ICON_FILE_IMAGE
= BND_ICONID
!(20, 3),
751 BND_ICON_FILE_MOVIE
= BND_ICONID
!(21, 3),
752 BND_ICON_FILE_SCRIPT
= BND_ICONID
!(22, 3),
753 BND_ICON_FILE_SOUND
= BND_ICONID
!(23, 3),
754 BND_ICON_FILE_FONT
= BND_ICONID
!(24, 3),
755 BND_ICON_FILE_TEXT
= BND_ICONID
!(25, 3),
757 public enum /*BNDicon*/ {
758 BND_ICON_RECOVER_AUTO
= BND_ICONID
!(0, 2),
759 BND_ICON_SAVE_PREFS
= BND_ICONID
!(1, 2),
760 BND_ICON_LINK_BLEND
= BND_ICONID
!(2, 2),
761 BND_ICON_APPEND_BLEND
= BND_ICONID
!(3, 2),
762 BND_ICON_IMPORT
= BND_ICONID
!(4, 2),
763 BND_ICON_EXPORT
= BND_ICONID
!(5, 2),
764 BND_ICON_EXTERNAL_DATA
= BND_ICONID
!(6, 2),
765 BND_ICON_LOAD_FACTORY
= BND_ICONID
!(7, 2),
766 BND_ICON_LOOP_BACK
= BND_ICONID
!(13, 2),
767 BND_ICON_LOOP_FORWARDS
= BND_ICONID
!(14, 2),
768 BND_ICON_BACK
= BND_ICONID
!(15, 2),
769 BND_ICON_FORWARD
= BND_ICONID
!(16, 2),
770 BND_ICON_FILE_BACKUP
= BND_ICONID
!(24, 2),
771 BND_ICON_DISK_DRIVE
= BND_ICONID
!(25, 2),
773 public enum /*BNDicon*/ {
774 BND_ICON_MATPLANE
= BND_ICONID
!(0, 1),
775 BND_ICON_MATSPHERE
= BND_ICONID
!(1, 1),
776 BND_ICON_MATCUBE
= BND_ICONID
!(2, 1),
777 BND_ICON_MONKEY
= BND_ICONID
!(3, 1),
778 BND_ICON_HAIR
= BND_ICONID
!(4, 1),
779 BND_ICON_ALIASED
= BND_ICONID
!(5, 1),
780 BND_ICON_ANTIALIASED
= BND_ICONID
!(6, 1),
781 BND_ICON_MAT_SPHERE_SKY
= BND_ICONID
!(7, 1),
782 BND_ICON_WORDWRAP_OFF
= BND_ICONID
!(12, 1),
783 BND_ICON_WORDWRAP_ON
= BND_ICONID
!(13, 1),
784 BND_ICON_SYNTAX_OFF
= BND_ICONID
!(14, 1),
785 BND_ICON_SYNTAX_ON
= BND_ICONID
!(15, 1),
786 BND_ICON_LINENUMBERS_OFF
= BND_ICONID
!(16, 1),
787 BND_ICON_LINENUMBERS_ON
= BND_ICONID
!(17, 1),
788 BND_ICON_SCRIPTPLUGINS
= BND_ICONID
!(18, 1),
790 public enum /*BNDicon*/ {
791 BND_ICON_SEQ_SEQUENCER
= BND_ICONID
!(0, 0),
792 BND_ICON_SEQ_PREVIEW
= BND_ICONID
!(1, 0),
793 BND_ICON_SEQ_LUMA_WAVEFORM
= BND_ICONID
!(2, 0),
794 BND_ICON_SEQ_CHROMA_SCOPE
= BND_ICONID
!(3, 0),
795 BND_ICON_SEQ_HISTOGRAM
= BND_ICONID
!(4, 0),
796 BND_ICON_SEQ_SPLITVIEW
= BND_ICONID
!(5, 0),
797 BND_ICON_IMAGE_RGB
= BND_ICONID
!(9, 0),
798 BND_ICON_IMAGE_RGB_ALPHA
= BND_ICONID
!(10, 0),
799 BND_ICON_IMAGE_ALPHA
= BND_ICONID
!(11, 0),
800 BND_ICON_IMAGE_ZDEPTH
= BND_ICONID
!(12, 0),
801 BND_ICON_IMAGEFILE
= BND_ICONID
!(13, 0),
805 ////////////////////////////////////////////////////////////////////////////////
806 public float bndMin(T
) (in T a
, in T b
) if (__traits(isFloating
, T
)) { pragma(inline
, true); import std
.math
: isNaN
; return (isNaN(a
) ? b
: ( isNaN(b
) ? a
: (a
< b ? a
: b
))); }
807 public float bndMax(T
) (in T a
, in T b
) if (__traits(isFloating
, T
)) { pragma(inline
, true); import std
.math
: isNaN
; return (isNaN(a
) ? b
: ( isNaN(b
) ? a
: (a
> b ? a
: b
))); }
810 ////////////////////////////////////////////////////////////////////////////////
811 /// default text size
812 public __gshared
float BND_LABEL_FONT_SIZE
= 13;
814 /// default text padding in inner box
815 public __gshared
int BND_PAD_LEFT
= 8;
816 public __gshared
int BND_PAD_RIGHT
= 8;
818 /// label: value separator string
819 public __gshared string BND_LABEL_SEPARATOR
= ": ";
821 /// alpha intensity of transparent items (0xa4)
822 public __gshared
float BND_TRANSPARENT_ALPHA
= 0.643;
824 /// shade intensity of beveled panels
825 public __gshared
int BND_BEVEL_SHADE
= 30;
826 /// shade intensity of beveled insets
827 public __gshared
int BND_INSET_BEVEL_SHADE
= 30;
828 /// shade intensity of hovered inner boxes
829 public __gshared
int BND_HOVER_SHADE
= 15;
830 /// shade intensity of splitter bevels
831 public __gshared
int BND_SPLITTER_SHADE
= 100;
833 /// width of icon sheet
834 public __gshared
int BND_ICON_SHEET_WIDTH
= 602;
835 /// height of icon sheet
836 public __gshared
int BND_ICON_SHEET_HEIGHT
= 640;
837 /// gridsize of icon sheet in both dimensions
838 public __gshared
int BND_ICON_SHEET_GRID
= 21;
839 /// offset of first icon tile relative to left border
840 public __gshared
int BND_ICON_SHEET_OFFSET_X
= 5;
841 /// offset of first icon tile relative to top border
842 public __gshared
int BND_ICON_SHEET_OFFSET_Y
= 10;
843 /// resolution of single icon
844 public __gshared
int BND_ICON_SHEET_RES
= 16;
846 /// size of number field arrow
847 public __gshared
float BND_NUMBER_ARROW_SIZE
= 4;
849 /// default text color
850 public enum BND_COLOR_TEXT
= nvgRGBAf(0, 0, 0, 1);
851 /// default highlighted text color
852 public enum BND_COLOR_TEXT_SELECTED
= nvgRGBAf(1, 1, 1, 1);
853 /// default color for active element
854 public enum BND_COLOR_ACTIVE
= nvgRGBA(255, 127, 0, 255);
856 /// radius of tool button
857 public __gshared
float BND_TOOL_RADIUS
= 4;
859 /// radius of option button
860 public __gshared
float BND_OPTION_RADIUS
= 4;
861 /// width of option button checkbox
862 public __gshared
float BND_OPTION_WIDTH
= 14;
863 /// height of option button checkbox
864 public __gshared
float BND_OPTION_HEIGHT
= 15;
866 /// radius of text field
867 public __gshared
float BND_TEXT_RADIUS
= 4;
869 /// radius of number button
870 public __gshared
float BND_NUMBER_RADIUS
= 10;
872 /// radius of menu popup
873 public __gshared
float BND_MENU_RADIUS
= 3;
874 /// feather of menu popup shadow
875 public __gshared
float BND_SHADOW_FEATHER
= 12;
876 /// alpha of menu popup shadow
877 public __gshared
float BND_SHADOW_ALPHA
= 0.5;
879 /// radius of scrollbar
880 public __gshared
float BND_SCROLLBAR_RADIUS
= 7;
881 /// shade intensity of active scrollbar
882 public __gshared
int BND_SCROLLBAR_ACTIVE_SHADE
= 15;
884 /// max glyphs for position testing
885 public enum BND_MAX_GLYPHS
= 1024;
887 /// max rows for position testing
888 public enum BND_MAX_ROWS
= 32;
890 /// text distance from bottom
891 public __gshared
int BND_TEXT_PAD_DOWN
= 7;
893 /// stroke width of wire outline
894 public __gshared
float BND_NODE_WIRE_OUTLINE_WIDTH
= 4;
895 /// stroke width of wire
896 public __gshared
float BND_NODE_WIRE_WIDTH
= 2;
897 /// radius of node box
898 public __gshared
float BND_NODE_RADIUS
= 8;
899 /// feather of node title text
900 public __gshared
float BND_NODE_TITLE_FEATHER
= 1;
901 /// size of node title arrow
902 public __gshared
float BND_NODE_ARROW_SIZE
= 9;
905 ////////////////////////////////////////////////////////////////////////////////
906 public float bndClamp() (float v
, float mn
, float mx
) { pragma(inline
, true); return (v
> mx ? mx
: (v
< mn ? mn
: v
)); }
909 ////////////////////////////////////////////////////////////////////////////////
911 /// the initial theme
912 public __gshared BNDtheme bndTheme
= BNDtheme(
915 nvgRGBA(113, 113, 113, 255),
919 nvgRGBA( 24, 24, 24, 255), // outlineColor
920 nvgRGBA( 24, 24, 24, 255), // itemColor
921 nvgRGBA(153, 153, 153, 255), // innerColor
922 nvgRGBA( 99, 99, 99, 255), // innerSelectedColor
923 BND_COLOR_TEXT
, // textColor
924 BND_COLOR_TEXT_SELECTED
, // textSelectedColor
931 nvgRGBA( 24, 24, 24, 255), // outlineColor
932 nvgRGBA( 24, 24, 24, 255), // itemColor
933 nvgRGBA(153, 153, 153, 255), // innerColor
934 nvgRGBA( 99, 99, 99, 255), // innerSelectedColor
935 BND_COLOR_TEXT
, // textColor
936 BND_COLOR_TEXT_SELECTED
, // textSelectedColor
943 nvgRGBA( 0, 0, 0, 255), // outlineColor
944 nvgRGBA(255, 255, 255, 255), // itemColor
945 nvgRGBA( 70, 70, 70, 255), // innerColor
946 BND_COLOR_ACTIVE
, // innerSelectedColor
947 BND_COLOR_TEXT_SELECTED
, // textColor
948 BND_COLOR_TEXT
, // textSelectedColor
955 nvgRGBA( 24, 24, 24, 255), // outlineColor
956 nvgRGBA( 60, 160, 160, 255), // itemColor
957 nvgRGBA(153, 153, 153, 255), // innerColor
958 nvgRGBA(213, 213, 213, 255), // innerSelectedColor
959 BND_COLOR_TEXT
, // textColor
960 BND_COLOR_TEXT
, // textSelectedColor
963 NVGColor
.transparent
, // textHoverColor
964 NVGColor
.black
, // textCaretColor
969 nvgRGBA( 0, 0, 0, 255), // outlineColor
970 nvgRGBA(255, 255, 255, 255), // itemColor
971 nvgRGBA( 70, 70, 70, 255), // innerColor
972 nvgRGBA( 70, 70, 70, 255), // innerSelectedColor
973 BND_COLOR_TEXT
, // textColor
974 BND_COLOR_TEXT_SELECTED
, // textSelectedColor
981 nvgRGBA( 0, 0, 0, 255), // outlineColor
982 nvgRGBA(255, 255, 255, 255), // itemColor
983 nvgRGBA( 70, 70, 70, 255), // innerColor
984 nvgRGBA( 70, 70, 70, 255), // innerSelectedColor
985 BND_COLOR_TEXT_SELECTED
, // textColor
986 nvgRGBA(204, 204, 204, 255), // textSelectedColor
993 nvgRGBA( 24, 24, 24, 255), // outlineColor
994 nvgRGBA( 90, 90, 90, 255), // itemColor
995 nvgRGBA(180, 180, 180, 255), // innerColor
996 nvgRGBA(153, 153, 153, 255), // innerSelectedColor
997 BND_COLOR_TEXT
, // textColor
998 BND_COLOR_TEXT_SELECTED
, // textSelectedColor
1005 nvgRGBA( 24, 24, 24, 255), // outlineColor
1006 nvgRGBA(128, 128, 128, 255), // itemColor
1007 nvgRGBA(180, 180, 180, 255), // innerColor
1008 nvgRGBA(153, 153, 153, 255), // innerSelectedColor
1009 BND_COLOR_TEXT
, // textColor
1010 BND_COLOR_TEXT_SELECTED
, // textSelectedColor
1017 nvgRGBA( 49, 49, 49, 255), // outlineColor
1018 nvgRGBA(128, 128, 128, 255), // itemColor
1019 nvgRGBA( 80, 80, 80, 180), // innerColor
1020 nvgRGBA( 99, 99, 99, 180), // innerSelectedColor
1021 BND_COLOR_TEXT
, // textColor
1022 BND_COLOR_TEXT_SELECTED
, // textSelectedColor
1029 nvgRGBA( 0, 0, 0, 255), // outlineColor
1030 nvgRGBA( 99, 99, 99, 255), // itemColor
1031 nvgRGBA( 24, 24, 24, 230), // innerColor
1032 nvgRGBA( 44, 44, 44, 230), // innerSelectedColor
1033 nvgRGBA(159, 159, 159, 255), // textColor
1034 BND_COLOR_TEXT_SELECTED
, // textSelectedColor
1041 nvgRGBA( 0, 0, 0, 255), // outlineColor
1042 nvgRGBA( 99, 99, 99, 255), // itemColor
1043 nvgRGBA( 24, 24, 24, 230), // innerColor
1044 nvgRGBA( 44, 44, 44, 230), // innerSelectedColor
1045 nvgRGBA(159, 159, 159, 255), // textColor
1046 BND_COLOR_TEXT_SELECTED
, // textSelectedColor
1053 nvgRGBA( 0, 0, 0, 255), // outlineColor
1054 nvgRGBA(172, 172, 172, 128), // itemColor
1055 nvgRGBA( 0, 100, 180, 255), // innerColor
1056 BND_COLOR_ACTIVE
, // innerSelectedColor
1057 BND_COLOR_TEXT_SELECTED
, // textColor
1058 BND_COLOR_TEXT
, // textSelectedColor
1061 nvgRGBA(255, 255, 255, 255), // textHoverColor
1066 nvgRGBA(240, 87, 0, 255), // nodeSelectedColor
1067 nvgRGBA( 0, 0, 0, 255), // wiresColor
1068 nvgRGBA(126, 111, 111, 255), // textSelectedColor
1069 nvgRGBA(255, 170, 64, 255), // activeNodeColor
1070 nvgRGBA(255, 255, 255, 255), // wireSelectColor
1071 nvgRGBA(155, 155, 155, 159), // nodeBackdropColor
1076 ////////////////////////////////////////////////////////////////////////////////
1078 /// Sets the current theme all widgets will be drawn with. the default Blender 2.6 theme is set by default.
1079 public void bndSetTheme (in ref BNDtheme theme
) { bndTheme
= theme
; }
1081 /// Returns the currently set theme
1082 public BNDtheme
* bndGetTheme () { return &bndTheme
; }
1084 // the handle to the image containing the icon sheet
1085 private __gshared NVGImage bndIconImage
;
1088 //shared static ~this () { bndIconImage.clear(); }
1090 /** Designates an image handle as returned by nvgCreateImage*() as the themes'
1091 * icon sheet. The icon sheet format must be compatible to Blender 2.6's icon
1092 * sheet; the order of icons does not matter.
1094 * A valid icon sheet is e.g. shown at
1095 * http://wiki.blender.org/index.php/Dev:2.5/Doc/How_to/Add_an_icon
1097 * $(WARNING Icon sheet image should not outlive it's parent context! Use [bndClearIconImage] before context deletion.)
1099 public void bndSetIconImage() (in auto ref NVGImage image
) nothrow @trusted @nogc { version(aliced
) pragma(inline
, true); bndIconImage
= image
; }
1101 /// Clears current icon image.
1102 public void bndClearIconImage () nothrow @trusted @nogc { version(aliced
) pragma(inline
, true); bndIconImage
.clear(); }
1104 /// Returns icon sheet image.
1105 public NVGImage
bndGetIconImage () nothrow @trusted @nogc { version(aliced
) pragma(inline
, true); return bndIconImage
; }
1107 // the handle to the UI font
1108 private __gshared
int bndFont
= -1;
1109 private __gshared string bndFontFace
= null;
1111 /** Designates an image handle as returned by nvgCreateFont*() as the themes'
1112 * UI font. Blender's original UI font Droid Sans is perfectly suited and
1114 * https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/datafiles/fonts/
1116 public void bndSetFont (int font
) nothrow @trusted @nogc { pragma(inline
, true); bndFont
= font
; bndFontFace
= null; }
1118 /** Designates an image handle as returned by nvgCreateFont*() as the themes'
1119 * UI font. Blender's original UI font Droid Sans is perfectly suited and
1121 * https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/datafiles/fonts/
1123 public void bndSetFont (string font
) nothrow @trusted @nogc { pragma(inline
, true); bndFont
= -1; bndFontFace
= font
; }
1125 public struct BndFontSaviour
{
1127 string bndFontFace
= null;
1130 /// Returns opaque object with the current font.
1131 public BndFontSaviour
bndGetFont () nothrow @trusted @nogc { pragma(inline
, true); return BndFontSaviour(bndFont
, bndFontFace
); }
1133 /// Sets current font from the opaque object, returned by [bndGetFont].
1134 public void bndSetFont (in BndFontSaviour fsv
) nothrow @trusted @nogc { pragma(inline
, true); bndFont
= fsv
.bndFont
; bndFontFace
= fsv
.bndFontFace
; }
1137 // returns `true` if font *looks* like valid
1138 public bool bndRealizeFont (NVGContext ctx
) nothrow @trusted @nogc {
1139 if (ctx
is null) return false;
1140 if (bndFont
>= 0) { ctx
.fontFaceId
= bndFont
; return true; }
1141 if (bndFontFace
.length
) { ctx
.fontFace
= bndFontFace
; return true; }
1146 ////////////////////////////////////////////////////////////////////////////////
1147 /// High Level Functions. Use these functions to draw themed widgets with your NVGcontext.
1149 /** Draw a label with its lower left origin at (x, y) and size of (w, h).
1151 * if iconid >= 0, an icon will be added to the widget
1153 * if label is not null, a label will be added to the widget
1155 * widget looks best when height is BND_WIDGET_HEIGHT
1157 public void bndLabel(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int iconid
, const(T
)[] label
, int align_
=BND_LEFT
)
1158 if (isAnyCharType
!T
)
1160 bndIconLabelValue(ctx
, x
, y
, w
, h
, iconid
, bndTheme
.regularTheme
.textColor
, /*BND_LEFT*/align_
, BND_LABEL_FONT_SIZE
, label
);
1163 /** Draw a tool button with its lower left origin at (x, y) and size of (w, h),
1164 * where flags is one or multiple flags from BNDcornerFlags and state denotes
1165 * the widgets current UI state.
1167 * if iconid >= 0, an icon will be added to the widget
1169 * if label is not null, a label will be added to the widget
1171 * widget looks best when height is BND_WIDGET_HEIGHT
1173 public void bndToolButton(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int flags
, BNDwidgetState state
, int iconid
, const(T
)[] label
)
1174 if (isAnyCharType
!T
)
1177 NVGColor shadeTop
, shadeDown
;
1178 bndSelectCorners(cr
[], BND_TOOL_RADIUS
, flags
);
1179 bndBevelInset(ctx
, x
, y
, w
, h
, cr
[2], cr
[3]);
1180 bndInnerColors(&shadeTop
, &shadeDown
, &bndTheme
.toolTheme
, state
, 1);
1181 bndInnerBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], shadeTop
, shadeDown
);
1182 bndOutlineBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], bndTransparent(bndTheme
.toolTheme
.outlineColor
));
1183 bndIconLabelValue(ctx
, x
, y
, w
, h
, iconid
, bndTextColor(&bndTheme
.toolTheme
, state
), BND_CENTER
, BND_LABEL_FONT_SIZE
, label
);
1186 /** Draw a radio button with its lower left origin at (x, y) and size of (w, h),
1187 * where flags is one or multiple flags from BNDcornerFlags and state denotes
1188 * the widgets current UI state.
1190 * if iconid >= 0, an icon will be added to the widget
1192 * if label is not null, a label will be added to the widget
1194 * widget looks best when height is BND_WIDGET_HEIGHT
1196 public void bndRadioButton(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int flags
, BNDwidgetState state
, int iconid
, const(T
)[] label
)
1197 if (isAnyCharType
!T
)
1200 NVGColor shadeTop
, shadeDown
;
1201 bndSelectCorners(cr
[], BND_OPTION_RADIUS
, flags
);
1202 bndBevelInset(ctx
, x
, y
, w
, h
, cr
[2], cr
[3]);
1203 bndInnerColors(&shadeTop
, &shadeDown
, &bndTheme
.radioTheme
, state
, 1);
1204 bndInnerBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], shadeTop
, shadeDown
);
1205 bndOutlineBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], bndTransparent(bndTheme
.radioTheme
.outlineColor
));
1206 bndIconLabelValue(ctx
, x
, y
, w
, h
, iconid
, bndTextColor(&bndTheme
.radioTheme
, state
), BND_CENTER
, BND_LABEL_FONT_SIZE
, label
);
1209 /** Draw a radio button with its lower left origin at (x, y) and size of (w, h),
1210 * where flags is one or multiple flags from BNDcornerFlags and state denotes
1211 * the widgets current UI state.
1213 * if iconid >= 0, an icon will be added to the widget
1215 * if label is not null, a label will be added to the widget
1217 * widget looks best when height is BND_WIDGET_HEIGHT
1219 public void bndRadioButton2(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int flags
, BNDwidgetState state
, int iconid
, const(T
)[] label
)
1220 if (isAnyCharType
!T
)
1223 NVGColor shadeTop
, shadeDown
;
1225 oy
= y
+h
-BND_OPTION_HEIGHT
-3;
1226 bndBevelInset(ctx
, ox
, oy
, BND_OPTION_WIDTH
, BND_OPTION_HEIGHT
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
);
1227 bndInnerColors(&shadeTop
, &shadeDown
, &bndTheme
.optionTheme
, state
, 1);
1228 bndInnerBox(ctx
, ox
, oy
, BND_OPTION_WIDTH
, BND_OPTION_HEIGHT
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, shadeTop
, shadeDown
);
1229 bndOutlineBox(ctx
, ox
, oy
, BND_OPTION_WIDTH
, BND_OPTION_HEIGHT
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, bndTransparent(bndTheme
.optionTheme
.outlineColor
));
1230 if (state
== BND_ACTIVE
) bndRadioCheck(ctx
, ox
, oy
, bndTransparent(bndTheme
.optionTheme
.itemColor
));
1231 bndIconLabelValue(ctx
, x
+12, y
, w
-12, h
, -1, bndTextColor(&bndTheme
.optionTheme
, state
), BND_LEFT
, BND_LABEL_FONT_SIZE
, label
);
1234 /** Calculate the corresponding text position for given coordinates px/py
1236 * See bndTextField for more info.
1238 public int bndTextFieldTextPosition(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int iconid
, const(T
)[] text
, int px
, int py
)
1239 if (isAnyCharType
!T
)
1241 return bndIconLabelTextPosition(ctx
, x
, y
, w
, h
, iconid
, BND_LABEL_FONT_SIZE
, text
, px
, py
);
1244 /** Draw a text field with its lower left origin at (x, y) and size of (w, h),
1245 * where flags is one or multiple flags from BNDcornerFlags and state denotes
1246 * the widgets current UI state.
1248 * if iconid >= 0, an icon will be added to the widget
1250 * if text is not null, text will be printed to the widget
1252 * cbegin must be >= 0 and <= strlen(text) and denotes the beginning of the caret
1254 * cend must be >= cbegin and <= strlen(text) and denotes the end of the caret
1256 * if cend < cbegin, then no caret will be drawn
1258 * widget looks best when height is BND_WIDGET_HEIGHT
1260 public void bndTextField(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int flags
, BNDwidgetState state
, int iconid
, const(T
)[] text
, int cbegin
, int cend
)
1261 if (isAnyCharType
!T
)
1264 NVGColor shadeTop
, shadeDown
;
1265 bndSelectCorners(cr
[], BND_TEXT_RADIUS
, flags
);
1266 bndBevelInset(ctx
, x
, y
, w
, h
, cr
[2], cr
[3]);
1267 bndInnerColors(&shadeTop
, &shadeDown
, &bndTheme
.textFieldTheme
, state
, 0);
1268 bndInnerBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], shadeTop
, shadeDown
);
1269 bndOutlineBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], bndTransparent(bndTheme
.textFieldTheme
.outlineColor
));
1270 if (state
!= BND_ACTIVE
) cend
= -1;
1271 NVGColor cc
= bndTheme
.textFieldTheme
.textCaretColor
;
1272 if (cc
.isTransparent
) cc
= bndTheme
.textFieldTheme
.textColor
;
1273 bndIconLabelCaret(ctx
, x
, y
, w
, h
, iconid
, bndTextColor(&bndTheme
.textFieldTheme
, state
), BND_LABEL_FONT_SIZE
, text
, bndTheme
.textFieldTheme
.itemColor
, cbegin
, cend
, cc
);
1276 /** Draw an option button with its lower left origin at (x, y) and size of (w, h),
1277 * where flags is one or multiple flags from BNDcornerFlags and state denotes
1278 * the widgets current UI state.
1280 * if label is not null, a label will be added to the widget
1282 * widget looks best when height is BND_WIDGET_HEIGHT
1284 public void bndOptionButton(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, BNDwidgetState state
, const(T
)[] label
)
1285 if (isAnyCharType
!T
)
1288 NVGColor shadeTop
, shadeDown
;
1290 oy
= y
+h
-BND_OPTION_HEIGHT
-3;
1291 bndBevelInset(ctx
, ox
, oy
, BND_OPTION_WIDTH
, BND_OPTION_HEIGHT
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
);
1292 bndInnerColors(&shadeTop
, &shadeDown
, &bndTheme
.optionTheme
, state
, 1);
1293 bndInnerBox(ctx
, ox
, oy
, BND_OPTION_WIDTH
, BND_OPTION_HEIGHT
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, shadeTop
, shadeDown
);
1294 bndOutlineBox(ctx
, ox
, oy
, BND_OPTION_WIDTH
, BND_OPTION_HEIGHT
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, BND_OPTION_RADIUS
, bndTransparent(bndTheme
.optionTheme
.outlineColor
));
1295 if (state
== BND_ACTIVE
) bndCheck(ctx
, ox
, oy
, bndTransparent(bndTheme
.optionTheme
.itemColor
));
1296 bndIconLabelValue(ctx
, x
+12, y
, w
-12, h
, -1, bndTextColor(&bndTheme
.optionTheme
, state
), BND_LEFT
, BND_LABEL_FONT_SIZE
, label
);
1299 /** Draw a choice button with its lower left origin at (x, y) and size of (w, h),
1300 * where flags is one or multiple flags from BNDcornerFlags and state denotes
1301 * the widgets current UI state.
1303 * if iconid >= 0, an icon will be added to the widget
1305 * if label is not null, a label will be added to the widget
1307 * widget looks best when height is BND_WIDGET_HEIGHT
1309 public void bndChoiceButton(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int flags
, BNDwidgetState state
, int iconid
, const(T
)[] label
)
1310 if (isAnyCharType
!T
)
1313 NVGColor shadeTop
, shadeDown
;
1314 bndSelectCorners(cr
[], BND_OPTION_RADIUS
, flags
);
1315 bndBevelInset(ctx
, x
, y
, w
, h
, cr
[2], cr
[3]);
1316 bndInnerColors(&shadeTop
, &shadeDown
, &bndTheme
.choiceTheme
, state
, 1);
1317 bndInnerBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], shadeTop
, shadeDown
);
1318 bndOutlineBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], bndTransparent(bndTheme
.choiceTheme
.outlineColor
));
1319 bndIconLabelValue(ctx
, x
, y
, w
, h
, iconid
, bndTextColor(&bndTheme
.choiceTheme
, state
), BND_LEFT
, BND_LABEL_FONT_SIZE
, label
);
1320 bndUpDownArrow(ctx
, x
+w
-10, y
+10, 5, bndTransparent(bndTheme
.choiceTheme
.itemColor
));
1323 /** Draw a color button with its lower left origin at (x, y) and size of (w, h),
1324 * where flags is one or multiple flags from BNDcornerFlags and state denotes
1325 * the widgets current UI state.
1327 * widget looks best when height is BND_WIDGET_HEIGHT
1329 public void bndColorButton (NVGContext ctx
, float x
, float y
, float w
, float h
, int flags
, NVGColor color
) {
1331 bndSelectCorners(cr
[], BND_TOOL_RADIUS
, flags
);
1332 bndBevelInset(ctx
, x
, y
, w
, h
, cr
[2], cr
[3]);
1333 bndInnerBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], color
, color
);
1334 bndOutlineBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], bndTransparent(bndTheme
.toolTheme
.outlineColor
));
1337 /** Draw a number field with its lower left origin at (x, y) and size of (w, h),
1338 * where flags is one or multiple flags from BNDcornerFlags and state denotes
1339 * the widgets current UI state.
1341 * if label is not null, a label will be added to the widget
1343 * if value is not null, a value will be added to the widget, along with a ":" separator
1345 * widget looks best when height is BND_WIDGET_HEIGHT
1347 public void bndNumberField(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int flags
, BNDwidgetState state
, const(T
)[] label
, const(char)[] value
)
1348 if (isAnyCharType
!T
)
1351 NVGColor shadeTop
, shadeDown
;
1352 bndSelectCorners(cr
[], BND_NUMBER_RADIUS
, flags
);
1353 bndBevelInset(ctx
, x
, y
, w
, h
, cr
[2], cr
[3]);
1354 bndInnerColors(&shadeTop
, &shadeDown
, &bndTheme
.numberFieldTheme
, state
, 0);
1355 bndInnerBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], shadeTop
, shadeDown
);
1356 bndOutlineBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], bndTransparent(bndTheme
.numberFieldTheme
.outlineColor
));
1357 bndIconLabelValue(ctx
, x
, y
, w
, h
, -1, bndTextColor(&bndTheme
.numberFieldTheme
, state
), BND_CENTER
, BND_LABEL_FONT_SIZE
, label
, value
);
1358 bndArrow(ctx
, x
+8, y
+10, -BND_NUMBER_ARROW_SIZE
, bndTransparent(bndTheme
.numberFieldTheme
.itemColor
));
1359 bndArrow(ctx
, x
+w
-8, y
+10, BND_NUMBER_ARROW_SIZE
, bndTransparent(bndTheme
.numberFieldTheme
.itemColor
));
1362 /** Draw slider control with its lower left origin at (x, y) and size of (w, h),
1363 * where flags is one or multiple flags from BNDcornerFlags and state denotes
1364 * the widgets current UI state.
1366 * progress must be in the range 0..1 and controls the size of the slider bar
1368 * if label is not null, a label will be added to the widget
1370 * if value is not null, a value will be added to the widget, along with a ":" separator
1372 * widget looks best when height is BND_WIDGET_HEIGHT
1374 public void bndSlider(T
=char,TV
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int flags
, BNDwidgetState state
, float progress
, const(T
)[] label
, const(TV
)[] value
)
1375 if (isAnyCharType
!T
&& isAnyCharType
!TV
)
1378 NVGColor shadeTop
, shadeDown
;
1380 bndSelectCorners(cr
[], BND_NUMBER_RADIUS
, flags
);
1381 bndBevelInset(ctx
, x
, y
, w
, h
, cr
[2], cr
[3]);
1382 bndInnerColors(&shadeTop
, &shadeDown
, &bndTheme
.sliderTheme
, state
, 0);
1383 bndInnerBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], shadeTop
, shadeDown
);
1385 if (state
== BND_ACTIVE
) {
1386 shadeTop
= bndOffsetColor(bndTheme
.sliderTheme
.itemColor
, bndTheme
.sliderTheme
.shadeTop
);
1387 shadeDown
= bndOffsetColor(bndTheme
.sliderTheme
.itemColor
, bndTheme
.sliderTheme
.shadeDown
);
1389 shadeTop
= bndOffsetColor(bndTheme
.sliderTheme
.itemColor
, bndTheme
.sliderTheme
.shadeDown
);
1390 shadeDown
= bndOffsetColor(bndTheme
.sliderTheme
.itemColor
, bndTheme
.sliderTheme
.shadeTop
);
1392 ctx
.scissor(x
, y
, 8+(w
-8)*bndClamp(progress
, 0, 1), h
);
1393 bndInnerBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], shadeTop
, shadeDown
);
1396 bndOutlineBox(ctx
, x
, y
, w
, h
, cr
[0], cr
[1], cr
[2], cr
[3], bndTransparent(bndTheme
.sliderTheme
.outlineColor
));
1397 bndIconLabelValue(ctx
, x
, y
, w
, h
, -1, bndTextColor(&bndTheme
.sliderTheme
, state
), BND_CENTER
, BND_LABEL_FONT_SIZE
, label
, value
);
1400 /** Draw scrollbar with its lower left origin at (x, y) and size of (w, h),
1401 * where state denotes the widgets current UI state.
1403 * offset is in the range 0..1 and controls the position of the scroll handle
1405 * size is in the range 0..1 and controls the size of the scroll handle
1407 * horizontal widget looks best when height is BND_SCROLLBAR_HEIGHT,
1409 * vertical looks best when width is BND_SCROLLBAR_WIDTH
1411 public void bndScrollBar (NVGContext ctx
, float x
, float y
, float w
, float h
, BNDwidgetState state
, float offset
, float size
) {
1412 bndBevelInset(ctx
, x
, y
, w
, h
, BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
);
1413 bndInnerBox(ctx
, x
, y
, w
, h
,
1414 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1415 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1416 bndOffsetColor(bndTheme
.scrollBarTheme
.innerColor
, 3*bndTheme
.scrollBarTheme
.shadeDown
),
1417 bndOffsetColor(bndTheme
.scrollBarTheme
.innerColor
, 3*bndTheme
.scrollBarTheme
.shadeTop
));
1418 bndOutlineBox(ctx
, x
, y
, w
, h
,
1419 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1420 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1421 bndTransparent(bndTheme
.scrollBarTheme
.outlineColor
));
1423 NVGColor itemColor
= bndOffsetColor(bndTheme
.scrollBarTheme
.itemColor
, (state
== BND_ACTIVE ? BND_SCROLLBAR_ACTIVE_SHADE
: 0));
1425 bndScrollHandleRect(&x
, &y
, &w
, &h
, offset
, size
);
1427 bndInnerBox(ctx
, x
, y
, w
, h
,
1428 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1429 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1430 bndOffsetColor(itemColor
, 3*bndTheme
.scrollBarTheme
.shadeTop
),
1431 bndOffsetColor(itemColor
, 3*bndTheme
.scrollBarTheme
.shadeDown
));
1432 bndOutlineBox(ctx
, x
, y
, w
, h
,
1433 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1434 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1435 bndTransparent(bndTheme
.scrollBarTheme
.outlineColor
));
1438 /** Draw scrollbar with its lower left origin at (x, y) and size of (w, h),
1439 * where state denotes the widgets current UI state.
1441 * offset is in the range 0..1 and controls the position of the scroll handle
1443 * size is in the range 0..1 and controls the size of the scroll handle
1445 * horizontal widget looks best when height is BND_SCROLLBAR_HEIGHT,
1447 * vertical looks best when width is BND_SCROLLBAR_WIDTH
1449 public void bndScrollSlider (NVGContext ctx
, float x
, float y
, float w
, float h
, BNDwidgetState state
, float offset
, float size
=0) {
1450 bndBevelInset(ctx
, x
, y
, w
, h
, BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
);
1451 bndInnerBox(ctx
, x
, y
, w
, h
,
1452 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1453 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1454 bndOffsetColor(bndTheme
.scrollBarTheme
.innerColor
, 3*bndTheme
.scrollBarTheme
.shadeDown
),
1455 bndOffsetColor(bndTheme
.scrollBarTheme
.innerColor
, 3*bndTheme
.scrollBarTheme
.shadeTop
));
1456 bndOutlineBox(ctx
, x
, y
, w
, h
,
1457 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1458 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1459 bndTransparent(bndTheme
.scrollBarTheme
.outlineColor
));
1461 NVGColor itemColor
= bndOffsetColor(bndTheme
.scrollBarTheme
.itemColor
, (state
== BND_ACTIVE ? BND_SCROLLBAR_ACTIVE_SHADE
: 0));
1463 bndScrollSliderRect(&w
, &h
, offset
, size
);
1465 bndInnerBox(ctx
, x
, y
, w
, h
,
1466 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1467 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1468 bndOffsetColor(itemColor
, 3*bndTheme
.scrollBarTheme
.shadeTop
),
1469 bndOffsetColor(itemColor
, 3*bndTheme
.scrollBarTheme
.shadeDown
));
1470 bndOutlineBox(ctx
, x
, y
, w
, h
,
1471 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1472 BND_SCROLLBAR_RADIUS
, BND_SCROLLBAR_RADIUS
,
1473 bndTransparent(bndTheme
.scrollBarTheme
.outlineColor
));
1476 /** Draw a menu background with its lower left origin at (x, y) and size of (w, h),
1477 * where flags is one or multiple flags from BNDcornerFlags.
1479 public void bndMenuBackground (NVGContext ctx
, float x
, float y
, float w
, float h
, int flags
) {
1481 NVGColor shadeTop
, shadeDown
;
1482 bndSelectCorners(cr
[], BND_MENU_RADIUS
, flags
);
1483 bndInnerColors(&shadeTop
, &shadeDown
, &bndTheme
.menuTheme
, BND_DEFAULT
, 0);
1484 bndInnerBox(ctx
, x
, y
, w
, h
+1, cr
[0], cr
[1], cr
[2], cr
[3], shadeTop
, shadeDown
);
1485 bndOutlineBox(ctx
, x
, y
, w
, h
+1, cr
[0], cr
[1], cr
[2], cr
[3], bndTransparent(bndTheme
.menuTheme
.outlineColor
));
1486 bndDropShadow(ctx
, x
, y
, w
, h
, BND_MENU_RADIUS
, BND_SHADOW_FEATHER
, BND_SHADOW_ALPHA
);
1489 /// Draw a tooltip background with its lower left origin at (x, y) and size of (w, h)
1490 public void bndTooltipBackground (NVGContext ctx
, float x
, float y
, float w
, float h
) {
1491 NVGColor shadeTop
, shadeDown
;
1492 bndInnerColors(&shadeTop
, &shadeDown
, &bndTheme
.tooltipTheme
, BND_DEFAULT
, 0);
1493 bndInnerBox(ctx
, x
, y
, w
, h
+1, BND_MENU_RADIUS
, BND_MENU_RADIUS
, BND_MENU_RADIUS
, BND_MENU_RADIUS
, shadeTop
, shadeDown
);
1494 bndOutlineBox(ctx
, x
, y
, w
, h
+1, BND_MENU_RADIUS
, BND_MENU_RADIUS
, BND_MENU_RADIUS
, BND_MENU_RADIUS
, bndTransparent(bndTheme
.tooltipTheme
.outlineColor
));
1495 bndDropShadow(ctx
, x
, y
, w
, h
, BND_MENU_RADIUS
, BND_SHADOW_FEATHER
, BND_SHADOW_ALPHA
);
1498 /** Draw a menu label with its lower left origin at (x, y) and size of (w, h).
1500 * if iconid >= 0, an icon will be added to the widget
1502 * if label is not null, a label will be added to the widget
1504 * widget looks best when height is BND_WIDGET_HEIGHT
1506 public void bndMenuLabel(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int iconid
, const(T
)[] label
)
1507 if (isAnyCharType
!T
)
1509 bndIconLabelValue(ctx
, x
, y
, w
, h
, iconid
, bndTheme
.menuTheme
.textColor
, BND_LEFT
, BND_LABEL_FONT_SIZE
, label
);
1512 /** Draw a menu item with its lower left origin at (x, y) and size of (w, h),
1513 * where state denotes the widgets current UI state.
1515 * if iconid >= 0, an icon will be added to the widget
1517 * if label is not null, a label will be added to the widget
1519 * widget looks best when height is BND_WIDGET_HEIGHT
1521 public void bndMenuItem(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, BNDwidgetState state
, int iconid
, const(T
)[] label
)
1522 if (isAnyCharType
!T
)
1524 if (state
!= BND_DEFAULT
) {
1525 auto clr
= (state
== BND_HOVER ?
bndOffsetColor(bndTheme
.menuItemTheme
.innerColor
/*innerSelectedColor*/, BND_HOVER_SHADE
) : bndTheme
.menuItemTheme
.innerSelectedColor
);
1526 bndInnerBox(ctx
, x
, y
, w
, h
, 0, 0, 0, 0,
1527 bndOffsetColor(clr
, bndTheme
.menuItemTheme
.shadeTop
),
1528 bndOffsetColor(clr
, bndTheme
.menuItemTheme
.shadeDown
));
1529 //state = BND_ACTIVE;
1531 bndIconLabelValue(ctx
, x
, y
, w
, h
, iconid
,
1532 bndTextColor(&bndTheme
.menuItemTheme
, state
), BND_LEFT
,
1533 BND_LABEL_FONT_SIZE
, label
);
1536 /// Draw a node port at the given position filled with the given color
1537 public void bndNodePort (NVGContext ctx
, float x
, float y
, BNDwidgetState state
, NVGColor color
) {
1539 ctx
.circle(x
, y
, BND_NODE_PORT_RADIUS
);
1540 ctx
.strokeColor(bndTheme
.nodeTheme
.wiresColor
);
1541 ctx
.strokeWidth(1.0f);
1543 ctx
.fillColor((state
!= BND_DEFAULT ?
bndOffsetColor(color
, BND_HOVER_SHADE
) : color
));
1547 /// Draw a node wire originating at (x0, y0) and floating to (x1, y1), with a colored gradient based on the two colors color0 and color1
1548 public void bndColoredNodeWire (NVGContext ctx
, float x0
, float y0
, float x1
, float y1
, NVGColor color0
, NVGColor color1
) {
1549 import core
.stdc
.math
: fabsf
;
1550 float length
= bndMax(fabsf(x1
-x0
), fabsf(y1
-y0
));
1551 float delta
= length
*cast(float)bndTheme
.nodeTheme
.noodleCurving
/10.0f;
1555 ctx
.bezierTo(x0
+delta
, y0
, x1
-delta
, y1
, x1
, y1
);
1556 NVGColor colorw
= bndTheme
.nodeTheme
.wiresColor
;
1557 colorw
.a
= (color0
.a
< color1
.a ? color0
.a
: color1
.a
);
1558 ctx
.strokeColor(colorw
);
1559 ctx
.strokeWidth(BND_NODE_WIRE_OUTLINE_WIDTH
);
1561 ctx
.strokePaint(ctx
.linearGradient(x0
, y0
, x1
, y1
, color0
, color1
));
1562 ctx
.strokeWidth(BND_NODE_WIRE_WIDTH
);
1566 /** Draw a node wire originating at (x0, y0) and floating to (x1, y1), with
1567 * a colored gradient based on the states state0 and state1:
1569 * BND_DEFAULT: default wire color
1571 * BND_HOVER: selected wire color
1573 * BND_ACTIVE: dragged wire color
1575 public void bndNodeWire (NVGContext ctx
, float x0
, float y0
, float x1
, float y1
, BNDwidgetState state0
, BNDwidgetState state1
) {
1576 bndColoredNodeWire(ctx
, x0
, y0
, x1
, y1
, bndNodeWireColor(&bndTheme
.nodeTheme
, state0
), bndNodeWireColor(&bndTheme
.nodeTheme
, state1
));
1579 /// Draw a node background with its upper left origin at (x, y) and size of (w, h) where titleColor provides the base color for the title bar
1580 public void bndNodeBackground(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, BNDwidgetState state
, int iconid
, const(T
)[] label
, NVGColor titleColor
)
1581 if (isAnyCharType
!T
)
1583 bndInnerBox(ctx
, x
, y
, w
, BND_NODE_TITLE_HEIGHT
+2,
1584 BND_NODE_RADIUS
, BND_NODE_RADIUS
, 0, 0,
1585 bndTransparent(bndOffsetColor(titleColor
, BND_BEVEL_SHADE
)),
1586 bndTransparent(titleColor
));
1587 bndInnerBox(ctx
, x
, y
+BND_NODE_TITLE_HEIGHT
-1, w
, h
+2-BND_NODE_TITLE_HEIGHT
,
1588 0, 0, BND_NODE_RADIUS
, BND_NODE_RADIUS
,
1589 bndTransparent(bndTheme
.nodeTheme
.nodeBackdropColor
),
1590 bndTransparent(bndTheme
.nodeTheme
.nodeBackdropColor
));
1591 bndNodeIconLabel(ctx
,
1592 x
+BND_NODE_ARROW_AREA_WIDTH
, y
,
1593 w
-BND_NODE_ARROW_AREA_WIDTH
-BND_NODE_MARGIN_SIDE
, BND_NODE_TITLE_HEIGHT
,
1594 iconid
, bndTheme
.regularTheme
.textColor
,
1595 bndOffsetColor(titleColor
, BND_BEVEL_SHADE
),
1596 BND_LEFT
, BND_LABEL_FONT_SIZE
, label
);
1597 NVGColor arrowColor
;
1598 NVGColor borderColor
;
1602 borderColor
= nvgRGBf(0, 0, 0);
1603 arrowColor
= bndOffsetColor(titleColor
, -BND_BEVEL_SHADE
);
1606 borderColor
= bndTheme
.nodeTheme
.nodeSelectedColor
;
1607 arrowColor
= bndTheme
.nodeTheme
.nodeSelectedColor
;
1610 borderColor
= bndTheme
.nodeTheme
.activeNodeColor
;
1611 arrowColor
= bndTheme
.nodeTheme
.nodeSelectedColor
;
1614 bndOutlineBox(ctx
, x
, y
, w
, h
+1, BND_NODE_RADIUS
, BND_NODE_RADIUS
, BND_NODE_RADIUS
, BND_NODE_RADIUS
, bndTransparent(borderColor
));
1615 //bndNodeArrowDown(ctx, x+BND_NODE_MARGIN_SIDE, y+BND_NODE_TITLE_HEIGHT-4, BND_NODE_ARROW_SIZE, arrowColor);
1616 bndDropShadow(ctx
, x
, y
, w
, h
, BND_NODE_RADIUS
, BND_SHADOW_FEATHER
, BND_SHADOW_ALPHA
);
1619 /// Draw a window with the upper right and lower left splitter widgets into the rectangle at origin (x, y) and size (w, h)
1620 public void bndSplitterWidgets (NVGContext ctx
, float x
, float y
, float w
, float h
) {
1621 NVGColor insetLight
= bndTransparent(bndOffsetColor(bndTheme
.backgroundColor
, BND_SPLITTER_SHADE
));
1622 NVGColor insetDark
= bndTransparent(bndOffsetColor(bndTheme
.backgroundColor
, -BND_SPLITTER_SHADE
));
1623 NVGColor inset
= bndTransparent(bndTheme
.backgroundColor
);
1629 ctx
.moveTo(x
, y2
-13);
1630 ctx
.lineTo(x
+13, y2
);
1631 ctx
.moveTo(x
, y2
-9);
1632 ctx
.lineTo(x
+9, y2
);
1633 ctx
.moveTo(x
, y2
-5);
1634 ctx
.lineTo(x
+5, y2
);
1636 ctx
.moveTo(x2
-11, y
);
1637 ctx
.lineTo(x2
, y
+11);
1638 ctx
.moveTo(x2
-7, y
);
1639 ctx
.lineTo(x2
, y
+7);
1640 ctx
.moveTo(x2
-3, y
);
1641 ctx
.lineTo(x2
, y
+3);
1643 ctx
.strokeColor(insetDark
);
1647 ctx
.moveTo(x
, y2
-11);
1648 ctx
.lineTo(x
+11, y2
);
1649 ctx
.moveTo(x
, y2
-7);
1650 ctx
.lineTo(x
+7, y2
);
1651 ctx
.moveTo(x
, y2
-3);
1652 ctx
.lineTo(x
+3, y2
);
1654 ctx
.moveTo(x2
-13, y
);
1655 ctx
.lineTo(x2
, y
+13);
1656 ctx
.moveTo(x2
-9, y
);
1657 ctx
.lineTo(x2
, y
+9);
1658 ctx
.moveTo(x2
-5, y
);
1659 ctx
.lineTo(x2
, y
+5);
1661 ctx
.strokeColor(insetLight
);
1665 ctx
.moveTo(x
, y2
-12);
1666 ctx
.lineTo(x
+12, y2
);
1667 ctx
.moveTo(x
, y2
-8);
1668 ctx
.lineTo(x
+8, y2
);
1669 ctx
.moveTo(x
, y2
-4);
1670 ctx
.lineTo(x
+4, y2
);
1672 ctx
.moveTo(x2
-12, y
);
1673 ctx
.lineTo(x2
, y
+12);
1674 ctx
.moveTo(x2
-8, y
);
1675 ctx
.lineTo(x2
, y
+8);
1676 ctx
.moveTo(x2
-4, y
);
1677 ctx
.lineTo(x2
, y
+4);
1679 ctx
.strokeColor(inset
);
1683 /** Draw the join area overlay stencil into the rectangle
1684 * at origin (x, y) and size (w, h)
1686 * vertical is `false` or `true` and designates the arrow orientation, mirror is `false` or `true` and flips the arrow side
1688 public void bndJoinAreaOverlay (NVGContext ctx
, float x
, float y
, float w
, float h
, bool vertical
, bool mirror
) {
1694 float s
= (w
< h ? w
: h
);
1696 float x0
, y0
, x1
, y1
;
1710 float yc
= (y0
+y1
)*0.5f;
1716 float[2][11] points
= [
1731 int count
= cast(int)points
.length
; //sizeof(points)/(sizeof(float)*2);
1732 ctx
.moveTo(x
+points
[0][vertical
&1], y
+points
[0][(vertical
&1)^
1]);
1733 foreach (int i
; 1..count
) ctx
.lineTo(x
+points
[i
][vertical
&1], y
+points
[i
][(vertical
&1)^
1]);
1735 ctx
.fillColor(nvgRGBAf(0, 0, 0, 0.3));
1740 ////////////////////////////////////////////////////////////////////////////////
1741 /// Estimator Functions
1742 /// Use these functions to estimate sizes for widgets with your NVGcontext.
1744 /// returns the ideal width for a label with given icon and text
1745 public float bndLabelWidth(T
=char) (NVGContext ctx
, int iconid
, const(T
)[] label
) if (isAnyCharType
!T
) {
1746 float w
= BND_PAD_LEFT
+BND_PAD_RIGHT
;
1747 if (iconid
>= 0) w
+= BND_ICON_SHEET_RES
;
1748 if (label
.length
&& bndRealizeFont(ctx
)) {
1749 ctx
.fontSize(BND_LABEL_FONT_SIZE
);
1750 w
+= ctx
.textBounds(1, 1, label
, null);
1752 return cast(float)cast(int)(w
+0.5);
1755 /// returns the height for a label with given icon, text and width; this function is primarily useful in conjunction with multiline labels and textboxes
1756 public float bndLabelHeight(T
=char) (NVGContext ctx
, int iconid
, const(T
)[] label
, float width
) if (isAnyCharType
!T
) {
1757 float h
= BND_WIDGET_HEIGHT
;
1758 width
-= BND_TEXT_RADIUS
*2;
1759 if (iconid
>= 0) width
-= BND_ICON_SHEET_RES
;
1760 if (label
.length
&& bndRealizeFont(ctx
)) {
1761 ctx
.fontSize(BND_LABEL_FONT_SIZE
);
1762 float[4] bounds
= void;
1763 ctx
.textBoxBounds(1, 1, width
, label
, bounds
[]);
1764 float bh
= (bounds
[3]-bounds
[1])+BND_TEXT_PAD_DOWN
;
1767 return cast(float)cast(int)(h
+0.5);
1771 ////////////////////////////////////////////////////////////////////////////////
1772 /// Low Level Functions
1773 /// these are part of the implementation detail and can be used to theme new kinds of controls in a similar fashion.
1775 /** Add a rounded box path at position (x, y) with size (w, h) and a separate
1776 * radius for each corner listed in clockwise order, so that cr0 = top left,
1777 * cr1 = top right, cr2 = bottom right, cr3 = bottom left;
1779 * this is a low level drawing function: the path must be stroked or filled
1780 * to become visible.
1782 public void bndRoundedBox (NVGContext ctx
, float x
, float y
, float w
, float h
, float cr0
, float cr1
, float cr2
, float cr3
) {
1787 ctx
.moveTo(x
, y
+h
*0.5f);
1788 ctx
.arcTo(x
, y
, x
+w
, y
, bndMin(cr0
, d
/2));
1789 ctx
.arcTo(x
+w
, y
, x
+w
, y
+h
, bndMin(cr1
, d
/2));
1790 ctx
.arcTo(x
+w
, y
+h
, x
, y
+h
, bndMin(cr2
, d
/2));
1791 ctx
.arcTo(x
, y
+h
, x
, y
, bndMin(cr3
, d
/2));
1795 /// make color transparent using the default alpha value
1796 public NVGColor
bndTransparent (NVGColor color
) {
1797 color
.a
*= BND_TRANSPARENT_ALPHA
;
1801 /// offset a color by a given integer delta in the range -100 to 100
1802 public NVGColor
bndOffsetColor (NVGColor color
, int delta
) {
1803 float offset
= cast(float)delta
/255.0f;
1804 return (delta ?
nvgRGBAf(bndClamp(color
.r
+offset
, 0, 1), bndClamp(color
.g
+offset
, 0, 1), bndClamp(color
.b
+offset
, 0, 1), color
.a
) : color
);
1807 /// Draw a beveled border at position (x, y) with size (w, h) shaded with lighter and darker versions of backgroundColor
1808 public void bndBevel (NVGContext ctx
, float x
, float y
, float w
, float h
) {
1818 ctx
.lineTo(x
+w
, y
+h
);
1820 ctx
.strokeColor(bndTransparent(bndOffsetColor(bndTheme
.backgroundColor
, -BND_BEVEL_SHADE
)));
1827 ctx
.strokeColor(bndTransparent(bndOffsetColor(bndTheme
.backgroundColor
, BND_BEVEL_SHADE
)));
1831 /** Draw a lower inset for a rounded box at position (x, y) with size (w, h)
1832 * that gives the impression the surface has been pushed in.
1834 * cr2 and cr3 contain the radiuses of the bottom right and bottom left
1835 * corners of the rounded box.
1837 public void bndBevelInset (NVGContext ctx
, float x
, float y
, float w
, float h
, float cr2
, float cr3
) {
1842 cr2
= bndMin(cr2
, d
/2);
1843 cr3
= bndMin(cr3
, d
/2);
1846 ctx
.moveTo(x
+w
, y
+h
-cr2
);
1847 ctx
.arcTo(x
+w
, y
+h
, x
, y
+h
, cr2
);
1848 ctx
.arcTo(x
, y
+h
, x
, y
, cr3
);
1850 NVGColor bevelColor
= bndOffsetColor(bndTheme
.backgroundColor
, BND_INSET_BEVEL_SHADE
);
1853 ctx
.strokePaint(ctx
.linearGradient(x
, y
+h
-bndMax(cr2
, cr3
)-1, x
, y
+h
-1, nvgRGBAf(bevelColor
.r
, bevelColor
.g
, bevelColor
.b
, 0), bevelColor
));
1857 /// Draw a flat panel without any decorations at position (x, y) with size (w, h) and fills it with backgroundColor
1858 public void bndBackground (NVGContext ctx
, float x
, float y
, float w
, float h
) {
1860 ctx
.rect(x
, y
, w
, h
);
1861 ctx
.fillColor(bndTheme
.backgroundColor
);
1865 /// Draw an icon with (x, y) as its upper left coordinate; the iconid selects the icon from the sheet; use the BND_ICONID macro to build icon IDs.
1866 public void bndIcon (NVGContext ctx
, float x
, float y
, int iconid
) {
1868 if (!bndIconImage
.valid
) return; // no icons loaded
1871 iy
= (iconid
>>8)&0xff;
1872 u
= BND_ICON_SHEET_OFFSET_X
+ix
*BND_ICON_SHEET_GRID
;
1873 v
= BND_ICON_SHEET_OFFSET_Y
+iy
*BND_ICON_SHEET_GRID
;
1876 ctx
.rect(x
, y
, BND_ICON_SHEET_RES
, BND_ICON_SHEET_RES
);
1877 ctx
.fillPaint(ctx
.imagePattern(x
-u
, y
-v
, BND_ICON_SHEET_WIDTH
, BND_ICON_SHEET_HEIGHT
, 0, bndIconImage
, 1));
1881 /** Draw a drop shadow around the rounded box at (x, y) with size (w, h) and
1882 * radius r, with feather as its maximum range in pixels.
1884 * No shadow will be painted inside the rounded box.
1886 public void bndDropShadow (NVGContext ctx
, float x
, float y
, float w
, float h
, float r
, float feather
, float alpha
) {
1891 ctx
.moveTo(x
-feather
, y
-feather
);
1892 ctx
.lineTo(x
, y
-feather
);
1893 ctx
.lineTo(x
, y
+h
-feather
);
1894 ctx
.arcTo(x
, y
+h
, x
+r
, y
+h
, r
);
1895 ctx
.arcTo(x
+w
, y
+h
, x
+w
, y
+h
-r
, r
);
1896 ctx
.lineTo(x
+w
, y
-feather
);
1897 ctx
.lineTo(x
+w
+feather
, y
-feather
);
1898 ctx
.lineTo(x
+w
+feather
, y
+h
+feather
);
1899 ctx
.lineTo(x
-feather
, y
+h
+feather
);
1902 ctx
.fillPaint(ctx
.boxGradient(x
-feather
*0.5f, y
-feather
*0.5f,
1903 w
+feather
, h
+feather
,
1906 nvgRGBAf(0, 0, 0, alpha
*alpha
),
1907 nvgRGBAf(0, 0, 0, 0)));
1911 /* Draw the inner part of a widget box, with a gradient from shadeTop to
1912 * shadeDown. If h>w, the gradient will be horizontal instead of vertical.
1914 public void bndInnerBox (NVGContext ctx
, float x
, float y
, float w
, float h
, float cr0
, float cr1
, float cr2
, float cr3
, NVGColor shadeTop
, NVGColor shadeDown
) {
1916 bndRoundedBox(ctx
, x
+1, y
+1, w
-2, h
-3, bndMax(0, cr0
-1), bndMax(0, cr1
-1), bndMax(0, cr2
-1), bndMax(0, cr3
-1));
1917 ctx
.fillPaint((h
-2 > w ? ctx
.linearGradient(x
, y
, x
+w
, y
, shadeTop
, shadeDown
) : ctx
.linearGradient(x
, y
, x
, y
+h
, shadeTop
, shadeDown
)));
1921 /// Draw the outline part of a widget box with the given color
1922 public void bndOutlineBox (NVGContext ctx
, float x
, float y
, float w
, float h
, float cr0
, float cr1
, float cr2
, float cr3
, NVGColor color
) {
1924 bndRoundedBox(ctx
, x
+0.5f, y
+0.5f, w
-1, h
-2, cr0
, cr1
, cr2
, cr3
);
1925 ctx
.strokeColor(color
);
1930 /** assigns radius r to the four entries of array radiuses depending on whether
1931 * the corner is marked as sharp or not; see BNDcornerFlags for possible
1934 public void bndSelectCorners (float[] radiuses
, float r
, int flags
) {
1935 if (radiuses
.length
> 0) radiuses
.ptr
[0] = (flags
&BND_CORNER_TOP_LEFT ?
0 : r
);
1936 if (radiuses
.length
> 1) radiuses
.ptr
[1] = (flags
&BND_CORNER_TOP_RIGHT ?
0 : r
);
1937 if (radiuses
.length
> 2) radiuses
.ptr
[2] = (flags
&BND_CORNER_DOWN_RIGHT ?
0 : r
);
1938 if (radiuses
.length
> 3) radiuses
.ptr
[3] = (flags
&BND_CORNER_DOWN_LEFT ?
0 : r
);
1941 /** computes the upper and lower gradient colors for the inner box from a widget
1942 * theme and the widgets state. If flipActive is set and the state is
1943 * BND_ACTIVE, the upper and lower colors will be swapped.
1945 public void bndInnerColors (NVGColor
* shadeTop
, NVGColor
* shadeDown
, const(BNDwidgetTheme
)* theme
, BNDwidgetState state
, int flipActive
) {
1949 if (shadeTop
!is null) *shadeTop
= bndOffsetColor(theme
.innerColor
, theme
.shadeTop
);
1950 if (shadeDown
!is null) *shadeDown
= bndOffsetColor(theme
.innerColor
, theme
.shadeDown
);
1953 NVGColor color
= bndOffsetColor(theme
.innerColor
, BND_HOVER_SHADE
);
1954 if (shadeTop
!is null) *shadeTop
= bndOffsetColor(color
, theme
.shadeTop
);
1955 if (shadeDown
!is null) *shadeDown
= bndOffsetColor(color
, theme
.shadeDown
);
1958 if (shadeTop
!is null) *shadeTop
= bndOffsetColor(theme
.innerSelectedColor
, flipActive?theme
.shadeDown
:theme
.shadeTop
);
1959 if (shadeDown
!is null) *shadeDown
= bndOffsetColor(theme
.innerSelectedColor
, flipActive?theme
.shadeTop
:theme
.shadeDown
);
1964 /// computes the text color for a widget label from a widget theme and the widgets state.
1965 public NVGColor
bndTextColor (const(BNDwidgetTheme
)* theme
, BNDwidgetState state
) nothrow @trusted @nogc {
1966 pragma(inline
, true);
1968 state
== BND_ACTIVE ? theme
.textSelectedColor
:
1969 state
== BND_HOVER ?
(theme
.textHoverColor
.isTransparent ? theme
.textColor
: theme
.textHoverColor
) :
1973 /** Draw an optional icon specified by <iconid> and an optional label with
1974 * given alignment (BNDtextAlignment), fontsize and color within a widget box.
1976 * if iconid is >= 0, an icon will be drawn and the labels remaining space will be adjusted.
1978 * if label is not null, it will be drawn with the specified alignment, fontsize and color.
1980 * if value is not null, label and value will be drawn with a ":" separator inbetween.
1982 public void bndIconLabelValue(T
=char,TV
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int iconid
, NVGColor color
, int align_
, float fontsize
, const(T
)[] label
, const(TV
)[] value
=null)
1983 if (isAnyCharType
!T
&& isAnyCharType
!TV
)
1985 float pleft
= BND_PAD_LEFT
;
1988 bndIcon(ctx
, x
+4, y
+2, iconid
);
1989 pleft
+= BND_ICON_SHEET_RES
;
1992 if (!bndRealizeFont(ctx
)) return;
1993 ctx
.fontSize(fontsize
);
1995 ctx
.fillColor(color
);
1997 float label_width
= ctx
.textBounds(1, 1, label
, null);
1998 float sep_width
= ctx
.textBounds(1, 1, BND_LABEL_SEPARATOR
, null);
2000 ctx
.textAlign(NVGTextAlign
.H
.Left
, NVGTextAlign
.V
.Baseline
);
2002 if (align_
== BND_CENTER
) {
2003 float width
= label_width
+sep_width
+ctx
.textBounds(1, 1, value
, null);
2004 x
+= ((w
-BND_PAD_RIGHT
-pleft
)-width
)*0.5f;
2005 } else if (align_
== BND_RIGHT
) {
2006 float width
= label_width
+sep_width
+ctx
.textBounds(1, 1, value
, null);
2007 x
+= w
-BND_PAD_RIGHT
-width
;
2009 y
+= BND_WIDGET_HEIGHT
-BND_TEXT_PAD_DOWN
;
2010 ctx
.text(x
, y
, label
);
2012 ctx
.text(x
, y
, BND_LABEL_SEPARATOR
);
2014 ctx
.text(x
, y
, value
);
2016 ctx
.textAlign((align_
== BND_LEFT ?
NVGTextAlign(NVGTextAlign
.H
.Left
, NVGTextAlign
.V
.Baseline
) : align_
== BND_CENTER ?
NVGTextAlign(NVGTextAlign
.H
.Center
, NVGTextAlign
.V
.Baseline
) : NVGTextAlign(NVGTextAlign
.H
.Right
, NVGTextAlign
.V
.Baseline
)));
2017 ctx
.textBox(x
+pleft
, y
+BND_WIDGET_HEIGHT
-BND_TEXT_PAD_DOWN
, w
-BND_PAD_RIGHT
-pleft
, label
);
2018 //{ import core.stdc.stdio : printf; printf("l=%u\n", cast(uint)label.length); }
2020 } else if (iconid
>= 0) {
2021 bndIcon(ctx
, x
+2, y
+2, iconid
);
2025 /** Draw an optional icon specified by <iconid> and an optional label with
2026 * given alignment (BNDtextAlignment), fontsize and color within a node title bar
2028 * if iconid is >= 0, an icon will be drawn
2030 * if label is not null, it will be drawn with the specified alignment, fontsize and color.
2032 public void bndNodeIconLabel(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int iconid
, NVGColor color
, NVGColor shadowColor
, int align_
, float fontsize
, const(T
)[] label
)
2033 if (isAnyCharType
!T
)
2035 if (label
.length
&& bndRealizeFont(ctx
)) {
2036 ctx
.fontSize(fontsize
);
2038 ctx
.textAlign(NVGTextAlign
.H
.Left
, NVGTextAlign
.V
.Baseline
);
2039 ctx
.fillColor(shadowColor
);
2040 ctx
.fontBlur(BND_NODE_TITLE_FEATHER
);
2041 ctx
.textBox(x
+1, y
+h
+3-BND_TEXT_PAD_DOWN
, w
, label
);
2042 ctx
.fillColor(color
);
2044 ctx
.textBox(x
, y
+h
+2-BND_TEXT_PAD_DOWN
, w
, label
);
2046 if (iconid
>= 0) bndIcon(ctx
, x
+w
-BND_ICON_SHEET_RES
, y
+3, iconid
);
2049 /** Calculate the corresponding text position for given coordinates px/py in an iconLabel.
2050 * See bndIconLabelCaret for more info.
2052 public int bndIconLabelTextPosition(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int iconid
, float fontsize
, const(T
)[] label
, int px
, int py
)
2053 if (isAnyCharType
!T
)
2056 float pleft
= BND_TEXT_RADIUS
;
2057 if (label
.length
== 0) return -1;
2058 if (iconid
>= 0) pleft
+= BND_ICON_SHEET_RES
;
2060 if (!bndRealizeFont(ctx
)) return -1;
2063 y
+= BND_WIDGET_HEIGHT
-BND_TEXT_PAD_DOWN
;
2065 ctx
.fontSize(fontsize
);
2066 ctx
.textAlign(NVGTextAlign
.H
.Left
, NVGTextAlign
.V
.Baseline
);
2068 w
-= BND_TEXT_RADIUS
+pleft
;
2070 float asc
, desc
, lh
;
2071 static NVGTextRow
!T
[BND_MAX_ROWS
] rows
;
2072 auto rres
= ctx
.textBreakLines(label
, w
, rows
[]);
2073 //{ import core.stdc.stdio : printf; printf("rlen=%u\n", cast(uint)rres.length); }
2074 if (rres
.length
== 0) return 0;
2075 ctx
.textBoxBounds(x
, y
, w
, label
, bounds
[]);
2076 ctx
.textMetrics(&asc
, &desc
, &lh
);
2078 // calculate vertical position
2079 int row
= cast(int)bndClamp(cast(int)(cast(float)(py
-bounds
[1])/lh
), 0, cast(int)rres
.length
-1);
2080 // search horizontal position
2081 static NVGGlyphPosition
[BND_MAX_GLYPHS
] glyphs
;
2082 //int nglyphs = ctx.textGlyphPositions(x, y, rows[row].start, rows[row].end+1, glyphs.ptr, BND_MAX_GLYPHS);
2083 auto rglyphs
= ctx
.textGlyphPositions(x
, y
, rows
[row
].row
!T
, glyphs
[]);
2084 int nglyphs
= cast(int)rglyphs
.length
;
2086 for (col
= 0; col
< nglyphs
&& glyphs
[col
].x
< px
; ++col
) p
= cast(int)glyphs
[col
].strpos
;
2087 // see if we should move one character further
2088 if (col
> 0 && col
< nglyphs
&& glyphs
[col
].x
-px
< px
-glyphs
[col
-1].x
) p
= cast(int)glyphs
[col
].strpos
;
2092 void bndCaretPosition(RT
) (NVGContext ctx
, float x
, float y
, float desc
, float lineHeight
, int caretpos
, RT
[] rows
, int* cr
, float* cx
, float* cy
)
2093 if (is(RT
: NVGTextRow
!CT
, CT
))
2095 static NVGGlyphPosition
[BND_MAX_GLYPHS
] glyphs
;
2097 //for (r = 0; r < nrows && rows[r].end < caret; ++r) {}
2098 while (r
< rows
.length
&& rows
[r
].end
< caretpos
) ++r
;
2099 if (cr
!is null) *cr
= cast(int)r
;
2100 if (cx
!is null) *cx
= x
;
2101 if (cy
!is null) *cy
= y
-lineHeight
-desc
+r
*lineHeight
;
2102 if (rows
.length
== 0) return;
2103 if (cx
!is null) *cx
= rows
[r
].minx
;
2104 //auto rglyphs = (rows[r].isChar ? ctx.textGlyphPositions(x, y, rows[r].row!char, glyphs[]) : ctx.textGlyphPositions(x, y, rows[r].row!dchar, glyphs[]));
2105 auto rglyphs
= ctx
.textGlyphPositions(x
, y
, rows
[r
].row
, glyphs
[]);
2106 foreach (immutable i
; 0..rglyphs
.length
) {
2107 if (cx
!is null) *cx
= glyphs
.ptr
[i
].x
;
2108 if (glyphs
.ptr
[i
].strpos
== caretpos
) break;
2112 /** Draw an optional icon specified by <iconid>, an optional label and
2113 * a caret with given fontsize and color within a widget box.
2115 * if iconid is >= 0, an icon will be drawn and the labels remaining space will be adjusted.
2117 * if label is not null, it will be drawn with the specified alignment, fontsize and color.
2119 * cbegin must be >= 0 and <= strlen(text) and denotes the beginning of the caret
2121 * cend must be >= cbegin and <= strlen(text) and denotes the end of the caret if cend < cbegin, then no caret will be drawn
2123 public void bndIconLabelCaret(T
=char) (NVGContext ctx
, float x
, float y
, float w
, float h
, int iconid
, NVGColor color
, float fontsize
, const(T
)[] label
, NVGColor caretcolor
, int cbegin
, int cend
, NVGColor thinCaretColor
=NVGColor
.black
)
2124 if (isAnyCharType
!T
)
2126 float pleft
= BND_TEXT_RADIUS
;
2127 if (label
.length
== 0) return;
2129 bndIcon(ctx
, x
+4, y
+2, iconid
);
2130 pleft
+= BND_ICON_SHEET_RES
;
2133 if (!bndRealizeFont(ctx
)) return;
2136 y
+= BND_WIDGET_HEIGHT
-BND_TEXT_PAD_DOWN
;
2138 ctx
.fontSize(fontsize
);
2139 ctx
.textAlign(NVGTextAlign
.H
.Left
, NVGTextAlign
.V
.Baseline
);
2141 w
-= BND_TEXT_RADIUS
+pleft
;
2143 if (cend
>= cbegin
) {
2145 float c0x
, c0y
, c1x
, c1y
;
2147 static NVGTextRow
!T
[BND_MAX_ROWS
] rows
;
2148 auto rrows
= ctx
.textBreakLines(label
[0..cend
], w
, rows
[]);
2149 ctx
.textMetrics(null, &desc
, &lh
);
2151 bndCaretPosition(ctx
, x
, y
, desc
, lh
, cbegin
, rrows
, &c0r
, &c0x
, &c0y
);
2152 bndCaretPosition(ctx
, x
, y
, desc
, lh
, cend
, rrows
, &c1r
, &c1x
, &c1y
);
2155 if (cbegin
== cend
) {
2156 //ctx.fillColor(nvgRGBf(0.337, 0.502, 0.761));
2157 ctx
.fillColor(thinCaretColor
);
2158 //ctx.rect(c0x-1, c0y, 2, lh+1);
2159 ctx
.rect(c0x
, c0y
, 1, lh
+1);
2161 ctx
.fillColor(caretcolor
);
2163 ctx
.rect(c0x
-1, c0y
, c1x
-c0x
+1, lh
+1);
2165 int blk
= c1r
-c0r
-1;
2166 ctx
.rect(c0x
-1, c0y
, x
+w
-c0x
+1, lh
+1);
2167 ctx
.rect(x
, c1y
, c1x
-x
+1, lh
+1);
2168 if (blk
) ctx
.rect(x
, c0y
+lh
, w
, blk
*lh
+1);
2175 ctx
.fillColor(color
);
2176 ctx
.textBox(x
, y
, w
, label
);
2179 /// Draw a checkmark for an option box with the given upper left coordinates (ox, oy) with the specified color.
2180 public void bndCheck (NVGContext ctx
, float ox
, float oy
, NVGColor color
) {
2183 ctx
.strokeColor(color
);
2184 ctx
.lineCap(NVGLineCap
.Butt
);
2185 ctx
.lineJoin(NVGLineCap
.Miter
);
2186 ctx
.moveTo(ox
+4, oy
+5);
2187 ctx
.lineTo(ox
+7, oy
+8);
2188 ctx
.lineTo(ox
+14, oy
+1);
2192 /// Draw a checkmark for a radio with the given upper left coordinates (ox, oy) with the specified color.
2193 public void bndRadioCheck (NVGContext ctx
, float ox
, float oy
, NVGColor color
) {
2195 ctx
.fillColor(color
);
2196 ctx
.circle(ox
+7, oy
+7, 3);
2200 /// Draw a horizontal arrow for a number field with its center at (x, y) and size s; if s is negative, the arrow points to the left.
2201 public void bndArrow (NVGContext ctx
, float x
, float y
, float s
, NVGColor color
) {
2204 ctx
.lineTo(x
-s
, y
+s
);
2205 ctx
.lineTo(x
-s
, y
-s
);
2207 ctx
.fillColor(color
);
2211 /// Draw an up/down arrow for a choice box with its center at (x, y) and size s
2212 public void bndUpDownArrow (NVGContext ctx
, float x
, float y
, float s
, NVGColor color
) {
2217 ctx
.lineTo(x
+0.5*w
, y
-s
-1);
2218 ctx
.lineTo(x
+w
, y
-1);
2221 ctx
.lineTo(x
+0.5*w
, y
+s
+1);
2222 ctx
.lineTo(x
+w
, y
+1);
2224 ctx
.fillColor(color
);
2228 /// Draw a node down-arrow with its tip at (x, y) and size s
2229 public void bndNodeArrowDown (NVGContext ctx
, float x
, float y
, float s
, NVGColor color
) {
2234 ctx
.lineTo(x
+0.5*w
, y
-s
);
2235 ctx
.lineTo(x
-0.5*w
, y
-s
);
2237 ctx
.fillColor(color
);
2241 /** computes the bounds of the scrollbar handle from the scrollbar size and the handles offset and size.
2243 * offset is in the range 0..1 and defines the position of the scroll handle
2245 * size is in the range 0..1 and defines the size of the scroll handle
2247 public void bndScrollHandleRect (float* x
, float* y
, float* w
, float* h
, float offset
, float size
) {
2250 size
= bndClamp(size
, 0, 1);
2251 offset
= bndClamp(offset
, 0, 1);
2253 immutable float hs
= bndMax(size
*(*h
), (*w
)+1);
2254 if (y
!is null) *y
= (*y
)+((*h
)-hs
)*offset
;
2257 immutable float ws
= bndMax(size
*(*w
), (*h
)-1);
2258 if (x
!is null) *x
= (*x
)+((*w
)-ws
)*offset
;
2263 /** computes the bounds of the scroll slider from the scrollbar size and the handles offset and size.
2265 * offset is in the range 0..1 and defines the position of the scroll handle
2267 * size is in the range 0..1 and defines the size of the scroll handle
2269 public void bndScrollSliderRect (float* w
, float* h
, float offset
, float size
) {
2272 size
= bndClamp(size
, 0, 1);
2273 offset
= bndClamp(offset
, 0, 1);
2275 immutable float hs
= bndMax(size
*(*h
), (*w
)+1);
2276 *h
= ((*h
)-hs
)*offset
+hs
;
2278 immutable float ws
= bndMax(size
*(*w
), (*h
)-1);
2279 *w
= ((*w
)-ws
)*offset
+ws
;
2283 /** return the color of a node wire based on state
2285 * BND_HOVER indicates selected state,
2287 * BND_ACTIVE indicates dragged state
2289 public NVGColor
bndNodeWireColor (const(BNDnodeTheme
)* theme
, BNDwidgetState state
) {
2292 case BND_DEFAULT
: return nvgRGBf(0.5f, 0.5f, 0.5f);
2293 case BND_HOVER
: return theme
.wireSelectColor
;
2294 case BND_ACTIVE
: return theme
.activeNodeColor
;