toast_widget.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #pragma once
  8. #include "ui/toast/toast.h"
  9. #include "ui/text/text.h"
  10. #include "ui/rp_widget.h"
  11. #include "ui/round_rect.h"
  12. namespace Ui::Toast::internal {
  13. class Widget final : public RpWidget {
  14. public:
  15. Widget(QWidget *parent, Config &&config);
  16. // shownLevel=1 completely visible, shownLevel=0 completely invisible
  17. void setShownLevel(float64 shownLevel);
  18. void parentResized();
  19. private:
  20. void paintEvent(QPaintEvent *e) override;
  21. void updateGeometry();
  22. void paintToProxy();
  23. void disableChildrenPaintOnce();
  24. void toggleChildrenPaint(bool enable);
  25. void scheduleChildrenPaintRestore();
  26. const not_null<const style::Toast*> _st;
  27. RoundRect _roundRect;
  28. RectPart _attach = RectPart::None;
  29. float64 _shownLevel = 0;
  30. QImage _shownProxy;
  31. object_ptr<RpWidget> _content;
  32. rpl::variable<QMargins> _padding;
  33. Fn<void(float64)> _updateShownGeometry;
  34. bool _childrenPaintDisabled : 1 = false;
  35. bool _childrenPaintRestoreScheduled : 1 = false;
  36. bool _adaptive : 1 = false;
  37. };
  38. } // namespace Ui::Toast::internal