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  // Since VuoShader_makeUnlitRoundedRectangleShader() produces a shader that fills half the size (to leave enough room for sharpness=0),
372  // make the layer twice the specified size.
375  background,
376  active,
377  sharpness,
378  roundness,
379  width/height,
380  orientation == VuoOrientation_Horizontal,
381  value),
382  VuoPoint3d_make(center.x, center.y, 0),
383  VuoPoint3d_make(0, 0, rotation),
384  width * 2,
385  height * 2 );
386  VuoSceneObject_setName(so, name);
387  return (VuoLayer)so;
388  }
389 
394  VuoText label,
395  VuoReal trackLength,
396  VuoReal normalizedProgress,
397  VuoPoint2d position,
398  VuoAnchor anchor,
399  VuoOrientation orientation,
400  bool isHovered,
401  bool isPressed)
402  {
404  VuoLocal(layers);
405 
406  // Track.
407  {
408  float width = orientation == VuoOrientation_Horizontal ? trackLength : trackDepth;
409  float height = orientation == VuoOrientation_Horizontal ? trackDepth : trackLength;
410 
411  float outerTrackWidth = width + trackBorderThickness * 2;
412  float outerTrackHeight = height + trackBorderThickness * 2;
413  float innerTrackCornerRoundness = (outerTrackHeight - trackBorderThickness * 2 - (outerTrackHeight * (1 - trackCornerRoundness))) / (outerTrackHeight - trackBorderThickness * 2);
414 
415  float hml = handleMovementLength(trackLength);
416  float hhml = trackLength - (trackLength - hml)/2;
417  float innerProgress = (trackLength - hhml)/trackLength + normalizedProgress * (trackLength - (trackLength - hhml) * 2) / trackLength;
418  float outerProgress = (trackBorderThickness + innerProgress * trackLength) / (trackLength + trackBorderThickness * 2);
419 
420  VuoLayer trackLayer = makeRoundedRectangleTrack(VuoText_make("Slider Track"),
421  isHovered ? inactiveTrackColorHovered : inactiveTrackColor,
422  isHovered ? activeTrackColorHovered : activeTrackColor,
423  VuoPoint2d_make(0, 0),
424  0,
425  width,
426  height,
427  1,
428  innerTrackCornerRoundness,
429  orientation,
430  innerProgress);
431 
432  VuoLayer trackBorderLayer = makeRoundedRectangleTrack(VuoText_make("Slider Track Border"),
433  isHovered ? inactiveTrackBorderColorHovered : inactiveTrackBorderColor,
434  isHovered ? activeTrackBorderColorHovered : activeTrackBorderColor,
435  VuoPoint2d_make(0, 0),
436  0,
437  outerTrackWidth,
438  outerTrackHeight,
439  1,
440  trackCornerRoundness,
441  orientation,
442  outerProgress);
443 
444  VuoListAppendValue_VuoLayer(layers, trackBorderLayer);
445  VuoListAppendValue_VuoLayer(layers, trackLayer);
446  }
447 
448 
449  // Handle.
450  {
451  float width = orientation == VuoOrientation_Horizontal ? handleWidth : handleHeight;
452  float height = orientation == VuoOrientation_Horizontal ? handleHeight : handleWidth;
453 
454  float hml = handleMovementLength(trackLength);
455  float handlePos = VuoReal_lerp(-hml / 2, hml / 2, normalizedProgress);
456  VuoPoint2d handlePosition = (VuoPoint2d){
457  orientation == VuoOrientation_Horizontal ? handlePos : 0,
458  orientation == VuoOrientation_Horizontal ? 0 : handlePos,
459  };
460 
461  float outerHandleWidth = width + handleBorderThickness * 2;
462  float outerHandleHeight = height + handleBorderThickness * 2;
463  float innerHandleCornerRoundness = (outerHandleHeight - handleBorderThickness * 2 - (outerHandleHeight * (1 - handleCornerRoundness))) / (outerHandleHeight - handleBorderThickness * 2);
464 
465  VuoLayer handleLayer = VuoLayer_makeRoundedRectangle(VuoText_make("Slider Handle"),
466  isPressed ? handleColorPressed : (isHovered ? handleColorHovered : handleColor),
467  handlePosition,
468  0,
469  width,
470  height,
471  1,
472  innerHandleCornerRoundness);
473 
474  VuoLayer handleBorderLayer = VuoLayer_makeRoundedRectangle(VuoText_make("Slider Handle Border"),
475  isPressed ? handleBorderColorPressed : (isHovered ? handleBorderColorHovered : handleBorderColor),
476  handlePosition,
477  0,
478  outerHandleWidth,
479  outerHandleHeight,
480  1,
481  handleCornerRoundness);
482 
483  // Ensures the layer bounds don't change when the handle is near either end of the track.
484  // Also extends hit detection for narrow tracks, and to cover the gap between the slider and its label.
485  VuoLayer spacerLayer = VuoLayer_makeColor(VuoText_make("Spacer"),
486  (VuoColor){ 0, 0, 0, 0 },
487  (VuoPoint2d){ 0, (float)-marginBetweenTrackAndLabel / 2 },
488  0,
489  outerHandleWidth + (orientation == VuoOrientation_Horizontal ? hml : 0),
490  outerHandleHeight + (orientation == VuoOrientation_Horizontal ? 0 : hml) + marginBetweenTrackAndLabel);
491 
492  VuoListAppendValue_VuoLayer(layers, spacerLayer);
493  VuoListAppendValue_VuoLayer(layers, handleBorderLayer);
494  VuoListAppendValue_VuoLayer(layers, handleLayer);
495  }
496 
497 
498  if (!VuoText_isEmpty(label))
499  {
500  VuoFont f = labelFont;
501  if (isHovered)
502  f.color = (VuoColor){ f.color.r * labelColorHovered.r,
503  f.color.g * labelColorHovered.g,
504  f.color.b * labelColorHovered.b,
505  f.color.a * labelColorHovered.a };
506  else
507  f.color = (VuoColor){ f.color.r * labelColor.r,
508  f.color.g * labelColor.g,
509  f.color.b * labelColor.b,
510  f.color.a * labelColor.a };
511 
512  float yOffset = -marginBetweenTrackAndLabel;
513  if (orientation == VuoOrientation_Horizontal)
514  yOffset -= fmax(trackDepth + trackBorderThickness, handleHeight + handleBorderThickness) / 2;
515  else
516  yOffset -= fmax(trackLength + trackBorderThickness, handleMovementLength(trackLength) + handleWidth + handleBorderThickness) / 2;
517 
518  VuoSceneObject textLayer = VuoSceneText_make(label, f, true, INFINITY, VuoAnchor_make(VuoHorizontalAlignment_Center, VuoVerticalAlignment_Top));
519  VuoSceneObject_setTransform(textLayer, VuoTransform_makeEuler((VuoPoint3d){ 0, yOffset, 0 },
520  (VuoPoint3d){ 0, 0, 0 },
521  (VuoPoint3d){ 1, 1, 1 }));
522  VuoListAppendValue_VuoLayer(layers, (VuoLayer)textLayer);
523  }
524 
525  VuoLayer groupLayer = VuoLayer_makeGroup(layers, VuoTransform2d_make(position, 0, VuoPoint2d_make(1, 1)));
526 
527  unsigned long int pixelsWide, pixelsHigh;
528  float backingScaleFactor;
529  if (!VuoRenderedLayers_getRenderingDimensions(renderedLayers, &pixelsWide, &pixelsHigh, &backingScaleFactor))
530  {
531  VuoRetain(groupLayer);
532  VuoRelease(groupLayer);
533  return nullptr;
534  }
535 
536  return VuoLayer_setAnchor(groupLayer, anchor, pixelsWide, pixelsHigh, backingScaleFactor);
537  }
538 
543  VuoReal trackLength,
544  VuoReal normalizedProgress,
545  VuoPoint2d position,
546  VuoAnchor anchor,
547  VuoOrientation orientation,
548  VuoPoint2d pointToTest)
549  {
550  float width = orientation == VuoOrientation_Horizontal ? handleWidth : handleHeight;
551  float height = orientation == VuoOrientation_Horizontal ? handleHeight : handleWidth;
552 
553  float hml = handleMovementLength(trackLength);
554  float handlePos = VuoReal_lerp(-hml / 2, hml / 2, normalizedProgress);
555  VuoPoint2d handlePosition = (VuoPoint2d){
556  orientation == VuoOrientation_Horizontal ? handlePos : 0,
557  orientation == VuoOrientation_Horizontal ? 0 : handlePos,
558  };
559 
560  float outerHandleWidth = width + handleBorderThickness * 2;
561  float outerHandleHeight = height + handleBorderThickness * 2;
562 
563  return VuoRectangle_isPointInside((VuoRectangle){ handlePosition, { outerHandleWidth, outerHandleHeight } },
564  (VuoPoint2d){ pointToTest.x - position.x, pointToTest.y - position.y });
565  }
566 
571  {
572  return trackDepth * trackCornerRoundness;
573  }
574 
580  {
581  return trackLength - trackDepth * trackCornerRoundness;
582  }
583 };
584 
586 
591  VuoColor labelColor,
592  VuoColor labelColorHovered,
593 
594  VuoReal handleWidth,
595  VuoReal handleHeight,
596  VuoReal handleBorderThickness,
597  VuoReal handleCornerRoundness,
598 
599  VuoColor handleColor,
600  VuoColor handleColorHovered,
601  VuoColor handleColorPressed,
602 
603  VuoColor handleBorderColor,
604  VuoColor handleBorderColorHovered,
605  VuoColor handleBorderColorPressed,
606 
607  VuoReal trackDepth,
608  VuoReal trackBorderThickness,
609  VuoReal trackCornerRoundness,
610 
611  VuoColor activeTrackColor,
612  VuoColor activeTrackColorHovered,
613 
614  VuoColor activeTrackBorderColor,
615  VuoColor activeTrackBorderColorHovered,
616 
617  VuoColor inactiveTrackColor,
618  VuoColor inactiveTrackColorHovered,
619 
620  VuoColor inactiveTrackBorderColor,
621  VuoColor inactiveTrackBorderColorHovered,
622 
623  VuoReal marginBetweenTrackAndLabel)
624 {
625  return reinterpret_cast<VuoUiTheme>(new VuoUiThemeSliderRounded(labelFont,
626  labelColor,
627  labelColorHovered,
628 
629  handleWidth,
630  handleHeight,
631  handleBorderThickness,
632  handleCornerRoundness,
633 
634  handleColor,
635  handleColorHovered,
636  handleColorPressed,
637 
638  handleBorderColor,
639  handleBorderColorHovered,
640  handleBorderColorPressed,
641 
642  trackDepth,
643  trackBorderThickness,
644  trackCornerRoundness,
645 
646  activeTrackColor,
647  activeTrackColorHovered,
648 
649  activeTrackBorderColor,
650  activeTrackBorderColorHovered,
651 
652  inactiveTrackColor,
653  inactiveTrackColorHovered,
654 
655  inactiveTrackBorderColor,
656  inactiveTrackBorderColorHovered,
657 
658  marginBetweenTrackAndLabel));
659 }