| 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 { | 25 namespace internal { |
| 26 | 26 |
| 27 namespace { | |
| 28 | |
| 29 // Top/bottom padding of the text items. | |
| 30 const int kPaddingVertical = 10; | |
| 31 // Specify min width of status label for layout. | |
| 32 const int kLabelMinWidth = 120; | |
| 33 // Padding between battery status text and battery icon on default view. | 27 // Padding between battery status text and battery icon on default view. |
| 34 const int kPaddingBetweenBatteryStatusAndIcon = 3; | 28 const int kPaddingBetweenBatteryStatusAndIcon = 3; |
| 35 } // namespace | |
| 36 | 29 |
| 37 PowerStatusView::PowerStatusView(ViewType view_type, | 30 PowerStatusView::PowerStatusView(ViewType view_type, |
| 38 bool default_view_right_align) | 31 bool default_view_right_align) |
| 39 : default_view_right_align_(default_view_right_align), | 32 : default_view_right_align_(default_view_right_align), |
| 40 status_label_(NULL), | 33 status_label_(NULL), |
| 41 time_label_(NULL), | 34 time_label_(NULL), |
| 42 time_status_label_(NULL), | 35 time_status_label_(NULL), |
| 43 percentage_label_(NULL), | 36 percentage_label_(NULL), |
| 44 icon_(NULL), | 37 icon_(NULL), |
| 45 view_type_(view_type) { | 38 view_type_(view_type) { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 213 |
| 221 // Move the time_status_label_ closer to percentage_label_. | 214 // Move the time_status_label_ closer to percentage_label_. |
| 222 if (percentage_label_ && time_status_label_ && | 215 if (percentage_label_ && time_status_label_ && |
| 223 percentage_label_->visible() && time_status_label_->visible()) { | 216 percentage_label_->visible() && time_status_label_->visible()) { |
| 224 time_status_label_->SetX(percentage_label_->bounds().right() + 1); | 217 time_status_label_->SetX(percentage_label_->bounds().right() + 1); |
| 225 } | 218 } |
| 226 } | 219 } |
| 227 | 220 |
| 228 } // namespace internal | 221 } // namespace internal |
| 229 } // namespace ash | 222 } // namespace ash |
| OLD | NEW |