2021-02-05 05:44:04 +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"
|
|
|
|
|
2021-02-07 23:10:30 +00:00
|
|
|
#include "editor/photo_editor_common.h"
|
2021-07-07 17:51:13 +00:00
|
|
|
#include "editor/photo_editor_inner_common.h"
|
2021-02-20 04:27:10 +00:00
|
|
|
#include "ui/image/image.h"
|
2021-02-07 23:10:30 +00:00
|
|
|
|
2021-02-05 05:44:04 +00:00
|
|
|
namespace Editor {
|
|
|
|
|
2021-02-08 07:01:15 +00:00
|
|
|
class Crop;
|
2021-02-13 04:29:31 +00:00
|
|
|
class Paint;
|
2021-02-23 10:34:12 +00:00
|
|
|
struct Controllers;
|
2021-02-08 07:01:15 +00:00
|
|
|
|
2021-02-05 05:44:04 +00:00
|
|
|
class PhotoEditorContent final : public Ui::RpWidget {
|
|
|
|
public:
|
|
|
|
PhotoEditorContent(
|
|
|
|
not_null<Ui::RpWidget*> parent,
|
2021-02-20 04:27:10 +00:00
|
|
|
std::shared_ptr<Image> photo,
|
2021-03-14 09:42:18 +00:00
|
|
|
PhotoModifications modifications,
|
2021-02-23 10:34:12 +00:00
|
|
|
std::shared_ptr<Controllers> controllers,
|
2021-02-21 07:28:37 +00:00
|
|
|
EditorData data);
|
2021-02-05 05:44:04 +00:00
|
|
|
|
2021-02-07 23:10:30 +00:00
|
|
|
void applyModifications(PhotoModifications modifications);
|
2021-03-14 09:39:55 +00:00
|
|
|
void applyMode(const PhotoEditorMode &mode);
|
2021-02-16 03:45:05 +00:00
|
|
|
void applyBrush(const Brush &brush);
|
2021-02-13 04:29:31 +00:00
|
|
|
void save(PhotoModifications &modifications);
|
2021-02-07 23:10:30 +00:00
|
|
|
|
2021-05-04 22:38:55 +00:00
|
|
|
bool handleKeyPress(not_null<QKeyEvent*> e) const;
|
|
|
|
|
2021-05-06 21:47:49 +00:00
|
|
|
void setupDragArea();
|
|
|
|
|
2022-12-22 12:41:17 +00:00
|
|
|
[[nodiscard]] rpl::producer<QRect> innerRect() const {
|
|
|
|
return _innerRect.value();
|
|
|
|
}
|
|
|
|
|
2021-02-05 05:44:04 +00:00
|
|
|
private:
|
|
|
|
|
2021-02-20 04:27:10 +00:00
|
|
|
const QSize _photoSize;
|
2021-02-13 04:29:31 +00:00
|
|
|
const base::unique_qptr<Paint> _paint;
|
2021-02-08 07:01:15 +00:00
|
|
|
const base::unique_qptr<Crop> _crop;
|
2021-02-20 04:27:10 +00:00
|
|
|
const std::shared_ptr<Image> _photo;
|
2021-02-08 07:01:15 +00:00
|
|
|
|
2022-12-22 12:41:17 +00:00
|
|
|
rpl::variable<QRect> _innerRect;
|
2021-02-07 23:10:30 +00:00
|
|
|
rpl::variable<PhotoModifications> _modifications;
|
2021-05-04 22:38:55 +00:00
|
|
|
rpl::event_stream<int> _keyPresses;
|
2021-02-07 23:10:30 +00:00
|
|
|
|
2021-02-05 07:08:20 +00:00
|
|
|
QRect _imageRect;
|
2021-07-06 21:54:56 +00:00
|
|
|
QTransform _imageMatrix;
|
2021-02-13 04:29:31 +00:00
|
|
|
PhotoEditorMode _mode;
|
2021-02-05 07:08:20 +00:00
|
|
|
|
2021-02-05 05:44:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Editor
|