39 explicit Canvas(QWidget* parent);
48 const QRectF&
viewport()
const {
return viewport_rect_; }
69 void setViewport(
const QPointF& top_left,
const QPointF& bottom_right);
81 void resizeEvent(QResizeEvent* event)
override;
84 void updateTransformations()
const;
91 QRectF viewport_rect_{ 0, 0, 1, 1 };
94 mutable bool valid_transformations_ =
false;
95 mutable QTransform transform_from_viewport_;
96 mutable QTransform transform_to_viewport_;
97 mutable double scale_ = 0;
const QTransform & transformToViewport() const
Client window coordinates to logical viewport coordinates.
Definition: canvas.cpp:48
const QRectF & viewport() const
Current viewport rectangle (in logical coordinates)
Definition: canvas.h:48
A reusable canvas with support for logical coordinates and auto-scalling the content.
Definition: canvas.h:36
Reusable components for building UIs.
Definition: canvas.cpp:21
int borderSize() const
Border size value (in pixels)
Definition: canvas.h:42
const QTransform & transformFromViewport() const
Logical viewport coordinates to client window coordinates.
Definition: canvas.cpp:43
void setViewport(const QRectF &viewport_rect)
Sets the viewport rectangle (logical coordinates)
Definition: canvas.cpp:31
double scale() const
Returns the current scale factor.
Definition: canvas.cpp:53
void setBorderSize(int border_size)
Sets a new border size (pixels)
Definition: canvas.cpp:25
Canvas(QWidget *parent)
Creates a new Canvas.
Definition: canvas.cpp:23