follow_slide_wrap.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include "ui/wrap/follow_slide_wrap.h"
  8. #include "styles/style_basic.h"
  9. namespace Ui {
  10. FollowSlideWrap<RpWidget>::FollowSlideWrap(
  11. QWidget *parent,
  12. object_ptr<RpWidget> &&child)
  13. : Parent(parent, std::move(child))
  14. , _duration(st::slideWrapDuration) {
  15. if (const auto weak = wrapped()) {
  16. wrappedSizeUpdated(weak->size());
  17. }
  18. }
  19. FollowSlideWrap<RpWidget> *FollowSlideWrap<RpWidget>::setDuration(
  20. crl::time duration) {
  21. _duration = duration;
  22. return this;
  23. }
  24. int FollowSlideWrap<RpWidget>::naturalWidth() const {
  25. return -1;
  26. }
  27. void FollowSlideWrap<RpWidget>::wrappedSizeUpdated(QSize size) {
  28. updateWrappedPosition(size.height());
  29. }
  30. void FollowSlideWrap<RpWidget>::updateWrappedPosition(int forHeight) {
  31. _animation.stop();
  32. _animation.start(
  33. [=](float64 value) { resize(width(), value); },
  34. height(),
  35. forHeight,
  36. _duration);
  37. }
  38. } // namespace Ui