2021-02-13 04:29:31 +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 "ui/rp_widget.h"
|
|
|
|
|
|
|
|
#include "editor/photo_editor_common.h"
|
2021-07-07 17:51:13 +00:00
|
|
|
#include "editor/photo_editor_inner_common.h"
|
2021-07-04 12:57:07 +00:00
|
|
|
#include "editor/scene/scene_item_base.h"
|
2021-02-13 04:29:31 +00:00
|
|
|
|
2021-03-03 09:24:35 +00:00
|
|
|
class QGraphicsItem;
|
2021-02-13 04:29:31 +00:00
|
|
|
class QGraphicsView;
|
|
|
|
|
|
|
|
namespace Editor {
|
|
|
|
|
2021-02-23 10:34:12 +00:00
|
|
|
struct Controllers;
|
2021-03-03 09:24:35 +00:00
|
|
|
class Scene;
|
2021-03-14 09:42:18 +00:00
|
|
|
|
2021-02-13 04:29:31 +00:00
|
|
|
// Paint control.
|
|
|
|
class Paint final : public Ui::RpWidget {
|
|
|
|
public:
|
|
|
|
Paint(
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
|
|
|
PhotoModifications &modifications,
|
2021-03-14 09:42:18 +00:00
|
|
|
const QSize &imageSize,
|
2021-02-23 10:34:12 +00:00
|
|
|
std::shared_ptr<Controllers> controllers);
|
2021-02-13 04:29:31 +00:00
|
|
|
|
2021-03-03 09:24:35 +00:00
|
|
|
[[nodiscard]] std::shared_ptr<Scene> saveScene() const;
|
2021-07-07 18:14:50 +00:00
|
|
|
void restoreScene();
|
2021-02-13 04:29:31 +00:00
|
|
|
|
|
|
|
void applyTransform(QRect geometry, int angle, bool flipped);
|
2021-02-16 03:45:05 +00:00
|
|
|
void applyBrush(const Brush &brush);
|
2021-03-14 09:39:55 +00:00
|
|
|
void cancel();
|
|
|
|
void keepResult();
|
2021-03-14 09:42:18 +00:00
|
|
|
void updateUndoState();
|
2021-02-13 04:29:31 +00:00
|
|
|
|
2021-05-06 21:47:49 +00:00
|
|
|
void handleMimeData(const QMimeData *data);
|
|
|
|
|
2021-02-13 04:29:31 +00:00
|
|
|
private:
|
2021-03-14 09:42:18 +00:00
|
|
|
struct SavedItem {
|
2021-03-10 15:51:23 +00:00
|
|
|
std::shared_ptr<QGraphicsItem> item;
|
2021-03-14 09:42:18 +00:00
|
|
|
bool undid = false;
|
|
|
|
};
|
|
|
|
|
2021-07-04 12:57:07 +00:00
|
|
|
ItemBase::Data itemBaseData() const;
|
|
|
|
|
2021-03-14 09:42:18 +00:00
|
|
|
void clearRedoList();
|
|
|
|
|
2021-05-06 21:47:49 +00:00
|
|
|
const std::shared_ptr<Controllers> _controllers;
|
2021-03-03 09:24:35 +00:00
|
|
|
const std::shared_ptr<Scene> _scene;
|
2021-02-13 04:29:31 +00:00
|
|
|
const base::unique_qptr<QGraphicsView> _view;
|
|
|
|
const QSize _imageSize;
|
|
|
|
|
2021-03-21 17:00:56 +00:00
|
|
|
struct {
|
|
|
|
int angle = 0;
|
|
|
|
bool flipped = false;
|
2021-07-06 23:10:13 +00:00
|
|
|
float64 zoom = 0.;
|
2021-03-21 17:00:56 +00:00
|
|
|
} _transform;
|
|
|
|
|
2021-03-14 09:42:18 +00:00
|
|
|
rpl::variable<bool> _hasUndo = true;
|
|
|
|
rpl::variable<bool> _hasRedo = true;
|
|
|
|
|
2021-03-10 07:45:42 +00:00
|
|
|
|
2021-02-13 04:29:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Editor
|