| 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/common/material_design/material_design_controller.h" |    7 #include "ash/common/material_design/material_design_controller.h" | 
|    8 #include "ash/common/shelf/wm_shelf_util.h" |    8 #include "ash/common/shelf/wm_shelf_util.h" | 
|    9 #include "ash/common/shell_window_ids.h" |    9 #include "ash/common/shell_window_ids.h" | 
|   10 #include "ash/common/system/tray/tray_constants.h" |   10 #include "ash/common/system/tray/tray_constants.h" | 
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  205 void TrayBackgroundView::TrayContainer::ChildVisibilityChanged(View* child) { |  205 void TrayBackgroundView::TrayContainer::ChildVisibilityChanged(View* child) { | 
|  206   PreferredSizeChanged(); |  206   PreferredSizeChanged(); | 
|  207 } |  207 } | 
|  208  |  208  | 
|  209 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( |  209 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( | 
|  210     const ViewHierarchyChangedDetails& details) { |  210     const ViewHierarchyChangedDetails& details) { | 
|  211   if (details.parent == this) |  211   if (details.parent == this) | 
|  212     PreferredSizeChanged(); |  212     PreferredSizeChanged(); | 
|  213 } |  213 } | 
|  214  |  214  | 
 |  215 // TODO(tdanderson): Adjust TrayContainer borders according to the material | 
 |  216 // design specs. See crbug.com/617295. | 
|  215 void TrayBackgroundView::TrayContainer::UpdateLayout() { |  217 void TrayBackgroundView::TrayContainer::UpdateLayout() { | 
|  216   // Adjust the size of status tray dark background by adding additional |  218   // Adjust the size of status tray dark background by adding additional | 
|  217   // empty border. |  219   // empty border. | 
|  218   if (IsHorizontalAlignment(alignment_)) { |  220   views::BoxLayout::Orientation orientation = | 
|  219     SetBorder(views::Border::CreateEmptyBorder( |  221       IsHorizontalAlignment(alignment_) ? views::BoxLayout::kHorizontal | 
|  220         kPaddingFromEdgeOfShelf, |  222                                         : views::BoxLayout::kVertical; | 
|  221         kPaddingFromEdgeOfShelf, |  223   SetBorder(views::Border::CreateEmptyBorder( | 
|  222         kPaddingFromEdgeOfShelf, |  224       kAdjustBackgroundPadding, kAdjustBackgroundPadding, | 
|  223         kPaddingFromEdgeOfShelf)); |  225       kAdjustBackgroundPadding, kAdjustBackgroundPadding)); | 
|  224  |  226  | 
|  225     views::BoxLayout* layout = |  227   views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0); | 
|  226         new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |  228   layout->SetDefaultFlex(1); | 
|  227     layout->SetDefaultFlex(1); |  229   views::View::SetLayoutManager(layout); | 
|  228     views::View::SetLayoutManager(layout); |  | 
|  229   } else { |  | 
|  230     SetBorder(views::Border::CreateEmptyBorder( |  | 
|  231         kPaddingFromEdgeOfShelf, |  | 
|  232         kPaddingFromEdgeOfShelf, |  | 
|  233         kPaddingFromEdgeOfShelf, |  | 
|  234         kPaddingFromEdgeOfShelf)); |  | 
|  235  |  | 
|  236     views::BoxLayout* layout = |  | 
|  237         new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); |  | 
|  238     layout->SetDefaultFlex(1); |  | 
|  239     views::View::SetLayoutManager(layout); |  | 
|  240   } |  | 
|  241   PreferredSizeChanged(); |  230   PreferredSizeChanged(); | 
|  242 } |  231 } | 
|  243  |  232  | 
|  244 //////////////////////////////////////////////////////////////////////////////// |  233 //////////////////////////////////////////////////////////////////////////////// | 
|  245 // TrayBackgroundView |  234 // TrayBackgroundView | 
|  246  |  235  | 
|  247 TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget) |  236 TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget) | 
|  248     : status_area_widget_(status_area_widget), |  237     : status_area_widget_(status_area_widget), | 
|  249       tray_container_(NULL), |  238       tray_container_(NULL), | 
|  250       shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), |  239       shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  264 } |  253 } | 
|  265  |  254  | 
|  266 TrayBackgroundView::~TrayBackgroundView() { |  255 TrayBackgroundView::~TrayBackgroundView() { | 
|  267   if (GetWidget()) |  256   if (GetWidget()) | 
|  268     GetWidget()->RemoveObserver(widget_observer_.get()); |  257     GetWidget()->RemoveObserver(widget_observer_.get()); | 
|  269   StopObservingImplicitAnimations(); |  258   StopObservingImplicitAnimations(); | 
|  270 } |  259 } | 
|  271  |  260  | 
|  272 void TrayBackgroundView::Initialize() { |  261 void TrayBackgroundView::Initialize() { | 
|  273   GetWidget()->AddObserver(widget_observer_.get()); |  262   GetWidget()->AddObserver(widget_observer_.get()); | 
|  274   SetTrayBorder(); |  | 
|  275 } |  263 } | 
|  276  |  264  | 
|  277 // static |  265 // static | 
|  278 void TrayBackgroundView::InitializeBubbleAnimations( |  266 void TrayBackgroundView::InitializeBubbleAnimations( | 
|  279     views::Widget* bubble_widget) { |  267     views::Widget* bubble_widget) { | 
|  280   aura::Window* window = bubble_widget->GetNativeWindow(); |  268   aura::Window* window = bubble_widget->GetNativeWindow(); | 
|  281   ::wm::SetWindowVisibilityAnimationType( |  269   ::wm::SetWindowVisibilityAnimationType( | 
|  282       window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |  270       window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | 
|  283   ::wm::SetWindowVisibilityAnimationTransition(window, ::wm::ANIMATE_HIDE); |  271   ::wm::SetWindowVisibilityAnimationTransition(window, ::wm::ANIMATE_HIDE); | 
|  284   ::wm::SetWindowVisibilityAnimationDuration( |  272   ::wm::SetWindowVisibilityAnimationDuration( | 
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  393   background_ = new TrayBackground(this); |  381   background_ = new TrayBackground(this); | 
|  394   tray_container_->set_background(background_); |  382   tray_container_->set_background(background_); | 
|  395 } |  383 } | 
|  396  |  384  | 
|  397 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { |  385 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { | 
|  398   return status_area_widget()->shelf_widget()->shelf_layout_manager(); |  386   return status_area_widget()->shelf_widget()->shelf_layout_manager(); | 
|  399 } |  387 } | 
|  400  |  388  | 
|  401 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |  389 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 
|  402   shelf_alignment_ = alignment; |  390   shelf_alignment_ = alignment; | 
|  403   SetTrayBorder(); |  | 
|  404   tray_container_->SetAlignment(alignment); |  391   tray_container_->SetAlignment(alignment); | 
|  405 } |  392 } | 
|  406  |  393  | 
|  407 void TrayBackgroundView::SetTrayBorder() { |  | 
|  408   views::View* parent = status_area_widget_->status_area_widget_delegate(); |  | 
|  409   // Tray views are laid out right-to-left or bottom-to-top |  | 
|  410   bool on_edge = (this == parent->child_at(0)); |  | 
|  411   int left_edge, top_edge, right_edge, bottom_edge; |  | 
|  412   if (IsHorizontalAlignment(shelf_alignment())) { |  | 
|  413     top_edge = ShelfLayoutManager::kShelfItemInset; |  | 
|  414     left_edge = 0; |  | 
|  415     bottom_edge = kShelfSize - |  | 
|  416         ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; |  | 
|  417     right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |  | 
|  418   } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { |  | 
|  419     top_edge = 0; |  | 
|  420     left_edge = kShelfSize - |  | 
|  421         ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; |  | 
|  422     bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |  | 
|  423     right_edge = ShelfLayoutManager::kShelfItemInset; |  | 
|  424   } else { // SHELF_ALIGNMENT_RIGHT |  | 
|  425     top_edge = 0; |  | 
|  426     left_edge = ShelfLayoutManager::kShelfItemInset; |  | 
|  427     bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |  | 
|  428     right_edge = kShelfSize - |  | 
|  429         ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; |  | 
|  430   } |  | 
|  431   SetBorder(views::Border::CreateEmptyBorder( |  | 
|  432       top_edge, left_edge, bottom_edge, right_edge)); |  | 
|  433 } |  | 
|  434  |  | 
|  435 void TrayBackgroundView::OnImplicitAnimationsCompleted() { |  394 void TrayBackgroundView::OnImplicitAnimationsCompleted() { | 
|  436   // If there is another animation in the queue, the reverse animation was |  395   // If there is another animation in the queue, the reverse animation was | 
|  437   // triggered before the completion of animating to invisible. Do not turn off |  396   // triggered before the completion of animating to invisible. Do not turn off | 
|  438   // the visibility so that the next animation may render. The value of |  397   // the visibility so that the next animation may render. The value of | 
|  439   // layer()->GetTargetVisibility() can be incorrect if the hide animation was |  398   // layer()->GetTargetVisibility() can be incorrect if the hide animation was | 
|  440   // aborted to schedule an animation to become visible. As the new animation |  399   // aborted to schedule an animation to become visible. As the new animation | 
|  441   // is not yet added to the queue. crbug.com/374236 |  400   // is not yet added to the queue. crbug.com/374236 | 
|  442   if(layer()->GetAnimator()->is_animating() || |  401   if(layer()->GetAnimator()->is_animating() || | 
|  443      layer()->GetTargetVisibility()) |  402      layer()->GetTargetVisibility()) | 
|  444     return; |  403     return; | 
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  567     return; |  526     return; | 
|  568   SchedulePaint(); |  527   SchedulePaint(); | 
|  569 } |  528 } | 
|  570  |  529  | 
|  571 void TrayBackgroundView::UpdateBubbleViewArrow( |  530 void TrayBackgroundView::UpdateBubbleViewArrow( | 
|  572     views::TrayBubbleView* bubble_view) { |  531     views::TrayBubbleView* bubble_view) { | 
|  573   // Nothing to do here. |  532   // Nothing to do here. | 
|  574 } |  533 } | 
|  575  |  534  | 
|  576 }  // namespace ash |  535 }  // namespace ash | 
| OLD | NEW |