File indexing completed on 2024-05-19 04:26:58

0001 /*
0002  *  SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 #ifndef LIBKIS_VIEW_H
0007 #define LIBKIS_VIEW_H
0008 
0009 #include <QObject>
0010 
0011 #include "kritalibkis_export.h"
0012 #include "libkis.h"
0013 
0014 class ManagedColor;
0015 class Resource;
0016 class Scratchpad;
0017 class Node;
0018 class KisView;
0019 
0020 /**
0021  * View represents one view on a document. A document can be
0022  * shown in more than one view at a time.
0023  */
0024 class KRITALIBKIS_EXPORT View : public QObject
0025 {
0026     Q_OBJECT
0027     Q_DISABLE_COPY(View)
0028 
0029 public:
0030     explicit View(KisView *view, QObject *parent = 0);
0031     ~View() override;
0032 
0033     bool operator==(const View &other) const;
0034     bool operator!=(const View &other) const;
0035 
0036 public Q_SLOTS:
0037 
0038     /**
0039      * @return the window this view is shown in.
0040      */
0041     Window* window() const;
0042 
0043     /**
0044      * @return the document this view is showing.
0045      */
0046     Document* document() const;
0047 
0048     /**
0049      * Reset the view to show @p document.
0050      */
0051     void setDocument(Document *document);
0052 
0053     /**
0054      * @return true if the current view is visible, false if not.
0055      */
0056     bool visible() const;
0057 
0058     /**
0059      * Make the current view visible.
0060      */
0061     void setVisible();
0062 
0063     /**
0064      * @return the canvas this view is showing. The canvas controls
0065      * things like zoom and rotation.
0066      */
0067     Canvas* canvas() const;
0068 
0069     /**
0070      * @brief activateResource activates the given resource.
0071      * @param resource: a pattern, gradient or paintop preset
0072      */
0073     void activateResource(Resource *resource);
0074 
0075 
0076 
0077     /**
0078      * @brief foregroundColor allows access to the currently active color.
0079      * This is nominally per canvas/view, but in practice per mainwindow.
0080      * @code
0081 color = Application.activeWindow().activeView().foregroundColor()
0082 components = color.components()
0083 components[0] = 1.0
0084 components[1] = 0.6
0085 components[2] = 0.7
0086 color.setComponents(components)
0087 Application.activeWindow().activeView().setForeGroundColor(color)
0088      * @endcode
0089      */
0090     ManagedColor *foregroundColor() const;
0091     void setForeGroundColor(ManagedColor *color);
0092 
0093     ManagedColor *backgroundColor() const;
0094     void setBackGroundColor(ManagedColor *color);
0095 
0096     Resource *currentBrushPreset() const;
0097     void setCurrentBrushPreset(Resource *resource);
0098 
0099     Resource *currentPattern() const;
0100     void setCurrentPattern(Resource *resource);
0101 
0102     Resource *currentGradient() const;
0103     void setCurrentGradient(Resource *resource);
0104 
0105     QString currentBlendingMode() const;
0106     void setCurrentBlendingMode(const QString &blendingMode);
0107 
0108     float HDRExposure() const;
0109     void setHDRExposure(float exposure);
0110 
0111     float HDRGamma() const;
0112     void setHDRGamma(float gamma);
0113 
0114     qreal paintingOpacity() const;
0115     void setPaintingOpacity(qreal opacity);
0116 
0117     qreal brushSize() const;
0118     void setBrushSize(qreal brushSize);
0119 
0120     qreal brushRotation() const;
0121     void setBrushRotation(qreal brushRotation);
0122 
0123     qreal paintingFlow() const;
0124     void setPaintingFlow(qreal flow);
0125 
0126     /**
0127      * @brief showFloatingMessage displays a floating message box on the top-left corner of the canvas
0128      * @param message: Message to be displayed inside the floating message box
0129      * @param icon: Icon to be displayed inside the message box next to the message string
0130      * @param timeout: Milliseconds until the message box disappears
0131      * @param priority: 0 = High, 1 = Medium, 2 = Low. Higher priority
0132      * messages will be displayed in place of lower priority messages
0133      */
0134     void showFloatingMessage(const QString &message, const QIcon& icon, int timeout, int priority);
0135 
0136     /**
0137      * @brief selectedNodes returns a list of Nodes that are selected in this view.
0138      *
0139      *
0140 @code
0141 from krita import *
0142 w = Krita.instance().activeWindow()
0143 v = w.activeView()
0144 selected_nodes = v.selectedNodes()
0145 print(selected_nodes)
0146 @endcode
0147      *
0148      *
0149      * @return a list of Node objects which may be empty.
0150      */
0151     QList<Node *> selectedNodes() const;
0152 
0153     /**
0154      * @brief flakeToDocumentTransform
0155      * The transformation of the document relative to the view without rotation and mirroring
0156      * @return QTransform
0157      */
0158     QTransform flakeToDocumentTransform() const;
0159 
0160     /**
0161      * @brief flakeToCanvasTransform
0162      * The transformation of the canvas relative to the view without rotation and mirroring
0163      * @return QTransform
0164      */
0165     QTransform flakeToCanvasTransform() const;
0166 
0167     /**
0168      * @brief flakeToImageTransform
0169      * The transformation of the image relative to the view without rotation and mirroring
0170      * @return QTransform
0171      */
0172     QTransform flakeToImageTransform() const;
0173 
0174 private:
0175 
0176     friend class Window;
0177     friend class Scratchpad;
0178 
0179 
0180     KisView *view();
0181 
0182     struct Private;
0183     Private *const d;
0184 
0185 };
0186 
0187 #endif // LIBKIS_VIEW_H