File indexing completed on 2024-05-12 15:59:08

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 paintingFlow() const;
0121     void setPaintingFlow(qreal flow);
0122 
0123     /**
0124      * @brief showFloatingMessage displays a floating message box on the top-left corner of the canvas
0125      * @param message: Message to be displayed inside the floating message box
0126      * @param icon: Icon to be displayed inside the message box next to the message string
0127      * @param timeout: Milliseconds until the message box disappears
0128      * @param priority: 0 = High, 1 = Medium, 2 = Low. Higher priority
0129      * messages will be displayed in place of lower priority messages
0130      */
0131     void showFloatingMessage(const QString &message, const QIcon& icon, int timeout, int priority);
0132 
0133     /**
0134      * @brief selectedNodes returns a list of Nodes that are selected in this view.
0135      *
0136      *
0137 @code
0138 from krita import *
0139 w = Krita.instance().activeWindow()
0140 v = w.activeView()
0141 selected_nodes = v.selectedNodes()
0142 print(selected_nodes)
0143 @endcode
0144      *
0145      *
0146      * @return a list of Node objects which may be empty.
0147      */
0148     QList<Node *> selectedNodes() const;
0149 
0150 private:
0151 
0152     friend class Window;
0153     friend class Scratchpad;
0154 
0155 
0156     KisView *view();
0157 
0158     struct Private;
0159     Private *const d;
0160 
0161 };
0162 
0163 #endif // LIBKIS_VIEW_H