split_view_highlight_view.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_SPLITVIEW_SPLIT_VIEW_HIGHLIGHT_VIEW_H_
  5. #define ASH_WM_SPLITVIEW_SPLIT_VIEW_HIGHLIGHT_VIEW_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/wm/splitview/split_view_drag_indicators.h"
  8. #include "ash/wm/splitview/split_view_utils.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. #include "ui/views/view.h"
  11. namespace ash {
  12. // View that is used for displaying and animating the highlights which tell
  13. // users where to drag windows to enter splitview, and previews the space which
  14. // a snapped window will occupy. It is a view consists of one solid color layer
  15. // with rounded corners. If animations are needed, they are performed by
  16. // animating the layer's clip rect.
  17. class ASH_EXPORT SplitViewHighlightView : public views::View {
  18. public:
  19. explicit SplitViewHighlightView(bool is_right_or_bottom);
  20. ~SplitViewHighlightView() override;
  21. SplitViewHighlightView(const SplitViewHighlightView&) = delete;
  22. SplitViewHighlightView& operator=(const SplitViewHighlightView&) = delete;
  23. // views::View:
  24. void OnThemeChanged() override;
  25. // Updates bounds, animating if |animation_type| has a value.
  26. void SetBounds(const gfx::Rect& bounds,
  27. const absl::optional<SplitviewAnimationType>& animation_type);
  28. // Called to update the opacity of the highlights view on transition from
  29. // |previous_window_dragging_state| to |window_dragging_state|. If
  30. // |previews_only|, then there shall be no visible drag indicators except for
  31. // snap previews. The highlights are white if |can_dragged_window_be_snapped|,
  32. // black otherwise.
  33. void OnWindowDraggingStateChanged(
  34. SplitViewDragIndicators::WindowDraggingState window_dragging_state,
  35. SplitViewDragIndicators::WindowDraggingState
  36. previous_window_dragging_state,
  37. bool previews_only,
  38. bool can_dragged_window_be_snapped);
  39. private:
  40. // Determines whether this particular highlight view is located at the right
  41. // or bottom of the screen. These highlights animate in the opposite direction
  42. // as left or top highlights, so when we use |SetBounds()| extra calucations
  43. // have to be done to ensure the animation is correct.
  44. const bool is_right_or_bottom_;
  45. };
  46. } // namespace ash
  47. #endif // ASH_WM_SPLITVIEW_SPLIT_VIEW_HIGHLIGHT_VIEW_H_