11#include <klocalizedstring.h>
28 m_filteringEnabled(false),
29 m_cursorSwitched(false),
41 t = t * QTransform::fromTranslate(handlePoint.x(), handlePoint.y());
50 const QRect imageRect =
m_canvas->coordinatesConverter()->imageRectInWidgetPixels().toAlignedRect();
51 const QRect widgetRect =
m_canvas->canvasWidget()->rect();
56 int xReserve = vastScrolling * widgetRect.width();
57 int yReserve = vastScrolling * widgetRect.height();
59 int xThreshold = imageRect.width() - 0.4 * xReserve;
60 int yThreshold = imageRect.height() - 0.4 * yReserve;
62 const int stripeWidth = 48;
64 int xCut = widgetRect.width() - stripeWidth;
65 int yCut = widgetRect.height() - stripeWidth;
77 if (imageRect.x() <= -xThreshold) {
78 QRect areaRect(widgetRect.adjusted(xCut, 0, 0, 0));
79 QPointF pt = areaRect.center() + QPointF(-0.1 * stripeWidth, 0);
84 if (imageRect.y() <= -yThreshold) {
85 QRect areaRect(widgetRect.adjusted(0, yCut, 0, 0));
86 QPointF pt = areaRect.center() + QPointF(0, -0.1 * stripeWidth);
91 if (imageRect.right() > widgetRect.width() + xThreshold) {
92 QRect areaRect(widgetRect.adjusted(0, 0, -xCut, 0));
93 QPointF pt = areaRect.center() + QPointF(0.1 * stripeWidth, 0);
98 if (imageRect.bottom() > widgetRect.height() + yThreshold) {
99 QRect areaRect(widgetRect.adjusted(0, 0, 0, -yCut));
100 QPointF pt = areaRect.center() + QPointF(0, 0.1 * stripeWidth);
126 Q_UNUSED(updateArea);
133 gc.setTransform(QTransform(),
false);
142 gc.fillPath(t.map(
p), color);
150 return qMax(x0 - maxExpand, qMin(x0, x1));
155 return qMin(x0 + maxExpand, qMax(x0, x1));
162 if (event->type() == QEvent::MouseMove ||
163 event->type() == QEvent::MouseButtonPress ||
164 event->type() == QEvent::MouseButtonRelease ||
165 event->type() == QEvent::Enter) {
167 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
168 result = mouseEvent->pos();
170 }
else if (event->type() == QEvent::TabletMove ||
171 event->type() == QEvent::TabletPress ||
172 event->type() == QEvent::TabletRelease) {
174 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
175 result = tabletEvent->pos();
183 Qt::MouseButton
button = Qt::NoButton;
185 if (event->type() == QEvent::MouseMove ||
186 event->type() == QEvent::MouseButtonPress ||
187 event->type() == QEvent::MouseButtonRelease) {
189 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
190 button = mouseEvent->button();
192 }
else if (event->type() == QEvent::TabletMove ||
193 event->type() == QEvent::TabletPress ||
194 event->type() == QEvent::TabletRelease) {
196 QTabletEvent *tabletEvent =
static_cast<QTabletEvent*
>(event);
197 button = tabletEvent->button();
217 switch (event->type()) {
219 case QEvent::MouseMove:
220 case QEvent::TabletMove: {
228 m_canvas->canvasWidget()->setCursor(Qt::PointingHandCursor);
236 case QEvent::Leave: {
243 case QEvent::MouseButtonPress:
244 case QEvent::TabletPress: {
248 if (
button == Qt::RightButton) {
254 case QEvent::MouseButtonRelease:
255 case QEvent::TabletRelease: {
266 QRect cropRect = image->
bounds();
268 const int hLimit = cropRect.width();
269 const int vLimit = cropRect.height();
272 cropRect.setRight(
expandRight(cropRect.right(), widgetRect.right(), hLimit));
275 cropRect.setBottom(
expandRight(cropRect.bottom(), widgetRect.bottom(), vLimit));
278 cropRect.setLeft(
expandLeft(cropRect.left(), widgetRect.left(), hLimit));
281 cropRect.setTop(
expandLeft(cropRect.top(), widgetRect.top(), vLimit));
300 return !retval ? KisCanvasDecoration::eventFilter(obj, event) :
true;
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void sigCanvasStateChanged()
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)
#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()