mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Fixed items order when opening photo editor with modified scene.
This commit is contained in:
parent
8ddbf08a97
commit
5bbf3a329d
4 changed files with 10 additions and 4 deletions
|
@ -52,7 +52,6 @@ Paint::Paint(
|
|||
std::shared_ptr<Controllers> controllers)
|
||||
: RpWidget(parent)
|
||||
, _controllers(controllers)
|
||||
, _lastZ(std::make_shared<float64>(9000.))
|
||||
, _scene(EnsureScene(modifications, imageSize))
|
||||
, _view(base::make_unique_q<QGraphicsView>(_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,
|
||||
|
|
|
@ -55,7 +55,6 @@ private:
|
|||
bool isItemHidden(const std::shared_ptr<QGraphicsItem> &item) const;
|
||||
|
||||
const std::shared_ptr<Controllers> _controllers;
|
||||
const std::shared_ptr<float64> _lastZ;
|
||||
const std::shared_ptr<Scene> _scene;
|
||||
const base::unique_qptr<QGraphicsView> _view;
|
||||
const QSize _imageSize;
|
||||
|
|
|
@ -27,7 +27,8 @@ bool SkipMouseEvent(not_null<QGraphicsSceneMouseEvent*> event) {
|
|||
|
||||
Scene::Scene(const QRectF &rect)
|
||||
: QGraphicsScene(rect)
|
||||
, _canvas(std::make_shared<ItemCanvas>()) {
|
||||
, _canvas(std::make_shared<ItemCanvas>())
|
||||
, _lastZ(std::make_shared<float64>(9000.)) {
|
||||
QGraphicsScene::addItem(_canvas.get());
|
||||
_canvas->clearPixmap();
|
||||
|
||||
|
@ -134,6 +135,10 @@ std::vector<MTPInputDocument> Scene::attachedStickers() const {
|
|||
}) | ranges::to_vector;
|
||||
}
|
||||
|
||||
std::shared_ptr<float64> Scene::lastZ() const {
|
||||
return _lastZ;
|
||||
}
|
||||
|
||||
Scene::~Scene() {
|
||||
// Prevent destroying by scene of all items.
|
||||
QGraphicsScene::removeItem(_canvas.get());
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
|
||||
[[nodiscard]] std::vector<MTPInputDocument> attachedStickers() const;
|
||||
|
||||
[[nodiscard]] std::shared_ptr<float64> 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<ItemCanvas> _canvas;
|
||||
const std::shared_ptr<float64> _lastZ;
|
||||
|
||||
std::vector<ItemPtr> _items;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue