| 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/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell/panel_window.h" | 8 #include "ash/shell/panel_window.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/system/audio/tray_volume.h" | 10 #include "ash/system/audio/tray_volume.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 brightness_observer_(NULL), | 131 brightness_observer_(NULL), |
| 132 caps_lock_observer_(NULL), | 132 caps_lock_observer_(NULL), |
| 133 clock_observer_(NULL), | 133 clock_observer_(NULL), |
| 134 drive_observer_(NULL), | 134 drive_observer_(NULL), |
| 135 ime_observer_(NULL), | 135 ime_observer_(NULL), |
| 136 locale_observer_(NULL), | 136 locale_observer_(NULL), |
| 137 network_observer_(NULL), | 137 network_observer_(NULL), |
| 138 update_observer_(NULL), | 138 update_observer_(NULL), |
| 139 user_observer_(NULL), | 139 user_observer_(NULL), |
| 140 should_show_launcher_(false), | 140 should_show_launcher_(false), |
| 141 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | |
| 142 default_bubble_height_(0) { | 141 default_bubble_height_(0) { |
| 143 tray_container_ = new internal::SystemTrayContainer; | 142 tray_container_ = new internal::SystemTrayContainer; |
| 144 tray_container_->SetLayoutManager(new views::BoxLayout( | 143 tray_container_->SetLayoutManager(new views::BoxLayout( |
| 145 views::BoxLayout::kHorizontal, 0, 0, 0)); | 144 views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 146 tray_container_->set_border( | 145 tray_container_->set_border( |
| 147 views::Border::CreateEmptyBorder(1, 1, 1, 1)); | 146 views::Border::CreateEmptyBorder(1, 1, 1, 1)); |
| 148 SetContents(tray_container_); | 147 SetContents(tray_container_); |
| 149 SetBorder(); | 148 SetBorder(); |
| 150 } | 149 } |
| 151 | 150 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 void SystemTray::UpdateNotificationAnchor() { | 467 void SystemTray::UpdateNotificationAnchor() { |
| 469 if (!notification_bubble_.get()) | 468 if (!notification_bubble_.get()) |
| 470 return; | 469 return; |
| 471 notification_bubble_->bubble_view()->UpdateAnchor(); | 470 notification_bubble_->bubble_view()->UpdateAnchor(); |
| 472 // Ensure that the notification buble is above the launcher/status area. | 471 // Ensure that the notification buble is above the launcher/status area. |
| 473 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); | 472 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); |
| 474 } | 473 } |
| 475 | 474 |
| 476 void SystemTray::SetBorder() { | 475 void SystemTray::SetBorder() { |
| 477 // Change the border padding for different shelf alignment. | 476 // Change the border padding for different shelf alignment. |
| 478 if (shelf_alignment_ == SHELF_ALIGNMENT_BOTTOM) { | 477 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
| 479 set_border(views::Border::CreateEmptyBorder(0, 0, | 478 set_border(views::Border::CreateEmptyBorder(0, 0, |
| 480 kPaddingFromBottomOfScreenBottomAlignment, | 479 kPaddingFromBottomOfScreenBottomAlignment, |
| 481 kPaddingFromRightEdgeOfScreenBottomAlignment)); | 480 kPaddingFromRightEdgeOfScreenBottomAlignment)); |
| 482 } else if (shelf_alignment_ == SHELF_ALIGNMENT_LEFT) { | 481 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { |
| 483 set_border(views::Border::CreateEmptyBorder(0, | 482 set_border(views::Border::CreateEmptyBorder(0, |
| 484 kPaddingFromEdgeOfScreenVerticalAlignment, | 483 kPaddingFromEdgeOfScreenVerticalAlignment, |
| 485 kPaddingFromBottomOfScreenVerticalAlignment, | 484 kPaddingFromBottomOfScreenVerticalAlignment, |
| 486 kPaddingFromEdgeOfLauncherVerticalAlignment)); | 485 kPaddingFromEdgeOfLauncherVerticalAlignment)); |
| 487 } else { | 486 } else { |
| 488 set_border(views::Border::CreateEmptyBorder(0, | 487 set_border(views::Border::CreateEmptyBorder(0, |
| 489 kPaddingFromEdgeOfLauncherVerticalAlignment, | 488 kPaddingFromEdgeOfLauncherVerticalAlignment, |
| 490 kPaddingFromBottomOfScreenVerticalAlignment, | 489 kPaddingFromBottomOfScreenVerticalAlignment, |
| 491 kPaddingFromEdgeOfScreenVerticalAlignment)); | 490 kPaddingFromEdgeOfScreenVerticalAlignment)); |
| 492 } | 491 } |
| 493 } | 492 } |
| 494 | 493 |
| 495 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { | 494 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 496 if (alignment == shelf_alignment_) | 495 if (alignment == shelf_alignment()) |
| 497 return; | 496 return; |
| 498 shelf_alignment_ = alignment; | 497 internal::TrayBackgroundView::SetShelfAlignment(alignment); |
| 499 UpdateAfterShelfAlignmentChange(alignment); | 498 UpdateAfterShelfAlignmentChange(alignment); |
| 500 SetBorder(); | 499 SetBorder(); |
| 501 tray_container_->SetLayoutManager(new views::BoxLayout( | 500 tray_container_->SetLayoutManager(new views::BoxLayout( |
| 502 alignment == SHELF_ALIGNMENT_BOTTOM ? | 501 alignment == SHELF_ALIGNMENT_BOTTOM ? |
| 503 views::BoxLayout::kHorizontal : views::BoxLayout::kVertical, | 502 views::BoxLayout::kHorizontal : views::BoxLayout::kVertical, |
| 504 0, 0, 0)); | 503 0, 0, 0)); |
| 505 } | 504 } |
| 506 | 505 |
| 507 bool SystemTray::PerformAction(const views::Event& event) { | 506 bool SystemTray::PerformAction(const views::Event& event) { |
| 508 // If we're already showing the default view, hide it; otherwise, show it | 507 // If we're already showing the default view, hide it; otherwise, show it |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 | 549 |
| 551 void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) { | 550 void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) { |
| 552 // The tray itself expands to the right and bottom edge of the screen to make | 551 // The tray itself expands to the right and bottom edge of the screen to make |
| 553 // sure clicking on the edges brings up the popup. However, the focus border | 552 // sure clicking on the edges brings up the popup. However, the focus border |
| 554 // should be only around the container. | 553 // should be only around the container. |
| 555 if (GetWidget() && GetWidget()->IsActive()) | 554 if (GetWidget() && GetWidget()->IsActive()) |
| 556 canvas->DrawFocusRect(tray_container_->bounds()); | 555 canvas->DrawFocusRect(tray_container_->bounds()); |
| 557 } | 556 } |
| 558 | 557 |
| 559 } // namespace ash | 558 } // namespace ash |
| OLD | NEW |