27 [[nodiscard]]
bool isValid() const noexcept {
43 [[nodiscard]]
bool isValid() const noexcept {
54 QPointF
pan{0.0, 0.0};
147 [[nodiscard]]
float calculateFitZoom(
const QSize& source_size)
const noexcept;
175 [[nodiscard]] QSize
viewportSize() const noexcept {
return m_viewport_logical; }
199 [[nodiscard]]
float qualityMargin() const noexcept {
return m_quality_margin; }
205 [[nodiscard]]
int plafond() const noexcept {
return m_plafond; }
211 [[nodiscard]]
int maxDownsample() const noexcept {
return m_max_downsample; }
228 void updateMaxDownsample();
233 bool m_initialized{
false};
238 QSize m_viewport_logical;
243 QSize m_viewport_physical;
Manages viewport calculations for optimal display across all screen types.
~ViewportManager() override=default
QSize viewportPhysicalSize() const noexcept
Gets the physical viewport size.
ScreenInfo screenInfo() const noexcept
Gets the screen information.
QSize calculateDownsampleSize(const QSize &source_size) const
Calculates the downsample size for a source image.
int plafond() const noexcept
Gets the screen-based ceiling.
void setMaxDownsample(int max_dim)
Sets the maximum downsample dimension manually.
float calculateFitZoom(const QSize &source_size) const noexcept
Calculates the zoom factor to fit an image in the viewport.
bool isInitialized() const noexcept
Gets the initialization status.
void setQualityMargin(float margin)
Sets the quality margin for zoom headroom.
void initialize(const QSize &viewport_logical, const ScreenInfo &screen)
Initializes the manager with screen and viewport parameters.
ViewportCalculation calculateDisplay(const QSize &source_size) const
Calculates optimal display parameters for a source image.
ViewportManager(const ViewportManager &)=delete
float devicePixelRatio() const noexcept
Gets the device pixel ratio.
int maxDownsample() const noexcept
Gets the maximum downsample dimension.
void viewportSizeChanged(const QSize &size)
ViewportState calculateFitToView(const QSize &display_size) const noexcept
Calculates viewport state for fit-to-view.
void setViewportSize(const QSize &viewport_logical)
Updates the viewport size.
ViewportManager & operator=(ViewportManager &&)=default
float qualityMargin() const noexcept
Gets the current quality margin.
QSize viewportSize() const noexcept
Gets the logical viewport size.
ViewportManager(QObject *parent=nullptr)
void maxDownsampleChanged(int max_dim)
ViewportManager(ViewportManager &&)=default
ViewportManager & operator=(const ViewportManager &)=delete
static consteval int plafondSmallScreen() noexcept
Plafond (ceiling) for small physical screens.
static consteval float defaultQualityMargin() noexcept
Default quality margin for zoom headroom.
Physical screen characteristics.
float dpr
Device pixel ratio (density)
int physical_width
Physical screen width in pixels.
int physical_height
Physical screen height in pixels.
bool isValid() const noexcept
Result of viewport calculation for an image.
QSize display_size
Size to display in QML (logical pixels)
bool needs_downsample
True if downsample is required.
QSize downsample_size
Size to downsample source image to (GPU texture)
float fit_zoom
Zoom factor to fit image in viewport (0.0-1.0)
bool isValid() const noexcept
size_t texture_memory_mb
Estimated GPU memory usage in MB.
Current viewport state for zoom/pan operations.
QPointF center_offset
Offset to center image in viewport.
QPointF pan
Current pan offset in logical pixels.
float zoom
Current zoom level (1.0 = 100%)
Configuration constants and helper functions for viewport management.