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/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( | 185 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( |
186 const ViewHierarchyChangedDetails& details) { | 186 const ViewHierarchyChangedDetails& details) { |
187 if (details.parent == this) | 187 if (details.parent == this) |
188 PreferredSizeChanged(); | 188 PreferredSizeChanged(); |
189 } | 189 } |
190 | 190 |
191 void TrayBackgroundView::TrayContainer::UpdateLayout() { | 191 void TrayBackgroundView::TrayContainer::UpdateLayout() { |
192 // Adjust the size of status tray dark background by adding additional | 192 // Adjust the size of status tray dark background by adding additional |
193 // empty border. | 193 // empty border. |
194 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || | 194 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { |
195 alignment_ == SHELF_ALIGNMENT_TOP) { | |
196 SetBorder(views::Border::CreateEmptyBorder( | 195 SetBorder(views::Border::CreateEmptyBorder( |
197 kPaddingFromEdgeOfShelf, | 196 kPaddingFromEdgeOfShelf, |
198 kPaddingFromEdgeOfShelf, | 197 kPaddingFromEdgeOfShelf, |
199 kPaddingFromEdgeOfShelf, | 198 kPaddingFromEdgeOfShelf, |
200 kPaddingFromEdgeOfShelf)); | 199 kPaddingFromEdgeOfShelf)); |
201 | 200 |
202 views::BoxLayout* layout = | 201 views::BoxLayout* layout = |
203 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 202 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
204 layout->SetDefaultFlex(1); | 203 layout->SetDefaultFlex(1); |
205 views::View::SetLayoutManager(layout); | 204 views::View::SetLayoutManager(layout); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 // This is needed so that OnImplicitAnimationsCompleted() is called even upon | 442 // This is needed so that OnImplicitAnimationsCompleted() is called even upon |
444 // destruction of the animator. This can occure when parallel animations | 443 // destruction of the animator. This can occure when parallel animations |
445 // caused by ScreenRotationAnimator end before the animations of | 444 // caused by ScreenRotationAnimator end before the animations of |
446 // TrayBackgroundView. This allows for a proper update to the visual state of | 445 // TrayBackgroundView. This allows for a proper update to the visual state of |
447 // the view. (crbug.com/476667) | 446 // the view. (crbug.com/476667) |
448 return true; | 447 return true; |
449 } | 448 } |
450 | 449 |
451 void TrayBackgroundView::HideTransformation() { | 450 void TrayBackgroundView::HideTransformation() { |
452 gfx::Transform transform; | 451 gfx::Transform transform; |
453 if (shelf_alignment_ == SHELF_ALIGNMENT_BOTTOM || | 452 if (shelf_alignment_ == SHELF_ALIGNMENT_BOTTOM) |
454 shelf_alignment_ == SHELF_ALIGNMENT_TOP) | |
455 transform.Translate(width(), 0.0f); | 453 transform.Translate(width(), 0.0f); |
456 else | 454 else |
457 transform.Translate(0.0f, height()); | 455 transform.Translate(0.0f, height()); |
458 layer()->SetTransform(transform); | 456 layer()->SetTransform(transform); |
459 } | 457 } |
460 | 458 |
461 void TrayBackgroundView::InitializeBubbleAnimations( | 459 void TrayBackgroundView::InitializeBubbleAnimations( |
462 views::Widget* bubble_widget) { | 460 views::Widget* bubble_widget) { |
463 wm::SetWindowVisibilityAnimationType( | 461 wm::SetWindowVisibilityAnimationType( |
464 bubble_widget->GetNativeWindow(), | 462 bubble_widget->GetNativeWindow(), |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 } | 558 } |
561 | 559 |
562 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { | 560 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { |
563 switch (shelf_alignment_) { | 561 switch (shelf_alignment_) { |
564 case SHELF_ALIGNMENT_BOTTOM: | 562 case SHELF_ALIGNMENT_BOTTOM: |
565 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 563 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
566 case SHELF_ALIGNMENT_LEFT: | 564 case SHELF_ALIGNMENT_LEFT: |
567 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; | 565 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; |
568 case SHELF_ALIGNMENT_RIGHT: | 566 case SHELF_ALIGNMENT_RIGHT: |
569 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; | 567 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; |
570 case SHELF_ALIGNMENT_TOP: | |
571 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; | |
572 } | 568 } |
573 NOTREACHED(); | 569 NOTREACHED(); |
574 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 570 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
575 } | 571 } |
576 | 572 |
577 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { | 573 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { |
578 if (draw_background_as_active_ == visible) | 574 if (draw_background_as_active_ == visible) |
579 return; | 575 return; |
580 draw_background_as_active_ = visible; | 576 draw_background_as_active_ = visible; |
581 if (!background_) | 577 if (!background_) |
582 return; | 578 return; |
583 | 579 |
584 // Do not change gradually, changing color between grey and blue is weird. | 580 // Do not change gradually, changing color between grey and blue is weird. |
585 if (draw_background_as_active_) | 581 if (draw_background_as_active_) |
586 background_->set_color(kTrayBackgroundPressedColor); | 582 background_->set_color(kTrayBackgroundPressedColor); |
587 else if (hovered_) | 583 else if (hovered_) |
588 background_->set_alpha(kTrayBackgroundHoverAlpha); | 584 background_->set_alpha(kTrayBackgroundHoverAlpha); |
589 else | 585 else |
590 background_->set_alpha(kTrayBackgroundAlpha); | 586 background_->set_alpha(kTrayBackgroundAlpha); |
591 SchedulePaint(); | 587 SchedulePaint(); |
592 } | 588 } |
593 | 589 |
594 void TrayBackgroundView::UpdateBubbleViewArrow( | 590 void TrayBackgroundView::UpdateBubbleViewArrow( |
595 views::TrayBubbleView* bubble_view) { | 591 views::TrayBubbleView* bubble_view) { |
596 // Nothing to do here. | 592 // Nothing to do here. |
597 } | 593 } |
598 | 594 |
599 } // namespace ash | 595 } // namespace ash |
OLD | NEW |