11#include <klocalizedstring.h>
29 m_filteringEnabled(false),
30 m_cursorSwitched(false),
42 t = t * QTransform::fromTranslate(handlePoint.x(), handlePoint.y());
51 const QRect imageRect =
m_canvas->coordinatesConverter()->imageRectInWidgetPixels().toAlignedRect();
52 const QRect widgetRect =
m_canvas->canvasWidget()->rect();
57 int xReserve = vastScrolling * widgetRect.width();
58 int yReserve = vastScrolling * widgetRect.height();
60 int xThreshold = imageRect.width() - 0.4 * xReserve;
61 int yThreshold = imageRect.height() - 0.4 * yReserve;
63 const int stripeWidth = 48;
65 int xCut = widgetRect.width() - stripeWidth;
66 int yCut = widgetRect.height() - stripeWidth;
78 if (imageRect.x() <= -xThreshold) {
79 QRect areaRect(widgetRect.adjusted(xCut, 0, 0, 0));
80 QPointF pt = areaRect.center() + QPointF(-0.1 * stripeWidth, 0);
85 if (imageRect.y() <= -yThreshold) {
86 QRect areaRect(widgetRect.adjusted(0, yCut, 0, 0));
87 QPointF pt = areaRect.center() + QPointF(0, -0.1 * stripeWidth);
92 if (imageRect.right() > widgetRect.width() + xThreshold) {
93 QRect areaRect(widgetRect.adjusted(0, 0, -xCut, 0));
94 QPointF pt = areaRect.center() + QPointF(0.1 * stripeWidth, 0);
99 if (imageRect.bottom() > widgetRect.height() + yThreshold) {
100 QRect areaRect(widgetRect.adjusted(0, 0, 0, -yCut));
101 QPointF pt = areaRect.center() + QPointF(0, 0.1 * stripeWidth);
127 Q_UNUSED(updateArea);
134 gc.setTransform(QTransform(),
false);
148 gc.fillPath(t.map(
p), color);
156 return qMax(x0 - maxExpand, qMin(x0, x1));
161 return qMin(x0 + maxExpand, qMax(x0, x1));
168 if (event->type() == QEvent::MouseMove ||
169 event->type() == QEvent::MouseButtonPress ||
170 event->type() == QEvent::MouseButtonRelease ||
171 event->type() == QEvent::Enter) {
173 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
174 result = mouseEvent->pos();
176 }
else if (event->type() == QEvent::TabletMove ||
177 event->type() == QEvent::TabletPress ||
178 event->type() == QEvent::TabletRelease) {
180 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
181 result = tabletEvent->pos();
189 Qt::MouseButton
button = Qt::NoButton;
191 if (event->type() == QEvent::MouseMove ||
192 event->type() == QEvent::MouseButtonPress ||
193 event->type() == QEvent::MouseButtonRelease) {
195 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
196 button = mouseEvent->button();
198 }
else if (event->type() == QEvent::TabletMove ||
199 event->type() == QEvent::TabletPress ||
200 event->type() == QEvent::TabletRelease) {
202 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
203 button = tabletEvent->button();
223 switch (event->type()) {
225 case QEvent::MouseMove:
226 case QEvent::TabletMove: {
234 m_canvas->canvasWidget()->setCursor(Qt::PointingHandCursor);
242 case QEvent::Leave: {
249 case QEvent::MouseButtonPress:
250 case QEvent::TabletPress: {
254 if (
button == Qt::RightButton) {
260 case QEvent::MouseButtonRelease:
261 case QEvent::TabletRelease: {
272 QRect cropRect = image->
bounds();
274 const int hLimit = cropRect.width();
275 const int vLimit = cropRect.height();
278 cropRect.setRight(
expandRight(cropRect.right(), widgetRect.right(), hLimit));
281 cropRect.setBottom(
expandRight(cropRect.bottom(), widgetRect.bottom(), vLimit));
284 cropRect.setLeft(
expandLeft(cropRect.left(), widgetRect.left(), hLimit));
287 cropRect.setTop(
expandLeft(cropRect.top(), widgetRect.top(), vLimit));
306 return !retval ? KisCanvasDecoration::eventFilter(obj, event) :
true;
void sigCanvasStateChanged()
KoColorDisplayRendererInterface * displayRendererInterface() const override
displayRendererInterface The display renderer interface has a number of color conversion functions wh...
QPointer< KisView > view() const
qreal vastScrolling(bool defaultValue=false) const
QColor canvasBorderColor(bool defaultValue=false) const
_Private::Traits< T >::Result widgetToImage(const T &obj) const
void resizeImage(const QRect &newRect)
start asynchronous operation on resizing the image
QRect bounds() const override
bool eventFilter(QObject *obj, QEvent *event) override
QPointer< KisCanvas2 > m_canvas
void drawDecoration(QPainter &gc, const QRectF &updateArea, const KisCoordinatesConverter *converter, KisCanvas2 *canvas) override
QPainterPath m_decorationPath
KisInfinityManager(QPointer< KisView >view, KisCanvas2 *canvas)
void imagePositionChanged()
QVector< QTransform > m_handleTransform
QVector< QRect > m_sideRects
void addDecoration(const QRect &areaRect, const QPointF &handlePoint, qreal angle, Side side)
virtual QColor convertColorToDisplayColorSpace(const KoColor color) const =0
convertColorToDisplayColorSpace
void fromQColor(const QColor &c)
Convenient function for converting from a QColor.
#define KIS_ASSERT_RECOVER_NOOP(cond)
int expandLeft(int x0, int x1, int maxExpand)
QPoint getPointFromEvent(QEvent *event)
int expandRight(int x0, int x1, int maxExpand)
Qt::MouseButton getButtonFromEvent(QEvent *event)
static const QString INFINITY_DECORATION_ID
QString button(const QWheelEvent &ev)
QPainterPath smallArrow()