tdesktop/Telegram/SourceFiles/editor/scene.h

60 lines
1.2 KiB
C
Raw Normal View History

/*
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;
class QGraphicsSceneMouseEvent;
class QGraphicsSceneMouseEvent;
namespace Ui {
class RpWidget;
} // namespace Ui
namespace Editor {
class ItemCanvas;
class Scene final : public QGraphicsScene {
public:
Scene(const QRectF &rect);
~Scene();
void applyBrush(const QColor &color, float size);
[[nodiscard]] rpl::producer<> mousePresses() const;
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
private:
void clearPath();
void addLineItem();
const not_null<ItemCanvas*> _canvas;
QPainterPath _path;
bool _drawing = false;
float64 _lastLineZ = 0.;
struct {
float size = 1.;
QColor color;
} _brushData;
rpl::event_stream<> _mousePresses;
rpl::lifetime _lifetime;
};
} // namespace Editor