CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
base_image_item.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <QQuickItem>
11#include <QPointF>
12#include <QMutex>
13#include <QSize>
15
16namespace CaptureMoment::UI {
17
18namespace Rendering {
19
28{
29public:
34 explicit BaseImageItem();
35
40 void setZoom(float zoom) override;
41
46 void setPan(const QPointF& pan) override;
47
52 [[nodiscard]] QPointF pan() const override { return m_pan; };
53
58 [[nodiscard]] float zoom() const override { return m_zoom; };
59
65 [[nodiscard]] int imageWidth() const override;
66
72 [[nodiscard]] int imageHeight() const override;
73
79 [[nodiscard]] bool isImageValid() const override;
80
81
88 [[nodiscard]] QMutex* getImageMutex() const override { return &m_image_mutex; };
89
95 [[nodiscard]] const Core::Common::ImageRegion* getFullImage() const override {
96 return m_full_image.get();}
97
98protected:
99
100 /* --------------------- Protected Members --------------------*/
101
107 std::unique_ptr<Core::Common::ImageRegion> m_full_image;
108
113 mutable QMutex m_image_mutex;
114
120 float m_zoom{1.0f};
121
127 QPointF m_pan{0, 0};
128
129 /* --------------------- Protected Methods --------------------*/
130 /*
131 * @brief Virtual methods for handling state changes (can be overridden by derived classes).
132 * These methods are called when the corresponding state changes (zoom, pan, image).
133 * The base implementation does nothing, but derived classes can override to react to changes.
134 */
135 virtual void onZoomChanged(float new_zoom) {};
136
137 /*
138 * @brief Virtual method for handling pan changes.
139 * This method is called when the pan offset changes.
140 * The base implementation does nothing, but derived classes can override to react to pan changes.
141 */
142 virtual void onPanChanged(const QPointF& new_pan) {};
143
144 /*
145 * @brief Virtual method for handling image changes.
146 * This method is called when the image data changes (setImage or updateTile).
147 * The base implementation does nothing, but derived classes can override to react to image changes.
148 */
149 virtual void onImageChanged() {};
150};
151
152} // namespace Rendering
153
154} // namespace CaptureMoment::UI
Base class for Qt Quick image display items managing common state dimensions.
bool isImageValid() const override
Checks if the full image data is loaded and valid. This method provides thread-safe access to check t...
virtual void onZoomChanged(float new_zoom)
QPointF pan() const override
Gets the current pan offset.
std::unique_ptr< Core::Common::ImageRegion > m_full_image
Unique pointer to the full image data displayed by this item.
virtual void onPanChanged(const QPointF &new_pan)
QMutex m_image_mutex
Mutex protecting access to m_full_image and related state. Ensures thread-safe updates to the image d...
int imageHeight() const override
Gets the height of the image. This method provides thread-safe access to m_image_height.
float zoom() const override
Gets the current zoom level.
QPointF m_pan
Current pan offset applied to the image.
float m_zoom
Current zoom level applied to the image.
int imageWidth() const override
Gets the width of the image. This method provides thread-safe access to m_image_width.
void setZoom(float zoom) override
Sets the zoom level.
QMutex * getImageMutex() const override
Gets a pointer to the mutex protecting the image data. This method provides access to the mutex for t...
void setPan(const QPointF &pan) override
Sets the pan offset.
const Core::Common::ImageRegion * getFullImage() const override
Gets a pointer to the full image data. This method provides access to the internal image data pointer...
Abstract base class for image display items managing common state (zoom, pan, dimensions).
Represents a rectangular region of an image and its pixel data.
CaptureMoment — footer