Vuo  2.0.0
VuoUiThemeSliderRounded.cc
Go to the documentation of this file.
1 
10 #include "VuoUiThemeBase.hh"
11 
12 #include "type.h"
13 
14 extern "C" {
15 #include "VuoImage.h"
16 #include "VuoAnchor.h"
17 #include "VuoPoint2d.h"
18 #include "VuoSceneText.h"
19 #include "VuoShader.h"
20 }
21 
22 #include "VuoUiTheme.h"
23 
25 #ifdef VUO_COMPILER
27  "title": "UI Theme: Slider (Rounded)",
28  "dependencies": [
29  "VuoBoolean",
30  "VuoColor",
31  "VuoFont",
32  "VuoImage",
33  "VuoLayer",
34  "VuoPoint2d",
35  "VuoReal",
36  "VuoRectangle",
37  "VuoSceneText",
38  "VuoAnchor",
39  "VuoHorizontalAlignment",
40  "VuoVerticalAlignment"
41  ],
42  });
43 #endif
44 
50 {
51 private:
52  VuoFont labelFont;
53  VuoColor labelColor;
54  VuoColor labelColorHovered;
55 
56  VuoReal handleWidth;
57  VuoReal handleHeight;
58  VuoReal handleBorderThickness;
59  VuoReal handleCornerRoundness;
60 
61  VuoColor handleColor;
62  VuoColor handleColorHovered;
63  VuoColor handleColorPressed;
64 
65  VuoColor handleBorderColor;
66  VuoColor handleBorderColorHovered;
67  VuoColor handleBorderColorPressed;
68 
69  VuoReal trackDepth;
70  VuoReal trackBorderThickness;
71  VuoReal trackCornerRoundness;
72 
73  VuoColor activeTrackColor;
74  VuoColor activeTrackColorHovered;
75 
76  VuoColor activeTrackBorderColor;
77  VuoColor activeTrackBorderColorHovered;
78 
79  VuoColor inactiveTrackColor;
80  VuoColor inactiveTrackColorHovered;
81 
82  VuoColor inactiveTrackBorderColor;
83  VuoColor inactiveTrackBorderColorHovered;
84 
85  VuoReal marginBetweenTrackAndLabel;
86 
87 public:
88  static std::string type;
89 
94  {
95  return new VuoUiThemeSliderRounded(
96  VuoJson_getObjectValue(VuoFont, js, "labelFont", (VuoFont){VuoText_make("Avenir-Medium"), 24, false, (VuoColor){1,1,1,1}, VuoHorizontalAlignment_Center, 1, 1}),
97  VuoJson_getObjectValue(VuoColor, js, "labelColor", (VuoColor){.7,.7,.7,.7}),
98  VuoJson_getObjectValue(VuoColor, js, "labelColorHovered", (VuoColor){.7,.7,.7,.8}),
99 
100  VuoJson_getObjectValue(VuoReal, js, "handleWidth", .06),
101  VuoJson_getObjectValue(VuoReal, js, "handleHeight", .06),
102  VuoJson_getObjectValue(VuoReal, js, "handleBorderThickness", .005),
103  VuoJson_getObjectValue(VuoReal, js, "handleCornerRoundness", 1),
104 
105  VuoJson_getObjectValue(VuoColor, js, "handleColor", (VuoColor){.4,.5, .6, 1}),
106  VuoJson_getObjectValue(VuoColor, js, "handleColorHovered", (VuoColor){.4,.52,.64,1}),
107  VuoJson_getObjectValue(VuoColor, js, "handleColorPressed", (VuoColor){.4,.6, .8, 1}),
108 
109  VuoJson_getObjectValue(VuoColor, js, "handleBorderColor", (VuoColor){.2,.3, .4, 1}),
110  VuoJson_getObjectValue(VuoColor, js, "handleBorderColorHovered", (VuoColor){.2,.32,.44,1}),
111  VuoJson_getObjectValue(VuoColor, js, "handleBorderColorPressed", (VuoColor){.2,.4, .6, 1}),
112 
113  VuoJson_getObjectValue(VuoReal, js, "trackDepth", .015),
114  VuoJson_getObjectValue(VuoReal, js, "trackBorderThickness", .005),
115  VuoJson_getObjectValue(VuoReal, js, "trackCornerRoundness", 1),
116 
117  VuoJson_getObjectValue(VuoColor, js, "activeTrackColor", (VuoColor){.4,.5, .6, 1}),
118  VuoJson_getObjectValue(VuoColor, js, "activeTrackColorHovered", (VuoColor){.4,.52,.64,1}),
119 
120  VuoJson_getObjectValue(VuoColor, js, "activeTrackBorderColor", (VuoColor){.2,.3, .4, 1}),
121  VuoJson_getObjectValue(VuoColor, js, "activeTrackBorderColorHovered", (VuoColor){.2,.32,.44,1}),
122 
123  VuoJson_getObjectValue(VuoColor, js, "inactiveTrackColor", (VuoColor){.4,.4, .4, 1}),
124  VuoJson_getObjectValue(VuoColor, js, "inactiveTrackColorHovered", (VuoColor){.4,.42,.44,1}),
125 
126  VuoJson_getObjectValue(VuoColor, js, "inactiveTrackBorderColor", (VuoColor){.2,.2, .2, .9}),
127  VuoJson_getObjectValue(VuoColor, js, "inactiveTrackBorderColorHovered", (VuoColor){.24,.24,.24,1}),
128 
129  VuoJson_getObjectValue(VuoReal, js, "marginBetweenTrackAndLabel", 0.01));
130  }
131 
136  VuoFont _labelFont,
137  VuoColor _labelColor,
138  VuoColor _labelColorHovered,
139 
140  VuoReal _handleWidth,
141  VuoReal _handleHeight,
142  VuoReal _handleBorderThickness,
143  VuoReal _handleCornerRoundness,
144 
145  VuoColor _handleColor,
146  VuoColor _handleColorHovered,
147  VuoColor _handleColorPressed,
148 
149  VuoColor _handleBorderColor,
150  VuoColor _handleBorderColorHovered,
151  VuoColor _handleBorderColorPressed,
152 
153  VuoReal _trackDepth,
154  VuoReal _trackBorderThickness,
155  VuoReal _trackCornerRoundness,
156 
157  VuoColor _activeTrackColor,
158  VuoColor _activeTrackColorHovered,
159 
160  VuoColor _activeTrackBorderColor,
161  VuoColor _activeTrackBorderColorHovered,
162 
163  VuoColor _inactiveTrackColor,
164  VuoColor _inactiveTrackColorHovered,
165 
166  VuoColor _inactiveTrackBorderColor,
167  VuoColor _inactiveTrackBorderColorHovered,
168 
169  VuoReal _marginBetweenTrackAndLabel)
170  {
171  labelFont = _labelFont;
172  VuoFont_retain(labelFont);
173 
174  labelColor = _labelColor;
175  labelColorHovered = _labelColorHovered;
176 
177  handleWidth = _handleWidth;
178  handleHeight = _handleHeight;
179  handleBorderThickness = _handleBorderThickness;
180  handleCornerRoundness = _handleCornerRoundness;
181 
182  handleColor = _handleColor;
183  handleColorHovered = _handleColorHovered;
184  handleColorPressed = _handleColorPressed;
185 
186  handleBorderColor = _handleBorderColor;
187  handleBorderColorHovered = _handleBorderColorHovered;
188  handleBorderColorPressed = _handleBorderColorPressed;
189 
190  trackDepth = _trackDepth;
191  trackBorderThickness = _trackBorderThickness;
192  trackCornerRoundness = _trackCornerRoundness;
193 
194  activeTrackColor = _activeTrackColor;
195  activeTrackColorHovered = _activeTrackColorHovered;
196 
197  activeTrackBorderColor = _activeTrackBorderColor;
198  activeTrackBorderColorHovered = _activeTrackBorderColorHovered;
199 
200  inactiveTrackColor = _inactiveTrackColor;
201  inactiveTrackColorHovered = _inactiveTrackColorHovered;
202 
203  inactiveTrackBorderColor = _inactiveTrackBorderColor;
204  inactiveTrackBorderColorHovered = _inactiveTrackBorderColorHovered;
205 
206  marginBetweenTrackAndLabel = _marginBetweenTrackAndLabel;
207  }
208 
210  {
211  VuoFont_release(labelFont);
212  }
213 
218  {
220 
221  json_object_object_add(js, "labelFont", VuoFont_getJson(labelFont));
222  json_object_object_add(js, "labelColor", VuoColor_getJson(labelColor));
223  json_object_object_add(js, "labelColorHovered", VuoColor_getJson(labelColorHovered));
224 
225  json_object_object_add(js, "handleWidth", VuoReal_getJson(handleWidth));
226  json_object_object_add(js, "handleHeight", VuoReal_getJson(handleHeight));
227  json_object_object_add(js, "handleBorderThickness", VuoReal_getJson(handleBorderThickness));
228  json_object_object_add(js, "handleCornerRoundness", VuoReal_getJson(handleCornerRoundness));
229 
230  json_object_object_add(js, "handleColor", VuoColor_getJson(handleColor));
231  json_object_object_add(js, "handleColorHovered", VuoColor_getJson(handleColorHovered));
232  json_object_object_add(js, "handleColorPressed", VuoColor_getJson(handleColorPressed));
233 
234  json_object_object_add(js, "handleBorderColor", VuoColor_getJson(handleBorderColor));
235  json_object_object_add(js, "handleBorderColorHovered", VuoColor_getJson(handleBorderColorHovered));
236  json_object_object_add(js, "handleBorderColorPressed", VuoColor_getJson(handleBorderColorPressed));
237 
238  json_object_object_add(js, "trackDepth", VuoReal_getJson(trackDepth));
239  json_object_object_add(js, "trackBorderThickness", VuoReal_getJson(trackBorderThickness));
240  json_object_object_add(js, "trackCornerRoundness", VuoReal_getJson(trackCornerRoundness));
241 
242  json_object_object_add(js, "activeTrackColor", VuoColor_getJson(activeTrackColor));
243  json_object_object_add(js, "activeTrackColorHovered", VuoColor_getJson(activeTrackColorHovered));
244 
245  json_object_object_add(js, "activeTrackBorderColor", VuoColor_getJson(activeTrackBorderColor));
246  json_object_object_add(js, "activeTrackBorderColorHovered", VuoColor_getJson(activeTrackBorderColorHovered));
247 
248  json_object_object_add(js, "inactiveTrackColor", VuoColor_getJson(inactiveTrackColor));
249  json_object_object_add(js, "inactiveTrackColorHovered", VuoColor_getJson(inactiveTrackColorHovered));
250 
251  json_object_object_add(js, "inactiveTrackBorderColor", VuoColor_getJson(inactiveTrackBorderColor));
252  json_object_object_add(js, "inactiveTrackBorderColorHovered", VuoColor_getJson(inactiveTrackBorderColorHovered));
253 
254  json_object_object_add(js, "marginBetweenTrackAndLabel", VuoReal_getJson(marginBetweenTrackAndLabel));
255 
256  return js;
257  }
258 
262  char *getSummary()
263  {
264  return strdup("Slider Theme (Rounded)");
265  }
266 
270  bool operator==(const VuoSerializable &that)
271  {
273 
274  return VuoFont_areEqual(labelFont, thatSpecialized->labelFont)
275  && VuoColor_areEqual(labelColor, thatSpecialized->labelColor)
276  && VuoColor_areEqual(labelColorHovered, thatSpecialized->labelColorHovered)
277 
278  && VuoReal_areEqual(handleWidth, thatSpecialized->handleWidth)
279  && VuoReal_areEqual(handleHeight, thatSpecialized->handleHeight)
280  && VuoReal_areEqual(handleBorderThickness, thatSpecialized->handleBorderThickness)
281  && VuoReal_areEqual(handleCornerRoundness, thatSpecialized->handleCornerRoundness)
282 
283  && VuoColor_areEqual(handleColor, thatSpecialized->handleColor)
284  && VuoColor_areEqual(handleColorHovered, thatSpecialized->handleColorHovered)
285  && VuoColor_areEqual(handleColorPressed, thatSpecialized->handleColorPressed)
286 
287  && VuoColor_areEqual(handleBorderColor, thatSpecialized->handleBorderColor)
288  && VuoColor_areEqual(handleBorderColorHovered, thatSpecialized->handleBorderColorHovered)
289  && VuoColor_areEqual(handleBorderColorPressed, thatSpecialized->handleBorderColorPressed)
290 
291  && VuoReal_areEqual(trackDepth, thatSpecialized->trackDepth)
292  && VuoReal_areEqual(trackBorderThickness, thatSpecialized->trackBorderThickness)
293  && VuoReal_areEqual(trackCornerRoundness, thatSpecialized->trackCornerRoundness)
294 
295  && VuoColor_areEqual(activeTrackColor, thatSpecialized->activeTrackColor)
296  && VuoColor_areEqual(activeTrackColorHovered, thatSpecialized->activeTrackColorHovered)
297 
298  && VuoColor_areEqual(activeTrackBorderColor, thatSpecialized->activeTrackBorderColor)
299  && VuoColor_areEqual(activeTrackBorderColorHovered, thatSpecialized->activeTrackBorderColorHovered)
300 
301  && VuoColor_areEqual(inactiveTrackColor, thatSpecialized->inactiveTrackColor)
302  && VuoColor_areEqual(inactiveTrackColorHovered, thatSpecialized->inactiveTrackColorHovered)
303 
304  && VuoColor_areEqual(inactiveTrackBorderColor, thatSpecialized->inactiveTrackBorderColor)
305  && VuoColor_areEqual(inactiveTrackBorderColorHovered, thatSpecialized->inactiveTrackBorderColorHovered)
306 
307  && VuoReal_areEqual(marginBetweenTrackAndLabel, thatSpecialized->marginBetweenTrackAndLabel);
308  }
309 
313  bool operator<(const VuoSerializable &that)
314  {
316 
317  VuoType_returnInequality(VuoFont, labelFont, thatSpecialized->labelFont);
318  VuoType_returnInequality(VuoColor, labelColor, thatSpecialized->labelColor);
319  VuoType_returnInequality(VuoColor, labelColorHovered, thatSpecialized->labelColorHovered);
320 
321  VuoType_returnInequality(VuoReal, handleWidth, thatSpecialized->handleWidth);
322  VuoType_returnInequality(VuoReal, handleHeight, thatSpecialized->handleHeight);
323  VuoType_returnInequality(VuoReal, handleBorderThickness, thatSpecialized->handleBorderThickness);
324  VuoType_returnInequality(VuoReal, handleCornerRoundness, thatSpecialized->handleCornerRoundness);
325 
326  VuoType_returnInequality(VuoColor, handleColor, thatSpecialized->handleColor);
327  VuoType_returnInequality(VuoColor, handleColorHovered, thatSpecialized->handleColorHovered);
328  VuoType_returnInequality(VuoColor, handleColorPressed, thatSpecialized->handleColorPressed);
329 
330  VuoType_returnInequality(VuoColor, handleBorderColor, thatSpecialized->handleBorderColor);
331  VuoType_returnInequality(VuoColor, handleBorderColorHovered, thatSpecialized->handleBorderColorHovered);
332  VuoType_returnInequality(VuoColor, handleBorderColorPressed, thatSpecialized->handleBorderColorPressed);
333 
334  VuoType_returnInequality(VuoReal, trackDepth, thatSpecialized->trackDepth);
335  VuoType_returnInequality(VuoReal, trackBorderThickness, thatSpecialized->trackBorderThickness);
336  VuoType_returnInequality(VuoReal, trackCornerRoundness, thatSpecialized->trackCornerRoundness);
337 
338  VuoType_returnInequality(VuoColor, activeTrackColor, thatSpecialized->activeTrackColor);
339  VuoType_returnInequality(VuoColor, activeTrackColorHovered, thatSpecialized->activeTrackColorHovered);
340 
341  VuoType_returnInequality(VuoColor, activeTrackBorderColor, thatSpecialized->activeTrackBorderColor);
342  VuoType_returnInequality(VuoColor, activeTrackBorderColorHovered, thatSpecialized->activeTrackBorderColorHovered);
343 
344  VuoType_returnInequality(VuoColor, inactiveTrackColor, thatSpecialized->inactiveTrackColor);
345  VuoType_returnInequality(VuoColor, inactiveTrackColorHovered, thatSpecialized->inactiveTrackColorHovered);
346 
347  VuoType_returnInequality(VuoColor, inactiveTrackBorderColor, thatSpecialized->inactiveTrackBorderColor);
348  VuoType_returnInequality(VuoColor, inactiveTrackBorderColorHovered, thatSpecialized->inactiveTrackBorderColorHovered);
349 
350  VuoType_returnInequality(VuoReal, marginBetweenTrackAndLabel, thatSpecialized->marginBetweenTrackAndLabel);
351 
352  return false;
353  }
354 
359  VuoText name,
360  VuoColor background,
361  VuoColor active,
362  VuoPoint2d center,
363  VuoReal rotation,
364  VuoReal width,
365  VuoReal height,
366  VuoReal sharpness,
367  VuoReal roundness,
368  VuoOrientation orientation,
369  VuoReal value)
370  {
371  VuoLayer o;
372  // Since VuoShader_makeUnlitRoundedRectangleShader() produces a shader that fills half the size (to leave enough room for sharpness=0),
373  // make the layer twice the specified size.
376  background,
377  active,
378  sharpness,
379  roundness,
380  width/height,
381  orientation == VuoOrientation_Horizontal,
382  value),
383  VuoPoint3d_make(center.x, center.y, 0),
384  VuoPoint3d_make(0, 0, rotation),
385  width * 2,
386  height * 2 );
387  o.sceneObject.name = name;
388  return o;
389  }
390 
395  VuoText label,
396  VuoReal trackLength,
397  VuoReal normalizedProgress,
398  VuoPoint2d position,
399  VuoAnchor anchor,
400  VuoOrientation orientation,
401  bool isHovered,
402  bool isPressed)
403  {
405  VuoLocal(layers);
406 
407  // Track.
408  {
409  float width = orientation == VuoOrientation_Horizontal ? trackLength : trackDepth;
410  float height = orientation == VuoOrientation_Horizontal ? trackDepth : trackLength;
411 
412  float outerTrackWidth = width + trackBorderThickness * 2;
413  float outerTrackHeight = height + trackBorderThickness * 2;
414  float innerTrackCornerRoundness = (outerTrackHeight - trackBorderThickness * 2 - (outerTrackHeight * (1 - trackCornerRoundness))) / (outerTrackHeight - trackBorderThickness * 2);
415 
416  float hml = handleMovementLength(trackLength);
417  float hhml = trackLength - (trackLength - hml)/2;
418  float innerProgress = (trackLength - hhml)/trackLength + normalizedProgress * (trackLength - (trackLength - hhml) * 2) / trackLength;
419  float outerProgress = (trackBorderThickness + innerProgress * trackLength) / (trackLength + trackBorderThickness * 2);
420 
421  VuoLayer trackLayer = makeRoundedRectangleTrack(VuoText_make("Slider Track"),
422  isHovered ? inactiveTrackColorHovered : inactiveTrackColor,
423  isHovered ? activeTrackColorHovered : activeTrackColor,
424  VuoPoint2d_make(0, 0),
425  0,
426  width,
427  height,
428  1,
429  innerTrackCornerRoundness,
430  orientation,
431  innerProgress);
432 
433  VuoLayer trackBorderLayer = makeRoundedRectangleTrack(VuoText_make("Slider Track Border"),
434  isHovered ? inactiveTrackBorderColorHovered : inactiveTrackBorderColor,
435  isHovered ? activeTrackBorderColorHovered : activeTrackBorderColor,
436  VuoPoint2d_make(0, 0),
437  0,
438  outerTrackWidth,
439  outerTrackHeight,
440  1,
441  trackCornerRoundness,
442  orientation,
443  outerProgress);
444 
445  VuoListAppendValue_VuoLayer(layers, trackBorderLayer);
446  VuoListAppendValue_VuoLayer(layers, trackLayer);
447  }
448 
449 
450  // Handle.
451  {
452  float width = orientation == VuoOrientation_Horizontal ? handleWidth : handleHeight;
453  float height = orientation == VuoOrientation_Horizontal ? handleHeight : handleWidth;
454 
455  float hml = handleMovementLength(trackLength);
456  float handlePos = VuoReal_lerp(-hml / 2, hml / 2, normalizedProgress);
457  VuoPoint2d handlePosition = (VuoPoint2d){
458  orientation == VuoOrientation_Horizontal ? handlePos : 0,
459  orientation == VuoOrientation_Horizontal ? 0 : handlePos,
460  };
461 
462  float outerHandleWidth = width + handleBorderThickness * 2;
463  float outerHandleHeight = height + handleBorderThickness * 2;
464  float innerHandleCornerRoundness = (outerHandleHeight - handleBorderThickness * 2 - (outerHandleHeight * (1 - handleCornerRoundness))) / (outerHandleHeight - handleBorderThickness * 2);
465 
466  VuoLayer handleLayer = VuoLayer_makeRoundedRectangle(VuoText_make("Slider Handle"),
467  isPressed ? handleColorPressed : (isHovered ? handleColorHovered : handleColor),
468  handlePosition,
469  0,
470  width,
471  height,
472  1,
473  innerHandleCornerRoundness);
474 
475  VuoLayer handleBorderLayer = VuoLayer_makeRoundedRectangle(VuoText_make("Slider Handle Border"),
476  isPressed ? handleBorderColorPressed : (isHovered ? handleBorderColorHovered : handleBorderColor),
477  handlePosition,
478  0,
479  outerHandleWidth,
480  outerHandleHeight,
481  1,
482  handleCornerRoundness);
483 
484  // Ensures the layer bounds don't change when the handle is near either end of the track.
485  // Also extends hit detection for narrow tracks, and to cover the gap between the slider and its label.
486  VuoLayer spacerLayer = VuoLayer_makeColor(VuoText_make("Spacer"),
487  (VuoColor){ 0, 0, 0, 0 },
488  (VuoPoint2d){ 0, (float)-marginBetweenTrackAndLabel / 2 },
489  0,
490  outerHandleWidth + (orientation == VuoOrientation_Horizontal ? hml : 0),
491  outerHandleHeight + (orientation == VuoOrientation_Horizontal ? 0 : hml) + marginBetweenTrackAndLabel);
492 
493  VuoListAppendValue_VuoLayer(layers, spacerLayer);
494  VuoListAppendValue_VuoLayer(layers, handleBorderLayer);
495  VuoListAppendValue_VuoLayer(layers, handleLayer);
496  }
497 
498 
499  if (!VuoText_isEmpty(label))
500  {
501  VuoFont f = labelFont;
502  if (isHovered)
503  f.color = (VuoColor){ f.color.r * labelColorHovered.r,
504  f.color.g * labelColorHovered.g,
505  f.color.b * labelColorHovered.b,
506  f.color.a * labelColorHovered.a };
507  else
508  f.color = (VuoColor){ f.color.r * labelColor.r,
509  f.color.g * labelColor.g,
510  f.color.b * labelColor.b,
511  f.color.a * labelColor.a };
512 
513  float yOffset = -marginBetweenTrackAndLabel;
514  if (orientation == VuoOrientation_Horizontal)
515  yOffset -= fmax(trackDepth + trackBorderThickness, handleHeight + handleBorderThickness) / 2;
516  else
517  yOffset -= fmax(trackLength + trackBorderThickness, handleMovementLength(trackLength) + handleWidth + handleBorderThickness) / 2;
518 
519  VuoLayer textLayer;
520  textLayer.sceneObject = VuoSceneText_make(label, f, true, INFINITY, VuoAnchor_make(VuoHorizontalAlignment_Center, VuoVerticalAlignment_Top));
521  textLayer.sceneObject.transform = VuoTransform_makeEuler((VuoPoint3d){ 0, yOffset, 0 },
522  (VuoPoint3d){ 0, 0, 0 },
523  (VuoPoint3d){ 1, 1, 1 });
524  VuoListAppendValue_VuoLayer(layers, textLayer);
525  }
526 
527  VuoLayer groupLayer = VuoLayer_makeGroup(layers, VuoTransform2d_make(position, 0, VuoPoint2d_make(1, 1)));
528  return VuoLayer_setAnchor(groupLayer, anchor, renderedLayers.pixelsWide, renderedLayers.pixelsHigh, renderedLayers.backingScaleFactor);
529  }
530 
535  VuoReal trackLength,
536  VuoReal normalizedProgress,
537  VuoPoint2d position,
538  VuoAnchor anchor,
539  VuoOrientation orientation,
540  VuoPoint2d pointToTest)
541  {
542  float width = orientation == VuoOrientation_Horizontal ? handleWidth : handleHeight;
543  float height = orientation == VuoOrientation_Horizontal ? handleHeight : handleWidth;
544 
545  float hml = handleMovementLength(trackLength);
546  float handlePos = VuoReal_lerp(-hml / 2, hml / 2, normalizedProgress);
547  VuoPoint2d handlePosition = (VuoPoint2d){
548  orientation == VuoOrientation_Horizontal ? handlePos : 0,
549  orientation == VuoOrientation_Horizontal ? 0 : handlePos,
550  };
551 
552  float outerHandleWidth = width + handleBorderThickness * 2;
553  float outerHandleHeight = height + handleBorderThickness * 2;
554 
555  return VuoRectangle_isPointInside((VuoRectangle){ handlePosition, { outerHandleWidth, outerHandleHeight } },
556  (VuoPoint2d){ pointToTest.x - position.x, pointToTest.y - position.y });
557  }
558 
563  {
564  return trackDepth * trackCornerRoundness;
565  }
566 
572  {
573  return trackLength - trackDepth * trackCornerRoundness;
574  }
575 };
576 
578 
583  VuoColor labelColor,
584  VuoColor labelColorHovered,
585 
586  VuoReal handleWidth,
587  VuoReal handleHeight,
588  VuoReal handleBorderThickness,
589  VuoReal handleCornerRoundness,
590 
591  VuoColor handleColor,
592  VuoColor handleColorHovered,
593  VuoColor handleColorPressed,
594 
595  VuoColor handleBorderColor,
596  VuoColor handleBorderColorHovered,
597  VuoColor handleBorderColorPressed,
598 
599  VuoReal trackDepth,
600  VuoReal trackBorderThickness,
601  VuoReal trackCornerRoundness,
602 
603  VuoColor activeTrackColor,
604  VuoColor activeTrackColorHovered,
605 
606  VuoColor activeTrackBorderColor,
607  VuoColor activeTrackBorderColorHovered,
608 
609  VuoColor inactiveTrackColor,
610  VuoColor inactiveTrackColorHovered,
611 
612  VuoColor inactiveTrackBorderColor,
613  VuoColor inactiveTrackBorderColorHovered,
614 
615  VuoReal marginBetweenTrackAndLabel)
616 {
617  return reinterpret_cast<VuoUiTheme>(new VuoUiThemeSliderRounded(labelFont,
618  labelColor,
619  labelColorHovered,
620 
621  handleWidth,
622  handleHeight,
623  handleBorderThickness,
624  handleCornerRoundness,
625 
626  handleColor,
627  handleColorHovered,
628  handleColorPressed,
629 
630  handleBorderColor,
631  handleBorderColorHovered,
632  handleBorderColorPressed,
633 
634  trackDepth,
635  trackBorderThickness,
636  trackCornerRoundness,
637 
638  activeTrackColor,
639  activeTrackColorHovered,
640 
641  activeTrackBorderColor,
642  activeTrackBorderColorHovered,
643 
644  inactiveTrackColor,
645  inactiveTrackColorHovered,
646 
647  inactiveTrackBorderColor,
648  inactiveTrackBorderColorHovered,
649 
650  marginBetweenTrackAndLabel));
651 }