Chromium Code Reviews| Index: ui/chromeos/network/network_icon.cc |
| diff --git a/ui/chromeos/network/network_icon.cc b/ui/chromeos/network/network_icon.cc |
| index ff56ac63268837aa64a8b12553b9fa96fb75d964..b7cb3e5df9140cdc0d1fe49e39dd0a6398b1e967 100644 |
| --- a/ui/chromeos/network/network_icon.cc |
| +++ b/ui/chromeos/network/network_icon.cc |
| @@ -273,12 +273,12 @@ class NetworkIconImageSourceMd : public gfx::CanvasImageSource { |
| } |
| if (!badges_.bottom_left.isNull()) { |
| canvas->DrawImageInt(badges_.bottom_left, 0, |
| - height - badges_.bottom_left.height()); |
| + height - badges_.bottom_left.height() - 1); |
|
varkha
2016/09/19 20:19:23
Not sure why this is necessary but without it the
Evan Stade
2016/09/19 20:40:47
I don't think this is correct.
Note that the size
varkha
2016/09/23 00:35:53
Acknowledged.
|
| } |
| if (!badges_.bottom_right.isNull()) { |
| canvas->DrawImageInt(badges_.bottom_right, |
| width - badges_.bottom_right.width(), |
| - height - badges_.bottom_right.height()); |
| + height - badges_.bottom_right.height() - 1); |
| } |
| } |
| @@ -316,6 +316,7 @@ class SignalStrengthImageSource : public gfx::CanvasImageSource { |
| : CanvasImageSource(GetSizeForIconType(icon_type), false), |
| image_type_(image_type), |
| icon_type_(icon_type), |
| + color_(GetBaseColorForIconType(icon_type_)), |
|
varkha
2016/09/19 20:19:23
[self review] Need to add a color or alpha for the
varkha
2016/09/23 00:35:53
Done.
|
| signal_strength_(signal_strength) { |
| if (image_type_ == NONE) |
| image_type_ = ARCS; |
| @@ -325,6 +326,8 @@ class SignalStrengthImageSource : public gfx::CanvasImageSource { |
| } |
| ~SignalStrengthImageSource() override {} |
| + void set_color(SkColor color) { color_ = color; } |
| + |
| // gfx::CanvasImageSource: |
| void Draw(gfx::Canvas* canvas) override { |
| if (image_type_ == ARCS) |
| @@ -360,16 +363,15 @@ class SignalStrengthImageSource : public gfx::CanvasImageSource { |
| SkPaint paint; |
| paint.setAntiAlias(true); |
| paint.setStyle(SkPaint::kFill_Style); |
| - const SkColor base_color = GetBaseColorForIconType(icon_type_); |
| // Background. Skip drawing for full signal. |
| if (signal_strength_ != kNumNetworkImages - 1) { |
| - paint.setColor(SkColorSetA(base_color, kBgAlpha)); |
| + paint.setColor(SkColorSetA(color_, kBgAlpha)); |
| canvas->sk_canvas()->drawArc(gfx::RectFToSkRect(oval_bounds), kStartAngle, |
| kSweepAngle, true, paint); |
| } |
| // Foreground (signal strength). |
| if (signal_strength_ != 0) { |
| - paint.setColor(base_color); |
| + paint.setColor(color_); |
| // Percent of the height of the background wedge that we draw the |
| // foreground wedge, indexed by signal strength. |
| static const float kWedgeHeightPercentages[] = {0.f, 0.375f, 0.5833f, |
| @@ -406,15 +408,14 @@ class SignalStrengthImageSource : public gfx::CanvasImageSource { |
| SkPaint paint; |
| paint.setAntiAlias(true); |
| paint.setStyle(SkPaint::kFill_Style); |
| - const SkColor base_color = GetBaseColorForIconType(icon_type_); |
| // Background. Skip drawing for full signal. |
| if (signal_strength_ != kNumNetworkImages - 1) { |
| - paint.setColor(SkColorSetA(base_color, kBgAlpha)); |
| + paint.setColor(SkColorSetA(color_, kBgAlpha)); |
| canvas->DrawPath(make_triangle(kFullTriangleSide), paint); |
| } |
| // Foreground (signal strength). |
| if (signal_strength_ != 0) { |
| - paint.setColor(base_color); |
| + paint.setColor(color_); |
| // As a percentage of the bg triangle, the length of one of the short |
| // sides of the fg triangle, indexed by signal strength. |
| static const float kTriangleSidePercents[] = {0.f, 0.5f, 0.625f, 0.75f, |
| @@ -427,6 +428,7 @@ class SignalStrengthImageSource : public gfx::CanvasImageSource { |
| ImageType image_type_; |
| IconType icon_type_; |
| + SkColor color_; |
| // On a scale of 0 to kNum{Arcs,Bars}Images - 1, how connected we are. |
| int signal_strength_; |
| @@ -470,10 +472,13 @@ ImageType ImageTypeForNetworkType(const std::string& type) { |
| gfx::ImageSkia GetImageForIndex(ImageType image_type, |
| IconType icon_type, |
| + SkColor color, |
| int index) { |
| if (UseMd()) { |
| - gfx::CanvasImageSource* source = |
| + SignalStrengthImageSource* source = |
| new SignalStrengthImageSource(image_type, icon_type, index); |
| + if (color != SK_ColorTRANSPARENT) |
|
varkha
2016/09/19 20:19:23
[self review] This seems hacky. Maybe provide a mo
|
| + source->set_color(color); |
| return gfx::ImageSkia(source, source->size()); |
| } |
| @@ -491,7 +496,8 @@ const gfx::ImageSkia GetDisconnectedImage(IconType icon_type, |
| DCHECK_NE(shill::kTypeVPN, network_type); |
| ImageType image_type = ImageTypeForNetworkType(network_type); |
| const int disconnected_index = 0; |
| - return GetImageForIndex(image_type, icon_type, disconnected_index); |
| + return GetImageForIndex(image_type, icon_type, SK_ColorTRANSPARENT, |
| + disconnected_index); |
| } |
| gfx::ImageSkia* ConnectingWirelessImage(ImageType image_type, |
| @@ -513,7 +519,8 @@ gfx::ImageSkia* ConnectingWirelessImage(ImageType image_type, |
| if (!images[index]) { |
| // Lazily cache images. |
| // TODO(estade): should the alpha be applied in SignalStrengthImageSource? |
| - gfx::ImageSkia source = GetImageForIndex(image_type, icon_type, index + 1); |
| + gfx::ImageSkia source = |
| + GetImageForIndex(image_type, icon_type, SK_ColorTRANSPARENT, index + 1); |
| images[index] = |
| new gfx::ImageSkia(gfx::ImageSkiaOperations::CreateTransparentImage( |
| source, kConnectingImageAlpha)); |
| @@ -639,7 +646,7 @@ gfx::ImageSkia GetIcon(const NetworkState* network, |
| } else if (network->Matches(NetworkTypePattern::Wireless())) { |
| DCHECK(strength_index > 0); |
| return GetImageForIndex(ImageTypeForNetworkType(network->type()), icon_type, |
| - strength_index); |
| + SK_ColorTRANSPARENT, strength_index); |
| } else if (network->Matches(NetworkTypePattern::VPN())) { |
| DCHECK_NE(ICON_TYPE_TRAY, icon_type); |
| return GetVpnImage(); |
| @@ -904,13 +911,25 @@ gfx::ImageSkia GetImageForConnectedMobileNetwork() { |
| ImageType image_type = ImageTypeForNetworkType(shill::kTypeWifi); |
| const IconType icon_type = ICON_TYPE_LIST; |
| const int connected_index = kNumNetworkImages - 1; |
| - return GetImageForIndex(image_type, icon_type, connected_index); |
| + return GetImageForIndex(image_type, icon_type, SK_ColorTRANSPARENT, |
| + connected_index); |
| } |
| gfx::ImageSkia GetImageForDisconnectedCellNetwork() { |
| return GetDisconnectedImage(ICON_TYPE_LIST, shill::kTypeCellular); |
| } |
| +gfx::ImageSkia GetImageForHeaderWifiNetwork(SkColor color) { |
| + ImageType image_type = ImageTypeForNetworkType(shill::kTypeWifi); |
| + const int connected_index = kNumNetworkImages - 1; |
| + gfx::ImageSkia icon = |
| + GetImageForIndex(image_type, ICON_TYPE_LIST, color, connected_index); |
| + Badges badges; |
| + badges.bottom_right = |
| + gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_BADGE_ADD_OTHER, color); |
| + return NetworkIconImageSourceMd::CreateImage(icon, badges); |
| +} |
| + |
| gfx::ImageSkia GetVpnImage() { |
| return UseMd() |
| ? gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_VPN, |