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/system/chromeos/power/power_status.h" | 7 #include "ash/common/system/chromeos/power/power_status.h" |
8 #include "ash/common/system/chromeos/power/tray_power.h" | 8 #include "ash/common/system/chromeos/power/tray_power.h" |
9 #include "ash/common/system/tray/fixed_sized_image_view.h" | 9 #include "ash/common/system/tray/fixed_sized_image_view.h" |
10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 PowerStatus::Get()->AddObserver(this); | 36 PowerStatus::Get()->AddObserver(this); |
37 OnPowerStatusChanged(); | 37 OnPowerStatusChanged(); |
38 } | 38 } |
39 | 39 |
40 PowerStatusView::~PowerStatusView() { | 40 PowerStatusView::~PowerStatusView() { |
41 PowerStatus::Get()->RemoveObserver(this); | 41 PowerStatus::Get()->RemoveObserver(this); |
42 } | 42 } |
43 | 43 |
44 void PowerStatusView::OnPowerStatusChanged() { | 44 void PowerStatusView::OnPowerStatusChanged() { |
45 UpdateText(); | 45 UpdateText(); |
| 46 |
| 47 // We do not show a battery icon in the material design system menu. |
| 48 // TODO(tdanderson): Remove the non-MD code and the IconSet enum once |
| 49 // material design is enabled by default. See crbug.com/614453. |
| 50 if (MaterialDesignController::UseMaterialDesignSystemIcons()) |
| 51 return; |
| 52 |
46 const PowerStatus::BatteryImageInfo info = | 53 const PowerStatus::BatteryImageInfo info = |
47 PowerStatus::Get()->GetBatteryImageInfo(PowerStatus::ICON_DARK); | 54 PowerStatus::Get()->GetBatteryImageInfo(PowerStatus::ICON_DARK); |
48 if (info != previous_battery_image_info_) { | 55 if (info != previous_battery_image_info_) { |
49 icon_->SetImage( | 56 icon_->SetImage(PowerStatus::Get()->GetBatteryImage(info)); |
50 PowerStatus::Get()->GetBatteryImage(PowerStatus::ICON_DARK)); | |
51 icon_->SetVisible(true); | 57 icon_->SetVisible(true); |
52 previous_battery_image_info_ = info; | 58 previous_battery_image_info_ = info; |
53 } | 59 } |
54 } | 60 } |
55 | 61 |
56 void PowerStatusView::LayoutView() { | 62 void PowerStatusView::LayoutView() { |
57 if (default_view_right_align_) { | 63 if (default_view_right_align_) { |
58 views::BoxLayout* layout = | 64 views::BoxLayout* layout = |
59 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, | 65 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, |
60 kPaddingBetweenBatteryStatusAndIcon); | 66 kPaddingBetweenBatteryStatusAndIcon); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Move the time_status_label_, separator_label_, and percentage_label_ | 146 // Move the time_status_label_, separator_label_, and percentage_label_ |
141 // closer to each other. | 147 // closer to each other. |
142 if (percentage_label_ && separator_label_ && time_status_label_ && | 148 if (percentage_label_ && separator_label_ && time_status_label_ && |
143 percentage_label_->visible() && time_status_label_->visible()) { | 149 percentage_label_->visible() && time_status_label_->visible()) { |
144 separator_label_->SetX(percentage_label_->bounds().right() + 1); | 150 separator_label_->SetX(percentage_label_->bounds().right() + 1); |
145 time_status_label_->SetX(separator_label_->bounds().right() + 1); | 151 time_status_label_->SetX(separator_label_->bounds().right() + 1); |
146 } | 152 } |
147 } | 153 } |
148 | 154 |
149 } // namespace ash | 155 } // namespace ash |
OLD | NEW |