diff --git a/krita/krita4.xmlgui b/krita/krita4.xmlgui
index 1e8ec06428..62d34350ff 100644
--- a/krita/krita4.xmlgui
+++ b/krita/krita4.xmlgui
@@ -1,386 +1,387 @@
&View&Canvas&Snap To
+ &Image&Rotate&LayerNew&Import/ExportImport&Convert&Select&Group&Transform&RotateS&plitS&plit Alpha&SelectFilte&r&ToolsScriptingRecordingMacrosSetti&ngs&HelpFileBrushes and Stuff
diff --git a/krita/kritamenu.action b/krita/kritamenu.action
index 651b3d5a0e..042d09b78d 100644
--- a/krita/kritamenu.action
+++ b/krita/kritamenu.action
@@ -1,1795 +1,1809 @@
Filedocument-new&NewCreate new documentNew00Ctrl+Nfalsedocument-open&Open...Open an existing documentOpen00Ctrl+Ofalsedocument-open-recentOpen &RecentOpen a document which was recently openedOpen Recent10falsedocument-save&SaveSaveSave10Ctrl+Sfalsedocument-save-asSave &As...Save document under a new nameSave As10Ctrl+Shift+Sfalsedocument-importOpen ex&isting Document as Untitled Document...Open existing Document as Untitled DocumentOpen existing Document as Untitled Document00falsedocument-exportE&xport...ExportExport10falseapplication-pdf&Export as PDF...Export as PDFExport as PDF10falseImport animation frames...Import animation framesImport animation frames10false&Render Animation...Render Animation to GIF, Image Sequence or VideoRender Animation10000false&Render Image Sequence AgainRender Animation to Image Sequence AgainRender Animation10000falseSave Incremental &VersionSave Incremental VersionSave Incremental Version10Ctrl+Alt+SfalseSave Incremental &BackupSave Incremental BackupSave Incremental Backup10F4false&Create Template From Image...Create Template From ImageCreate Template From Image10falseCreate Copy &From Current ImageCreate Copy From Current ImageCreate Copy From Current Image10falsedocument-print&Print...Print documentPrint10Ctrl+Pfalsedocument-print-previewPrint Previe&wShow a print preview of documentPrint Preview10falseconfigure&Document InformationDocument InformationDocument Information10false&Close AllClose AllClose All10Ctrl+Shift+WfalseC&loseCloseClose10false&QuitQuit applicationQuit00Ctrl+QfalseEditedit-undoUndoUndo last actionUndo10Ctrl+Zfalseedit-redoRedoRedo last undone actionRedo10Ctrl+Shift+Zfalseedit-cutCu&tCut selection to clipboardCut00Ctrl+Xfalseedit-copy&CopyCopy selection to clipboardCopy00Ctrl+CfalseC&opy (sharp)Copy (sharp)Copy (sharp)1000000000falseCut (&sharp)Cut (sharp)Cut (sharp)1000000000falseCopy &mergedCopy mergedCopy merged1000000000Ctrl+Shift+Cfalseedit-paste&PastePaste clipboard contentPaste00Ctrl+VfalsePaste at CursorPaste at cursorPaste at cursor00Ctrl+Alt+VfalsePaste into &New ImagePaste into New ImagePaste into New Image00Ctrl+Shift+Nfalseedit-clearC&learClearClear10Delfalse&Fill with Foreground ColorFill with Foreground ColorFill with Foreground Color100001Shift+BackspacefalseFill &with Background ColorFill with Background ColorFill with Background Color100001BackspacefalseF&ill with PatternFill with PatternFill with Pattern100001falseFill SpecialFill with Foreground Color (Opacity)Fill with Foreground Color (Opacity)Fill with Foreground Color (Opacity)100001Ctrl+Shift+BackspacefalseFill with Background Color (Opacity)Fill with Background Color (Opacity)Fill with Background Color (Opacity)100001Ctrl+BackspacefalseFill with Pattern (Opacity)Fill with Pattern (Opacity)Fill with Pattern (Opacity)100001falseStro&ke selected shapesStroke selected shapesStroke selected shapes10000000000falseStroke Selec&tion...Stroke selectionStroke selection100000000000falseDelete keyframeDelete keyframeDelete keyframe1000000falseWindowwindow-new&New WindowNew WindowNew Window00falseN&extNextNext100falsePreviousPreviousPreviousfalseView&Show Canvas OnlyShow just the canvas or the whole windowShow Canvas Only00Tabtrueview-fullscreenF&ull Screen ModeDisplay the window in full screenFull Screen Mode00Ctrl+Shift+Ftrue&Wrap Around ModeWrap Around ModeWrap Around Mode10Wtrue&Instant Preview ModeInstant Preview ModeInstant Preview Mode10Shift+LtrueSoft ProofingTurns on Soft ProofingTurns on Soft ProofingCtrl+YtrueOut of Gamut WarningsTurns on warnings for colors out of proofed gamut, needs soft proofing to be turned on.Turns on warnings for colors out of proofed gamut, needs soft proofing to be turned on.Ctrl+Shift+Ytruemirror-viewMirror ViewMirror ViewMirror ViewMfalsezoom-original&Reset zoomReset zoomReset zoom10Ctrl+0falsezoom-inZoom &InZoom In00Ctrl++falsezoom-outZoom &OutZoom Out00Ctrl+-falserotate-canvas-rightRotate &Canvas RightRotate Canvas RightRotate Canvas Right10Ctrl+]falserotate-canvas-leftRotate Canvas &LeftRotate Canvas LeftRotate Canvas Left10Ctrl+[falserotation-resetReset Canvas RotationReset Canvas RotationReset Canvas Rotation10falseShow &RulersThe rulers show the horizontal and vertical positions of the mouse on the image and can be used to position your mouse at the right place on the canvas. <p>Uncheck this to hide the rulers.</p>Show RulersShow Rulers10trueRulers Track PointerThe rulers will track current mouse position and show it on screen. It can cause suptle performance slowdownRulers Track PointerRulers Track Pointer10trueShow GuidesShow or hide guidesShow Guides10trueLock GuidesLock or unlock guidesLock Guides10trueSnap to GuidesSnap cursor to guides positionSnap to Guides10trueShow Status &BarShow or hide the status barShow Status Bar00trueShow Pixel GridShow Pixel GridShow Pixel Grid10000trueview-gridShow &GridShow GridShow Grid10000Ctrl+Shift+'trueSnap To GridSnap To GridSnap To Grid1000Ctrl+Shift+;trueShow Snap Options PopupShow Snap Options PopupShow Snap Options Popup1000Shift+sfalseSnap OrthogonalSnap OrthogonalSnap Orthogonal1000trueSnap NodeSnap NodeSnap Node1000trueSnap ExtensionSnap ExtensionSnap Extension1000trueSnap IntersectionSnap IntersectionSnap Intersection1000trueSnap Bounding BoxSnap Bounding BoxSnap Bounding Box1000trueSnap Image BoundsSnap Image BoundsSnap Image Bounds1000trueSnap Image CenterSnap Image CenterSnap Image Center1000trueS&how Painting AssistantsShow Painting AssistantsShow Painting Assistants10000trueShow &Assistant PreviewsShow Assistant PreviewsShow Assistant Previews10000true
+
+
+
+ S&how Reference Images
+
+ Show Reference Images
+ Show Reference Images
+ 1000
+ 0
+
+ true
+
+
+
Imagedocument-properties&Properties...PropertiesProperties10000falseformat-stroke-color&Image Background Color and Transparency...Change the background color of the imageImage Background Color and Transparency10000false&Convert Image Color Space...Convert Image Color SpaceConvert Image Color Space10000falsetrim-to-image&Trim to Image SizeTrim to Image SizeTrim to Image Size10falseTrim to Current &LayerTrim to Current LayerTrim to Current Layer1000000falseTrim to S&electionTrim to SelectionTrim to Selection1000000000false&Rotate Image...Rotate ImageRotate Image10000falseobject-rotate-rightRotate &Image 90° to the RightRotate Image 90° to the RightRotate Image 90° to the Right10000falseobject-rotate-leftRotate Image &90° to the LeftRotate Image 90° to the LeftRotate Image 90° to the Left10000falseRotate Image &180°Rotate Image 180°Rotate Image 180°10000false&Shear Image...Shear ImageShear Image10000falsesymmetry-horizontal&Mirror Image HorizontallyMirror Image HorizontallyMirror Image Horizontally10000falsesymmetry-verticalMirror Image &VerticallyMirror Image VerticallyMirror Image Vertically10000falseScale Image To &New Size...Scale Image To New SizeScale Image To New Size10000Ctrl+Alt+Ifalse&Offset Image...Offset ImageOffset Image10000falseR&esize Canvas...Resize CanvasResize Canvas10000Ctrl+Alt+CfalseIm&age Split Image SplitImage Split10000falseSeparate Ima&ge...Separate ImageSeparate Image10000falseSelectedit-select-allSelect &AllSelect AllSelect All00Ctrl+Afalseedit-select-all&DeselectDeselectDeselect11000000000Ctrl+Shift+Afalse&ReselectReselectReselect00Ctrl+Shift+Dfalse&InvertInvertInvert100000Ctrl+Ifalse&Convert to Vector SelectionConvert to Vector SelectionConvert to Vector Selection100000000000falseConvert Shapes to &Vector SelectionConvert Shapes to Vector SelectionConvert Shapes to Vector Selection10000000000false&Feather Selection...Feather SelectionFeather Selection10000000000100Shift+F6falseDis&play SelectionDisplay SelectionDisplay Selection10000Ctrl+HtrueSca&le...ScaleScale100000000100falseS&elect from Color Range...Select from Color RangeSelect from Color Range10000100falseSelect &OpaqueSelect OpaqueSelect Opaque10000100false&Grow Selection...Grow SelectionGrow Selection10000000000100falseS&hrink Selection...Shrink SelectionShrink Selection10000000000100false&Border Selection...Border SelectionBorder Selection10000000000100falseS&moothSmoothSmooth10000000000100falseFilter&Apply Filter AgainApply Filter AgainApply Filter Again00Ctrl+FfalseAdjustAdjustAdjustfalseArtisticArtisticArtisticfalseBlurBlurBlurfalseColorsColorsColorsfalseEdge DetectionEdge DetectionEdge DetectionfalseEnhanceEnhanceEnhancefalseEmbossEmbossEmbossfalseMapMapMapfalseOtherOtherOtherfalsegmicStart G'MIC-QtStart G'Mic-QtStart G'Mic-QtfalsegmicRe-apply the last G'MIC filterApply the last G'Mic-Qt action againApply the last G'Mic-Qt action againfalseToolsmedia-record&Start recording macroStart recording macroStart recording macro10000falsemedia-playback-stopStop &recording actionsStop recording actionsStop recording actions10000falsemedia-playback-start&Open and play...Open and playOpen and play00falsedocument-editOpen &and edit...Open and editOpen and edit00falseSettingsconfigure&Configure Krita...Configure KritaConfigure Krita00false&Manage Resources...Manage ResourcesManage Resources00falsepreferences-desktop-localeSwitch Application &Language...Switch Application LanguageSwitch Application Languagefalse&Show DockersShow DockersShow Dockers00trueSho&w Docker TitlebarsShow Docker TitlebarsShow Docker Titlebars00trueconfigureConfigure Tool&bars...Configure ToolbarsConfigure Toolbars00falseDockersDockersDockersfalse&ThemesThemesThemesfalseim-userActive Author ProfileActive Author ProfileActive Author Profileconfigure-shortcutsConfigure S&hortcuts...Configure ShortcutsConfigure Shortcuts00false&WindowWindowWindowfalseHelphelp-contentsKrita &HandbookKrita HandbookKrita HandbookF1falsetools-report-bug&Report Bug...Report BugReport Bugfalsecalligrakrita&About KritaAbout KritaAbout KritafalsekdeAbout &KDEAbout KDEAbout KDEfalseBrushes and Stuff&GradientsGradientsGradientsfalse&PatternsPatternsPatternsfalse&ColorColorColorfalse&Painter's ToolsPainter's ToolsPainter's ToolsfalseBrush compositeBrush compositeBrush compositefalseBrush option slider 1Brush option slider 1Brush option slider 1falseBrush option slider 2Brush option slider 2Brush option slider 2falseBrush option slider 3Brush option slider 3Brush option slider 3falseMirrorMirrorMirrorfalseWorkspacesWorkspacesWorkspacesfalse
diff --git a/krita/pics/tools/SVG/16/dark_krita_tool_reference_images.svg b/krita/pics/tools/SVG/16/dark_krita_tool_reference_images.svg
new file mode 100644
index 0000000000..2aa3fe0b92
--- /dev/null
+++ b/krita/pics/tools/SVG/16/dark_krita_tool_reference_images.svg
@@ -0,0 +1,155 @@
+
+
+
+
diff --git a/krita/pics/tools/SVG/16/light_krita_tool_reference_images.svg b/krita/pics/tools/SVG/16/light_krita_tool_reference_images.svg
new file mode 100644
index 0000000000..42f486435d
--- /dev/null
+++ b/krita/pics/tools/SVG/16/light_krita_tool_reference_images.svg
@@ -0,0 +1,155 @@
+
+
+
+
diff --git a/krita/pics/tools/SVG/16/tools-svg-16-icons.qrc b/krita/pics/tools/SVG/16/tools-svg-16-icons.qrc
index ffa77b7afd..d760fb0128 100644
--- a/krita/pics/tools/SVG/16/tools-svg-16-icons.qrc
+++ b/krita/pics/tools/SVG/16/tools-svg-16-icons.qrc
@@ -1,80 +1,82 @@
dark_calligraphy.svgdark_draw-text.svgdark_format-fill-color.svgdark_krita_draw_path.svgdark_krita_tool_color_fill.svgdark_krita_tool_color_picker.svgdark_krita_tool_dyna.svgdark_krita_tool_ellipse.svgdark_krita_tool_freehand.svgdark_krita_tool_freehandvector.svgdark_krita_tool_gradient.svgdark_krita_tool_grid.svgdark_krita_tool_line.svgdark_krita_tool_measure.svgdark_krita_tool_move.svgdark_krita_tool_multihand.svgdark_krita_tool_polygon.svgdark_krita_tool_rectangle.svgdark_krita_tool_transform.svgdark_pattern.svgdark_polyline.svgdark_select.svgdark_tool_contiguous_selection.svgdark_tool_crop.svgdark_tool_elliptical_selection.svgdark_tool_outline_selection.svgdark_tool_pan.svgdark_tool_path_selection.svgdark_tool_perspectivegrid.svgdark_tool_polygonal_selection.svgdark_tool_rect_selection.svgdark_tool_similar_selection.svgdark_tool_zoom.svglight_calligraphy.svglight_draw-text.svglight_format-fill-color.svglight_krita_draw_path.svglight_krita_tool_color_fill.svglight_krita_tool_color_picker.svglight_krita_tool_dyna.svglight_krita_tool_ellipse.svglight_krita_tool_freehand.svglight_krita_tool_freehandvector.svglight_krita_tool_gradient.svglight_krita_tool_grid.svglight_krita_tool_line.svglight_krita_tool_measure.svglight_krita_tool_move.svglight_krita_tool_multihand.svglight_krita_tool_polygon.svglight_krita_tool_rectangle.svglight_krita_tool_transform.svglight_pattern.svglight_polyline.svglight_select.svglight_tool_contiguous_selection.svglight_tool_crop.svglight_tool_elliptical_selection.svglight_tool_outline_selection.svglight_tool_pan.svglight_tool_path_selection.svglight_tool_perspectivegrid.svglight_tool_polygonal_selection.svglight_tool_rect_selection.svglight_tool_similar_selection.svglight_tool_zoom.svgdark_shape_handling.svgdark_artistic_text.svglight_artistic_text.svglight_shape_handling.svgdark_krita_tool_lazybrush.svglight_krita_tool_lazybrush.svgdark_krita_tool_smart_patch.svglight_krita_tool_smart_patch.svglight_krita_tool_assistant.svgdark_krita_tool_assistant.svg
+ dark_krita_tool_reference_images.svg
+ light_krita_tool_reference_images.svg
diff --git a/libs/flake/commands/KoShapeCreateCommand.cpp b/libs/flake/commands/KoShapeCreateCommand.cpp
index 196d0e9a14..545c47014e 100644
--- a/libs/flake/commands/KoShapeCreateCommand.cpp
+++ b/libs/flake/commands/KoShapeCreateCommand.cpp
@@ -1,124 +1,129 @@
/* This file is part of the KDE project
* Copyright (C) 2006 Thomas Zander
* Copyright (C) 2006 Jan Hambrecht
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoShapeCreateCommand.h"
#include "KoShape.h"
#include "KoShapeContainer.h"
#include "KoShapeBasedDocumentBase.h"
#include
#include "kis_assert.h"
#include
#include
#include
#include
class Q_DECL_HIDDEN KoShapeCreateCommand::Private
{
public:
Private(KoShapeBasedDocumentBase *_document, const QList &_shapes, KoShapeContainer *_parentShape)
: shapesDocument(_document),
shapes(_shapes),
explicitParentShape(_parentShape),
deleteShapes(true)
{
}
~Private() {
if (deleteShapes) {
qDeleteAll(shapes);
}
}
KoShapeBasedDocumentBase *shapesDocument;
QList shapes;
KoShapeContainer *explicitParentShape;
bool deleteShapes;
std::vector> reorderingCommands;
};
KoShapeCreateCommand::KoShapeCreateCommand(KoShapeBasedDocumentBase *controller, KoShape *shape, KoShapeContainer *parentShape, KUndo2Command *parent)
: KoShapeCreateCommand(controller, QList() << shape, parentShape, parent)
{
}
KoShapeCreateCommand::KoShapeCreateCommand(KoShapeBasedDocumentBase *controller, const QList shapes, KoShapeContainer *parentShape, KUndo2Command *parent)
- : KUndo2Command(kundo2_i18np("Create shape", "Create shapes", shapes.size()), parent),
- d(new Private(controller, shapes, parentShape))
+ : KoShapeCreateCommand(controller, shapes, parentShape, parent, kundo2_i18np("Create shape", "Create shapes", shapes.size()))
+{
+}
+
+KoShapeCreateCommand::KoShapeCreateCommand(KoShapeBasedDocumentBase *controller, const QList shapes, KoShapeContainer *parentShape, KUndo2Command *parent, const KUndo2MagicString &undoString)
+ : KUndo2Command(undoString, parent)
+ , d(new Private(controller, shapes, parentShape))
{
}
KoShapeCreateCommand::~KoShapeCreateCommand()
{
delete d;
}
void KoShapeCreateCommand::redo()
{
KUndo2Command::redo();
KIS_ASSERT(d->shapesDocument);
d->deleteShapes = false;
d->reorderingCommands.clear();
Q_FOREACH(KoShape *shape, d->shapes) {
if (d->explicitParentShape) {
shape->setParent(d->explicitParentShape);
}
d->shapesDocument->addShape(shape);
KoShapeContainer *shapeParent = shape->parent();
KIS_SAFE_ASSERT_RECOVER_NOOP(shape->parent() ||
dynamic_cast(shape));
if (shapeParent) {
KUndo2Command *cmd = KoShapeReorderCommand::mergeInShape(shapeParent->shapes(), shape);
if (cmd) {
cmd->redo();
d->reorderingCommands.push_back(
std::unique_ptr(cmd));
}
}
}
}
void KoShapeCreateCommand::undo()
{
KUndo2Command::undo();
KIS_ASSERT(d->shapesDocument);
while (!d->reorderingCommands.empty()) {
std::unique_ptr cmd = std::move(d->reorderingCommands.back());
cmd->undo();
d->reorderingCommands.pop_back();
}
Q_FOREACH(KoShape *shape, d->shapes) {
d->shapesDocument->removeShape(shape);
}
d->deleteShapes = true;
}
diff --git a/libs/flake/commands/KoShapeCreateCommand.h b/libs/flake/commands/KoShapeCreateCommand.h
index 9be7022554..3806c19366 100644
--- a/libs/flake/commands/KoShapeCreateCommand.h
+++ b/libs/flake/commands/KoShapeCreateCommand.h
@@ -1,65 +1,70 @@
/* This file is part of the KDE project
* Copyright (C) 2006 Thomas Zander
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOSHAPECREATECOMMAND_H
#define KOSHAPECREATECOMMAND_H
#include "kritaflake_export.h"
#include
class KoShape;
class KoShapeContainer;
class KoShapeBasedDocumentBase;
/// The undo / redo command for creating shapes
class KRITAFLAKE_EXPORT KoShapeCreateCommand : public KUndo2Command
{
public:
/**
* Command used on creation of new shapes
* @param controller the controller used to add/remove the shape from
* @param shape the shape that's just been created.
* @param parent the parent command used for macro commands
*/
KoShapeCreateCommand(KoShapeBasedDocumentBase *controller, KoShape *shape,
KoShapeContainer *parentShape = 0,
KUndo2Command *parent = 0);
/**
* Command used on creation of new shapes
* @param controller the controller used to add/remove the shape from
* @param shapes the shapes that have just been created.
* @param parent the parent command used for macro commands
*/
KoShapeCreateCommand(KoShapeBasedDocumentBase *controller, const QList shape,
KoShapeContainer *parentShape = 0,
KUndo2Command *parent = 0);
~KoShapeCreateCommand() override;
/// redo the command
void redo() override;
/// revert the actions done in redo
void undo() override;
+protected:
+ KoShapeCreateCommand(KoShapeBasedDocumentBase *controller, const QList shapes,
+ KoShapeContainer *parentShape, KUndo2Command *parent,
+ const KUndo2MagicString &undoString);
+
private:
class Private;
Private * const d;
};
#endif
diff --git a/libs/flake/commands/KoShapeKeepAspectRatioCommand.cpp b/libs/flake/commands/KoShapeKeepAspectRatioCommand.cpp
index e61080c61f..2ace186e1f 100644
--- a/libs/flake/commands/KoShapeKeepAspectRatioCommand.cpp
+++ b/libs/flake/commands/KoShapeKeepAspectRatioCommand.cpp
@@ -1,55 +1,54 @@
/* This file is part of the KDE project
* Copyright (C) 2007 Peter Simonsson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoShapeKeepAspectRatioCommand.h"
#include
#include
-KoShapeKeepAspectRatioCommand::KoShapeKeepAspectRatioCommand(const QList& shapes,
- const QList& oldKeepAspectRatio,
- const QList& newKeepAspectRatio,
- KUndo2Command* parent)
- : KUndo2Command(kundo2_i18n("Keep Aspect Ratio"), parent)
+KoShapeKeepAspectRatioCommand::KoShapeKeepAspectRatioCommand(const QList &shapes, bool newKeepAspectRatio, KUndo2Command *parent)
+ : KUndo2Command(kundo2_i18n("Keep Aspect Ratio"), parent)
+ , m_shapes(shapes)
{
- m_shapes = shapes;
- m_oldKeepAspectRatio = oldKeepAspectRatio;
- m_newKeepAspectRatio = newKeepAspectRatio;
+ Q_FOREACH (KoShape *shape, shapes) {
+ m_oldKeepAspectRatio << shape->keepAspectRatio();
+ m_newKeepAspectRatio << newKeepAspectRatio;
+ }
}
KoShapeKeepAspectRatioCommand::~KoShapeKeepAspectRatioCommand()
{
}
void KoShapeKeepAspectRatioCommand::redo()
{
KUndo2Command::redo();
for (int i = 0; i < m_shapes.count(); ++i) {
m_shapes[i]->setKeepAspectRatio(m_newKeepAspectRatio[i]);
}
}
void KoShapeKeepAspectRatioCommand::undo()
{
KUndo2Command::undo();
for (int i = 0; i < m_shapes.count(); ++i) {
m_shapes[i]->setKeepAspectRatio(m_oldKeepAspectRatio[i]);
}
}
diff --git a/libs/flake/commands/KoShapeKeepAspectRatioCommand.h b/libs/flake/commands/KoShapeKeepAspectRatioCommand.h
index dc03eff77c..44b53266da 100644
--- a/libs/flake/commands/KoShapeKeepAspectRatioCommand.h
+++ b/libs/flake/commands/KoShapeKeepAspectRatioCommand.h
@@ -1,56 +1,55 @@
/* This file is part of the KDE project
* Copyright (C) 2007 Peter Simonsson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOSHAPEKEEPASPECTRATIOCOMMAND_H
#define KOSHAPEKEEPASPECTRATIOCOMMAND_H
#include "kritaflake_export.h"
#include
#include
class KoShape;
/**
* Command that changes the keepAspectRatio property of KoShape
*/
class KRITAFLAKE_EXPORT KoShapeKeepAspectRatioCommand : public KUndo2Command
{
public:
/**
* Constructor
* @param shapes the shapes affected by the command
- * @param oldKeepAspectRatio the old settings
- * @param newKeepAspectRatio the new settings
+ * @param newKeepAspectRatio the new setting
* @param parent the parent command
*/
- KoShapeKeepAspectRatioCommand(const QList &shapes, const QList &oldKeepAspectRatio, const QList &newKeepAspectRatio, KUndo2Command* parent = 0);
+ KoShapeKeepAspectRatioCommand(const QList &shapes, bool newKeepAspectRatio, KUndo2Command* parent = 0);
~KoShapeKeepAspectRatioCommand() override;
/// Execute the command
void redo() override;
/// Unexecute the command
void undo() override;
private:
QList m_shapes;
QList m_oldKeepAspectRatio;
QList m_newKeepAspectRatio;
};
#endif
diff --git a/libs/flake/tools/KoShapeRubberSelectStrategy.cpp b/libs/flake/tools/KoShapeRubberSelectStrategy.cpp
index 458c3b90d9..b6463dd161 100644
--- a/libs/flake/tools/KoShapeRubberSelectStrategy.cpp
+++ b/libs/flake/tools/KoShapeRubberSelectStrategy.cpp
@@ -1,140 +1,122 @@
/* This file is part of the KDE project
Copyright (C) 2006 Thorsten Zachmann
Copyright (C) 2006 Thomas Zander
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoShapeRubberSelectStrategy.h"
#include "KoShapeRubberSelectStrategy_p.h"
#include "KoViewConverter.h"
#include
#include "KoShapeManager.h"
#include "KoSelection.h"
#include "KoCanvasBase.h"
-
KoShapeRubberSelectStrategy::KoShapeRubberSelectStrategy(KoToolBase *tool, const QPointF &clicked, bool useSnapToGrid)
: KoInteractionStrategy(*(new KoShapeRubberSelectStrategyPrivate(tool)))
{
Q_D(KoShapeRubberSelectStrategy);
d->snapGuide->enableSnapStrategies(KoSnapGuide::GridSnapping);
d->snapGuide->enableSnapping(useSnapToGrid);
d->selectRect = QRectF(d->snapGuide->snap(clicked, 0), QSizeF(0, 0));
}
void KoShapeRubberSelectStrategy::paint(QPainter &painter, const KoViewConverter &converter)
{
Q_D(KoShapeRubberSelectStrategy);
painter.setRenderHint(QPainter::Antialiasing, false);
const QColor crossingColor(80,130,8);
const QColor coveringColor(8,60,167);
QColor selectColor(
currentMode() == CrossingSelection ?
crossingColor : coveringColor);
selectColor.setAlphaF(0.8);
painter.setPen(QPen(selectColor, 0));
selectColor.setAlphaF(0.4);
const QBrush fillBrush(selectColor);
painter.setBrush(fillBrush);
QRectF paintRect = converter.documentToView(d->selectedRect());
paintRect = paintRect.normalized();
painter.drawRect(paintRect);
}
void KoShapeRubberSelectStrategy::handleMouseMove(const QPointF &p, Qt::KeyboardModifiers modifiers)
{
Q_D(KoShapeRubberSelectStrategy);
QPointF point = d->snapGuide->snap(p, modifiers);
if (modifiers & Qt::ControlModifier) {
d->tool->canvas()->updateCanvas(d->selectedRect());
d->selectRect.moveTopLeft(d->selectRect.topLeft() - (d->lastPos - point));
d->lastPos = point;
d->tool->canvas()->updateCanvas(d->selectedRect());
return;
}
d->lastPos = point;
QPointF old = d->selectRect.bottomRight();
d->selectRect.setBottomRight(point);
/*
+---------------|--+
| | | We need to figure out rects A and B based on the two points. BUT
| old | A| we need to do that even if the points are switched places
| \ | | (i.e. the rect got smaller) and even if the rect is mirrored
+---------------+ | in either the horizontal or vertical axis.
| B |
+------------------+
`- point
*/
QPointF x1 = old;
x1.setY(d->selectRect.topLeft().y());
qreal h1 = point.y() - x1.y();
qreal h2 = old.y() - x1.y();
QRectF A(x1, QSizeF(point.x() - x1.x(), point.y() < d->selectRect.top() ? qMin(h1, h2) : qMax(h1, h2)));
A = A.normalized();
d->tool->canvas()->updateCanvas(A);
QPointF x2 = old;
x2.setX(d->selectRect.topLeft().x());
qreal w1 = point.x() - x2.x();
qreal w2 = old.x() - x2.x();
QRectF B(x2, QSizeF(point.x() < d->selectRect.left() ? qMin(w1, w2) : qMax(w1, w2), point.y() - x2.y()));
B = B.normalized();
d->tool->canvas()->updateCanvas(B);
}
-void KoShapeRubberSelectStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
-{
- Q_D(KoShapeRubberSelectStrategy);
- Q_UNUSED(modifiers);
- KoSelection * selection = d->tool->canvas()->shapeManager()->selection();
-
- const bool useContainedMode = currentMode() == CoveringSelection;
-
- QList shapes =
- d->tool->canvas()->shapeManager()->
- shapesAt(d->selectedRect(), true, useContainedMode);
-
- Q_FOREACH (KoShape * shape, shapes) {
- if (!shape->isSelectable()) continue;
-
- selection->select(shape);
- }
-
- d->tool->repaintDecorations();
- d->tool->canvas()->updateCanvas(d->selectedRect());
-}
-
KoShapeRubberSelectStrategy::SelectionMode KoShapeRubberSelectStrategy::currentMode() const
{
Q_D(const KoShapeRubberSelectStrategy);
return d->selectRect.left() < d->selectRect.right() ? CoveringSelection : CrossingSelection;
}
KUndo2Command *KoShapeRubberSelectStrategy::createCommand()
{
return 0;
}
+
+QRectF KoShapeRubberSelectStrategy::selectedRectangle() const {
+ Q_D(const KoShapeRubberSelectStrategy);
+ return d->selectedRect();
+}
diff --git a/libs/flake/tools/KoShapeRubberSelectStrategy.h b/libs/flake/tools/KoShapeRubberSelectStrategy.h
index 13beb562ab..1b5464903c 100644
--- a/libs/flake/tools/KoShapeRubberSelectStrategy.h
+++ b/libs/flake/tools/KoShapeRubberSelectStrategy.h
@@ -1,74 +1,76 @@
/* This file is part of the KDE project
Copyright (C) 2006 Thorsten Zachmann
Copyright (C) 2006 Thomas Zander
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOSHAPERUBBERSELECTSTRATEGY_H
#define KOSHAPERUBBERSELECTSTRATEGY_H
#include "KoInteractionStrategy.h"
#include
#include "kritaflake_export.h"
class KoToolBase;
class KoShapeRubberSelectStrategyPrivate;
/**
- * Implement the rubber band selection of flake objects.
+ * This is a base class for interactions based on dragging a rectangular area on the canvas,
+ * such as selection, zooming or shape creation.
*
* When the user selects stuff in left-to-right way, selection is in "covering"
* (or "containing") mode, when in "left-to-right" in "crossing" mode
*/
class KRITAFLAKE_EXPORT KoShapeRubberSelectStrategy : public KoInteractionStrategy
{
public:
/**
* Constructor that initiates the rubber select.
* A rubber select is basically rectangle area that the user drags out
* from @p clicked to a point later provided in the handleMouseMove() continuously
* showing a semi-transarant 'rubber-mat' over the objects it is about to select.
* @param tool the parent tool which controls this strategy
* @param clicked the initial point that the user depressed (in pt).
* @param useSnapToGrid use the snap-to-grid settings while doing the rubberstamp.
*/
KoShapeRubberSelectStrategy(KoToolBase *tool, const QPointF &clicked, bool useSnapToGrid = false);
void paint(QPainter &painter, const KoViewConverter &converter) override;
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override;
KUndo2Command *createCommand() override;
- void finishInteraction(Qt::KeyboardModifiers modifiers) override;
protected:
/// constructor
KoShapeRubberSelectStrategy(KoShapeRubberSelectStrategyPrivate &);
+ QRectF selectedRectangle() const;
+
enum SelectionMode {
CrossingSelection,
CoveringSelection
};
virtual SelectionMode currentMode() const;
private:
Q_DECLARE_PRIVATE(KoShapeRubberSelectStrategy)
};
#endif /* KOSHAPERUBBERSELECTSTRATEGY_H */
diff --git a/libs/image/kis_types.h b/libs/image/kis_types.h
index e875996a92..87793d8db0 100644
--- a/libs/image/kis_types.h
+++ b/libs/image/kis_types.h
@@ -1,306 +1,310 @@
/*
* Copyright (c) 2002 Patrick Julien
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KISTYPES_H_
#define KISTYPES_H_
#include
#include
#include
#include "kritaimage_export.h"
template
class KisWeakSharedPtr;
template
class KisSharedPtr;
template class QSharedPointer;
template class QWeakPointer;
template
uint qHash(KisSharedPtr ptr) {
return qHash(ptr.data());
}
template
uint qHash(KisWeakSharedPtr ptr) {
return qHash(ptr.data());
}
/**
* Define lots of shared pointer versions of Krita classes.
* Shared pointer classes have the advantage of near automatic
* memory management (but beware of circular references)
* These types should never be passed by reference,
* because that will mess up their reference counter.
*
* An example of the naming pattern used:
*
* KisPaintDeviceSP is a KisSharedPtr of KisPaintDevice
* KisPaintDeviceWSP is a KisWeakSharedPtr of KisPaintDevice
* vKisPaintDeviceSP is a QVector of KisPaintDeviceSP
* vKisPaintDeviceSP_it is an iterator of vKisPaintDeviceSP
*
*/
class KisImage;
typedef KisSharedPtr KisImageSP;
typedef KisWeakSharedPtr KisImageWSP;
class KisPaintDevice;
typedef KisSharedPtr KisPaintDeviceSP;
typedef KisWeakSharedPtr KisPaintDeviceWSP;
typedef QVector vKisPaintDeviceSP;
typedef vKisPaintDeviceSP::iterator vKisPaintDeviceSP_it;
class KisFixedPaintDevice;
typedef KisSharedPtr KisFixedPaintDeviceSP;
class KisMask;
typedef KisSharedPtr KisMaskSP;
typedef KisWeakSharedPtr KisMaskWSP;
class KisNode;
typedef KisSharedPtr KisNodeSP;
typedef KisWeakSharedPtr KisNodeWSP;
typedef QVector vKisNodeSP;
typedef vKisNodeSP::iterator vKisNodeSP_it;
typedef vKisNodeSP::const_iterator vKisNodeSP_cit;
class KisBaseNode;
typedef KisSharedPtr KisBaseNodeSP;
typedef KisWeakSharedPtr KisBaseNodeWSP;
class KisEffectMask;
typedef KisSharedPtr KisEffectMaskSP;
typedef KisWeakSharedPtr KisEffectMaskWSP;
class KisFilterMask;
typedef KisSharedPtr KisFilterMaskSP;
typedef KisWeakSharedPtr KisFilterMaskWSP;
class KisTransformMask;
typedef KisSharedPtr KisTransformMaskSP;
typedef KisWeakSharedPtr KisTransformMaskWSP;
class KisTransformMaskParamsInterface;
typedef QSharedPointer KisTransformMaskParamsInterfaceSP;
typedef QWeakPointer KisTransformMaskParamsInterfaceWSP;
class KisTransparencyMask;
typedef KisSharedPtr KisTransparencyMaskSP;
typedef KisWeakSharedPtr KisTransparencyMaskWSP;
class KisColorizeMask;
typedef KisSharedPtr KisColorizeMaskSP;
typedef KisWeakSharedPtr KisColorizeMaskWSP;
class KisLayer;
typedef KisSharedPtr KisLayerSP;
typedef KisWeakSharedPtr KisLayerWSP;
class KisShapeLayer;
typedef KisSharedPtr KisShapeLayerSP;
class KisPaintLayer;
typedef KisSharedPtr KisPaintLayerSP;
class KisAdjustmentLayer;
typedef KisSharedPtr KisAdjustmentLayerSP;
class KisGeneratorLayer;
typedef KisSharedPtr KisGeneratorLayerSP;
class KisCloneLayer;
typedef KisSharedPtr KisCloneLayerSP;
typedef KisWeakSharedPtr KisCloneLayerWSP;
class KisGroupLayer;
typedef KisSharedPtr KisGroupLayerSP;
typedef KisWeakSharedPtr KisGroupLayerWSP;
class KisFileLayer;
typedef KisSharedPtr KisFileLayerSP;
typedef KisWeakSharedPtr KisFileLayerWSP;
class KisSelection;
typedef KisSharedPtr KisSelectionSP;
typedef KisWeakSharedPtr KisSelectionWSP;
class KisSelectionComponent;
typedef KisSharedPtr KisSelectionComponentSP;
class KisSelectionMask;
typedef KisSharedPtr KisSelectionMaskSP;
class KisPixelSelection;
typedef KisSharedPtr KisPixelSelectionSP;
class KisHistogram;
typedef KisSharedPtr KisHistogramSP;
typedef QVector vKisSegments;
class KisFilter;
typedef KisSharedPtr KisFilterSP;
class KisLayerStyleFilter;
typedef KisSharedPtr KisLayerStyleFilterSP;
class KisGenerator;
typedef KisSharedPtr KisGeneratorSP;
class KisConvolutionKernel;
typedef KisSharedPtr KisConvolutionKernelSP;
class KisAnnotation;
typedef KisSharedPtr KisAnnotationSP;
typedef QVector vKisAnnotationSP;
typedef vKisAnnotationSP::iterator vKisAnnotationSP_it;
typedef vKisAnnotationSP::const_iterator vKisAnnotationSP_cit;
class KisAnimationFrameCache;
typedef KisSharedPtr KisAnimationFrameCacheSP;
typedef KisWeakSharedPtr KisAnimationFrameCacheWSP;
class KisPaintingAssistant;
typedef QSharedPointer KisPaintingAssistantSP;
typedef QWeakPointer KisPaintingAssistantWSP;
+class KisReferenceImage;
+typedef QSharedPointer KisReferenceImageSP;
+typedef QWeakPointer KisReferenceImageWSP;
+
// Repeat iterators
class KisHLineIterator2;
template class KisRepeatHLineIteratorPixelBase;
typedef KisRepeatHLineIteratorPixelBase< KisHLineIterator2 > KisRepeatHLineConstIteratorNG;
typedef KisSharedPtr KisRepeatHLineConstIteratorSP;
class KisVLineIterator2;
template class KisRepeatVLineIteratorPixelBase;
typedef KisRepeatVLineIteratorPixelBase< KisVLineIterator2 > KisRepeatVLineConstIteratorNG;
typedef KisSharedPtr KisRepeatVLineConstIteratorSP;
// NG Iterators
class KisHLineIteratorNG;
typedef KisSharedPtr KisHLineIteratorSP;
class KisHLineConstIteratorNG;
typedef KisSharedPtr KisHLineConstIteratorSP;
class KisVLineIteratorNG;
typedef KisSharedPtr KisVLineIteratorSP;
class KisVLineConstIteratorNG;
typedef KisSharedPtr KisVLineConstIteratorSP;
class KisRandomConstAccessorNG;
typedef KisSharedPtr KisRandomConstAccessorSP;
class KisRandomAccessorNG;
typedef KisSharedPtr KisRandomAccessorSP;
class KisRandomSubAccessor;
typedef KisSharedPtr KisRandomSubAccessorSP;
// Things
typedef QVector vQPointF;
class KisPaintOpPreset;
typedef KisSharedPtr KisPaintOpPresetSP;
typedef KisWeakSharedPtr KisPaintOpPresetWSP;
template
class KisPinnedSharedPtr;
class KisPaintOpSettings;
typedef KisPinnedSharedPtr KisPaintOpSettingsSP;
template
class KisRestrictedSharedPtr;
typedef KisRestrictedSharedPtr KisPaintOpSettingsRestrictedSP;
class KisPaintOp;
typedef KisSharedPtr KisPaintOpSP;
class KoID;
typedef QList KoIDList;
class KoUpdater;
template class QPointer;
typedef QPointer KoUpdaterPtr;
class KisProcessingVisitor;
typedef KisSharedPtr KisProcessingVisitorSP;
class KUndo2Command;
typedef QSharedPointer KUndo2CommandSP;
typedef QList KisNodeList;
typedef QSharedPointer KisNodeListSP;
typedef QList KisPaintDeviceList;
class KisStroke;
typedef QSharedPointer KisStrokeSP;
typedef QWeakPointer KisStrokeWSP;
typedef KisStrokeWSP KisStrokeId;
class KisFilterConfiguration;
typedef KisPinnedSharedPtr KisFilterConfigurationSP;
class KisPropertiesConfiguration;
typedef KisPinnedSharedPtr KisPropertiesConfigurationSP;
class KisLockedProperties;
typedef KisSharedPtr KisLockedPropertiesSP;
class KisProjectionUpdatesFilter;
typedef QSharedPointer KisProjectionUpdatesFilterSP;
class KisAbstractProjectionPlane;
typedef QSharedPointer KisAbstractProjectionPlaneSP;
typedef QWeakPointer KisAbstractProjectionPlaneWSP;
class KisProjectionLeaf;
typedef QSharedPointer KisProjectionLeafSP;
typedef QWeakPointer KisProjectionLeafWSP;
class KisKeyframe;
typedef QSharedPointer KisKeyframeSP;
typedef QWeakPointer KisKeyframeWSP;
class KisFilterChain;
typedef KisSharedPtr KisFilterChainSP;
class KisProofingConfiguration;
typedef QSharedPointer KisProofingConfigurationSP;
typedef QWeakPointer KisProofingConfigurationWSP;
class KisLayerComposition;
typedef QSharedPointer KisLayerCompositionSP;
typedef QWeakPointer KisLayerCompositionWSP;
#include
#include
#include
#include
#include
#endif // KISTYPES_H_
diff --git a/libs/image/krita_utils.cpp b/libs/image/krita_utils.cpp
index 419e349c10..5c5a208e82 100644
--- a/libs/image/krita_utils.cpp
+++ b/libs/image/krita_utils.cpp
@@ -1,478 +1,478 @@
/*
* Copyright (c) 2011 Dmitry Kazakov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "krita_utils.h"
#include
#include
#include
#include
#include
#include
#include
#include "kis_algebra_2d.h"
#include
#include "kis_image_config.h"
#include "kis_debug.h"
#include "kis_node.h"
#include "kis_sequential_iterator.h"
#include "kis_random_accessor_ng.h"
#include
namespace KritaUtils
{
QSize optimalPatchSize()
{
KisImageConfig cfg;
return QSize(cfg.updatePatchWidth(),
cfg.updatePatchHeight());
}
QVector splitRectIntoPatches(const QRect &rc, const QSize &patchSize)
{
using namespace KisAlgebra2D;
QVector patches;
const qint32 firstCol = divideFloor(rc.x(), patchSize.width());
const qint32 firstRow = divideFloor(rc.y(), patchSize.height());
// TODO: check if -1 is needed here
const qint32 lastCol = divideFloor(rc.x() + rc.width(), patchSize.width());
const qint32 lastRow = divideFloor(rc.y() + rc.height(), patchSize.height());
for(qint32 i = firstRow; i <= lastRow; i++) {
for(qint32 j = firstCol; j <= lastCol; j++) {
QRect maxPatchRect(j * patchSize.width(), i * patchSize.height(),
patchSize.width(), patchSize.height());
QRect patchRect = rc & maxPatchRect;
if (!patchRect.isEmpty()) {
patches.append(patchRect);
}
}
}
return patches;
}
QVector splitRegionIntoPatches(const QRegion ®ion, const QSize &patchSize)
{
QVector patches;
Q_FOREACH (const QRect rect, region.rects()) {
patches << KritaUtils::splitRectIntoPatches(rect, patchSize);
}
return patches;
}
bool checkInTriangle(const QRectF &rect,
const QPolygonF &triangle)
{
return triangle.intersected(rect).boundingRect().isValid();
}
QRegion KRITAIMAGE_EXPORT splitTriangles(const QPointF ¢er,
const QVector &points)
{
Q_ASSERT(points.size());
Q_ASSERT(!(points.size() & 1));
QVector triangles;
QRect totalRect;
for (int i = 0; i < points.size(); i += 2) {
QPolygonF triangle;
triangle << center;
triangle << points[i];
triangle << points[i+1];
totalRect |= triangle.boundingRect().toAlignedRect();
triangles << triangle;
}
const int step = 64;
const int right = totalRect.x() + totalRect.width();
const int bottom = totalRect.y() + totalRect.height();
QRegion dirtyRegion;
for (int y = totalRect.y(); y < bottom;) {
int nextY = qMin((y + step) & ~(step-1), bottom);
for (int x = totalRect.x(); x < right;) {
int nextX = qMin((x + step) & ~(step-1), right);
QRect rect(x, y, nextX - x, nextY - y);
Q_FOREACH (const QPolygonF &triangle, triangles) {
if(checkInTriangle(rect, triangle)) {
dirtyRegion |= rect;
break;
}
}
x = nextX;
}
y = nextY;
}
return dirtyRegion;
}
QRegion KRITAIMAGE_EXPORT splitPath(const QPainterPath &path)
{
QRect totalRect = path.boundingRect().toAlignedRect();
// adjust the rect for antialiasing to work
totalRect = totalRect.adjusted(-1,-1,1,1);
const int step = 64;
const int right = totalRect.x() + totalRect.width();
const int bottom = totalRect.y() + totalRect.height();
QRegion dirtyRegion;
for (int y = totalRect.y(); y < bottom;) {
int nextY = qMin((y + step) & ~(step-1), bottom);
for (int x = totalRect.x(); x < right;) {
int nextX = qMin((x + step) & ~(step-1), right);
QRect rect(x, y, nextX - x, nextY - y);
if(path.intersects(rect)) {
dirtyRegion |= rect;
}
x = nextX;
}
y = nextY;
}
return dirtyRegion;
}
QString KRITAIMAGE_EXPORT prettyFormatReal(qreal value)
{
return QString("%1").arg(value, 6, 'f', 1);
}
qreal KRITAIMAGE_EXPORT maxDimensionPortion(const QRectF &bounds, qreal portion, qreal minValue)
{
qreal maxDimension = qMax(bounds.width(), bounds.height());
return qMax(portion * maxDimension, minValue);
}
bool tryMergePoints(QPainterPath &path,
const QPointF &startPoint,
const QPointF &endPoint,
qreal &distance,
qreal distanceThreshold,
bool lastSegment)
{
qreal length = (endPoint - startPoint).manhattanLength();
if (lastSegment || length > distanceThreshold) {
if (lastSegment) {
qreal wrappedLength =
(endPoint - QPointF(path.elementAt(0))).manhattanLength();
if (length < distanceThreshold ||
wrappedLength < distanceThreshold) {
return true;
}
}
distance = 0;
return false;
}
distance += length;
if (distance > distanceThreshold) {
path.lineTo(endPoint);
distance = 0;
}
return true;
}
QPainterPath trySimplifyPath(const QPainterPath &path, qreal lengthThreshold)
{
QPainterPath newPath;
QPointF startPoint;
qreal distance = 0;
int count = path.elementCount();
for (int i = 0; i < count; i++) {
QPainterPath::Element e = path.elementAt(i);
QPointF endPoint = QPointF(e.x, e.y);
switch (e.type) {
case QPainterPath::MoveToElement:
newPath.moveTo(endPoint);
break;
case QPainterPath::LineToElement:
if (!tryMergePoints(newPath, startPoint, endPoint,
distance, lengthThreshold, i == count - 1)) {
newPath.lineTo(endPoint);
}
break;
case QPainterPath::CurveToElement: {
Q_ASSERT(i + 2 < count);
if (!tryMergePoints(newPath, startPoint, endPoint,
distance, lengthThreshold, i == count - 1)) {
e = path.elementAt(i + 1);
Q_ASSERT(e.type == QPainterPath::CurveToDataElement);
QPointF ctrl1 = QPointF(e.x, e.y);
e = path.elementAt(i + 2);
Q_ASSERT(e.type == QPainterPath::CurveToDataElement);
QPointF ctrl2 = QPointF(e.x, e.y);
newPath.cubicTo(ctrl1, ctrl2, endPoint);
}
i += 2;
}
default:
;
}
startPoint = endPoint;
}
return newPath;
}
QList splitDisjointPaths(const QPainterPath &path)
{
QList resultList;
QList inputPolygons = path.toSubpathPolygons();
Q_FOREACH (const QPolygonF &poly, inputPolygons) {
QPainterPath testPath;
testPath.addPolygon(poly);
if (resultList.isEmpty()) {
resultList.append(testPath);
continue;
}
QPainterPath mergedPath = testPath;
for (auto it = resultList.begin(); it != resultList.end(); /*noop*/) {
if (it->intersects(testPath)) {
mergedPath.addPath(*it);
it = resultList.erase(it);
} else {
++it;
}
}
resultList.append(mergedPath);
}
return resultList;
}
quint8 mergeOpacity(quint8 opacity, quint8 parentOpacity)
{
if (parentOpacity != OPACITY_OPAQUE_U8) {
opacity = (int(opacity) * parentOpacity) / OPACITY_OPAQUE_U8;
}
return opacity;
}
QBitArray mergeChannelFlags(const QBitArray &childFlags, const QBitArray &parentFlags)
{
QBitArray flags = childFlags;
if (!flags.isEmpty() &&
!parentFlags.isEmpty() &&
flags.size() == parentFlags.size()) {
flags &= parentFlags;
} else if (!parentFlags.isEmpty()) {
flags = parentFlags;
}
return flags;
}
bool compareChannelFlags(QBitArray f1, QBitArray f2)
{
if (f1.isNull() && f2.isNull()) return true;
if (f1.isNull()) {
f1.fill(true, f2.size());
}
if (f2.isNull()) {
f2.fill(true, f1.size());
}
return f1 == f2;
}
QString KRITAIMAGE_EXPORT toLocalizedOnOff(bool value) {
return value ? i18n("on") : i18n("off");
}
KisNodeSP nearestNodeAfterRemoval(KisNodeSP node)
{
KisNodeSP newNode = node->nextSibling();
if (!newNode) {
newNode = node->prevSibling();
}
if (!newNode) {
newNode = node->parent();
}
return newNode;
}
void renderExactRect(QPainter *p, const QRect &rc)
{
p->drawRect(rc.adjusted(0,0,-1,-1));
}
void renderExactRect(QPainter *p, const QRect &rc, const QPen &pen)
{
QPen oldPen = p->pen();
p->setPen(pen);
renderExactRect(p, rc);
p->setPen(oldPen);
}
QImage convertQImageToGrayA(const QImage &image)
{
QImage dstImage(image.size(), QImage::Format_ARGB32);
// TODO: if someone feel bored, a more optimized version of this would be welcome
const QSize size = image.size();
- for(int i = 0; i < size.height(); ++i) {
- for(int j = 0; j < size.width(); ++j) {
- const QRgb pixel = image.pixel(i,j);
+ for(int y = 0; y < size.height(); ++y) {
+ for(int x = 0; x < size.width(); ++x) {
+ const QRgb pixel = image.pixel(x,y);
const int gray = qGray(pixel);
- dstImage.setPixel(i, j, qRgba(gray, gray, gray, qAlpha(pixel)));
+ dstImage.setPixel(x, y, qRgba(gray, gray, gray, qAlpha(pixel)));
}
}
return dstImage;
}
QColor blendColors(const QColor &c1, const QColor &c2, qreal r1)
{
const qreal r2 = 1.0 - r1;
return QColor::fromRgbF(
c1.redF() * r1 + c2.redF() * r2,
c1.greenF() * r1 + c2.greenF() * r2,
c1.blueF() * r1 + c2.blueF() * r2);
}
void applyToAlpha8Device(KisPaintDeviceSP dev, const QRect &rc, std::function func) {
KisSequentialConstIterator dstIt(dev, rc);
while (dstIt.nextPixel()) {
const quint8 *dstPtr = dstIt.rawDataConst();
func(*dstPtr);
}
}
void filterAlpha8Device(KisPaintDeviceSP dev, const QRect &rc, std::function func) {
KisSequentialIterator dstIt(dev, rc);
while (dstIt.nextPixel()) {
quint8 *dstPtr = dstIt.rawData();
*dstPtr = func(*dstPtr);
}
}
qreal estimatePortionOfTransparentPixels(KisPaintDeviceSP dev, const QRect &rect, qreal samplePortion) {
const KoColorSpace *cs = dev->colorSpace();
const qreal linearPortion = std::sqrt(samplePortion);
const qreal ratio = qreal(rect.width()) / rect.height();
const int xStep = qMax(1, qRound(1.0 / linearPortion * ratio));
const int yStep = qMax(1, qRound(1.0 / linearPortion / ratio));
int numTransparentPixels = 0;
int numPixels = 0;
KisRandomConstAccessorSP it = dev->createRandomConstAccessorNG(rect.x(), rect.y());
for (int y = rect.y(); y <= rect.bottom(); y += yStep) {
for (int x = rect.x(); x <= rect.right(); x += xStep) {
it->moveTo(x, y);
const quint8 alpha = cs->opacityU8(it->rawDataConst());
if (alpha != OPACITY_OPAQUE_U8) {
numTransparentPixels++;
}
numPixels++;
}
}
return qreal(numTransparentPixels) / numPixels;
}
void mirrorDab(Qt::Orientation dir, const QPoint ¢er, KisRenderedDab *dab)
{
const QRect rc = dab->realBounds();
if (dir == Qt::Horizontal) {
const int mirrorX = -((rc.x() + rc.width()) - center.x()) + center.x();
dab->device->mirror(true, false);
dab->offset.rx() = mirrorX;
} else /* if (dir == Qt::Vertical) */ {
const int mirrorY = -((rc.y() + rc.height()) - center.y()) + center.y();
dab->device->mirror(false, true);
dab->offset.ry() = mirrorY;
}
}
void mirrorRect(Qt::Orientation dir, const QPoint ¢er, QRect *rc)
{
if (dir == Qt::Horizontal) {
const int mirrorX = -((rc->x() + rc->width()) - center.x()) + center.x();
rc->moveLeft(mirrorX);
} else /* if (dir == Qt::Vertical) */ {
const int mirrorY = -((rc->y() + rc->height()) - center.y()) + center.y();
rc->moveTop(mirrorY);
}
}
}
diff --git a/libs/libkis/Node.cpp b/libs/libkis/Node.cpp
index d5488b14d4..ebee7c2e19 100644
--- a/libs/libkis/Node.cpp
+++ b/libs/libkis/Node.cpp
@@ -1,601 +1,605 @@
/*
* Copyright (c) 2016 Boudewijn Rempt
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
+#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "Krita.h"
#include "Node.h"
#include "Channel.h"
#include "Filter.h"
#include "Selection.h"
#include "GroupLayer.h"
#include "CloneLayer.h"
#include "FilterLayer.h"
#include "FillLayer.h"
#include "FileLayer.h"
#include "VectorLayer.h"
#include "FilterMask.h"
#include "SelectionMask.h"
#include "LibKisUtils.h"
struct Node::Private {
Private() {}
KisImageWSP image;
KisNodeSP node;
};
Node::Node(KisImageSP image, KisNodeSP node, QObject *parent)
: QObject(parent)
, d(new Private)
{
d->image = image;
d->node = node;
}
Node::~Node()
{
delete d;
}
bool Node::operator==(const Node &other) const
{
return (d->node == other.d->node
&& d->image == other.d->image);
}
bool Node::operator!=(const Node &other) const
{
return !(operator==(other));
}
Node *Node::clone() const
{
KisNodeSP clone = d->node->clone();
Node *node = new Node(0, clone);
return node;
}
bool Node::alphaLocked() const
{
if (!d->node) return false;
KisPaintLayerSP paintLayer = qobject_cast(d->node.data());
if (paintLayer) {
return paintLayer->alphaLocked();
}
return false;
}
void Node::setAlphaLocked(bool value)
{
if (!d->node) return;
KisPaintLayerSP paintLayer = qobject_cast(d->node.data());
if (paintLayer) {
paintLayer->setAlphaLocked(value);
}
}
QString Node::blendingMode() const
{
if (!d->node) return QString();
return d->node->compositeOpId();
}
void Node::setBlendingMode(QString value)
{
if (!d->node) return;
d->node->setCompositeOpId(value);
}
QList Node::channels() const
{
QList channels;
if (!d->node) return channels;
if (!d->node->inherits("KisLayer")) return channels;
Q_FOREACH(KoChannelInfo *info, d->node->colorSpace()->channels()) {
Channel *channel = new Channel(d->node, info);
channels << channel;
}
return channels;
}
QList Node::childNodes() const
{
QList nodes;
if (d->node) {
KisNodeList nodeList;
int childCount = d->node->childCount();
for (int i = 0; i < childCount; ++i) {
nodeList << d->node->at(i);
}
nodes = LibKisUtils::createNodeList(nodeList, d->image);
}
return nodes;
}
bool Node::addChildNode(Node *child, Node *above)
{
if (!d->node) return false;
if (above) {
return d->image->addNode(child->node(), d->node, above->node());
}
else {
return d->image->addNode(child->node(), d->node, d->node->childCount());
}
}
bool Node::removeChildNode(Node *child)
{
if (!d->node) return false;
return d->image->removeNode(child->node());
}
void Node::setChildNodes(QList nodes)
{
if (!d->node) return;
KisNodeSP node = d->node->firstChild();
while (node) {
d->image->removeNode(node);
node = node->nextSibling();
}
Q_FOREACH(Node *node, nodes) {
d->image->addNode(node->node(), d->node);
}
}
int Node::colorLabel() const
{
if (!d->node) return 0;
return d->node->colorLabelIndex();
}
void Node::setColorLabel(int index)
{
if (!d->node) return;
d->node->setColorLabelIndex(index);
}
QString Node::colorDepth() const
{
if (!d->node) return "";
return d->node->colorSpace()->colorDepthId().id();
}
QString Node::colorModel() const
{
if (!d->node) return "";
return d->node->colorSpace()->colorModelId().id();
}
QString Node::colorProfile() const
{
if (!d->node) return "";
return d->node->colorSpace()->profile()->name();
}
bool Node::setColorProfile(const QString &colorProfile)
{
if (!d->node) return false;
if (!d->node->inherits("KisLayer")) return false;
KisLayer *layer = qobject_cast(d->node.data());
const KoColorProfile *profile = KoColorSpaceRegistry::instance()->profileByName(colorProfile);
const KoColorSpace *srcCS = layer->colorSpace();
const KoColorSpace *dstCs = KoColorSpaceRegistry::instance()->colorSpace(srcCS->colorModelId().id(),
srcCS->colorDepthId().id(),
profile);
KisChangeProfileVisitor v(srcCS, dstCs);
return layer->accept(v);
}
bool Node::setColorSpace(const QString &colorModel, const QString &colorDepth, const QString &colorProfile)
{
if (!d->node) return false;
if (!d->node->inherits("KisLayer")) return false;
KisLayer *layer = qobject_cast(d->node.data());
const KoColorProfile *profile = KoColorSpaceRegistry::instance()->profileByName(colorProfile);
const KoColorSpace *srcCS = layer->colorSpace();
const KoColorSpace *dstCs = KoColorSpaceRegistry::instance()->colorSpace(colorModel,
colorDepth,
profile);
KisColorSpaceConvertVisitor v(d->image, srcCS, dstCs, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
return layer->accept(v);
}
bool Node::animated() const
{
if (!d->node) return false;
return d->node->isAnimated();
}
void Node::enableAnimation() const
{
if (!d->node) return;
d->node->enableAnimation();
}
bool Node::collapsed() const
{
if (!d->node) return false;
return d->node->collapsed();
}
void Node::setCollapsed(bool collapsed)
{
if (!d->node) return;
d->node->setCollapsed(collapsed);
}
bool Node::inheritAlpha() const
{
if (!d->node) return false;
if (!d->node->inherits("KisLayer")) return false;
return qobject_cast(d->node)->alphaChannelDisabled();
}
void Node::setInheritAlpha(bool value)
{
if (!d->node) return;
if (!d->node->inherits("KisLayer")) return;
const_cast(qobject_cast(d->node))->disableAlphaChannel(value);
}
bool Node::locked() const
{
if (!d->node) return false;
return d->node->userLocked();
}
void Node::setLocked(bool value)
{
if (!d->node) return;
d->node->setUserLocked(value);
}
QString Node::name() const
{
if (!d->node) return QString();
return d->node->name();
}
void Node::setName(QString name)
{
if (!d->node) return;
d->node->setName(name);
}
int Node::opacity() const
{
if (!d->node) return 0;
return d->node->opacity();
}
void Node::setOpacity(int value)
{
if (!d->node) return;
if (value < 0) value = 0;
if (value > 255) value = 255;
d->node->setOpacity(value);
}
Node* Node::parentNode() const
{
if (!d->node) return 0;
return new Node(d->image, d->node->parent());
}
QString Node::type() const
{
if (!d->node) return QString();
if (qobject_cast(d->node)) {
return "paintlayer";
}
else if (qobject_cast(d->node)) {
return "grouplayer";
}
if (qobject_cast(d->node)) {
return "filelayer";
}
if (qobject_cast(d->node)) {
return "filterlayer";
}
if (qobject_cast(d->node)) {
return "filllayer";
}
if (qobject_cast(d->node)) {
return "clonelayer";
}
+ if (qobject_cast(d->node)) {
+ return "referenceimageslayer";
+ }
if (qobject_cast(d->node)) {
return "vectorlayer";
}
if (qobject_cast(d->node)) {
return "transparencymask";
}
if (qobject_cast(d->node)) {
return "filtermask";
}
if (qobject_cast(d->node)) {
return "transformmask";
}
if (qobject_cast(d->node)) {
return "selectionmask";
}
if (qobject_cast(d->node)) {
return "colorizemask";
}
return QString();
}
QIcon Node::icon() const
{
QIcon icon;
if (d->node) {
icon = d->node->icon();
}
return icon;
}
bool Node::visible() const
{
if (!d->node) return false;
return d->node->visible();;
}
void Node::setVisible(bool visible)
{
if (!d->node) return;
d->node->setVisible(visible);
}
QByteArray Node::pixelData(int x, int y, int w, int h) const
{
QByteArray ba;
if (!d->node) return ba;
KisPaintDeviceSP dev = d->node->paintDevice();
if (!dev) return ba;
ba.resize(w * h * dev->pixelSize());
dev->readBytes(reinterpret_cast(ba.data()), x, y, w, h);
return ba;
}
QByteArray Node::pixelDataAtTime(int x, int y, int w, int h, int time) const
{
QByteArray ba;
if (!d->node || !d->node->isAnimated()) return ba;
//
KisRasterKeyframeChannel *rkc = dynamic_cast(d->node->getKeyframeChannel(KisKeyframeChannel::Content.id()));
if (!rkc) return ba;
KisKeyframeSP frame = rkc->keyframeAt(time);
if (!frame) return ba;
KisPaintDeviceSP dev = d->node->paintDevice();
if (!dev) return ba;
rkc->fetchFrame(frame, dev);
ba.resize(w * h * dev->pixelSize());
dev->readBytes(reinterpret_cast(ba.data()), x, y, w, h);
return ba;
}
QByteArray Node::projectionPixelData(int x, int y, int w, int h) const
{
QByteArray ba;
if (!d->node) return ba;
KisPaintDeviceSP dev = d->node->projection();
ba.resize(w * h * dev->pixelSize());
dev->readBytes(reinterpret_cast(ba.data()), x, y, w, h);
return ba;
}
void Node::setPixelData(QByteArray value, int x, int y, int w, int h)
{
if (!d->node) return;
KisPaintDeviceSP dev = d->node->paintDevice();
if (!dev) return;
dev->writeBytes((const quint8*)value.constData(), x, y, w, h);
}
QRect Node::bounds() const
{
if (!d->node) return QRect();
return d->node->exactBounds();
}
void Node::move(int x, int y)
{
if (!d->node) return;
d->node->setX(x);
d->node->setY(y);
}
QPoint Node::position() const
{
if (!d->node) return QPoint();
return QPoint(d->node->x(), d->node->y());
}
bool Node::remove()
{
if (!d->node) return false;
if (!d->node->parent()) return false;
return d->image->removeNode(d->node);
}
Node* Node::duplicate()
{
if (!d->node) return 0;
return new Node(d->image, d->node->clone());
}
bool Node::save(const QString &filename, double xRes, double yRes)
{
if (!d->node) return false;
if (filename.isEmpty()) return false;
KisPaintDeviceSP projection = d->node->projection();
QRect bounds = d->node->exactBounds();
QString mimeType = KisMimeDatabase::mimeTypeForFile(filename, false);
QScopedPointer doc(KisPart::instance()->createDocument());
KisImageSP dst = new KisImage(doc->createUndoStore(),
bounds.right(),
bounds.bottom(),
projection->compositionSourceColorSpace(),
d->node->name());
dst->setResolution(xRes, yRes);
doc->setFileBatchMode(Krita::instance()->batchmode());
doc->setCurrentImage(dst);
KisPaintLayer* paintLayer = new KisPaintLayer(dst, "paint device", d->node->opacity());
paintLayer->paintDevice()->makeCloneFrom(projection, bounds);
dst->addNode(paintLayer, dst->rootLayer(), KisLayerSP(0));
dst->cropImage(bounds);
dst->initialRefreshGraph();
bool r = doc->exportDocumentSync(QUrl::fromLocalFile(filename), mimeType.toLatin1());
if (!r) {
qWarning() << doc->errorMessage();
}
return r;
}
Node *Node::mergeDown()
{
if (!d->node) return 0;
if (!qobject_cast(d->node.data())) return 0;
if (!d->node->nextSibling()) return 0;
if (!d->node->parent()) return 0;
int index = d->node->parent()->index(d->node->prevSibling());
d->image->mergeDown(qobject_cast(d->node.data()), KisMetaData::MergeStrategyRegistry::instance()->get("Drop"));
d->image->waitForDone();
return new Node(d->image, d->node->parent()->at(index));
}
void Node::scaleNode(int width, int height, QString strategy)
{
if (!d->node) return;
if (!qobject_cast(d->node.data())) return;
if (!d->node->parent()) return;
KisFilterStrategy *actualStrategy = KisFilterStrategyRegistry::instance()->get(strategy);
if (!actualStrategy) actualStrategy = KisFilterStrategyRegistry::instance()->get("Bicubic");
d->image->scaleNode(d->node, width, height, actualStrategy);
}
void Node::rotateNode(double radians)
{
if (!d->node) return;
if (!qobject_cast(d->node.data())) return;
if (!d->node->parent()) return;
d->image->rotateNode(d->node, radians);
}
void Node::cropNode(int x, int y, int w, int h)
{
if (!d->node) return;
if (!qobject_cast(d->node.data())) return;
if (!d->node->parent()) return;
QRect rect = QRect(x, y, w, h);
d->image->cropNode(d->node, rect);
}
void Node::shearNode(double angleX, double angleY)
{
if (!d->node) return;
if (!qobject_cast(d->node.data())) return;
if (!d->node->parent()) return;
d->image->shearNode(d->node, angleX, angleY);
}
QImage Node::thumbnail(int w, int h)
{
if (!d->node) return QImage();
return d->node->createThumbnail(w, h);
}
KisPaintDeviceSP Node::paintDevice() const
{
return d->node->paintDevice();
}
KisImageSP Node::image() const
{
return d->image;
}
KisNodeSP Node::node() const
{
return d->node;
}
diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt
index 72e8e67c81..fbe596f790 100644
--- a/libs/ui/CMakeLists.txt
+++ b/libs/ui/CMakeLists.txt
@@ -1,577 +1,582 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/qtlockedfile
${EXIV2_INCLUDE_DIR}
)
include_directories(SYSTEM
${EIGEN3_INCLUDE_DIR}
${OCIO_INCLUDE_DIR}
)
add_subdirectory( tests )
if (APPLE)
find_library(FOUNDATION_LIBRARY Foundation)
find_library(APPKIT_LIBRARY AppKit)
endif ()
set(kritaui_LIB_SRCS
canvas/kis_canvas_widget_base.cpp
canvas/kis_canvas2.cpp
canvas/kis_canvas_updates_compressor.cpp
canvas/kis_canvas_controller.cpp
canvas/kis_paintop_transformation_connector.cpp
canvas/kis_display_color_converter.cpp
canvas/kis_display_filter.cpp
canvas/kis_exposure_gamma_correction_interface.cpp
canvas/kis_tool_proxy.cpp
canvas/kis_canvas_decoration.cc
canvas/kis_coordinates_converter.cpp
canvas/kis_grid_manager.cpp
canvas/kis_grid_decoration.cpp
canvas/kis_grid_config.cpp
canvas/kis_prescaled_projection.cpp
canvas/kis_qpainter_canvas.cpp
canvas/kis_projection_backend.cpp
canvas/kis_update_info.cpp
canvas/kis_image_patch.cpp
canvas/kis_image_pyramid.cpp
canvas/kis_infinity_manager.cpp
canvas/kis_change_guides_command.cpp
canvas/kis_guides_decoration.cpp
canvas/kis_guides_manager.cpp
canvas/kis_guides_config.cpp
canvas/kis_snap_config.cpp
canvas/kis_snap_line_strategy.cpp
canvas/KisSnapPointStrategy.cpp
dialogs/kis_about_application.cpp
dialogs/kis_dlg_adj_layer_props.cc
dialogs/kis_dlg_adjustment_layer.cc
dialogs/kis_dlg_filter.cpp
dialogs/kis_dlg_generator_layer.cpp
dialogs/kis_dlg_file_layer.cpp
dialogs/kis_dlg_filter.cpp
dialogs/kis_dlg_stroke_selection_properties.cpp
dialogs/kis_dlg_image_properties.cc
dialogs/kis_dlg_layer_properties.cc
dialogs/kis_dlg_preferences.cc
dialogs/slider_and_spin_box_sync.cpp
dialogs/kis_dlg_blacklist_cleanup.cpp
dialogs/kis_dlg_layer_style.cpp
dialogs/kis_dlg_png_import.cpp
dialogs/kis_dlg_import_image_sequence.cpp
dialogs/kis_delayed_save_dialog.cpp
dialogs/kis_dlg_internal_color_selector.cpp
flake/kis_node_dummies_graph.cpp
flake/kis_dummies_facade_base.cpp
flake/kis_dummies_facade.cpp
flake/kis_node_shapes_graph.cpp
flake/kis_node_shape.cpp
flake/kis_shape_controller.cpp
flake/kis_shape_layer.cc
flake/kis_shape_layer_canvas.cpp
flake/kis_shape_selection.cpp
flake/kis_shape_selection_canvas.cpp
flake/kis_shape_selection_model.cpp
flake/kis_take_all_shapes_command.cpp
brushhud/kis_uniform_paintop_property_widget.cpp
brushhud/kis_brush_hud.cpp
brushhud/kis_round_hud_button.cpp
brushhud/kis_dlg_brush_hud_config.cpp
brushhud/kis_brush_hud_properties_list.cpp
brushhud/kis_brush_hud_properties_config.cpp
kis_aspect_ratio_locker.cpp
kis_autogradient.cc
kis_bookmarked_configurations_editor.cc
kis_bookmarked_configurations_model.cc
kis_bookmarked_filter_configurations_model.cc
kis_base_option.cpp
kis_canvas_resource_provider.cpp
kis_derived_resources.cpp
kis_categories_mapper.cpp
kis_categorized_list_model.cpp
kis_categorized_item_delegate.cpp
kis_clipboard.cc
kis_config.cc
kis_config_notifier.cpp
kis_control_frame.cpp
kis_composite_ops_model.cc
kis_paint_ops_model.cpp
kis_cursor.cc
kis_cursor_cache.cpp
kis_custom_pattern.cc
kis_file_layer.cpp
kis_change_file_layer_command.h
kis_safe_document_loader.cpp
kis_splash_screen.cpp
kis_filter_manager.cc
kis_filters_model.cc
kis_histogram_view.cc
KisImageBarrierLockerWithFeedback.cpp
kis_image_manager.cc
kis_image_view_converter.cpp
kis_import_catcher.cc
kis_layer_manager.cc
kis_mask_manager.cc
kis_mimedata.cpp
kis_node_commands_adapter.cpp
kis_node_manager.cpp
kis_node_juggler_compressed.cpp
kis_node_selection_adapter.cpp
kis_node_insertion_adapter.cpp
kis_node_model.cpp
kis_node_filter_proxy_model.cpp
kis_model_index_converter_base.cpp
kis_model_index_converter.cpp
kis_model_index_converter_show_all.cpp
kis_painting_assistant.cc
kis_painting_assistants_decoration.cpp
- kis_painting_assistants_manager.cpp
+ KisDecorationsManager.cpp
kis_paintop_box.cc
kis_paintop_option.cpp
kis_paintop_options_model.cpp
kis_paintop_settings_widget.cpp
kis_popup_palette.cpp
kis_png_converter.cpp
kis_preference_set_registry.cpp
KisResourceServerProvider.cpp
KisResourceBundleServerProvider.cpp
KisSelectedShapesProxy.cpp
kis_selection_decoration.cc
kis_selection_manager.cc
kis_statusbar.cc
kis_zoom_manager.cc
kis_favorite_resource_manager.cpp
kis_workspace_resource.cpp
kis_action.cpp
kis_action_manager.cpp
KisActionPlugin.cpp
kis_canvas_controls_manager.cpp
kis_tooltip_manager.cpp
kis_multinode_property.cpp
kis_stopgradient_editor.cpp
kisexiv2/kis_exif_io.cpp
kisexiv2/kis_exiv2.cpp
kisexiv2/kis_iptc_io.cpp
kisexiv2/kis_xmp_io.cpp
opengl/kis_opengl.cpp
opengl/kis_opengl_canvas2.cpp
opengl/kis_opengl_canvas_debugger.cpp
opengl/kis_opengl_image_textures.cpp
opengl/kis_texture_tile.cpp
opengl/kis_opengl_shader_loader.cpp
opengl/kis_texture_tile_info_pool.cpp
kis_fps_decoration.cpp
recorder/kis_node_query_path_editor.cc
recorder/kis_recorded_action_creator.cc
recorder/kis_recorded_action_creator_factory.cc
recorder/kis_recorded_action_creator_factory_registry.cc
recorder/kis_recorded_action_editor_factory.cc
recorder/kis_recorded_action_editor_factory_registry.cc
recorder/kis_recorded_filter_action_editor.cc
recorder/kis_recorded_filter_action_creator.cpp
recorder/kis_recorded_paint_action_editor.cc
tool/kis_selection_tool_helper.cpp
tool/kis_selection_tool_config_widget_helper.cpp
tool/kis_rectangle_constraint_widget.cpp
tool/kis_shape_tool_helper.cpp
tool/kis_tool.cc
tool/kis_delegated_tool_policies.cpp
tool/kis_tool_freehand.cc
tool/kis_speed_smoother.cpp
tool/kis_painting_information_builder.cpp
tool/kis_stabilized_events_sampler.cpp
tool/kis_tool_freehand_helper.cpp
tool/kis_tool_multihand_helper.cpp
tool/kis_figure_painting_tool_helper.cpp
tool/kis_recording_adapter.cpp
tool/kis_tool_paint.cc
tool/kis_tool_shape.cc
tool/kis_tool_ellipse_base.cpp
tool/kis_tool_rectangle_base.cpp
tool/kis_tool_polyline_base.cpp
tool/kis_tool_utils.cpp
tool/kis_resources_snapshot.cpp
tool/kis_smoothing_options.cpp
tool/KisStabilizerDelayedPaintHelper.cpp
tool/KisStrokeSpeedMonitor.cpp
tool/strokes/freehand_stroke.cpp
tool/strokes/KisStrokeEfficiencyMeasurer.cpp
tool/strokes/kis_painter_based_stroke_strategy.cpp
tool/strokes/kis_filter_stroke_strategy.cpp
tool/strokes/kis_color_picker_stroke_strategy.cpp
tool/strokes/KisFreehandStrokeInfo.cpp
tool/strokes/KisMaskedFreehandStrokePainter.cpp
tool/strokes/KisMaskingBrushRenderer.cpp
tool/strokes/KisMaskingBrushCompositeOpFactory.cpp
widgets/kis_cmb_composite.cc
widgets/kis_cmb_contour.cpp
widgets/kis_cmb_gradient.cpp
widgets/kis_paintop_list_widget.cpp
widgets/kis_cmb_idlist.cc
widgets/kis_color_space_selector.cc
widgets/kis_advanced_color_space_selector.cc
widgets/kis_cie_tongue_widget.cpp
widgets/kis_tone_curve_widget.cpp
widgets/kis_curve_widget.cpp
widgets/kis_custom_image_widget.cc
widgets/kis_image_from_clipboard_widget.cpp
widgets/kis_double_widget.cc
widgets/kis_filter_selector_widget.cc
widgets/kis_gradient_chooser.cc
widgets/kis_gradient_slider_widget.cc
widgets/kis_gradient_slider.cpp
widgets/kis_iconwidget.cc
widgets/kis_mask_widgets.cpp
widgets/kis_meta_data_merge_strategy_chooser_widget.cc
widgets/kis_multi_bool_filter_widget.cc
widgets/kis_multi_double_filter_widget.cc
widgets/kis_multi_integer_filter_widget.cc
widgets/kis_multipliers_double_slider_spinbox.cpp
widgets/kis_paintop_presets_popup.cpp
widgets/kis_tool_options_popup.cpp
widgets/kis_paintop_presets_chooser_popup.cpp
widgets/kis_paintop_presets_save.cpp
widgets/kis_paintop_preset_icon_library.cpp
widgets/kis_pattern_chooser.cc
widgets/kis_popup_button.cc
widgets/kis_preset_chooser.cpp
widgets/kis_progress_widget.cpp
widgets/kis_selection_options.cc
widgets/kis_scratch_pad.cpp
widgets/kis_scratch_pad_event_filter.cpp
widgets/kis_preset_selector_strip.cpp
widgets/kis_slider_spin_box.cpp
+ widgets/KisSelectionPropertySlider.cpp
widgets/kis_size_group.cpp
widgets/kis_size_group_p.cpp
widgets/kis_wdg_generator.cpp
widgets/kis_workspace_chooser.cpp
widgets/kis_categorized_list_view.cpp
widgets/kis_widget_chooser.cpp
widgets/kis_tool_button.cpp
widgets/kis_floating_message.cpp
widgets/kis_lod_availability_widget.cpp
widgets/kis_color_label_selector_widget.cpp
widgets/kis_color_filter_combo.cpp
widgets/kis_elided_label.cpp
widgets/kis_stopgradient_slider_widget.cpp
widgets/kis_spinbox_color_selector.cpp
widgets/kis_screen_color_picker.cpp
widgets/kis_preset_live_preview_view.cpp
widgets/KoDualColorButton.cpp
widgets/kis_color_input.cpp
widgets/kis_color_button.cpp
widgets/KisVisualColorSelector.cpp
widgets/KisVisualColorSelectorShape.cpp
widgets/KisVisualEllipticalSelectorShape.cpp
widgets/KisVisualRectangleSelectorShape.cpp
widgets/KisVisualTriangleSelectorShape.cpp
widgets/KoStrokeConfigWidget.cpp
widgets/KoFillConfigWidget.cpp
utils/kis_document_aware_spin_box_unit_manager.cpp
input/kis_input_manager.cpp
input/kis_input_manager_p.cpp
input/kis_extended_modifiers_mapper.cpp
input/kis_abstract_input_action.cpp
input/kis_tool_invocation_action.cpp
input/kis_pan_action.cpp
input/kis_alternate_invocation_action.cpp
input/kis_rotate_canvas_action.cpp
input/kis_zoom_action.cpp
input/kis_change_frame_action.cpp
input/kis_gamma_exposure_action.cpp
input/kis_show_palette_action.cpp
input/kis_change_primary_setting_action.cpp
input/kis_abstract_shortcut.cpp
input/kis_native_gesture_shortcut.cpp
input/kis_single_action_shortcut.cpp
input/kis_stroke_shortcut.cpp
input/kis_shortcut_matcher.cpp
input/kis_select_layer_action.cpp
input/KisQtWidgetsTweaker.cpp
input/KisInputActionGroup.cpp
operations/kis_operation.cpp
operations/kis_operation_configuration.cpp
operations/kis_operation_registry.cpp
operations/kis_operation_ui_factory.cpp
operations/kis_operation_ui_widget.cpp
operations/kis_filter_selection_operation.cpp
actions/kis_selection_action_factories.cpp
actions/KisPasteActionFactory.cpp
input/kis_touch_shortcut.cpp
kis_document_undo_store.cpp
kis_transaction_based_command.cpp
kis_gui_context_command.cpp
kis_gui_context_command_p.cpp
input/kis_tablet_debugger.cpp
input/kis_input_profile_manager.cpp
input/kis_input_profile.cpp
input/kis_shortcut_configuration.cpp
input/config/kis_input_configuration_page.cpp
input/config/kis_edit_profiles_dialog.cpp
input/config/kis_input_profile_model.cpp
input/config/kis_input_configuration_page_item.cpp
input/config/kis_action_shortcuts_model.cpp
input/config/kis_input_type_delegate.cpp
input/config/kis_input_mode_delegate.cpp
input/config/kis_input_button.cpp
input/config/kis_input_editor_delegate.cpp
input/config/kis_mouse_input_editor.cpp
input/config/kis_wheel_input_editor.cpp
input/config/kis_key_input_editor.cpp
processing/fill_processing_visitor.cpp
kis_asl_layer_style_serializer.cpp
kis_psd_layer_style_resource.cpp
canvas/kis_mirror_axis.cpp
kis_abstract_perspective_grid.cpp
KisApplication.cpp
KisAutoSaveRecoveryDialog.cpp
KisDetailsPane.cpp
KisDocument.cpp
KisNodeDelegate.cpp
kis_node_view_visibility_delegate.cpp
KisNodeToolTip.cpp
KisNodeView.cpp
kis_node_view_color_scheme.cpp
KisImportExportFilter.cpp
KisFilterEntry.cpp
KisImportExportManager.cpp
KisImportExportUtils.cpp
kis_async_action_feedback.cpp
KisMainWindow.cpp
KisOpenPane.cpp
KisPart.cpp
KisPrintJob.cpp
KisTemplate.cpp
KisTemplateCreateDia.cpp
KisTemplateGroup.cpp
KisTemplates.cpp
KisTemplatesPane.cpp
KisTemplateTree.cpp
KisUndoStackAction.cpp
KisView.cpp
thememanager.cpp
kis_mainwindow_observer.cpp
KisViewManager.cpp
kis_mirror_manager.cpp
qtlockedfile/qtlockedfile.cpp
qtsingleapplication/qtlocalpeer.cpp
qtsingleapplication/qtsingleapplication.cpp
KisResourceBundle.cpp
KisResourceBundleManifest.cpp
kis_md5_generator.cpp
KisApplicationArguments.cpp
KisNetworkAccessManager.cpp
KisMultiFeedRSSModel.cpp
KisRemoteFileFetcher.cpp
KisPaletteModel.cpp
kis_palette_delegate.cpp
kis_palette_view.cpp
KisColorsetChooser.cpp
KisSaveGroupVisitor.cpp
+ KisReferenceImagesDecoration.cpp
+ KisReferenceImage.cpp
+ flake/KisReferenceImagesLayer.cpp
+ flake/KisReferenceImagesLayer.h
)
if(WIN32)
set(kritaui_LIB_SRCS
${kritaui_LIB_SRCS}
input/kis_tablet_event.cpp
input/wintab/kis_tablet_support_win.cpp
input/wintab/kis_screen_size_choice_dialog.cpp
qtlockedfile/qtlockedfile_win.cpp
input/wintab/kis_tablet_support_win8.cpp
opengl/kis_opengl_win.cpp
)
endif()
set(kritaui_LIB_SRCS
${kritaui_LIB_SRCS}
kis_animation_frame_cache.cpp
kis_animation_cache_populator.cpp
KisAsyncAnimationRendererBase.cpp
KisAsyncAnimationCacheRenderer.cpp
KisAsyncAnimationFramesSavingRenderer.cpp
dialogs/KisAsyncAnimationRenderDialogBase.cpp
dialogs/KisAsyncAnimationCacheRenderDialog.cpp
dialogs/KisAsyncAnimationFramesSaveDialog.cpp
canvas/kis_animation_player.cpp
kis_animation_importer.cpp
KisSyncedAudioPlayback.cpp
)
if(UNIX)
set(kritaui_LIB_SRCS
${kritaui_LIB_SRCS}
input/kis_tablet_event.cpp
input/wintab/kis_tablet_support.cpp
qtlockedfile/qtlockedfile_unix.cpp
)
if(NOT APPLE)
set(kritaui_LIB_SRCS
${kritaui_LIB_SRCS}
input/wintab/qxcbconnection_xi2.cpp
input/wintab/qxcbconnection.cpp
input/wintab/kis_xi2_event_filter.cpp
)
endif()
endif()
if(APPLE)
set(kritaui_LIB_SRCS
${kritaui_LIB_SRCS}
osx.mm
)
endif()
ki18n_wrap_ui(kritaui_LIB_SRCS
widgets/KoFillConfigWidget.ui
widgets/KoStrokeConfigWidget.ui
forms/wdgdlgpngimport.ui
forms/wdgfullscreensettings.ui
forms/wdgautogradient.ui
forms/wdggeneralsettings.ui
forms/wdgperformancesettings.ui
forms/wdggenerators.ui
forms/wdgbookmarkedconfigurationseditor.ui
forms/wdgapplyprofile.ui
forms/wdgcustompattern.ui
forms/wdglayerproperties.ui
forms/wdgcolorsettings.ui
forms/wdgtabletsettings.ui
forms/wdgcolorspaceselector.ui
forms/wdgcolorspaceselectoradvanced.ui
forms/wdgdisplaysettings.ui
forms/kis_previewwidgetbase.ui
forms/kis_matrix_widget.ui
forms/wdgselectionoptions.ui
forms/wdggeometryoptions.ui
forms/wdgnewimage.ui
forms/wdgimageproperties.ui
forms/wdgmaskfromselection.ui
forms/wdgmasksource.ui
forms/wdgfilterdialog.ui
forms/wdgmetadatamergestrategychooser.ui
forms/wdgpaintoppresets.ui
forms/wdgpaintopsettings.ui
forms/wdgdlggeneratorlayer.ui
forms/wdgdlgfilelayer.ui
forms/wdgfilterselector.ui
forms/wdgfilternodecreation.ui
forms/wdgpaintactioneditor.ui
forms/wdgmultipliersdoublesliderspinbox.ui
forms/wdgnodequerypatheditor.ui
forms/wdgpresetselectorstrip.ui
forms/wdgsavebrushpreset.ui
forms/wdgpreseticonlibrary.ui
forms/wdgdlgblacklistcleanup.ui
forms/wdgrectangleconstraints.ui
forms/wdgimportimagesequence.ui
forms/wdgstrokeselectionproperties.ui
forms/KisDetailsPaneBase.ui
forms/KisOpenPaneBase.ui
forms/wdgstopgradienteditor.ui
brushhud/kis_dlg_brush_hud_config.ui
forms/wdgdlginternalcolorselector.ui
dialogs/kis_delayed_save_dialog.ui
input/config/kis_input_configuration_page.ui
input/config/kis_edit_profiles_dialog.ui
input/config/kis_input_configuration_page_item.ui
input/config/kis_mouse_input_editor.ui
input/config/kis_wheel_input_editor.ui
input/config/kis_key_input_editor.ui
layerstyles/wdgBevelAndEmboss.ui
layerstyles/wdgblendingoptions.ui
layerstyles/WdgColorOverlay.ui
layerstyles/wdgContour.ui
layerstyles/wdgdropshadow.ui
layerstyles/WdgGradientOverlay.ui
layerstyles/wdgInnerGlow.ui
layerstyles/wdglayerstyles.ui
layerstyles/WdgPatternOverlay.ui
layerstyles/WdgSatin.ui
layerstyles/WdgStroke.ui
layerstyles/wdgstylesselector.ui
layerstyles/wdgTexture.ui
wdgsplash.ui
input/wintab/kis_screen_size_choice_dialog.ui
)
QT5_WRAP_CPP(kritaui_HEADERS_MOC KisNodePropertyAction_p.h)
add_library(kritaui SHARED ${kritaui_HEADERS_MOC} ${kritaui_LIB_SRCS} )
generate_export_header(kritaui BASE_NAME kritaui)
target_link_libraries(kritaui KF5::CoreAddons KF5::Completion KF5::I18n KF5::ItemViews Qt5::Network
kritaimpex kritacolor kritaimage kritalibbrush kritawidgets kritawidgetutils ${PNG_LIBRARIES} ${EXIV2_LIBRARIES}
)
if (HAVE_QT_MULTIMEDIA)
target_link_libraries(kritaui Qt5::Multimedia)
endif()
if (HAVE_KIO)
target_link_libraries(kritaui KF5::KIOCore)
endif()
if (NOT WIN32 AND NOT APPLE)
target_link_libraries(kritaui ${X11_X11_LIB}
${X11_Xinput_LIB}
${XCB_LIBRARIES})
endif()
if(APPLE)
target_link_libraries(kritaui ${FOUNDATION_LIBRARY})
target_link_libraries(kritaui ${APPKIT_LIBRARY})
endif ()
target_link_libraries(kritaui ${OPENEXR_LIBRARIES})
# Add VSync disable workaround
if(NOT WIN32 AND NOT APPLE)
target_link_libraries(kritaui ${CMAKE_DL_LIBS} Qt5::X11Extras)
endif()
if(X11_FOUND)
target_link_libraries(kritaui Qt5::X11Extras ${X11_LIBRARIES})
endif()
target_include_directories(kritaui
PUBLIC
$
$
$
$