editor_paint.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "editor/photo_editor_common.h"
  10. #include "editor/photo_editor_inner_common.h"
  11. #include "editor/scene/scene_item_base.h"
  12. class QGraphicsItem;
  13. class QGraphicsView;
  14. namespace Editor {
  15. struct Controllers;
  16. class Scene;
  17. // Paint control.
  18. class Paint final : public Ui::RpWidget {
  19. public:
  20. Paint(
  21. not_null<Ui::RpWidget*> parent,
  22. PhotoModifications &modifications,
  23. const QSize &imageSize,
  24. std::shared_ptr<Controllers> controllers);
  25. [[nodiscard]] std::shared_ptr<Scene> saveScene() const;
  26. void restoreScene();
  27. void applyTransform(QRect geometry, int angle, bool flipped);
  28. void applyBrush(const Brush &brush);
  29. void cancel();
  30. void keepResult();
  31. void updateUndoState();
  32. void handleMimeData(const QMimeData *data);
  33. private:
  34. struct SavedItem {
  35. std::shared_ptr<QGraphicsItem> item;
  36. bool undid = false;
  37. };
  38. ItemBase::Data itemBaseData() const;
  39. void clearRedoList();
  40. const std::shared_ptr<Controllers> _controllers;
  41. const std::shared_ptr<Scene> _scene;
  42. const base::unique_qptr<QGraphicsView> _view;
  43. const QSize _imageSize;
  44. struct {
  45. int angle = 0;
  46. bool flipped = false;
  47. float64 zoom = 0.;
  48. } _transform;
  49. rpl::variable<bool> _hasUndo = true;
  50. rpl::variable<bool> _hasRedo = true;
  51. };
  52. } // namespace Editor