#pragma once #include "Document/LayerAdjustment.h" #include "Document/LayerAppearance.h" #include "Document/LayerGroups.h" #include "Document/LayerMask.h" #include "Document/LayerTransform.h" #include "Document/Selection.h" #include "Document/ShapeTool.h" #include "Document/TypeTool.h" #include "IO/ImageImporter.h" #include #include #include #include #include #include struct ImageLayer { QUuid id; std::optional asset; LayerTransform transform; QString name; bool isVisible = true; std::optional parentID; bool isGroup = false; double opacity = 1; LayerBlendMode blendMode = LayerBlendMode::normal; std::optional maskSourceID; std::optional mask; std::optional adjustment; // Set on layers the Shape tool made; see `liveShape`. std::optional shape; // A stroke, shadows or overlay drawn round the pixels. std::optional effects; std::optional text; ImageLayer(ImportedImage imported, QPointF origin); ImageLayer(QString name, QSizeF blankSize); // A layer as a project records it. ImageLayer(const ProjectLayerRecord &record, std::optional asset, std::optional mask); QPointF origin() const { return transform.origin; } QSizeF size() const { return transform.size; } ProjectLayerRecord hierarchyRecord() const; // Drawn opacity, folders included (LayerOpacity). double effectiveOpacity(const std::map &byID) const; LayerTransform maskTransform() const; // The shape this layer still is: none once repainted otherwise. std::optional liveShape() const; // The text this layer still is: none once repainted otherwise. std::optional liveText() const; friend bool operator==(const ImageLayer &lhs, const ImageLayer &rhs); }; // The layer's place in the list, or -1. int indexOf(const std::vector &layers, std::optional id); struct ProjectSnapshot; struct CanvasDocument { QUuid id; int width; int height; double resolution = 72; std::vector layers; // Bottom to top. // Part of the document so undo covers it; never saved. std::optional selection; CanvasDocument(int width, int height); // The canvas a project holds, each layer as recorded. explicit CanvasDocument(const ProjectSnapshot &snapshot); QSizeF size() const { return QSizeF(width, height); } static std::optional validDimension(const QString &value); std::vector hierarchyEntries() const; QSet effectiveVisibleIDs() const; QHash effectiveOpacities() const; std::vector renderLayers() const; friend bool operator==(const CanvasDocument &lhs, const CanvasDocument &rhs) = default; }; enum class NavigationTool { move, marquee, lasso, wand, crop, brush, spotHealing, cloneStamp, blur, gradient, shape, type, eyedropper, hand, zoom, idle }; // The rail's tooltip: the tool's name and its key. QString label(NavigationTool tool); bool isBrushTool(NavigationTool tool); bool isSelectionTool(NavigationTool tool);