Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dmitry Kazakov
Krita
Commits
b80b0154
Commit
b80b0154
authored
Apr 13, 2021
by
Daniel Doran
Browse files
Add "Canvas" crop mode.
Canvas will change the size of the canvas without cropping any layers. BUG: 393113
parent
c738c526
Changes
4
Hide whitespace changes
Inline
Side-by-side
plugins/tools/tool_crop/kis_tool_crop.cc
View file @
b80b0154
...
...
@@ -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
);
}
...
...
plugins/tools/tool_crop/kis_tool_crop.h
View file @
b80b0154
...
...
@@ -53,6 +53,7 @@ class KisToolCrop : public KisTool
public:
enum
CropToolType
{
ImageCropType
,
CanvasCropType
,
LayerCropType
,
FrameCropType
};
...
...
plugins/tools/tool_crop/kistoolcropconfigwidget.cpp
View file @
b80b0154
...
...
@@ -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
()
...
...
plugins/tools/tool_crop/wdg_tool_crop.ui
View file @
b80b0154
...
...
@@ -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>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment