| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/chromeos/status/power_menu_button.h" | 5 #include "chrome/browser/chromeos/status/power_menu_button.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 void PowerMenuButton::DrawPressed(gfx::Canvas* canvas) { | 108 void PowerMenuButton::DrawPressed(gfx::Canvas* canvas) { |
| 109 DrawPowerIcon(canvas, *ResourceBundle::GetSharedInstance(). | 109 DrawPowerIcon(canvas, *ResourceBundle::GetSharedInstance(). |
| 110 GetBitmapNamed(IDR_STATUSBAR_BATTERY_PRESSED)); | 110 GetBitmapNamed(IDR_STATUSBAR_BATTERY_PRESSED)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void PowerMenuButton::DrawIcon(gfx::Canvas* canvas) { | 113 void PowerMenuButton::DrawIcon(gfx::Canvas* canvas) { |
| 114 DrawPowerIcon(canvas, icon()); | 114 DrawPowerIcon(canvas, icon()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void PowerMenuButton::DrawPowerIcon(gfx::Canvas* canvas, SkBitmap icon) { | 117 void PowerMenuButton::DrawPowerIcon(gfx::Canvas* canvas, SkBitmap icon) { |
| 118 // Draw the battery icon 6 pixels down to center it. | 118 // Draw the battery icon 5 pixels down to center it. |
| 119 // Because the status icon is 24x24 but the images are 24x16. | 119 static const int kIconVerticalPadding = 5; |
| 120 // But since the images are shifted up by 4 pixels, we draw at 6 pixels down. | |
| 121 static const int kIconVerticalPadding = 6; | |
| 122 canvas->DrawBitmapInt(icon, 0, kIconVerticalPadding); | 120 canvas->DrawBitmapInt(icon, 0, kIconVerticalPadding); |
| 123 } | 121 } |
| 124 | 122 |
| 125 void PowerMenuButton::UpdateIcon() { | 123 void PowerMenuButton::UpdateIcon() { |
| 126 PowerLibrary* cros = CrosLibrary::Get()->GetPowerLibrary(); | 124 PowerLibrary* cros = CrosLibrary::Get()->GetPowerLibrary(); |
| 127 icon_id_ = IDR_STATUSBAR_BATTERY_UNKNOWN; | 125 icon_id_ = IDR_STATUSBAR_BATTERY_UNKNOWN; |
| 128 if (CrosLibrary::Get()->EnsureLoaded()) { | 126 if (CrosLibrary::Get()->EnsureLoaded()) { |
| 129 if (!cros->battery_is_present()) { | 127 if (!cros->battery_is_present()) { |
| 130 icon_id_ = IDR_STATUSBAR_BATTERY_MISSING; | 128 icon_id_ = IDR_STATUSBAR_BATTERY_MISSING; |
| 131 } else if (cros->line_power_on() && cros->battery_fully_charged()) { | 129 } else if (cros->line_power_on() && cros->battery_fully_charged()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 147 icon_id_ = IDR_STATUSBAR_BATTERY_CHARGING_1 + index; | 145 icon_id_ = IDR_STATUSBAR_BATTERY_CHARGING_1 + index; |
| 148 else | 146 else |
| 149 icon_id_ = IDR_STATUSBAR_BATTERY_DISCHARGING_1 + index; | 147 icon_id_ = IDR_STATUSBAR_BATTERY_DISCHARGING_1 + index; |
| 150 } | 148 } |
| 151 } | 149 } |
| 152 SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed(icon_id_)); | 150 SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed(icon_id_)); |
| 153 SchedulePaint(); | 151 SchedulePaint(); |
| 154 } | 152 } |
| 155 | 153 |
| 156 } // namespace chromeos | 154 } // namespace chromeos |
| OLD | NEW |