diff --git a/Telegram/SourceFiles/editor/editor_paint.cpp b/Telegram/SourceFiles/editor/editor_paint.cpp index d1fbf765b..0344e69a1 100644 --- a/Telegram/SourceFiles/editor/editor_paint.cpp +++ b/Telegram/SourceFiles/editor/editor_paint.cpp @@ -52,7 +52,6 @@ Paint::Paint( std::shared_ptr controllers) : RpWidget(parent) , _controllers(controllers) -, _lastZ(std::make_shared(9000.)) , _scene(EnsureScene(modifications, imageSize)) , _view(base::make_unique_q(_scene.get(), this)) , _imageSize(imageSize) { @@ -293,7 +292,7 @@ ItemBase::Data Paint::itemBaseData() const { const auto y = s.height() / 2; return ItemBase::Data{ .zoomValue = _transform.zoom.value(), - .zPtr = _lastZ, + .zPtr = _scene->lastZ(), .size = size, .x = x, .y = y, diff --git a/Telegram/SourceFiles/editor/editor_paint.h b/Telegram/SourceFiles/editor/editor_paint.h index b39267af0..259d3f99d 100644 --- a/Telegram/SourceFiles/editor/editor_paint.h +++ b/Telegram/SourceFiles/editor/editor_paint.h @@ -55,7 +55,6 @@ private: bool isItemHidden(const std::shared_ptr &item) const; const std::shared_ptr _controllers; - const std::shared_ptr _lastZ; const std::shared_ptr _scene; const base::unique_qptr _view; const QSize _imageSize; diff --git a/Telegram/SourceFiles/editor/scene/scene.cpp b/Telegram/SourceFiles/editor/scene/scene.cpp index 846e36cc6..184778c9a 100644 --- a/Telegram/SourceFiles/editor/scene/scene.cpp +++ b/Telegram/SourceFiles/editor/scene/scene.cpp @@ -27,7 +27,8 @@ bool SkipMouseEvent(not_null event) { Scene::Scene(const QRectF &rect) : QGraphicsScene(rect) -, _canvas(std::make_shared()) { +, _canvas(std::make_shared()) +, _lastZ(std::make_shared(9000.)) { QGraphicsScene::addItem(_canvas.get()); _canvas->clearPixmap(); @@ -134,6 +135,10 @@ std::vector Scene::attachedStickers() const { }) | ranges::to_vector; } +std::shared_ptr Scene::lastZ() const { + return _lastZ; +} + Scene::~Scene() { // Prevent destroying by scene of all items. QGraphicsScene::removeItem(_canvas.get()); diff --git a/Telegram/SourceFiles/editor/scene/scene.h b/Telegram/SourceFiles/editor/scene/scene.h index f51a21d79..168069fb7 100644 --- a/Telegram/SourceFiles/editor/scene/scene.h +++ b/Telegram/SourceFiles/editor/scene/scene.h @@ -40,6 +40,8 @@ public: [[nodiscard]] std::vector attachedStickers() const; + [[nodiscard]] std::shared_ptr lastZ() const; + void cancelDrawing(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event) override; @@ -47,6 +49,7 @@ protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; private: const std::shared_ptr _canvas; + const std::shared_ptr _lastZ; std::vector _items;