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_util.h" |
10 #include "ash/shelf/shelf_widget.h" | 11 #include "ash/shelf/shelf_widget.h" |
11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
12 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.h" |
13 #include "ash/system/status_area_widget.h" | 14 #include "ash/system/status_area_widget.h" |
14 #include "ash/system/status_area_widget_delegate.h" | 15 #include "ash/system/status_area_widget_delegate.h" |
15 #include "ash/system/tray/system_tray.h" | 16 #include "ash/system/tray/system_tray.h" |
16 #include "ash/system/tray/tray_constants.h" | 17 #include "ash/system/tray/tray_constants.h" |
17 #include "ash/system/tray/tray_event_filter.h" | 18 #include "ash/system/tray/tray_event_filter.h" |
18 #include "ash/wm/window_animations.h" | 19 #include "ash/wm/window_animations.h" |
19 #include "base/command_line.h" | 20 #include "base/command_line.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 186 |
186 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( | 187 void TrayBackgroundView::TrayContainer::ViewHierarchyChanged( |
187 const ViewHierarchyChangedDetails& details) { | 188 const ViewHierarchyChangedDetails& details) { |
188 if (details.parent == this) | 189 if (details.parent == this) |
189 PreferredSizeChanged(); | 190 PreferredSizeChanged(); |
190 } | 191 } |
191 | 192 |
192 void TrayBackgroundView::TrayContainer::UpdateLayout() { | 193 void TrayBackgroundView::TrayContainer::UpdateLayout() { |
193 // Adjust the size of status tray dark background by adding additional | 194 // Adjust the size of status tray dark background by adding additional |
194 // empty border. | 195 // empty border. |
195 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { | 196 if (IsHorizontalAlignment(alignment_)) { |
196 SetBorder(views::Border::CreateEmptyBorder( | 197 SetBorder(views::Border::CreateEmptyBorder( |
197 kPaddingFromEdgeOfShelf, | 198 kPaddingFromEdgeOfShelf, |
198 kPaddingFromEdgeOfShelf, | 199 kPaddingFromEdgeOfShelf, |
199 kPaddingFromEdgeOfShelf, | 200 kPaddingFromEdgeOfShelf, |
200 kPaddingFromEdgeOfShelf)); | 201 kPaddingFromEdgeOfShelf)); |
201 | 202 |
202 views::BoxLayout* layout = | 203 views::BoxLayout* layout = |
203 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 204 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
204 layout->SetDefaultFlex(1); | 205 layout->SetDefaultFlex(1); |
205 views::View::SetLayoutManager(layout); | 206 views::View::SetLayoutManager(layout); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 shelf_alignment_ = alignment; | 397 shelf_alignment_ = alignment; |
397 SetTrayBorder(); | 398 SetTrayBorder(); |
398 tray_container_->SetAlignment(alignment); | 399 tray_container_->SetAlignment(alignment); |
399 } | 400 } |
400 | 401 |
401 void TrayBackgroundView::SetTrayBorder() { | 402 void TrayBackgroundView::SetTrayBorder() { |
402 views::View* parent = status_area_widget_->status_area_widget_delegate(); | 403 views::View* parent = status_area_widget_->status_area_widget_delegate(); |
403 // Tray views are laid out right-to-left or bottom-to-top | 404 // Tray views are laid out right-to-left or bottom-to-top |
404 bool on_edge = (this == parent->child_at(0)); | 405 bool on_edge = (this == parent->child_at(0)); |
405 int left_edge, top_edge, right_edge, bottom_edge; | 406 int left_edge, top_edge, right_edge, bottom_edge; |
406 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | 407 if (IsHorizontalAlignment(shelf_alignment())) { |
407 top_edge = ShelfLayoutManager::kShelfItemInset; | 408 top_edge = ShelfLayoutManager::kShelfItemInset; |
408 left_edge = 0; | 409 left_edge = 0; |
409 bottom_edge = kShelfSize - | 410 bottom_edge = kShelfSize - |
410 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; | 411 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; |
411 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 412 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
412 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { | 413 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { |
413 top_edge = 0; | 414 top_edge = 0; |
414 left_edge = kShelfSize - | 415 left_edge = kShelfSize - |
415 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; | 416 ShelfLayoutManager::kShelfItemInset - kShelfItemHeight; |
416 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 417 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
(...skipping 26 matching lines...) Expand all Loading... |
443 // This is needed so that OnImplicitAnimationsCompleted() is called even upon | 444 // This is needed so that OnImplicitAnimationsCompleted() is called even upon |
444 // destruction of the animator. This can occure when parallel animations | 445 // destruction of the animator. This can occure when parallel animations |
445 // caused by ScreenRotationAnimator end before the animations of | 446 // caused by ScreenRotationAnimator end before the animations of |
446 // TrayBackgroundView. This allows for a proper update to the visual state of | 447 // TrayBackgroundView. This allows for a proper update to the visual state of |
447 // the view. (crbug.com/476667) | 448 // the view. (crbug.com/476667) |
448 return true; | 449 return true; |
449 } | 450 } |
450 | 451 |
451 void TrayBackgroundView::HideTransformation() { | 452 void TrayBackgroundView::HideTransformation() { |
452 gfx::Transform transform; | 453 gfx::Transform transform; |
453 if (shelf_alignment_ == SHELF_ALIGNMENT_BOTTOM) | 454 if (IsHorizontalAlignment(shelf_alignment_)) |
454 transform.Translate(width(), 0.0f); | 455 transform.Translate(width(), 0.0f); |
455 else | 456 else |
456 transform.Translate(0.0f, height()); | 457 transform.Translate(0.0f, height()); |
457 layer()->SetTransform(transform); | 458 layer()->SetTransform(transform); |
458 } | 459 } |
459 | 460 |
460 void TrayBackgroundView::InitializeBubbleAnimations( | 461 void TrayBackgroundView::InitializeBubbleAnimations( |
461 views::Widget* bubble_widget) { | 462 views::Widget* bubble_widget) { |
462 wm::SetWindowVisibilityAnimationType( | 463 wm::SetWindowVisibilityAnimationType( |
463 bubble_widget->GetNativeWindow(), | 464 bubble_widget->GetNativeWindow(), |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 kPaddingFromRightEdgeOfScreenBottomAlignment : | 553 kPaddingFromRightEdgeOfScreenBottomAlignment : |
553 rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment, | 554 rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment, |
554 rect.height() - kPaddingFromBottomOfScreenBottomAlignment, | 555 rect.height() - kPaddingFromBottomOfScreenBottomAlignment, |
555 0, 0); | 556 0, 0); |
556 } | 557 } |
557 } | 558 } |
558 return rect; | 559 return rect; |
559 } | 560 } |
560 | 561 |
561 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { | 562 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { |
562 switch (shelf_alignment_) { | 563 if (shelf_alignment_ == SHELF_ALIGNMENT_LEFT) |
563 case SHELF_ALIGNMENT_BOTTOM: | 564 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; |
564 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 565 if (shelf_alignment_ == SHELF_ALIGNMENT_RIGHT) |
565 case SHELF_ALIGNMENT_LEFT: | 566 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; |
566 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; | |
567 case SHELF_ALIGNMENT_RIGHT: | |
568 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; | |
569 } | |
570 NOTREACHED(); | |
571 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 567 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
572 } | 568 } |
573 | 569 |
574 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { | 570 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { |
575 if (draw_background_as_active_ == visible) | 571 if (draw_background_as_active_ == visible) |
576 return; | 572 return; |
577 draw_background_as_active_ = visible; | 573 draw_background_as_active_ = visible; |
578 if (!background_) | 574 if (!background_) |
579 return; | 575 return; |
580 | 576 |
581 // Do not change gradually, changing color between grey and blue is weird. | 577 // Do not change gradually, changing color between grey and blue is weird. |
582 if (draw_background_as_active_) | 578 if (draw_background_as_active_) |
583 background_->set_color(kTrayBackgroundPressedColor); | 579 background_->set_color(kTrayBackgroundPressedColor); |
584 else if (hovered_) | 580 else if (hovered_) |
585 background_->set_alpha(kTrayBackgroundHoverAlpha); | 581 background_->set_alpha(kTrayBackgroundHoverAlpha); |
586 else | 582 else |
587 background_->set_alpha(kTrayBackgroundAlpha); | 583 background_->set_alpha(kTrayBackgroundAlpha); |
588 SchedulePaint(); | 584 SchedulePaint(); |
589 } | 585 } |
590 | 586 |
591 void TrayBackgroundView::UpdateBubbleViewArrow( | 587 void TrayBackgroundView::UpdateBubbleViewArrow( |
592 views::TrayBubbleView* bubble_view) { | 588 views::TrayBubbleView* bubble_view) { |
593 // Nothing to do here. | 589 // Nothing to do here. |
594 } | 590 } |
595 | 591 |
596 } // namespace ash | 592 } // namespace ash |
OLD | NEW |