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-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;
|
|
|
|
class ItemBase;
|
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-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
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool hasUndo() const;
|
|
|
|
bool hasRedo() const;
|
|
|
|
void clearRedoList();
|
|
|
|
|
2021-03-10 15:51:23 +00:00
|
|
|
bool isItemToRemove(const std::shared_ptr<QGraphicsItem> &item) const;
|
|
|
|
bool isItemHidden(const std::shared_ptr<QGraphicsItem> &item) const;
|
2021-03-14 09:42:18 +00:00
|
|
|
|
2021-02-23 15:35:40 +00:00
|
|
|
const std::shared_ptr<float64> _lastZ;
|
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;
|
|
|
|
rpl::variable<float64> zoom = 0.;
|
|
|
|
} _transform;
|
|
|
|
|
2021-03-14 09:42:18 +00:00
|
|
|
std::vector<SavedItem> _previousItems;
|
2021-03-10 15:51:23 +00:00
|
|
|
std::vector<std::shared_ptr<QGraphicsItem>> _itemsToRemove;
|
2021-03-14 09:39:55 +00:00
|
|
|
|
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
|