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/chromeos/power/power_status_view.h" | 5 #include "ash/system/chromeos/power/power_status_view.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
9 #include "ash/system/chromeos/power/power_status.h" | 9 #include "ash/system/chromeos/power/power_status.h" |
10 #include "ash/system/chromeos/power/tray_power.h" | 10 #include "ash/system/chromeos/power/tray_power.h" |
11 #include "ash/system/tray/fixed_sized_image_view.h" | 11 #include "ash/system/tray/fixed_sized_image_view.h" |
12 #include "ash/system/tray/tray_constants.h" | 12 #include "ash/system/tray/tray_constants.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "grit/ash_strings.h" | 15 #include "grit/ash_strings.h" |
16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
17 #include "ui/base/l10n/time_format.h" | 17 #include "ui/base/l10n/time_format.h" |
18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/views/controls/image_view.h" | 19 #include "ui/views/controls/image_view.h" |
20 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
21 #include "ui/views/layout/box_layout.h" | 21 #include "ui/views/layout/box_layout.h" |
22 #include "ui/views/layout/grid_layout.h" | 22 #include "ui/views/layout/grid_layout.h" |
23 | 23 |
24 namespace ash { | 24 namespace ash { |
25 namespace internal { | |
26 | 25 |
27 // Padding between battery status text and battery icon on default view. | 26 // Padding between battery status text and battery icon on default view. |
28 const int kPaddingBetweenBatteryStatusAndIcon = 3; | 27 const int kPaddingBetweenBatteryStatusAndIcon = 3; |
29 | 28 |
30 PowerStatusView::PowerStatusView(ViewType view_type, | 29 PowerStatusView::PowerStatusView(ViewType view_type, |
31 bool default_view_right_align) | 30 bool default_view_right_align) |
32 : default_view_right_align_(default_view_right_align), | 31 : default_view_right_align_(default_view_right_align), |
33 status_label_(NULL), | 32 status_label_(NULL), |
34 time_label_(NULL), | 33 time_label_(NULL), |
35 time_status_label_(NULL), | 34 time_status_label_(NULL), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 76 |
78 icon_ = new views::ImageView; | 77 icon_ = new views::ImageView; |
79 AddChildView(icon_); | 78 AddChildView(icon_); |
80 } else { | 79 } else { |
81 // PowerStatusView is left aligned on the system tray pop up item. | 80 // PowerStatusView is left aligned on the system tray pop up item. |
82 views::BoxLayout* layout = | 81 views::BoxLayout* layout = |
83 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, | 82 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, |
84 kTrayPopupPaddingBetweenItems); | 83 kTrayPopupPaddingBetweenItems); |
85 SetLayoutManager(layout); | 84 SetLayoutManager(layout); |
86 | 85 |
87 icon_ = | 86 icon_ = new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight); |
88 new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight); | |
89 AddChildView(icon_); | 87 AddChildView(icon_); |
90 | 88 |
91 AddChildView(percentage_label_); | 89 AddChildView(percentage_label_); |
92 AddChildView(time_status_label_); | 90 AddChildView(time_status_label_); |
93 } | 91 } |
94 } | 92 } |
95 | 93 |
96 void PowerStatusView::LayoutNotificationView() { | 94 void PowerStatusView::LayoutNotificationView() { |
97 SetLayoutManager( | 95 SetLayoutManager( |
98 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); | 96 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 void PowerStatusView::Layout() { | 209 void PowerStatusView::Layout() { |
212 views::View::Layout(); | 210 views::View::Layout(); |
213 | 211 |
214 // Move the time_status_label_ closer to percentage_label_. | 212 // Move the time_status_label_ closer to percentage_label_. |
215 if (percentage_label_ && time_status_label_ && | 213 if (percentage_label_ && time_status_label_ && |
216 percentage_label_->visible() && time_status_label_->visible()) { | 214 percentage_label_->visible() && time_status_label_->visible()) { |
217 time_status_label_->SetX(percentage_label_->bounds().right() + 1); | 215 time_status_label_->SetX(percentage_label_->bounds().right() + 1); |
218 } | 216 } |
219 } | 217 } |
220 | 218 |
221 } // namespace internal | |
222 } // namespace ash | 219 } // namespace ash |
OLD | NEW |