31 "title":
"UI Theme: Text Field, Rounded",
42 "VuoHorizontalAlignment",
43 "VuoVerticalAlignment",
58 VuoPoint2d textPadding;
82 VuoJson_getObjectValue(
VuoFont, js,
"font", (
VuoFont){
VuoText_make(
"Avenir-Medium"), 24,
false, (
VuoColor){1,1,1,1}, VuoHorizontalAlignment_Left, 1, 1}),
105 VuoPoint2d _textPadding,
122 textAnchor = _textAnchor;
123 textPadding = _textPadding;
124 textColor = _textColor;
125 textColorHovered = _textColorHovered;
126 textColorActive = _textColorActive;
127 backgroundColor = _backgroundColor;
128 backgroundColorHovered = _backgroundColorHovered;
129 backgroundColorActive = _backgroundColorActive;
130 borderColor = _borderColor;
131 borderColorHovered = _borderColorHovered;
132 borderColorActive = _borderColorActive;
133 borderThickness = _borderThickness;
134 cursorColor = _cursorColor;
135 selectionColor = _selectionColor;
136 cornerRoundness = _cornerRoundness;
154 json_object_object_add(json,
"textColorHovered",
VuoColor_getJson(textColorHovered));
155 json_object_object_add(json,
"textColorActive",
VuoColor_getJson(textColorActive));
156 json_object_object_add(json,
"backgroundColor",
VuoColor_getJson(backgroundColor));
157 json_object_object_add(json,
"backgroundColorHovered",
VuoColor_getJson(backgroundColorHovered));
158 json_object_object_add(json,
"backgroundColorActive",
VuoColor_getJson(backgroundColorActive));
160 json_object_object_add(json,
"borderColorHovered",
VuoColor_getJson(borderColorHovered));
161 json_object_object_add(json,
"borderColorActive",
VuoColor_getJson(borderColorActive));
162 json_object_object_add(json,
"borderThickness",
VuoReal_getJson(borderThickness));
164 json_object_object_add(json,
"selectionColor",
VuoColor_getJson(selectionColor));
165 json_object_object_add(json,
"cornerRoundness",
VuoReal_getJson(cornerRoundness));
174 return strdup(
"Text Field Theme (Rounded)");
190 &&
VuoColor_areEqual(backgroundColorHovered, thatSpecialized->backgroundColorHovered)
191 &&
VuoColor_areEqual(backgroundColorActive, thatSpecialized->backgroundColorActive)
231 VuoReal screenBackingScaleFactor,
258 else if(isFocused || !hasPlaceholder)
261 labelText = placeholderText;
264 float actualWidth = fmax(width, 0.001);
271 f.color = (
VuoColor){f.color.r * textColorActive.r,
272 f.color.g * textColorActive.g,
273 f.color.b * textColorActive.b,
274 f.color.a * textColorActive.a};
276 f.color = (
VuoColor){f.color.r * textColorHovered.r,
277 f.color.g * textColorHovered.g,
278 f.color.b * textColorHovered.b,
279 f.color.a * textColorHovered.a};
281 f.color = (
VuoColor){f.color.r * textColor.r,
282 f.color.g * textColor.g,
283 f.color.b * textColor.b,
284 f.color.a * textColor.a};
293 textData->billboardAnchor = textAnchor;
296 textSize.x = textData->width;
297 textSize.y = textData->height;
301 actualWidth = fmax(width, textData->width);
303 actualHeight = textData->lineHeight * numLines;
312 actualHeight = lineHeight * numLines;
313 textSize.y = lineHeight;
322 for(
int i = 0; i < textData->charCount; i++)
325 if(textData->charAdvance[i] < .001)
329 unsigned int lineIndex;
331 p.x += textData->charAdvance[i] * .5;
332 p.y += textData->lineHeight * .5;
339 textData->charAdvance[i] * .95,
340 textData->lineHeight * .95));
351 VuoPoint2d cursorPosition;
356 cursorPosition.y += textData->lineHeight * .5;
371 selectionStart =
MIN(selectionStart, textLength);
372 selectionEnd =
MIN(selectionEnd, textLength);
374 int start = (selectionStart == selectionEnd ? cursorIndex :
MIN(selectionStart, selectionEnd));
375 int length = (selectionStart == selectionEnd ? 0 : (
MAX(selectionStart, selectionEnd) - start));
377 if (hasText && length > 0)
379 unsigned int lineCount = 0;
382 for(
int i = 0; i < lineCount; i++)
388 highlightRects[i].center,
390 highlightRects[i].size.x,
391 highlightRects[i].size.y) );
394 free(highlightRects);
398 *imageTextData = textData;
400 actualWidth += textPadding.x * 2;
401 actualHeight += textPadding.y * 2;
403 actualWidth += borderThickness * 2;
404 actualHeight += borderThickness * 2;
406 float outerCornerRoundness = cornerRoundness / numLines;
407 float innerCornerRoundness = (actualHeight - borderThickness * 2 - (actualHeight * (1 - outerCornerRoundness))) / (actualHeight - borderThickness * 2);
410 isFocused ? backgroundColorActive : (isHovered ? backgroundColorHovered : backgroundColor),
413 actualWidth - borderThickness * 2,
414 actualHeight - borderThickness * 2,
416 innerCornerRoundness);
419 isFocused ? borderColorActive : (isHovered ? borderColorHovered : borderColor),
425 outerCornerRoundness);
431 offset.x = actualWidth * .5f;
433 offset.x = -actualWidth * .5f;
436 offset.y = -actualHeight * .5f;
438 offset.y = actualHeight * .5f;
445 for(
auto& highlight : *((std::vector<VuoLayer> *) highlights))
452 if(h != VuoHorizontalAlignment_Center)
453 textOffset.x = ((actualWidth - textPadding.x * 2) * .5) * (h == VuoHorizontalAlignment_Left ? -1 : 1);
455 if(v != VuoVerticalAlignment_Center)
456 textOffset.y = ((actualHeight - textPadding.y * 2) * .5) * (v == VuoVerticalAlignment_Bottom ? -1 : 1);
462 if(h != VuoHorizontalAlignment_Center)
463 textOffset.x += (h == VuoHorizontalAlignment_Left ? textSize.x : -textSize.x) * .5;
465 if(v != VuoVerticalAlignment_Center)
466 textOffset.y += (v == VuoVerticalAlignment_Bottom ? textSize.y : -textSize.y) * .5;
468 for(
auto& highlight : *((std::vector<VuoLayer> *) highlights))
481 l.sceneObject.transform.translation =
VuoPoint3d_add(l.sceneObject.transform.translation, offset);
484 l.sceneObject.transform.translation.x += textOffset.x;
485 l.sceneObject.transform.translation.y += textOffset.y;
491 if (hasText || hasPlaceholder)
512 VuoPoint2d textPadding,
534 backgroundColorHovered,
535 backgroundColorActive,