Commit b80b0154 authored by Daniel Doran's avatar Daniel Doran
Browse files

Add "Canvas" crop mode.

Canvas will change the size of the canvas without cropping any layers.
BUG: 393113
parent c738c526
......@@ -215,7 +215,9 @@ void KisToolCrop::canvasResourceChanged(int key, const QVariant &res)
}
//vector layer
else {
setCropType(ImageCropType);
if (m_cropType != ImageCropType || m_cropType != CanvasCropType) {
setCropType(ImageCropType);
}
setCropTypeSelectable(false);
}
}
......@@ -450,7 +452,7 @@ void KisToolCrop::crop()
KIS_ASSERT_RECOVER_RETURN(currentImage());
if (m_finalRect.rect().isEmpty()) return;
const bool imageCrop = m_cropType == ImageCropType;
const bool imageCrop = m_cropType == ImageCropType || m_cropType == CanvasCropType;
if (!imageCrop) {
//Cropping layer
......@@ -466,7 +468,11 @@ void KisToolCrop::crop()
// The visitor adds the undo steps to the macro
if (imageCrop || !currentNode()->paintDevice()) {
currentImage()->cropImage(cropRect);
if (m_cropType == CanvasCropType) {
currentImage()->resizeImage(cropRect);
} else {
currentImage()->cropImage(cropRect);
}
} else {
currentImage()->cropNode(currentNode(), cropRect, m_cropType == FrameCropType);
}
......
......@@ -53,6 +53,7 @@ class KisToolCrop : public KisTool
public:
enum CropToolType {
ImageCropType,
CanvasCropType,
LayerCropType,
FrameCropType
};
......
......@@ -9,6 +9,7 @@
#include "kis_tool_crop.h"
#include <kis_icon.h>
#include <kis_acyclic_signal_connector.h>
#include <QStandardItemModel>
KisToolCropConfigWidget::KisToolCropConfigWidget(QWidget* parent, KisToolCrop* cropTool)
......@@ -18,9 +19,14 @@ KisToolCropConfigWidget::KisToolCropConfigWidget(QWidget* parent, KisToolCrop* c
setupUi(this);
// update the UI based off data from crop tool
intHeight->setValue(m_cropTool->cropHeight());
cmbType->setCurrentIndex(m_cropTool->cropType());
cmbType->setEnabled(m_cropTool->cropTypeSelectable());
QStandardItemModel *cmbTypeModel = qobject_cast<QStandardItemModel *>(cmbType->model());
// Disable "Layer"
cmbTypeModel->item(2)->setEnabled(m_cropTool->cropTypeSelectable());
// Disable "Frame"
cmbTypeModel->item(3)->setEnabled(m_cropTool->cropTypeSelectable());
intHeight->setValue(m_cropTool->cropHeight());
intWidth->setValue(m_cropTool->cropWidth());
intX->setValue(m_cropTool->cropX());
intY->setValue(m_cropTool->cropY());
......@@ -100,7 +106,11 @@ KisToolCropConfigWidget::KisToolCropConfigWidget(QWidget* parent, KisToolCrop* c
void KisToolCropConfigWidget::cropTypeSelectableChanged()
{
cmbType->setEnabled(m_cropTool->cropTypeSelectable());
QStandardItemModel *cmbTypeModel = qobject_cast<QStandardItemModel *>(cmbType->model());
// Disable "Layer"
cmbTypeModel->item(2)->setEnabled(m_cropTool->cropTypeSelectable());
// Disable "Frame"
cmbTypeModel->item(3)->setEnabled(m_cropTool->cropTypeSelectable());
}
void KisToolCropConfigWidget::updateLockRatioIcon()
......
......@@ -400,6 +400,11 @@
<string>Image</string>
</property>
</item>
<item>
<property name="text">
<string>Canvas</string>
</property>
</item>
<item>
<property name="text">
<string>Layer</string>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment