| 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/common/system/chromeos/power/power_status_view.h" | 5 #include "ash/common/system/chromeos/power/power_status_view.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/system/chromeos/power/power_status.h" | 8 #include "ash/common/system/chromeos/power/power_status.h" |
| 9 #include "ash/common/system/chromeos/power/tray_power.h" | 9 #include "ash/common/system/chromeos/power/tray_power.h" |
| 10 #include "ash/common/system/tray/fixed_sized_image_view.h" | 10 #include "ash/common/system/tray/fixed_sized_image_view.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 SetLayoutManager(layout); | 68 SetLayoutManager(layout); |
| 69 | 69 |
| 70 AddChildView(percentage_label_); | 70 AddChildView(percentage_label_); |
| 71 AddChildView(separator_label_); | 71 AddChildView(separator_label_); |
| 72 AddChildView(time_status_label_); | 72 AddChildView(time_status_label_); |
| 73 | 73 |
| 74 icon_ = new views::ImageView; | 74 icon_ = new views::ImageView; |
| 75 AddChildView(icon_); | 75 AddChildView(icon_); |
| 76 } else { | 76 } else { |
| 77 // PowerStatusView is left aligned on the system tray pop up item. | 77 // PowerStatusView is left aligned on the system tray pop up item. |
| 78 views::BoxLayout* layout = | 78 views::BoxLayout* layout = new views::BoxLayout( |
| 79 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, | 79 views::BoxLayout::kHorizontal, 0, 0, kTrayPopupPaddingBetweenItems); |
| 80 kTrayPopupPaddingBetweenItems); | |
| 81 SetLayoutManager(layout); | 80 SetLayoutManager(layout); |
| 82 | 81 |
| 83 icon_ = new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight); | 82 icon_ = new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight); |
| 84 AddChildView(icon_); | 83 AddChildView(icon_); |
| 85 | 84 |
| 86 AddChildView(percentage_label_); | 85 AddChildView(percentage_label_); |
| 87 AddChildView(separator_label_); | 86 AddChildView(separator_label_); |
| 88 AddChildView(time_status_label_); | 87 AddChildView(time_status_label_); |
| 89 } | 88 } |
| 90 } | 89 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 101 battery_percentage = base::i18n::MessageFormatter::FormatWithNumberedArgs( | 100 battery_percentage = base::i18n::MessageFormatter::FormatWithNumberedArgs( |
| 102 base::ASCIIToUTF16("{0,number,percent}"), | 101 base::ASCIIToUTF16("{0,number,percent}"), |
| 103 static_cast<double>(status.GetRoundedBatteryPercent()) / 100.0); | 102 static_cast<double>(status.GetRoundedBatteryPercent()) / 100.0); |
| 104 if (status.IsUsbChargerConnected()) { | 103 if (status.IsUsbChargerConnected()) { |
| 105 battery_time_status = l10n_util::GetStringUTF16( | 104 battery_time_status = l10n_util::GetStringUTF16( |
| 106 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE); | 105 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE); |
| 107 } else if (status.IsBatteryTimeBeingCalculated()) { | 106 } else if (status.IsBatteryTimeBeingCalculated()) { |
| 108 battery_time_status = | 107 battery_time_status = |
| 109 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING); | 108 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING); |
| 110 } else { | 109 } else { |
| 111 base::TimeDelta time = status.IsBatteryCharging() ? | 110 base::TimeDelta time = status.IsBatteryCharging() |
| 112 status.GetBatteryTimeToFull() : status.GetBatteryTimeToEmpty(); | 111 ? status.GetBatteryTimeToFull() |
| 112 : status.GetBatteryTimeToEmpty(); |
| 113 if (PowerStatus::ShouldDisplayBatteryTime(time) && | 113 if (PowerStatus::ShouldDisplayBatteryTime(time) && |
| 114 !status.IsBatteryDischargingOnLinePower()) { | 114 !status.IsBatteryDischargingOnLinePower()) { |
| 115 battery_time_status = l10n_util::GetStringFUTF16( | 115 battery_time_status = l10n_util::GetStringFUTF16( |
| 116 status.IsBatteryCharging() | 116 status.IsBatteryCharging() |
| 117 ? IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT | 117 ? IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT |
| 118 : IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT, | 118 : IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT, |
| 119 TimeDurationFormat(time, base::DURATION_WIDTH_NUMERIC)); | 119 TimeDurationFormat(time, base::DURATION_WIDTH_NUMERIC)); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 } | 122 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 147 // Move the time_status_label_, separator_label_, and percentage_label_ | 147 // Move the time_status_label_, separator_label_, and percentage_label_ |
| 148 // closer to each other. | 148 // closer to each other. |
| 149 if (percentage_label_ && separator_label_ && time_status_label_ && | 149 if (percentage_label_ && separator_label_ && time_status_label_ && |
| 150 percentage_label_->visible() && time_status_label_->visible()) { | 150 percentage_label_->visible() && time_status_label_->visible()) { |
| 151 separator_label_->SetX(percentage_label_->bounds().right() + 1); | 151 separator_label_->SetX(percentage_label_->bounds().right() + 1); |
| 152 time_status_label_->SetX(separator_label_->bounds().right() + 1); | 152 time_status_label_->SetX(separator_label_->bounds().right() + 1); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace ash | 156 } // namespace ash |
| OLD | NEW |