/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include
#include
#include
class QGraphicsSceneMouseEvent;
namespace Ui {
class RpWidget;
} // namespace Ui
namespace Editor {
class ItemCanvas;
class NumberedItem;
class Scene final : public QGraphicsScene {
public:
using ItemPtr = std::shared_ptr;
Scene(const QRectF &rect);
~Scene();
void applyBrush(const QColor &color, float size);
[[nodiscard]] std::vector items(
Qt::SortOrder order = Qt::DescendingOrder) const;
void addItem(ItemPtr item);
void removeItem(not_null item);
void removeItem(const std::shared_ptr &item);
[[nodiscard]] rpl::producer<> addsItem() const;
[[nodiscard]] rpl::producer<> removesItem() const;
[[nodiscard]] std::vector attachedStickers() const;
[[nodiscard]] std::shared_ptr lastZ() const;
void updateZoom(float64 zoom);
void cancelDrawing();
void saveItemsState(SaveState state);
void restoreItemsState(SaveState state);
[[nodiscard]] bool hasUndo() const;
[[nodiscard]] bool hasRedo() const;
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
private:
const std::shared_ptr _canvas;
const std::shared_ptr _lastZ;
std::vector _items;
float64 _lastLineZ = 0.;
int _itemNumber = 0;
rpl::event_stream<> _addsItem, _removesItem;
rpl::lifetime _lifetime;
};
} // namespace Editor