CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
painted_image_item.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <QQuickPaintedItem>
11#include <QImage>
12
14
15namespace CaptureMoment::UI {
16
23namespace Rendering {
24
38class PaintedImageItem : public QQuickPaintedItem, public BaseImageItem {
39
40 Q_OBJECT
41
42private:
49 QImage m_current_qimage;
50
51public:
56 explicit PaintedImageItem(QQuickItem* parent = nullptr);
57
61 ~PaintedImageItem() = default;
62
71 void setImage(std::unique_ptr<Core::Common::ImageRegion> image) override;
72
82 void updateTile(std::unique_ptr<Core::Common::ImageRegion> tile) override;
83
84protected:
85 // QQuickPaintedItem override
95 void paint(QPainter* painter) override;
96
97 /*
98 * @brief Handlers for state changes (zoom, pan, image).
99 * These methods are called when the corresponding state changes (zoom, pan, image).
100 * They can be overridden to react to changes, but the base implementation does nothing.
101 */
102 void onZoomChanged(float new_zoom) override;
103
104 /*
105 * @brief Handler for pan changes.
106 * This method is called when the pan offset changes.
107 * The base implementation does nothing, but it can be overridden to react to pan changes.
108 */
109 void onPanChanged(const QPointF& new_pan) override;
110
111 /*
112 * @brief Handler for image changes.
113 * This method is called when the image data changes (setImage or updateTile).
114 * The base implementation does nothing, but it can be overridden to react to image changes.
115 */
116 void onImageChanged() override;
117
118private:
127 [[nodiscard]] QImage convertImageRegionToQImage(const Core::Common::ImageRegion& region) const;
128
143 [[nodiscard]] bool isImagePaintValid() const;
144
145signals:
150 void zoomChanged(float zoom);
151
156 void panChanged(const QPointF& pan);
157
162};
163
164} // namespace Rendering
165
166} // namespace CaptureMoment::UI
Base class for Qt Quick image display items managing common state (zoom, pan, dimensions)
Base class for Qt Quick image display items managing common state dimensions.
QPointF pan() const override
Gets the current pan offset.
float zoom() const override
Gets the current zoom level.
QQuickItem that renders an image via QPainter.
void paint(QPainter *painter) override
Paints the image using QPainter.
void onPanChanged(const QPointF &new_pan) override
void setImage(std::unique_ptr< Core::Common::ImageRegion > image) override
Sets the full image to be displayed.
void updateTile(std::unique_ptr< Core::Common::ImageRegion > tile) override
Updates a specific tile of the displayed image.
void imageSizeChanged()
Signal emitted when the image dimensions change (width or height).
void panChanged(const QPointF &pan)
Signal emitted when the pan offset changes.
PaintedImageItem(QQuickItem *parent=nullptr)
Constructs a new PaintedImageItem.
~PaintedImageItem()=default
Destroys the PaintedImageItem.
void zoomChanged(float zoom)
Signal emitted when the zoom value changes.
Represents a rectangular region of an image and its pixel data.
CaptureMoment — footer