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"
|
2022-12-14 08:20:01 +00:00
|
|
|
#include "ui/image/image.h"
|
2021-02-05 07:08:20 +00:00
|
|
|
#include "base/unique_qptr.h"
|
2021-02-20 04:27:10 +00:00
|
|
|
#include "editor/photo_editor_common.h"
|
2021-07-07 17:51:13 +00:00
|
|
|
#include "editor/photo_editor_inner_common.h"
|
2022-12-14 08:20:01 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class LayerWidget;
|
2023-05-18 13:46:24 +00:00
|
|
|
class Show;
|
2022-12-14 08:20:01 +00:00
|
|
|
} // namespace Ui
|
2021-02-05 07:08:20 +00:00
|
|
|
|
2023-05-18 13:46:24 +00:00
|
|
|
namespace ChatHelpers {
|
|
|
|
class Show;
|
|
|
|
} // namespace ChatHelpers
|
|
|
|
|
2021-02-23 10:34:12 +00:00
|
|
|
namespace Window {
|
|
|
|
class Controller;
|
|
|
|
} // namespace Window
|
|
|
|
|
2021-02-05 05:44:04 +00:00
|
|
|
namespace Editor {
|
|
|
|
|
2021-02-16 03:45:05 +00:00
|
|
|
class ColorPicker;
|
2021-02-05 05:44:04 +00:00
|
|
|
class PhotoEditorContent;
|
|
|
|
class PhotoEditorControls;
|
2021-02-23 10:34:12 +00:00
|
|
|
struct Controllers;
|
2021-02-05 05:44:04 +00:00
|
|
|
|
|
|
|
class PhotoEditor final : public Ui::RpWidget {
|
|
|
|
public:
|
|
|
|
PhotoEditor(
|
2022-12-14 08:20:01 +00:00
|
|
|
not_null<QWidget*> parent,
|
2021-02-23 10:34:12 +00:00
|
|
|
not_null<Window::Controller*> controller,
|
2021-02-20 04:27:10 +00:00
|
|
|
std::shared_ptr<Image> photo,
|
2021-02-21 07:28:37 +00:00
|
|
|
PhotoModifications modifications,
|
|
|
|
EditorData data = EditorData());
|
2023-05-18 13:46:24 +00:00
|
|
|
PhotoEditor(
|
|
|
|
not_null<QWidget*> parent,
|
|
|
|
std::shared_ptr<Ui::Show> show,
|
|
|
|
std::shared_ptr<ChatHelpers::Show> sessionShow,
|
|
|
|
std::shared_ptr<Image> photo,
|
|
|
|
PhotoModifications modifications,
|
|
|
|
EditorData data = EditorData());
|
2021-02-05 05:44:04 +00:00
|
|
|
|
2021-02-08 03:13:40 +00:00
|
|
|
void save();
|
2022-12-14 08:20:01 +00:00
|
|
|
[[nodiscard]] rpl::producer<PhotoModifications> doneRequests() const;
|
|
|
|
[[nodiscard]] rpl::producer<> cancelRequests() const;
|
2021-05-04 22:38:55 +00:00
|
|
|
|
2021-02-05 05:44:04 +00:00
|
|
|
private:
|
2022-12-14 08:20:01 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2021-02-05 05:44:04 +00:00
|
|
|
|
2021-02-07 23:10:30 +00:00
|
|
|
PhotoModifications _modifications;
|
|
|
|
|
2021-02-23 10:34:12 +00:00
|
|
|
const std::shared_ptr<Controllers> _controllers;
|
2021-03-14 09:42:18 +00:00
|
|
|
|
2021-02-05 07:08:20 +00:00
|
|
|
base::unique_qptr<PhotoEditorContent> _content;
|
|
|
|
base::unique_qptr<PhotoEditorControls> _controls;
|
2021-02-16 03:45:05 +00:00
|
|
|
const std::unique_ptr<ColorPicker> _colorPicker;
|
2021-02-05 07:08:20 +00:00
|
|
|
|
2021-03-14 09:39:55 +00:00
|
|
|
rpl::variable<PhotoEditorMode> _mode = PhotoEditorMode{
|
|
|
|
.mode = PhotoEditorMode::Mode::Transform,
|
|
|
|
.action = PhotoEditorMode::Action::None,
|
|
|
|
};
|
2021-02-08 03:13:40 +00:00
|
|
|
rpl::event_stream<PhotoModifications> _done;
|
2021-02-18 00:06:44 +00:00
|
|
|
rpl::event_stream<> _cancel;
|
2021-02-08 03:13:40 +00:00
|
|
|
|
2021-02-05 05:44:04 +00:00
|
|
|
};
|
|
|
|
|
2022-12-14 08:20:01 +00:00
|
|
|
void InitEditorLayer(
|
|
|
|
not_null<Ui::LayerWidget*> layer,
|
|
|
|
not_null<PhotoEditor*> editor,
|
|
|
|
Fn<void(PhotoModifications)> doneCallback);
|
|
|
|
|
2021-02-05 05:44:04 +00:00
|
|
|
} // namespace Editor
|