Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_constrained_rect.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef __KIS_CONSTRAINED_RECT_H
8#define __KIS_CONSTRAINED_RECT_H
9
10#include <QObject>
11#include <QRect>
12
13
14
15class KisConstrainedRect : public QObject
16{
17 Q_OBJECT
18
19public:
33
34public:
36 ~KisConstrainedRect() override;
37
38 void setRectInitial(const QRect &rect);
39 void setCropRect(const QRect &cropRect);
40
41 bool centered() const;
42 void setCentered(bool value);
43
44 bool canGrow() const;
45 void setCanGrow(bool value);
46
47 QRect rect() const;
48
49 qreal ratio() const;
50
51 void moveHandle(HandleType handle, const QPoint &offset, const QRect &oldRect);
52 QPointF handleSnapPoint(HandleType handle, const QPointF &cursorPos);
53
54 void setRatio(qreal value);
55 void setOffset(const QPoint &offset);
56 void setWidth(int value);
57 void setHeight(int value);
58
59 bool widthLocked() const;
60 void setWidthLocked(bool value);
61
62 bool heightLocked() const;
63 void setHeightLocked(bool value);
64
65 bool ratioLocked() const;
66 void setRatioLocked(bool value);
67
68 void normalize();
69
70Q_SIGNALS:
73
74private:
75
76 int widthFromHeightUnsignedRatio(int height, qreal ratio, int oldWidth) const;
77 int heightFromWidthUnsignedRatio(int width, qreal ratio, int oldHeight) const;
78
79 void assignNewSize(const QSize &newSize);
80 void storeRatioSafe(const QSize &newSize);
81private:
82 bool m_centered {false};
83 bool m_canGrow {true};
84 QRect m_rect;
85 qreal m_ratio {1.0};
86
87 bool m_widthLocked {false};
88 bool m_heightLocked {false};
89 bool m_ratioLocked {false};
90
92};
93
94#endif /* __KIS_CONSTRAINED_RECT_H */
float value(const T *src, size_t ch)
void storeRatioSafe(const QSize &newSize)
void moveHandle(HandleType handle, const QPoint &offset, const QRect &oldRect)
void sigLockValuesChanged()
int widthFromHeightUnsignedRatio(int height, qreal ratio, int oldWidth) const
void setRectInitial(const QRect &rect)
QPointF handleSnapPoint(HandleType handle, const QPointF &cursorPos)
void setCropRect(const QRect &cropRect)
void setCentered(bool value)
void setCanGrow(bool value)
int heightFromWidthUnsignedRatio(int width, qreal ratio, int oldHeight) const
void assignNewSize(const QSize &newSize)
void setOffset(const QPoint &offset)
void setHeightLocked(bool value)
void setRatioLocked(bool value)
void setWidthLocked(bool value)