File indexing completed on 2024-12-22 04:12:59

0001 /*
0002  *  SPDX-FileCopyrightText: 2007 Sven Langkamp <sven.langkamp@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #ifndef KIS_SELECTION_TOOL_HELPER_H
0007 #define KIS_SELECTION_TOOL_HELPER_H
0008 
0009 #include <kritaui_export.h>
0010 #include <QMenu>
0011 #include <QPointer>
0012 
0013 #include "kundo2magicstring.h"
0014 #include "kis_layer.h"
0015 #include "kis_selection.h"
0016 #include "kis_canvas2.h"
0017 #include "kis_processing_applicator.h"
0018 
0019 class KoShape;
0020 
0021 /**
0022  * XXX: Doc!
0023  */
0024 class KRITAUI_EXPORT KisSelectionToolHelper
0025 {
0026 public:
0027 
0028     KisSelectionToolHelper(KisCanvas2* canvas, const KUndo2MagicString& name);
0029     virtual ~KisSelectionToolHelper();
0030 
0031     void selectPixelSelection(KisProcessingApplicator& applicator, KisPixelSelectionSP selection, SelectionAction action);
0032     void selectPixelSelection(KisPixelSelectionSP selection, SelectionAction action);
0033 
0034     void addSelectionShape(KoShape* shape, SelectionAction action = SELECTION_DEFAULT);
0035     void addSelectionShapes(QList<KoShape*> shapes, SelectionAction action = SELECTION_DEFAULT);
0036 
0037     bool canShortcutToDeselect(const QRect &rect, SelectionAction action);
0038     bool canShortcutToNoop(const QRect &rect, SelectionAction action);
0039 
0040     bool tryDeselectCurrentSelection(const QRectF selectionViewRect, SelectionAction action);
0041     static QMenu* getSelectionContextMenu(KisCanvas2* canvas);
0042 
0043     SelectionMode tryOverrideSelectionMode(KisSelectionSP activeSelection, SelectionMode currentMode, SelectionAction currentAction) const;
0044 
0045 
0046 private:
0047     QPointer<KisCanvas2> m_canvas;
0048     KisImageSP m_image;
0049     KisLayerSP m_layer;
0050     KUndo2MagicString m_name;
0051 };
0052 
0053 
0054 #endif