| 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_item.h" | 5 #include "ash/system/tray/system_tray_item.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
| 9 #include "ash/system/tray/tray_constants.h" |
| 10 #include "ash/system/tray/tray_item_view.h" |
| 11 #include "ui/views/controls/label.h" |
| 9 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
| 10 | 13 |
| 11 namespace ash { | 14 namespace ash { |
| 12 | 15 |
| 13 SystemTrayItem::SystemTrayItem() { | 16 SystemTrayItem::SystemTrayItem() { |
| 14 } | 17 } |
| 15 | 18 |
| 16 SystemTrayItem::~SystemTrayItem() { | 19 SystemTrayItem::~SystemTrayItem() { |
| 17 } | 20 } |
| 18 | 21 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 56 } |
| 54 | 57 |
| 55 void SystemTrayItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 58 void SystemTrayItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| 56 } | 59 } |
| 57 | 60 |
| 58 void SystemTrayItem::PopupDetailedView(int for_seconds, bool activate) { | 61 void SystemTrayItem::PopupDetailedView(int for_seconds, bool activate) { |
| 59 Shell::GetInstance()->system_tray()->ShowDetailedView( | 62 Shell::GetInstance()->system_tray()->ShowDetailedView( |
| 60 this, for_seconds, activate, BUBBLE_CREATE_NEW); | 63 this, for_seconds, activate, BUBBLE_CREATE_NEW); |
| 61 } | 64 } |
| 62 | 65 |
| 66 void SystemTrayItem::SetTrayImageItemBorder(views::View* tray_view, |
| 67 ShelfAlignment alignment) { |
| 68 if (alignment == SHELF_ALIGNMENT_BOTTOM) { |
| 69 tray_view->set_border(views::Border::CreateEmptyBorder( |
| 70 0, kTrayImageItemHorizontalPaddingBottomAlignment, |
| 71 0, kTrayImageItemHorizontalPaddingBottomAlignment)); |
| 72 } else { |
| 73 tray_view->set_border(views::Border::CreateEmptyBorder( |
| 74 kTrayImageItemVerticalPaddingVerticalAlignment, |
| 75 kTrayImageItemHorizontalPaddingVerticalAlignment, |
| 76 kTrayImageItemVerticalPaddingVerticalAlignment, |
| 77 kTrayImageItemHorizontalPaddingVerticalAlignment)); |
| 78 } |
| 79 } |
| 80 |
| 81 void SystemTrayItem::SetTrayLabelItemBorder(internal::TrayItemView* tray_view, |
| 82 ShelfAlignment alignment) { |
| 83 if (alignment == SHELF_ALIGNMENT_BOTTOM) { |
| 84 tray_view->set_border(views::Border::CreateEmptyBorder( |
| 85 0, kTrayLabelItemHorizontalPaddingBottomAlignment, |
| 86 0, kTrayLabelItemHorizontalPaddingBottomAlignment)); |
| 87 } else { |
| 88 // Center the label for vertical launcher alignment. |
| 89 int horizontal_padding = (tray_view->GetPreferredSize().width() - |
| 90 tray_view->label()->GetPreferredSize().width()) / 2; |
| 91 tray_view->set_border(views::Border::CreateEmptyBorder( |
| 92 kTrayLabelItemVerticalPaddingVeriticalAlignment, |
| 93 horizontal_padding, |
| 94 kTrayLabelItemVerticalPaddingVeriticalAlignment, |
| 95 horizontal_padding)); |
| 96 } |
| 97 } |
| 98 |
| 63 void SystemTrayItem::SetDetailedViewCloseDelay(int for_seconds) { | 99 void SystemTrayItem::SetDetailedViewCloseDelay(int for_seconds) { |
| 64 Shell::GetInstance()->system_tray()->SetDetailedViewCloseDelay(for_seconds); | 100 Shell::GetInstance()->system_tray()->SetDetailedViewCloseDelay(for_seconds); |
| 65 } | 101 } |
| 66 | 102 |
| 67 void SystemTrayItem::HideDetailedView() { | 103 void SystemTrayItem::HideDetailedView() { |
| 68 Shell::GetInstance()->system_tray()->HideDetailedView(this); | 104 Shell::GetInstance()->system_tray()->HideDetailedView(this); |
| 69 } | 105 } |
| 70 | 106 |
| 71 void SystemTrayItem::ShowNotificationView() { | 107 void SystemTrayItem::ShowNotificationView() { |
| 72 Shell::GetInstance()->system_tray()->ShowNotificationView(this); | 108 Shell::GetInstance()->system_tray()->ShowNotificationView(this); |
| 73 } | 109 } |
| 74 | 110 |
| 75 void SystemTrayItem::HideNotificationView() { | 111 void SystemTrayItem::HideNotificationView() { |
| 76 Shell::GetInstance()->system_tray()->HideNotificationView(this); | 112 Shell::GetInstance()->system_tray()->HideNotificationView(this); |
| 77 } | 113 } |
| 78 | 114 |
| 79 } // namespace ash | 115 } // namespace ash |
| OLD | NEW |