152 json_object_object_add(json,
"textColorHovered",
VuoColor_getJson(textColorHovered));
153 json_object_object_add(json,
"textColorActive",
VuoColor_getJson(textColorActive));
154 json_object_object_add(json,
"backgroundColor",
VuoColor_getJson(backgroundColor));
155 json_object_object_add(json,
"backgroundColorHovered",
VuoColor_getJson(backgroundColorHovered));
156 json_object_object_add(json,
"backgroundColorActive",
VuoColor_getJson(backgroundColorActive));
158 json_object_object_add(json,
"borderColorHovered",
VuoColor_getJson(borderColorHovered));
159 json_object_object_add(json,
"borderColorActive",
VuoColor_getJson(borderColorActive));
160 json_object_object_add(json,
"borderThickness",
VuoReal_getJson(borderThickness));
162 json_object_object_add(json,
"selectionColor",
VuoColor_getJson(selectionColor));
163 json_object_object_add(json,
"cornerRoundness",
VuoReal_getJson(cornerRoundness));
188 &&
VuoColor_areEqual(backgroundColorHovered, thatSpecialized->backgroundColorHovered)
189 &&
VuoColor_areEqual(backgroundColorActive, thatSpecialized->backgroundColorActive)
229 VuoReal screenBackingScaleFactor,
256 else if(isFocused || !hasPlaceholder)
259 labelText = placeholderText;
262 float actualWidth = fmax(width, 0.001);
269 f.color = (
VuoColor){f.color.r * textColorActive.r,
270 f.color.g * textColorActive.g,
271 f.color.b * textColorActive.b,
272 f.color.a * textColorActive.a};
274 f.color = (
VuoColor){f.color.r * textColorHovered.r,
275 f.color.g * textColorHovered.g,
276 f.color.b * textColorHovered.b,
277 f.color.a * textColorHovered.a};
279 f.color = (
VuoColor){f.color.r * textColor.r,
280 f.color.g * textColor.g,
281 f.color.b * textColor.b,
282 f.color.a * textColor.a};
291 textData->billboardAnchor = textAnchor;
294 textSize.x = textData->width;
295 textSize.y = textData->height;
299 actualWidth = fmax(width, textData->width);
301 actualHeight = textData->lineHeight * numLines;
310 actualHeight = lineHeight * numLines;
311 textSize.y = lineHeight;
320 for(
int i = 0; i < textData->charCount; i++)
323 if(textData->charAdvance[i] < .001)
327 unsigned int lineIndex;
329 p.x += textData->charAdvance[i] * .5;
330 p.y += textData->lineHeight * .5;
337 textData->charAdvance[i] * .95,
338 textData->lineHeight * .95));
349 VuoPoint2d cursorPosition;
354 cursorPosition.y += textData->lineHeight * .5;
369 selectionStart =
MIN(selectionStart, textLength);
370 selectionEnd =
MIN(selectionEnd, textLength);
372 int start = (selectionStart == selectionEnd ? cursorIndex :
MIN(selectionStart, selectionEnd));
373 int length = (selectionStart == selectionEnd ? 0 : (
MAX(selectionStart, selectionEnd) - start));
375 if (hasText && length > 0)
377 unsigned int lineCount = 0;
380 for(
int i = 0; i < lineCount; i++)
386 highlightRects[i].center,
388 highlightRects[i].size.x,
389 highlightRects[i].size.y) );
392 free(highlightRects);
396 *imageTextData = textData;
398 actualWidth += textPadding.x * 2;
399 actualHeight += textPadding.y * 2;
401 actualWidth += borderThickness * 2;
402 actualHeight += borderThickness * 2;
404 float outerCornerRoundness = cornerRoundness / numLines;
405 float innerCornerRoundness = (actualHeight - borderThickness * 2 - (actualHeight * (1 - outerCornerRoundness))) / (actualHeight - borderThickness * 2);
408 isFocused ? backgroundColorActive : (isHovered ? backgroundColorHovered : backgroundColor),
411 actualWidth - borderThickness * 2,
412 actualHeight - borderThickness * 2,
414 innerCornerRoundness);
417 isFocused ? borderColorActive : (isHovered ? borderColorHovered : borderColor),
423 outerCornerRoundness);
429 offset.x = actualWidth * .5f;
431 offset.x = -actualWidth * .5f;
434 offset.y = -actualHeight * .5f;
436 offset.y = actualHeight * .5f;
443 for(
auto& highlight : *((std::vector<VuoLayer> *) highlights))
450 if(h != VuoHorizontalAlignment_Center)
451 textOffset.x = ((actualWidth - textPadding.x * 2) * .5) * (h == VuoHorizontalAlignment_Left ? -1 : 1);
453 if(v != VuoVerticalAlignment_Center)
454 textOffset.y = ((actualHeight - textPadding.y * 2) * .5) * (v == VuoVerticalAlignment_Bottom ? -1 : 1);
460 if(h != VuoHorizontalAlignment_Center)
461 textOffset.x += (h == VuoHorizontalAlignment_Left ? textSize.x : -textSize.x) * .5;
463 if(v != VuoVerticalAlignment_Center)
464 textOffset.y += (v == VuoVerticalAlignment_Bottom ? textSize.y : -textSize.y) * .5;
466 for(
auto& highlight : *((std::vector<VuoLayer> *) highlights))
479 l.sceneObject.transform.translation =
VuoPoint3d_add(l.sceneObject.transform.translation, offset);
482 l.sceneObject.transform.translation.x += textOffset.x;
483 l.sceneObject.transform.translation.y += textOffset.y;
489 if (hasText || hasPlaceholder)