210void QQuickMaterialTextContainer::paint(QPainter *painter)
214 if (w <= 0 || h <= 0)
218 const qreal penWidth = m_filled ? 1 : (m_controlHasActiveFocus ? 2 : 1);
222 const qreal cornerRadius = 4;
225 const qreal gapPadding = 4;
230 const qreal halfPlaceholderWidth = m_placeholderTextWidth / 2;
233 switch (m_placeholderTextHAlign) {
234 case PlaceHolderHAlignment::AlignHCenter:
235 gapCenterX = width() / 2;
237 case PlaceHolderHAlignment::AlignRight:
238 gapCenterX = width() - halfPlaceholderWidth - m_horizontalPadding;
241 gapCenterX = m_horizontalPadding + halfPlaceholderWidth;
250 if (m_filled || m_focusAnimationProgress == 0) {
251 startPos = QPointF(cornerRadius, 0);
258 startPos = QPointF(gapCenterX - (m_focusAnimationProgress * halfPlaceholderWidth) - gapPadding - penWidth, 0);
260 path.moveTo(startPos);
261 path.arcTo(0, 0, cornerRadius * 2, cornerRadius * 2, 90, 90);
267 path.lineTo(0, h - cornerRadius * 2);
268 path.arcTo(0, h - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 180, 90);
275 path.lineTo(w - cornerRadius * 2, h);
276 path.arcTo(w - cornerRadius * 2, h - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 270, 90);
280 path.lineTo(w, cornerRadius);
281 path.arcTo(w - (cornerRadius * 2), 0, cornerRadius * 2, cornerRadius * 2, 0, 90);
283 if (m_filled || qFuzzyIsNull(m_focusAnimationProgress)) {
285 path.lineTo(startPos.x(), startPos.y());
287 path.lineTo(gapCenterX + (m_focusAnimationProgress * halfPlaceholderWidth) + gapPadding, startPos.y());
291 painter->translate(penWidth / 2, penWidth / 2);
293 painter->setRenderHint(QPainter::Antialiasing,
true);
295 auto control = textControl();
296 const bool focused = control && control->hasActiveFocus();
300 pen.setColor(m_filled ? m_fillColor : (focused ? m_focusedOutlineColor : m_outlineColor));
301 pen.setWidthF(penWidth);
302 painter->setPen(pen);
304 painter->setBrush(m_fillColor);
308 painter->drawPath(path);
312 if (!qFuzzyCompare(m_focusAnimationProgress, qreal(1.0))) {
317 pen.setColor(m_outlineColor);
318 painter->setPen(pen);
319 painter->drawLine(0, h, w, h);
322 if (!qFuzzyIsNull(m_focusAnimationProgress)) {
325 const int lineLength = m_focusAnimationProgress * w;
326 const int horizontalCenter = w / 2;
327 pen.setColor(m_focusedOutlineColor);
329 painter->setPen(pen);
330 painter->drawLine(horizontalCenter - (lineLength / 2), h,
331 horizontalCenter + (lineLength / 2) + pen.width() / 2, h);