Index: ash/system/chromeos/power/power_status.h |
diff --git a/ash/system/chromeos/power/power_status.h b/ash/system/chromeos/power/power_status.h |
index 7fb94d7236e4ae3fd95373cd9e978e83f06da934..630f673819660c9e2f9fbab4a44ecac65910278c 100644 |
--- a/ash/system/chromeos/power/power_status.h |
+++ b/ash/system/chromeos/power/power_status.h |
@@ -24,6 +24,16 @@ namespace ash { |
// available to interested classes within Ash. |
class ASH_EXPORT PowerStatus : public chromeos::PowerManagerClient::Observer { |
public: |
+ // Types of badges which can be drawn over top of a battery icon. |
+ enum IconBadge { |
+ ICON_BADGE_NONE, |
+ ICON_BADGE_ALERT, |
+ ICON_BADGE_X, |
+ ICON_BADGE_BOLT, |
+ ICON_BADGE_QUESTION, |
+ ICON_BADGE_UNRELIABLE |
+ }; |
+ |
// Different styles of battery icons. |
enum IconSet { |
ICON_LIGHT, |
@@ -62,18 +72,19 @@ class ASH_EXPORT PowerStatus : public chromeos::PowerManagerClient::Observer { |
int description_id; |
}; |
- // Information about the battery image corresponding to the status at a given |
- // point in time. This can be cached and later compared to avoid unnecessarily |
- // updating onscreen icons (GetBatteryImage() creates a new image on each |
- // call). |
- struct BatteryImageInfo { |
- BatteryImageInfo() : resource_id(-1), offset(-1), index(-1) {} |
+ // A version of BatteryImageInfo used when material design is not enabled. |
+ // TODO(tdanderson): Remove this once material design is enabled by default. |
+ // See crbug.com/614453. |
+ struct BatteryImageInfoNonMD { |
+ BatteryImageInfoNonMD() : resource_id(-1), offset(-1), index(-1) {} |
- bool operator==(const BatteryImageInfo& o) const { |
+ bool operator==(const BatteryImageInfoNonMD& o) const { |
return resource_id == o.resource_id && offset == o.offset && |
index == o.index; |
} |
- bool operator!=(const BatteryImageInfo& o) const { return !(*this == o); } |
+ bool operator!=(const BatteryImageInfoNonMD& o) const { |
+ return !(*this == o); |
+ } |
// Resource ID of the image containing the specific battery icon to use. |
int resource_id; |
@@ -87,6 +98,41 @@ class ASH_EXPORT PowerStatus : public chromeos::PowerManagerClient::Observer { |
int index; |
}; |
+ // Information about the battery image corresponding to the status at a given |
+ // point in time. This can be cached and later compared to avoid unnecessarily |
+ // updating onscreen icons (GetBatteryImage() creates a new image on each |
+ // call). |
+ struct BatteryImageInfo { |
+ BatteryImageInfo() : icon_set(ICON_LIGHT), icon_badge(ICON_BADGE_NONE), fill_level(-1) {} |
+ |
+ bool operator==(const BatteryImageInfo& o) const { |
+ return icon_set == o.icon_set && |
+ icon_badge == o.icon_badge && |
+ fill_level == o.fill_level; |
+ } |
+ |
+ bool operator!=(const BatteryImageInfo& o) const { |
+ return !(*this == o); |
+ } |
+ |
+ // The color scheme that should be used for the icon. ICON_LIGHT is used |
+ // for the system tray, and ICON_DARK is used elsewhere. |
+ IconSet icon_set; |
+ |
+ // The badge (lightning bolt, exclamation mark, etc) that should be drawn |
+ // on top of the battery icon. |
+ // TODO(tdanderson): Consider using gfx::VectorIconId instead of this enum |
+ // once all possible badges have been vectorized. See crbug.com/617298. |
+ IconBadge icon_badge; |
+ |
+ // A value between 0 and 14 representing the number of pixels that should |
+ // be drawn as the fill color, upwards from the bottom of the 16x16 grid |
+ // containing the battery image. Note that there is 2px of bottom padding |
+ // baked into the battery icon, which means that no fill amount will be |
+ // visible inside the battery for a |fill_level| of 0 or 1. |
+ int fill_level; |
+ }; |
+ |
// Maximum battery time-to-full or time-to-empty that should be displayed |
// in the UI. If the current is close to zero, battery time estimates can |
// get very large; avoid displaying these large numbers. |
@@ -193,8 +239,20 @@ class ASH_EXPORT PowerStatus : public chromeos::PowerManagerClient::Observer { |
// returned by this method to avoid creating new images unnecessarily. |
BatteryImageInfo GetBatteryImageInfo(IconSet icon_set) const; |
+ // Returns the BatteryImageInfoNonMD struct corresponding to |info|. |
+ // TODO(tdanderson): Remove this once material design is enabled by default. |
+ // See crbug.com/614453. |
+ BatteryImageInfoNonMD ConvertToBatteryImageInfoNonMD( |
+ const BatteryImageInfo info) const; |
+ |
// Creates a new image that should be shown for the battery's current state. |
- gfx::ImageSkia GetBatteryImage(IconSet icon_set) const; |
+ gfx::ImageSkia GetBatteryImage(const BatteryImageInfo info) const; |
+ |
+ // A version of GetBatteryImage() that is used when material design is not |
+ // enabled. |
+ // TODO(tdanderson): Remove this once material design is enabled by default. |
+ // See crbug.com/614453. |
+ gfx::ImageSkia GetBatteryImageNonMD(const BatteryImageInfoNonMD info) const; |
// Returns an string describing the current state for accessibility. |
base::string16 GetAccessibleNameString(bool full_description) const; |