OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/system/tray/tray_background_view.h" | 5 #include "ash/system/tray/tray_background_view.h" |
6 | 6 |
7 #include "ash/launcher/background_animator.h" | 7 #include "ash/launcher/background_animator.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
11 #include "ash/system/status_area_widget.h" | 11 #include "ash/system/status_area_widget.h" |
12 #include "ash/system/status_area_widget_delegate.h" | 12 #include "ash/system/status_area_widget_delegate.h" |
13 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
| 14 #include "ash/wm/property_util.h" |
| 15 #include "ash/wm/shelf_layout_manager.h" |
14 #include "ash/wm/window_animations.h" | 16 #include "ash/wm/window_animations.h" |
15 #include "ui/aura/event_filter.h" | 17 #include "ui/aura/event_filter.h" |
| 18 #include "ui/aura/root_window.h" |
16 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
17 #include "ui/base/accessibility/accessible_view_state.h" | 20 #include "ui/base/accessibility/accessible_view_state.h" |
18 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
19 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
20 #include "ui/gfx/skia_util.h" | 23 #include "ui/gfx/skia_util.h" |
21 #include "ui/views/background.h" | 24 #include "ui/views/background.h" |
22 #include "ui/views/layout/box_layout.h" | 25 #include "ui/views/layout/box_layout.h" |
23 | 26 |
24 namespace { | 27 namespace { |
25 | 28 |
26 const SkColor kTrayBackgroundAlpha = 100; | 29 const SkColor kTrayBackgroundAlpha = 100; |
27 const SkColor kTrayBackgroundHoverAlpha = 150; | 30 const SkColor kTrayBackgroundHoverAlpha = 150; |
28 | 31 |
29 // Adjust the size of TrayContainer with additional padding. | 32 // Adjust the size of TrayContainer with additional padding. |
30 const int kTrayContainerVerticalPaddingBottomAlignment = 1; | 33 const int kTrayContainerVerticalPaddingBottomAlignment = 1; |
31 const int kTrayContainerHorizontalPaddingBottomAlignment = 1; | 34 const int kTrayContainerHorizontalPaddingBottomAlignment = 1; |
32 const int kTrayContainerVerticalPaddingVerticalAlignment = 1; | 35 const int kTrayContainerVerticalPaddingVerticalAlignment = 1; |
33 const int kTrayContainerHorizontalPaddingVerticalAlignment = 1; | 36 const int kTrayContainerHorizontalPaddingVerticalAlignment = 1; |
34 | 37 |
35 const int kAnimationDurationForPopupMS = 200; | 38 const int kAnimationDurationForPopupMS = 200; |
36 | 39 |
37 } // namespace | 40 } // namespace |
38 | 41 |
39 using message_center::TrayBubbleView; | 42 using views::TrayBubbleView; |
40 | 43 |
41 namespace ash { | 44 namespace ash { |
42 namespace internal { | 45 namespace internal { |
43 | 46 |
44 // Used to track when the anchor widget changes position on screen so that the | 47 // Used to track when the anchor widget changes position on screen so that the |
45 // bubble position can be updated. | 48 // bubble position can be updated. |
46 class TrayBackgroundView::TrayWidgetObserver : public views::WidgetObserver { | 49 class TrayBackgroundView::TrayWidgetObserver : public views::WidgetObserver { |
47 public: | 50 public: |
48 explicit TrayWidgetObserver(TrayBackgroundView* host) | 51 explicit TrayWidgetObserver(TrayBackgroundView* host) |
49 : host_(host) { | 52 : host_(host) { |
50 } | 53 } |
51 | 54 |
52 virtual void OnWidgetMoved(views::Widget* widget) OVERRIDE { | 55 virtual void OnWidgetMoved(views::Widget* widget) OVERRIDE { |
53 host_->AnchorUpdated(); | 56 host_->AnchorUpdated(); |
54 } | 57 } |
55 | 58 |
| 59 virtual void OnWidgetVisibilityChanged(views::Widget* widget, |
| 60 bool visible) OVERRIDE { |
| 61 host_->AnchorUpdated(); |
| 62 } |
| 63 |
56 private: | 64 private: |
57 TrayBackgroundView* host_; | 65 TrayBackgroundView* host_; |
58 | 66 |
59 DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver); | 67 DISALLOW_COPY_AND_ASSIGN(TrayWidgetObserver); |
60 }; | 68 }; |
61 | 69 |
62 class TrayBackground : public views::Background { | 70 class TrayBackground : public views::Background { |
63 public: | 71 public: |
64 TrayBackground() : alpha_(kTrayBackgroundAlpha) {} | 72 TrayBackground() : alpha_(kTrayBackgroundAlpha) {} |
65 virtual ~TrayBackground() {} | 73 virtual ~TrayBackground() {} |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 356 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
349 case SHELF_ALIGNMENT_LEFT: | 357 case SHELF_ALIGNMENT_LEFT: |
350 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; | 358 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; |
351 case SHELF_ALIGNMENT_RIGHT: | 359 case SHELF_ALIGNMENT_RIGHT: |
352 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; | 360 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; |
353 } | 361 } |
354 NOTREACHED(); | 362 NOTREACHED(); |
355 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 363 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
356 } | 364 } |
357 | 365 |
| 366 void TrayBackgroundView::UpdateBubbleViewArrow( |
| 367 views::TrayBubbleView* bubble_view) { |
| 368 aura::RootWindow* root_window = |
| 369 bubble_view->GetWidget()->GetNativeView()->GetRootWindow(); |
| 370 ash::internal::ShelfLayoutManager* shelf = |
| 371 ash::GetRootWindowController(root_window)->shelf(); |
| 372 bubble_view->SetPaintArrow(shelf->IsVisible()); |
| 373 } |
| 374 |
358 } // namespace internal | 375 } // namespace internal |
359 } // namespace ash | 376 } // namespace ash |
OLD | NEW |