mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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)
|
std::shared_ptr<Controllers> controllers)
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _controllers(controllers)
|
, _controllers(controllers)
|
||||||
, _lastZ(std::make_shared<float64>(9000.))
|
|
||||||
, _scene(EnsureScene(modifications, imageSize))
|
, _scene(EnsureScene(modifications, imageSize))
|
||||||
, _view(base::make_unique_q<QGraphicsView>(_scene.get(), this))
|
, _view(base::make_unique_q<QGraphicsView>(_scene.get(), this))
|
||||||
, _imageSize(imageSize) {
|
, _imageSize(imageSize) {
|
||||||
|
@ -293,7 +292,7 @@ ItemBase::Data Paint::itemBaseData() const {
|
||||||
const auto y = s.height() / 2;
|
const auto y = s.height() / 2;
|
||||||
return ItemBase::Data{
|
return ItemBase::Data{
|
||||||
.zoomValue = _transform.zoom.value(),
|
.zoomValue = _transform.zoom.value(),
|
||||||
.zPtr = _lastZ,
|
.zPtr = _scene->lastZ(),
|
||||||
.size = size,
|
.size = size,
|
||||||
.x = x,
|
.x = x,
|
||||||
.y = y,
|
.y = y,
|
||||||
|
|
|
@ -55,7 +55,6 @@ private:
|
||||||
bool isItemHidden(const std::shared_ptr<QGraphicsItem> &item) const;
|
bool isItemHidden(const std::shared_ptr<QGraphicsItem> &item) const;
|
||||||
|
|
||||||
const std::shared_ptr<Controllers> _controllers;
|
const std::shared_ptr<Controllers> _controllers;
|
||||||
const std::shared_ptr<float64> _lastZ;
|
|
||||||
const std::shared_ptr<Scene> _scene;
|
const std::shared_ptr<Scene> _scene;
|
||||||
const base::unique_qptr<QGraphicsView> _view;
|
const base::unique_qptr<QGraphicsView> _view;
|
||||||
const QSize _imageSize;
|
const QSize _imageSize;
|
||||||
|
|
|
@ -27,7 +27,8 @@ bool SkipMouseEvent(not_null<QGraphicsSceneMouseEvent*> event) {
|
||||||
|
|
||||||
Scene::Scene(const QRectF &rect)
|
Scene::Scene(const QRectF &rect)
|
||||||
: QGraphicsScene(rect)
|
: QGraphicsScene(rect)
|
||||||
, _canvas(std::make_shared<ItemCanvas>()) {
|
, _canvas(std::make_shared<ItemCanvas>())
|
||||||
|
, _lastZ(std::make_shared<float64>(9000.)) {
|
||||||
QGraphicsScene::addItem(_canvas.get());
|
QGraphicsScene::addItem(_canvas.get());
|
||||||
_canvas->clearPixmap();
|
_canvas->clearPixmap();
|
||||||
|
|
||||||
|
@ -134,6 +135,10 @@ std::vector<MTPInputDocument> Scene::attachedStickers() const {
|
||||||
}) | ranges::to_vector;
|
}) | ranges::to_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<float64> Scene::lastZ() const {
|
||||||
|
return _lastZ;
|
||||||
|
}
|
||||||
|
|
||||||
Scene::~Scene() {
|
Scene::~Scene() {
|
||||||
// Prevent destroying by scene of all items.
|
// Prevent destroying by scene of all items.
|
||||||
QGraphicsScene::removeItem(_canvas.get());
|
QGraphicsScene::removeItem(_canvas.get());
|
||||||
|
|
|
@ -40,6 +40,8 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] std::vector<MTPInputDocument> attachedStickers() const;
|
[[nodiscard]] std::vector<MTPInputDocument> attachedStickers() const;
|
||||||
|
|
||||||
|
[[nodiscard]] std::shared_ptr<float64> lastZ() const;
|
||||||
|
|
||||||
void cancelDrawing();
|
void cancelDrawing();
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
|
@ -47,6 +49,7 @@ protected:
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
private:
|
private:
|
||||||
const std::shared_ptr<ItemCanvas> _canvas;
|
const std::shared_ptr<ItemCanvas> _canvas;
|
||||||
|
const std::shared_ptr<float64> _lastZ;
|
||||||
|
|
||||||
std::vector<ItemPtr> _items;
|
std::vector<ItemPtr> _items;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue