editor_layer_widget.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/layers/layer_widget.h"
  9. #include "ui/image/image.h"
  10. #include "editor/photo_editor_common.h"
  11. #include "base/unique_qptr.h"
  12. #include "base/timer.h"
  13. enum class ImageRoundRadius;
  14. namespace Window {
  15. class Controller;
  16. class SessionController;
  17. } // namespace Window
  18. namespace Editor {
  19. class LayerWidget final : public Ui::LayerWidget {
  20. public:
  21. LayerWidget(
  22. not_null<QWidget*> parent,
  23. base::unique_qptr<Ui::RpWidget> content);
  24. void parentResized() override;
  25. bool closeByOutsideClick() const override;
  26. private:
  27. bool eventHook(QEvent *e) override;
  28. void keyPressEvent(QKeyEvent *e) override;
  29. int resizeGetHeight(int newWidth) override;
  30. void start();
  31. void cacheBackground();
  32. void checkBackgroundStale();
  33. void checkCacheBackground();
  34. [[nodiscard]] QImage renderBackground();
  35. void backgroundReady(QImage background, bool night);
  36. void startBackgroundFade();
  37. const base::unique_qptr<Ui::RpWidget> _content;
  38. QImage _backgroundBack;
  39. QImage _background;
  40. QImage _backgroundNext;
  41. Ui::Animations::Simple _backgroundFade;
  42. base::Timer _backgroundTimer;
  43. crl::time _lastAreaChangeTime = 0;
  44. bool _backgroundCaching = false;
  45. bool _backgroundNight = false;
  46. };
  47. } // namespace Editor