All Classes Namespaces Functions Variables Enumerations Properties Pages
bitmapbucket.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 #ifndef BITMAPBUCKET_H
18 #define BITMAPBUCKET_H
19 
20 #include "bitmapimage.h"
21 #include "basetool.h"
22 
23 #include <functional>
24 
25 class Layer;
26 class Editor;
27 
28 enum class BucketState
29 {
30  WillFillTarget, // Before applying to target image
31  DidFillTarget, // After calling floodfill and applied to target
32 };
33 
35 {
36 public:
37  explicit BitmapBucket();
38  explicit BitmapBucket(Editor* editor, QColor color, QRect maxFillRegion, QPointF fillPoint, Properties properties);
39 
46  void paint(const QPointF updatedPoint, std::function<void(BucketState, int, int)> progress);
47 
48 private:
49 
50 
60  bool shouldFill(QPointF checkPoint) const;
61 
62  std::pair<Layer*, int> findBitmapLayerBelow(Layer* targetLayer, int layerIndex) const;
63  BitmapImage flattenBitmapLayersToImage();
64 
65  Editor* mEditor = nullptr;
66  Layer* mTargetFillToLayer = nullptr;
67 
68  BitmapImage mReferenceImage;
69  QRgb mBucketColor = 0;
70  QRgb mReferenceColor = 0;
71  QRgb mAppliedColor = 0;
72 
73  QPointF mBucketStartPoint;
74  QRect mMaxFillRegion;
75 
76  int mTargetFillToLayerIndex = -1;
77 
78  Properties mProperties;
79 
80  bool mFirstPaint = true;
81 };
82 
83 #endif // BITMAPBUCKET_H
Definition: layer.h:38
bool shouldFill(QPointF checkPoint) const
Based on the various factors dependant on which tool properties are set, the result will: ...
void paint(const QPointF updatedPoint, std::function< void(BucketState, int, int)> progress)
Will paint at the given point, given that it makes sense.
Definition: editor.h:55