1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qquickclippedtext_p.h"
5
6#include <QtQuick/private/qquickitem_p.h>
7
8QT_BEGIN_NAMESPACE
9
10QQuickClippedText::QQuickClippedText(QQuickItem *parent)
11 : QQuickText(parent)
12{
13}
14
15qreal QQuickClippedText::clipX() const
16{
17 return m_clipX;
18}
19
20void QQuickClippedText::setClipX(qreal x)
21{
22 if (qFuzzyCompare(p1: x, p2: m_clipX))
23 return;
24
25 m_clipX = x;
26 markClipDirty();
27}
28
29qreal QQuickClippedText::clipY() const
30{
31 return m_clipY;
32}
33
34void QQuickClippedText::setClipY(qreal y)
35{
36 if (qFuzzyCompare(p1: y, p2: m_clipY))
37 return;
38
39 m_clipY = y;
40 markClipDirty();
41}
42
43qreal QQuickClippedText::clipWidth() const
44{
45 return m_clipWidth ? m_clipWidth : width();
46}
47
48void QQuickClippedText::setClipWidth(qreal width)
49{
50 m_hasClipWidth = true;
51 if (qFuzzyCompare(p1: width, p2: m_clipWidth))
52 return;
53
54 m_clipWidth = width;
55 markClipDirty();
56}
57
58qreal QQuickClippedText::clipHeight() const
59{
60 return m_clipHeight ? m_clipHeight : height();
61}
62
63void QQuickClippedText::setClipHeight(qreal height)
64{
65 m_hasClipHeight = true;
66 if (qFuzzyCompare(p1: height, p2: m_clipHeight))
67 return;
68
69 m_clipHeight = height;
70 markClipDirty();
71}
72
73QRectF QQuickClippedText::clipRect() const
74{
75 return QRectF(clipX(), clipY(), clipWidth(), clipHeight());
76}
77
78void QQuickClippedText::markClipDirty()
79{
80 QQuickItemPrivate::get(item: this)->dirty(QQuickItemPrivate::Size);
81}
82
83QT_END_NAMESPACE
84
85#include "moc_qquickclippedtext_p.cpp"
86

source code of qtdeclarative/src/quickcontrolsimpl/qquickclippedtext.cpp