Chromium Code Reviews| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 clock_observer_(NULL), | 161 clock_observer_(NULL), |
| 162 drive_observer_(NULL), | 162 drive_observer_(NULL), |
| 163 ime_observer_(NULL), | 163 ime_observer_(NULL), |
| 164 network_observer_(NULL), | 164 network_observer_(NULL), |
| 165 power_status_observer_(NULL), | 165 power_status_observer_(NULL), |
| 166 update_observer_(NULL), | 166 update_observer_(NULL), |
| 167 user_observer_(NULL), | 167 user_observer_(NULL), |
| 168 widget_(NULL), | 168 widget_(NULL), |
| 169 background_(new internal::SystemTrayBackground), | 169 background_(new internal::SystemTrayBackground), |
| 170 should_show_launcher_(false), | 170 should_show_launcher_(false), |
| 171 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | |
| 171 ALLOW_THIS_IN_INITIALIZER_LIST(hide_background_animator_(this, | 172 ALLOW_THIS_IN_INITIALIZER_LIST(hide_background_animator_(this, |
| 172 0, kTrayBackgroundAlpha)), | 173 0, kTrayBackgroundAlpha)), |
| 173 ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(this, | 174 ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(this, |
| 174 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) { | 175 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) { |
| 175 tray_container_ = new internal::SystemTrayContainer; | 176 tray_container_ = new internal::SystemTrayContainer; |
| 176 tray_container_->SetLayoutManager(new views::BoxLayout( | 177 tray_container_->SetLayoutManager(new views::BoxLayout( |
| 177 views::BoxLayout::kHorizontal, 0, 0, 0)); | 178 views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 178 tray_container_->set_background(background_); | 179 tray_container_->set_background(background_); |
| 179 tray_container_->set_border( | 180 tray_container_->set_border( |
| 180 views::Border::CreateEmptyBorder(1, 1, 1, 1)); | 181 views::Border::CreateEmptyBorder(1, 1, 1, 1)); |
| 181 set_border(views::Border::CreateEmptyBorder(0, 0, | 182 set_border(views::Border::CreateEmptyBorder(0, 0, |
| 182 kPaddingFromBottomOfScreen, kPaddingFromRightEdgeOfScreen)); | 183 kPaddingFromBottomOfScreenBottomAlignment, |
| 184 kPaddingFromRightEdgeOfScreenBottomAlignment)); | |
| 183 set_notify_enter_exit_on_child(true); | 185 set_notify_enter_exit_on_child(true); |
| 184 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 186 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 185 AddChildView(tray_container_); | 187 AddChildView(tray_container_); |
| 186 | 188 |
| 187 // Initially we want to paint the background, but without the hover effect. | 189 // Initially we want to paint the background, but without the hover effect. |
| 188 SetPaintsBackground(true, internal::BackgroundAnimator::CHANGE_IMMEDIATE); | 190 SetPaintsBackground(true, internal::BackgroundAnimator::CHANGE_IMMEDIATE); |
| 189 hover_background_animator_.SetPaintsBackground(false, | 191 hover_background_animator_.SetPaintsBackground(false, |
| 190 internal::BackgroundAnimator::CHANGE_IMMEDIATE); | 192 internal::BackgroundAnimator::CHANGE_IMMEDIATE); |
| 191 } | 193 } |
| 192 | 194 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 } | 473 } |
| 472 | 474 |
| 473 void SystemTray::UpdateNotificationAnchor() { | 475 void SystemTray::UpdateNotificationAnchor() { |
| 474 if (!notification_bubble_.get()) | 476 if (!notification_bubble_.get()) |
| 475 return; | 477 return; |
| 476 notification_bubble_->bubble_view()->UpdateAnchor(); | 478 notification_bubble_->bubble_view()->UpdateAnchor(); |
| 477 // Ensure that the notification buble is above the launcher/status area. | 479 // Ensure that the notification buble is above the launcher/status area. |
| 478 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); | 480 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); |
| 479 } | 481 } |
| 480 | 482 |
| 483 void SystemTray::SetAlignment(ShelfAlignment alignment) { | |
|
sadrul
2012/05/17 19:57:05
SetShelfAlignment
jennyz
2012/05/17 22:13:30
Done.
| |
| 484 if (alignment == shelf_alignment_) | |
| 485 return; | |
| 486 | |
| 487 if (alignment == SHELF_ALIGNMENT_BOTTOM){ | |
| 488 tray_container_->SetLayoutManager(new views::BoxLayout( | |
| 489 views::BoxLayout::kHorizontal, 0, 0, 0)); | |
| 490 } else if (alignment == SHELF_ALIGNMENT_LEFT || | |
| 491 alignment == SHELF_ALIGNMENT_RIGHT) { | |
| 492 if (shelf_alignment_ == SHELF_ALIGNMENT_BOTTOM) | |
| 493 tray_container_->SetLayoutManager(new views::BoxLayout( | |
| 494 views::BoxLayout::kVertical, 0, 0, 0)); | |
| 495 } | |
| 496 shelf_alignment_ = alignment; | |
| 497 } | |
| 498 | |
| 499 ShelfAlignment SystemTray::GetAlignment() const { | |
| 500 return shelf_alignment_; | |
|
sadrul
2012/05/17 19:57:05
This should be unix_hacker style and inlined, i.e.
jennyz
2012/05/17 22:13:30
Done.
| |
| 501 } | |
| 502 | |
| 481 bool SystemTray::PerformAction(const views::Event& event) { | 503 bool SystemTray::PerformAction(const views::Event& event) { |
| 482 // If we're already showing the default view, hide it; otherwise, show it | 504 // If we're already showing the default view, hide it; otherwise, show it |
| 483 // (and hide any popup that's currently shown). | 505 // (and hide any popup that's currently shown). |
| 484 if (bubble_.get() && | 506 if (bubble_.get() && |
| 485 bubble_->bubble_type() == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) { | 507 bubble_->bubble_type() == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) { |
| 486 bubble_->Close(); | 508 bubble_->Close(); |
| 487 } else { | 509 } else { |
| 488 int arrow_offset = -1; | 510 int arrow_offset = -1; |
| 489 if (event.IsMouseEvent() || event.IsTouchEvent()) { | 511 if (event.IsMouseEvent() || event.IsTouchEvent()) { |
| 490 const views::LocatedEvent& located_event = | 512 const views::LocatedEvent& located_event = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 canvas->DrawFocusRect(tray_container_->bounds()); | 553 canvas->DrawFocusRect(tray_container_->bounds()); |
| 532 } | 554 } |
| 533 | 555 |
| 534 void SystemTray::UpdateBackground(int alpha) { | 556 void SystemTray::UpdateBackground(int alpha) { |
| 535 background_->set_alpha(hide_background_animator_.alpha() + | 557 background_->set_alpha(hide_background_animator_.alpha() + |
| 536 hover_background_animator_.alpha()); | 558 hover_background_animator_.alpha()); |
| 537 SchedulePaint(); | 559 SchedulePaint(); |
| 538 } | 560 } |
| 539 | 561 |
| 540 } // namespace ash | 562 } // namespace ash |
| OLD | NEW |