23#include <klocalizedstring.h>
24#include <ksharedconfig.h>
94#define DECORATION_COUNT 5
98 :
KisTool(canvas,
KisCursor::loadWithSize(
"tool_crop_cursor.svg", 32, 32, 6, 6))
100 setObjectName(
"tool_crop");
303 const QRect initialRect = QRect(
m_dragStart, QSize(initialWidth, initialHeight));
330 if ((lastCommand =
image()->undoAdapter()->presentCommand()) &&
333 bool cropImageConsistent =
338 bool cropLayerConsistent =
344 if (cropImageConsistent || cropLayerConsistent) {
364 const bool haveValidRect =
413#define BORDER_LINE_WIDTH 0
414#define HALF_BORDER_LINE_WIDTH 0
415#define HANDLE_BORDER_LINE_WIDTH 1
427#define OUTSIDE_CROP_ALPHA 200
439 path.addRect(wholeImageRect);
440 path.addRect(borderRect);
441 gc.setPen(Qt::NoPen);
446 QPen pen(Qt::SolidLine);
449 pen.setCosmetic(
true);
454 gc.setClipRect(borderRect, Qt::IntersectClip);
573 if (!kisCanvas)
return;
763 specialSpacer->setObjectName(
"SpecialSpacer");
764 specialSpacer->setFixedSize(0, 0);
787 connect(
applyCrop, SIGNAL(triggered(
bool)),
this, SLOT(
crop()));
875 }
else if (
leftHandleRect(borderRect).contains(currentViewPoint)) {
879 }
else if (borderRect.contains(currentViewPoint)) {
930 QPointF start =
rect.topLeft();
931 QPointF end =
rect.topLeft();
932 qreal small = qMin(
rect.width(),
rect.height());
933 qreal large = qMax(
rect.width(),
rect.height());
937 start.setX(start.x() + decorLine->
start.x() *
rect.width());
940 start.setX(start.x() + decorLine->
start.x() *
rect.height());
943 start.setX(start.x() + decorLine->
start.x() * small);
946 start.setX(start.x() + decorLine->
start.x() * large);
952 start.setY(start.y() + decorLine->
start.y() *
rect.width());
955 start.setY(start.y() + decorLine->
start.y() *
rect.height());
958 start.setY(start.y() + decorLine->
start.y() * small);
961 start.setY(start.y() + decorLine->
start.y() * large);
967 end.setX(end.x() + decorLine->
end.x() *
rect.width());
970 end.setX(end.x() + decorLine->
end.x() *
rect.height());
973 end.setX(end.x() + decorLine->
end.x() * small);
976 end.setX(end.x() + decorLine->
end.x() * large);
982 end.setY(end.y() + decorLine->
end.y() *
rect.width());
985 end.setY(end.y() + decorLine->
end.y() *
rect.height());
988 end.setY(end.y() + decorLine->
end.y() * small);
991 end.setY(end.y() + decorLine->
end.y() * large);
995 p->drawLine(start, end);
float value(const T *src, size_t ch)
KUndo2CommandExtraData * extraData() const
KisDisplayColorConverter displayColorConverter
KisViewManager * viewManager() const
void setHeight(int value)
void setRatio(qreal value)
void moveHandle(HandleType handle, const QPoint &offset, const QRect &oldRect)
bool heightLocked() 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)
void setOffset(const QPoint &offset)
void setHeightLocked(bool value)
void setRatioLocked(bool value)
void setWidthLocked(bool value)
static QCursor sizeBDiagCursor()
static QCursor sizeAllCursor()
static QCursor sizeHorCursor()
static QCursor sizeFDiagCursor()
static QCursor arrowCursor()
static QCursor sizeVerCursor()
QColor convertColorToDisplayColorSpace(const KoColor color, bool applyOcio=false) const
convertColorToDisplayColorSpace This applies displayfiltering to the given KoColor,...
void resizeImage(const QRect &newRect)
start asynchronous operation on resizing the image
KisUndoAdapter * undoAdapter() const
void cropNode(KisNodeSP node, const QRect &newRect, const bool activeFrameOnly=false)
start asynchronous operation on cropping a subtree of nodes starting at node
QPointF pixelToDocument(const QPointF &pixelCoord) const
void cropImage(const QRect &newRect)
start asynchronous operation on cropping the image
QRect bounds() const override
The KisResourcesSnapshot class takes a snapshot of the various resources like colors and settings use...
KisNodeSP currentNode() const
KisSelectionSP activeSelection() const
virtual void undoLastCommand()=0
virtual const KUndo2Command * presentCommand()=0
void showFloatingMessage(const QString &message, const QIcon &icon, int timeout=4500, KisFloatingMessage::Priority priority=KisFloatingMessage::Medium, int alignment=Qt::AlignCenter|Qt::TextWordWrap)
shows a floating message in the top right corner of the canvas
void fromQColor(const QColor &c)
Convenient function for converting from a QColor.
#define KIS_ASSERT_RECOVER_RETURN(cond)
virtual KisPaintDeviceSP paintDevice() const =0
QRect selectedExactRect() const
Slow, but exact way of determining the rectangle that encloses the selection.