Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: ash/common/system/chromeos/power/power_status_view.cc

Issue 2063633002: Render Ash material design battery image icon without PNGs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add battery percentage constant Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/system/chromeos/power/power_status.h" 8 #include "ash/common/system/chromeos/power/power_status.h"
8 #include "ash/common/system/chromeos/power/tray_power.h" 9 #include "ash/common/system/chromeos/power/tray_power.h"
9 #include "ash/common/system/tray/fixed_sized_image_view.h" 10 #include "ash/common/system/tray/fixed_sized_image_view.h"
10 #include "ash/common/system/tray/tray_constants.h" 11 #include "ash/common/system/tray/tray_constants.h"
11 #include "base/i18n/message_formatter.h" 12 #include "base/i18n/message_formatter.h"
12 #include "base/i18n/time_formatting.h" 13 #include "base/i18n/time_formatting.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "grit/ash_strings.h" 15 #include "grit/ash_strings.h"
15 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/views/controls/image_view.h" 17 #include "ui/views/controls/image_view.h"
(...skipping 19 matching lines...) Expand all
36 PowerStatus::Get()->AddObserver(this); 37 PowerStatus::Get()->AddObserver(this);
37 OnPowerStatusChanged(); 38 OnPowerStatusChanged();
38 } 39 }
39 40
40 PowerStatusView::~PowerStatusView() { 41 PowerStatusView::~PowerStatusView() {
41 PowerStatus::Get()->RemoveObserver(this); 42 PowerStatus::Get()->RemoveObserver(this);
42 } 43 }
43 44
44 void PowerStatusView::OnPowerStatusChanged() { 45 void PowerStatusView::OnPowerStatusChanged() {
45 UpdateText(); 46 UpdateText();
47
48 // We do not show a battery icon in the material design system menu.
49 // TODO(tdanderson): Remove the non-MD code and the IconSet enum once
50 // material design is enabled by default. See crbug.com/614453.
51 if (MaterialDesignController::UseMaterialDesignSystemIcons())
52 return;
53
46 const PowerStatus::BatteryImageInfo info = 54 const PowerStatus::BatteryImageInfo info =
47 PowerStatus::Get()->GetBatteryImageInfo(PowerStatus::ICON_DARK); 55 PowerStatus::Get()->GetBatteryImageInfo(PowerStatus::ICON_DARK);
48 if (info != previous_battery_image_info_) { 56 if (info != previous_battery_image_info_) {
49 icon_->SetImage( 57 icon_->SetImage(PowerStatus::Get()->GetBatteryImage(info));
50 PowerStatus::Get()->GetBatteryImage(PowerStatus::ICON_DARK));
51 icon_->SetVisible(true); 58 icon_->SetVisible(true);
52 previous_battery_image_info_ = info; 59 previous_battery_image_info_ = info;
53 } 60 }
54 } 61 }
55 62
56 void PowerStatusView::LayoutView() { 63 void PowerStatusView::LayoutView() {
57 if (default_view_right_align_) { 64 if (default_view_right_align_) {
58 views::BoxLayout* layout = 65 views::BoxLayout* layout =
59 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 66 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
60 kPaddingBetweenBatteryStatusAndIcon); 67 kPaddingBetweenBatteryStatusAndIcon);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // Move the time_status_label_, separator_label_, and percentage_label_ 147 // Move the time_status_label_, separator_label_, and percentage_label_
141 // closer to each other. 148 // closer to each other.
142 if (percentage_label_ && separator_label_ && time_status_label_ && 149 if (percentage_label_ && separator_label_ && time_status_label_ &&
143 percentage_label_->visible() && time_status_label_->visible()) { 150 percentage_label_->visible() && time_status_label_->visible()) {
144 separator_label_->SetX(percentage_label_->bounds().right() + 1); 151 separator_label_->SetX(percentage_label_->bounds().right() + 1);
145 time_status_label_->SetX(separator_label_->bounds().right() + 1); 152 time_status_label_->SetX(separator_label_->bounds().right() + 1);
146 } 153 }
147 } 154 }
148 155
149 } // namespace ash 156 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/power/power_status_unittest.cc ('k') | ash/common/system/chromeos/power/tray_power.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698