OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/shelf/overflow_bubble_view.h" | 5 #include "ash/shelf/overflow_bubble_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
11 #include "ash/shelf/shelf_constants.h" | 11 #include "ash/shelf/shelf_constants.h" |
12 #include "ash/shelf/wm_shelf.h" | 12 #include "ash/shelf/wm_shelf.h" |
| 13 #include "ash/shell.h" |
13 #include "ash/wm_window.h" | 14 #include "ash/wm_window.h" |
14 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
15 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
16 #include "ui/display/screen.h" | 17 #include "ui/display/screen.h" |
17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
18 #include "ui/gfx/geometry/insets.h" | 19 #include "ui/gfx/geometry/insets.h" |
19 #include "ui/views/bubble/bubble_frame_view.h" | 20 #include "ui/views/bubble/bubble_frame_view.h" |
20 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
21 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
22 | 23 |
23 namespace ash { | 24 namespace ash { |
24 namespace { | 25 namespace { |
25 | 26 |
26 // Padding at the two ends of the bubble. | 27 // Padding at the two ends of the bubble. |
27 const int kEndPadding = 16; | 28 const int kEndPadding = 16; |
28 | 29 |
29 // Distance between overflow bubble and the main shelf. | 30 // Distance between overflow bubble and the main shelf. |
30 const int kDistanceToMainShelf = 4; | 31 const int kDistanceToMainShelf = 4; |
31 | 32 |
32 constexpr SkColor kBackgroundColor = | |
33 SkColorSetA(kShelfDefaultBaseColor, kShelfTranslucentAlpha); | |
34 | |
35 } // namespace | 33 } // namespace |
36 | 34 |
37 OverflowBubbleView::OverflowBubbleView(WmShelf* wm_shelf) | 35 OverflowBubbleView::OverflowBubbleView(WmShelf* wm_shelf) |
38 : wm_shelf_(wm_shelf), shelf_view_(nullptr) { | 36 : wm_shelf_(wm_shelf), |
| 37 shelf_view_(nullptr), |
| 38 background_animator_(SHELF_BACKGROUND_OVERLAP, |
| 39 // Don't pass the WmShelf so the translucent color is |
| 40 // always used. |
| 41 nullptr, |
| 42 Shell::Get()->wallpaper_controller()) { |
39 DCHECK(wm_shelf_); | 43 DCHECK(wm_shelf_); |
| 44 |
| 45 background_animator_.AddObserver(this); |
40 } | 46 } |
41 | 47 |
42 OverflowBubbleView::~OverflowBubbleView() {} | 48 OverflowBubbleView::~OverflowBubbleView() { |
| 49 background_animator_.RemoveObserver(this); |
| 50 } |
43 | 51 |
44 void OverflowBubbleView::InitOverflowBubble(views::View* anchor, | 52 void OverflowBubbleView::InitOverflowBubble(views::View* anchor, |
45 views::View* shelf_view) { | 53 views::View* shelf_view) { |
46 shelf_view_ = shelf_view; | 54 shelf_view_ = shelf_view; |
47 | 55 |
48 SetAnchorView(anchor); | 56 SetAnchorView(anchor); |
49 set_arrow(views::BubbleBorder::NONE); | 57 set_arrow(views::BubbleBorder::NONE); |
50 set_background(nullptr); | 58 set_background(nullptr); |
51 set_color(kBackgroundColor); | |
52 if (wm_shelf_->IsHorizontalAlignment()) | 59 if (wm_shelf_->IsHorizontalAlignment()) |
53 set_margins(gfx::Insets(0, kEndPadding)); | 60 set_margins(gfx::Insets(0, kEndPadding)); |
54 else | 61 else |
55 set_margins(gfx::Insets(kEndPadding, 0)); | 62 set_margins(gfx::Insets(kEndPadding, 0)); |
56 set_shadow(views::BubbleBorder::NO_ASSETS); | 63 set_shadow(views::BubbleBorder::NO_ASSETS); |
57 // Overflow bubble should not get focus. If it get focus when it is shown, | 64 // Overflow bubble should not get focus. If it get focus when it is shown, |
58 // active state item is changed to running state. | 65 // active state item is changed to running state. |
59 set_can_activate(false); | 66 set_can_activate(false); |
60 | 67 |
61 // Makes bubble view has a layer and clip its children layers. | 68 // Makes bubble view has a layer and clip its children layers. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bounds.set_x(anchor_rect.right() + kDistanceToMainShelf); | 197 bounds.set_x(anchor_rect.right() + kDistanceToMainShelf); |
191 else | 198 else |
192 bounds.set_x(anchor_rect.x() - kDistanceToMainShelf - content_size.width()); | 199 bounds.set_x(anchor_rect.x() - kDistanceToMainShelf - content_size.width()); |
193 if (bounds.y() < monitor_rect.y()) | 200 if (bounds.y() < monitor_rect.y()) |
194 bounds.Offset(0, monitor_rect.y() - bounds.y()); | 201 bounds.Offset(0, monitor_rect.y() - bounds.y()); |
195 else if (bounds.bottom() > monitor_rect.bottom()) | 202 else if (bounds.bottom() > monitor_rect.bottom()) |
196 bounds.Offset(monitor_rect.bottom() - bounds.bottom(), 0); | 203 bounds.Offset(monitor_rect.bottom() - bounds.bottom(), 0); |
197 return bounds; | 204 return bounds; |
198 } | 205 } |
199 | 206 |
| 207 void OverflowBubbleView::UpdateShelfBackground(SkColor color) { |
| 208 set_color(color); |
| 209 } |
| 210 |
200 } // namespace ash | 211 } // namespace ash |
OLD | NEW |