fixup! Fix for Geolocation webTCT failures
[platform/framework/web/chromium-efl.git] / ash / display / display_alignment_indicator.h
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ASH_DISPLAY_DISPLAY_ALIGNMENT_INDICATOR_H_
6 #define ASH_DISPLAY_DISPLAY_ALIGNMENT_INDICATOR_H_
7
8 #include <memory>
9
10 #include "ash/ash_export.h"
11 #include "base/memory/raw_ptr.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/views/widget/widget.h"
14
15 namespace display {
16 class Display;
17 }  // namespace display
18
19 namespace ash {
20
21 class IndicatorHighlightView;
22 class IndicatorPillView;
23
24 // DisplayAlignmentIndicator is a container for indicator highlighting a shared
25 // edge between two displays and a pill that contains an arrow and target
26 // display's name.
27 class ASH_EXPORT DisplayAlignmentIndicator {
28  public:
29   // Construct and show indicator highlight without a pill.
30   // |src_display| is the display that the indicator is shown in.
31   // |bounds| is the position and size of the 1px thick shared edge between
32   // |src_display| and target display.
33   static std::unique_ptr<DisplayAlignmentIndicator> Create(
34       const display::Display& src_display,
35       const gfx::Rect& bounds);
36
37   // Construct and show indicator highlight with a pill.
38   // |src_display| is the display that the indicator is shown in.
39   // |bounds| is the position and size of the 1px thick shared edge between
40   // |src_display| and target display. |target_name| is the name of the adjacent
41   // display that is displayed in the pill.
42   static std::unique_ptr<DisplayAlignmentIndicator> CreateWithPill(
43       const display::Display& src_display,
44       const gfx::Rect& bounds,
45       const std::string& target_name);
46
47   DisplayAlignmentIndicator(const DisplayAlignmentIndicator&) = delete;
48   DisplayAlignmentIndicator& operator=(const DisplayAlignmentIndicator&) =
49       delete;
50   ~DisplayAlignmentIndicator();
51
52   int64_t display_id() const { return display_id_; }
53
54   // Shows/Hides the indicator.
55   void Show();
56   void Hide();
57
58   // Updates the position of the indicator according to |bounds|. Used to move
59   // around preview indicators during dragging. The indicator must NOT have a
60   // pill.
61   void Update(const display::Display& display, gfx::Rect bounds);
62
63  private:
64   friend class DisplayAlignmentIndicatorTest;
65   friend class DisplayAlignmentControllerTest;
66
67   // Pill does not render if |target_name| is an empty string.
68   DisplayAlignmentIndicator(const display::Display& src_display,
69                             const gfx::Rect& bounds,
70                             const std::string& target_name);
71
72   // The ID of the display that the indicator is shown on.
73   const int64_t display_id_;
74
75   // View and Widget for showing the blue indicator highlights on the edge of
76   // the display.
77   raw_ptr<IndicatorHighlightView, DanglingUntriaged | ExperimentalAsh>
78       indicator_view_ = nullptr;  // NOT OWNED
79   views::Widget indicator_widget_;
80
81   // View and Widget for showing a pill with name of the neighboring display and
82   // an arrow pointing towards it. May not be initialized if ctor without
83   // |target_name| is used (for preview indicator).
84   raw_ptr<IndicatorPillView, DanglingUntriaged | ExperimentalAsh> pill_view_ =
85       nullptr;  // NOT OWNED
86   std::unique_ptr<views::Widget> pill_widget_;
87 };
88
89 }  // namespace ash
90
91 #endif  // ASH_DISPLAY_DISPLAY_ALIGNMENT_INDICATOR_H_