pip_window_resizer.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_WM_PIP_PIP_WINDOW_RESIZER_H_
  5. #define ASH_WM_PIP_PIP_WINDOW_RESIZER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/wm/window_resizer.h"
  8. #include "ui/display/display.h"
  9. #include "ui/gfx/geometry/point_f.h"
  10. namespace gfx {
  11. class Rect;
  12. }
  13. namespace ash {
  14. class WindowState;
  15. // Controls resizing for windows with the PIP window state type. This
  16. // includes things like snapping the PIP window to the edges of the work area
  17. // and handling swipe-to-dismiss.
  18. class ASH_EXPORT PipWindowResizer : public WindowResizer {
  19. public:
  20. explicit PipWindowResizer(WindowState* window_state);
  21. PipWindowResizer(const PipWindowResizer&) = delete;
  22. PipWindowResizer& operator=(const PipWindowResizer&) = delete;
  23. ~PipWindowResizer() override;
  24. // WindowResizer:
  25. void Drag(const gfx::PointF& location_in_parent, int event_flags) override;
  26. void CompleteDrag() override;
  27. void RevertDrag() override;
  28. void FlingOrSwipe(ui::GestureEvent* event) override;
  29. private:
  30. WindowState* window_state() { return window_state_; }
  31. gfx::Rect ComputeFlungPosition();
  32. gfx::PointF last_location_in_screen_;
  33. int fling_velocity_x_ = 0;
  34. int fling_velocity_y_ = 0;
  35. float dismiss_fraction_ = 1.f;
  36. bool moved_or_resized_ = false;
  37. bool may_dismiss_horizontally_ = false;
  38. bool may_dismiss_vertically_ = false;
  39. };
  40. } // namespace ash
  41. #endif // ASH_WM_PIP_PIP_WINDOW_RESIZER_H_