2021-03-03 09:24:35 +00:00
|
|
|
/*
|
|
|
|
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 <base/unique_qptr.h>
|
|
|
|
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
|
|
|
|
class QGraphicsSceneMouseEvent;
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class RpWidget;
|
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Editor {
|
|
|
|
|
|
|
|
class ItemCanvas;
|
2021-03-14 09:44:49 +00:00
|
|
|
class NumberedItem;
|
2021-03-03 09:24:35 +00:00
|
|
|
|
|
|
|
class Scene final : public QGraphicsScene {
|
|
|
|
public:
|
|
|
|
Scene(const QRectF &rect);
|
|
|
|
~Scene();
|
|
|
|
void applyBrush(const QColor &color, float size);
|
|
|
|
|
2021-03-14 09:44:49 +00:00
|
|
|
[[nodiscard]] std::vector<QGraphicsItem*> items(
|
|
|
|
Qt::SortOrder order = Qt::DescendingOrder) const;
|
|
|
|
void addItem(not_null<NumberedItem*> item);
|
2021-03-08 16:31:48 +00:00
|
|
|
[[nodiscard]] rpl::producer<> addsItem() const;
|
2021-03-03 09:24:35 +00:00
|
|
|
[[nodiscard]] rpl::producer<> mousePresses() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
|
|
|
private:
|
|
|
|
const not_null<ItemCanvas*> _canvas;
|
|
|
|
|
|
|
|
float64 _lastLineZ = 0.;
|
2021-03-14 09:44:49 +00:00
|
|
|
int _itemNumber = 0;
|
|
|
|
|
2021-03-03 09:24:35 +00:00
|
|
|
rpl::event_stream<> _mousePresses;
|
2021-03-08 16:31:48 +00:00
|
|
|
rpl::event_stream<> _addsItem;
|
2021-03-03 09:24:35 +00:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Editor
|