photo_editor.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "ui/rp_widget.h"
  9. #include "ui/image/image.h"
  10. #include "base/unique_qptr.h"
  11. #include "editor/photo_editor_common.h"
  12. #include "editor/photo_editor_inner_common.h"
  13. namespace Ui {
  14. class LayerWidget;
  15. class Show;
  16. } // namespace Ui
  17. namespace ChatHelpers {
  18. class Show;
  19. } // namespace ChatHelpers
  20. namespace Window {
  21. class Controller;
  22. } // namespace Window
  23. namespace Editor {
  24. class ColorPicker;
  25. class PhotoEditorContent;
  26. class PhotoEditorControls;
  27. struct Controllers;
  28. class PhotoEditor final : public Ui::RpWidget {
  29. public:
  30. PhotoEditor(
  31. not_null<QWidget*> parent,
  32. not_null<Window::Controller*> controller,
  33. std::shared_ptr<Image> photo,
  34. PhotoModifications modifications,
  35. EditorData data = EditorData());
  36. PhotoEditor(
  37. not_null<QWidget*> parent,
  38. std::shared_ptr<Ui::Show> show,
  39. std::shared_ptr<ChatHelpers::Show> sessionShow,
  40. std::shared_ptr<Image> photo,
  41. PhotoModifications modifications,
  42. EditorData data = EditorData());
  43. void save();
  44. [[nodiscard]] rpl::producer<PhotoModifications> doneRequests() const;
  45. [[nodiscard]] rpl::producer<> cancelRequests() const;
  46. private:
  47. void keyPressEvent(QKeyEvent *e) override;
  48. PhotoModifications _modifications;
  49. const std::shared_ptr<Controllers> _controllers;
  50. base::unique_qptr<PhotoEditorContent> _content;
  51. base::unique_qptr<PhotoEditorControls> _controls;
  52. const std::unique_ptr<ColorPicker> _colorPicker;
  53. rpl::variable<PhotoEditorMode> _mode = PhotoEditorMode{
  54. .mode = PhotoEditorMode::Mode::Transform,
  55. .action = PhotoEditorMode::Action::None,
  56. };
  57. rpl::event_stream<PhotoModifications> _done;
  58. rpl::event_stream<> _cancel;
  59. };
  60. void InitEditorLayer(
  61. not_null<Ui::LayerWidget*> layer,
  62. not_null<PhotoEditor*> editor,
  63. Fn<void(PhotoModifications)> doneCallback);
  64. } // namespace Editor