31 "title":
"UI Theme: Text Field, Rounded",
42 "VuoHorizontalAlignment",
43 "VuoVerticalAlignment",
59 VuoPoint2d labelPadding;
76 VuoJson_getObjectValue(
VuoFont, js,
"labelFont", (
VuoFont){NULL, 18,
false,
VuoColor_makeWithRGBA(0,0,0,1), VuoHorizontalAlignment_Left, 1, 1}),
77 VuoJson_getObjectValue(
VuoFont, js,
"placeholderFont", (
VuoFont){NULL, 18,
false,
VuoColor_makeWithRGBA(0, 0, 0, 0.25), VuoHorizontalAlignment_Left, 1, 1}),
95 VuoPoint2d _labelPadding,
103 labelFont = _labelFont;
105 placeholderFont = _placeholderFont;
107 labelPosition = _labelPosition;
108 labelPadding = _labelPadding;
110 hoveredColor = _hoveredColor;
111 pressedColor = _pressedColor;
112 borderColor = _borderColor;
113 borderThickness = _borderThickness;
114 cornerRoundness = _cornerRoundness;
130 json_object_object_add(json,
"placeholderFont",
VuoFont_getJson(placeholderFont));
134 json_object_object_add(json,
"hoveredColor",
VuoColor_getJson(hoveredColor));
135 json_object_object_add(json,
"pressedColor",
VuoColor_getJson(pressedColor));
137 json_object_object_add(json,
"borderThickness",
VuoReal_getJson(borderThickness));
138 json_object_object_add(json,
"cornerRoundness",
VuoReal_getJson(cornerRoundness));
147 return strdup(
"Text Field Theme (Rounded)");
192 VuoReal screenBackingScaleFactor,
220 else if(isFocused || !hasPlaceholder)
223 labelText = placeholderText;
226 float actualWidth = fmax(width, 0.001);
231 VuoFont& font = ((hasLabel || isFocused) ? labelFont : placeholderFont);
239 textSize.x = textData->
width;
240 textSize.y = textData->
height;
243 actualHeight = textData->
lineHeight * numLines;
252 actualHeight = lineHeight * numLines;
261 for(
int i = 0; i < textData->
charCount; i++)
268 unsigned int lineIndex;
288 cursorSize.x *= .15f;
290 VuoPoint2d cursorPosition;
295 cursorPosition.y += textData->
lineHeight * .5;
309 int start = (selectionStart == selectionEnd ? cursorIndex :
MIN(selectionStart, selectionEnd));
310 int length = (selectionStart == selectionEnd ? 0 : (
MAX(selectionStart, selectionEnd) - start));
312 if(hasLabel && length > 0)
314 unsigned int lineCount = 0;
317 for(
int i = 0; i < lineCount; i++)
323 highlightRects[i].center,
325 highlightRects[i].size.x,
326 highlightRects[i].size.y) );
329 free(highlightRects);
333 *imageTextData = textData;
335 actualWidth += labelPadding.x;
336 actualHeight += labelPadding.y;
338 float border = borderThickness * fmin(actualWidth, actualHeight);
344 actualWidth - border,
345 actualHeight - border,
362 offset.x = actualWidth * .5f;
364 offset.x = -actualWidth * .5f;
367 offset.y = -actualHeight * .5f;
369 offset.y = actualHeight * .5f;
374 if(hasLabel || hasPlaceholder)
377 for(
auto& highlight : *((std::vector<VuoLayer> *) highlights))
384 if(h != VuoHorizontalAlignment_Center)
385 textOffset.x = ((actualWidth - labelPadding.x) * .5) * (h == VuoHorizontalAlignment_Left ? -1 : 1);
387 if(v != VuoVerticalAlignment_Center)
388 textOffset.y = ((actualHeight - labelPadding.y) * .5) * (v == VuoVerticalAlignment_Bottom ? -1 : 1);
394 if(h != VuoHorizontalAlignment_Center)
395 textOffset.x += (h == VuoHorizontalAlignment_Left ? textSize.x : -textSize.x) * .5;
397 if(v != VuoVerticalAlignment_Center)
398 textOffset.y += (v == VuoVerticalAlignment_Bottom ? textSize.y : -textSize.y) * .5;
400 for(
auto& highlight : *((std::vector<VuoLayer> *) highlights))
413 l.sceneObject.transform.translation =
VuoPoint3d_add(l.sceneObject.transform.translation, offset);
416 l.sceneObject.transform.translation.x += textOffset.x;
417 l.sceneObject.transform.translation.y += textOffset.y;
423 if(hasLabel || hasPlaceholder)
446 VuoPoint2d labelPadding,