Commit d7a963df authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Fix tray icon padding & network icon size

This CL adds 2dip padding between tray icons & fix WiFi icon padding.
WiFi icon is also used in network detailed view, so we have to set the
custom padding by checking IconType.

TEST=manual
BUG=885233

Change-Id: I5848007a1c71af54bba29105bcef7e063f7b6cf0
Reviewed-on: https://chromium-review.googlesource.com/c/1286237
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600645}
parent 253378d3
...@@ -21,10 +21,6 @@ namespace network_icon { ...@@ -21,10 +21,6 @@ namespace network_icon {
namespace { namespace {
// Padding between outside of icon and edge of the canvas, in dp. This value
// stays the same regardless of the canvas size.
constexpr int kSignalStrengthImageInset = 2;
// TODO(estade): share this alpha with other things in ash (battery, etc.). // TODO(estade): share this alpha with other things in ash (battery, etc.).
// See https://crbug.com/623987 and https://crbug.com/632827 // See https://crbug.com/623987 and https://crbug.com/632827
constexpr int kSignalStrengthImageBgAlpha = 0x4D; constexpr int kSignalStrengthImageBgAlpha = 0x4D;
...@@ -102,11 +98,13 @@ bool NetworkIconImageSource::HasRepresentationAtAllScales() const { ...@@ -102,11 +98,13 @@ bool NetworkIconImageSource::HasRepresentationAtAllScales() const {
SignalStrengthImageSource::SignalStrengthImageSource(ImageType image_type, SignalStrengthImageSource::SignalStrengthImageSource(ImageType image_type,
SkColor color, SkColor color,
const gfx::Size& size, const gfx::Size& size,
int signal_strength) int signal_strength,
int padding)
: CanvasImageSource(size, false /* is_opaque */), : CanvasImageSource(size, false /* is_opaque */),
image_type_(image_type), image_type_(image_type),
color_(color), color_(color),
signal_strength_(signal_strength) { signal_strength_(signal_strength),
padding_(padding) {
if (image_type_ == NONE) if (image_type_ == NONE)
image_type_ = ARCS; image_type_ = ARCS;
...@@ -130,7 +128,7 @@ bool SignalStrengthImageSource::HasRepresentationAtAllScales() const { ...@@ -130,7 +128,7 @@ bool SignalStrengthImageSource::HasRepresentationAtAllScales() const {
void SignalStrengthImageSource::DrawArcs(gfx::Canvas* canvas) { void SignalStrengthImageSource::DrawArcs(gfx::Canvas* canvas) {
gfx::RectF oval_bounds((gfx::Rect(size()))); gfx::RectF oval_bounds((gfx::Rect(size())));
oval_bounds.Inset(gfx::Insets(kSignalStrengthImageInset)); oval_bounds.Inset(gfx::Insets(padding_));
// Double the width and height. The new midpoint should be the former // Double the width and height. The new midpoint should be the former
// bottom center. // bottom center.
oval_bounds.Inset(-oval_bounds.width() / 2, 0, -oval_bounds.width() / 2, oval_bounds.Inset(-oval_bounds.width() / 2, 0, -oval_bounds.width() / 2,
...@@ -174,12 +172,11 @@ void SignalStrengthImageSource::DrawBars(gfx::Canvas* canvas) { ...@@ -174,12 +172,11 @@ void SignalStrengthImageSource::DrawBars(gfx::Canvas* canvas) {
// Length of short side of an isosceles right triangle, in dip. // Length of short side of an isosceles right triangle, in dip.
const SkScalar kFullTriangleSide = const SkScalar kFullTriangleSide =
SkIntToScalar(size().width()) - kSignalStrengthImageInset * 2; SkIntToScalar(size().width()) - padding_ * 2;
auto make_triangle = [scale, kFullTriangleSide](SkScalar side) { auto make_triangle = [scale, kFullTriangleSide, this](SkScalar side) {
SkPath triangle; SkPath triangle;
triangle.moveTo(scale(kSignalStrengthImageInset), triangle.moveTo(scale(padding_), scale(padding_ + kFullTriangleSide));
scale(kSignalStrengthImageInset + kFullTriangleSide));
triangle.rLineTo(scale(side), 0); triangle.rLineTo(scale(side), 0);
triangle.rLineTo(0, -scale(side)); triangle.rLineTo(0, -scale(side));
triangle.close(); triangle.close();
......
...@@ -70,7 +70,8 @@ class ASH_PUBLIC_EXPORT SignalStrengthImageSource ...@@ -70,7 +70,8 @@ class ASH_PUBLIC_EXPORT SignalStrengthImageSource
SignalStrengthImageSource(ImageType image_type, SignalStrengthImageSource(ImageType image_type,
SkColor color, SkColor color,
const gfx::Size& size, const gfx::Size& size,
int signal_strength); int signal_strength,
int padding = 2);
~SignalStrengthImageSource() override; ~SignalStrengthImageSource() override;
...@@ -88,6 +89,10 @@ class ASH_PUBLIC_EXPORT SignalStrengthImageSource ...@@ -88,6 +89,10 @@ class ASH_PUBLIC_EXPORT SignalStrengthImageSource
// On a scale of 0 to kNumNetworkImages - 1, how connected we are. // On a scale of 0 to kNumNetworkImages - 1, how connected we are.
int signal_strength_; int signal_strength_;
// Padding between outside of icon and edge of the canvas, in dp. This value
// stays the same regardless of the canvas size.
const int padding_;
DISALLOW_COPY_AND_ASSIGN(SignalStrengthImageSource); DISALLOW_COPY_AND_ASSIGN(SignalStrengthImageSource);
}; };
......
...@@ -250,12 +250,18 @@ gfx::Size GetSizeForIconType(IconType icon_type) { ...@@ -250,12 +250,18 @@ gfx::Size GetSizeForIconType(IconType icon_type) {
return gfx::Size(size, size); return gfx::Size(size, size);
} }
int GetPaddingForIconType(IconType icon_type) {
if (features::IsSystemTrayUnifiedEnabled() && IsTrayIcon(icon_type))
return kUnifiedTrayNetworkIconPadding;
return kTrayNetworkIconPadding;
}
gfx::ImageSkia GetImageForIndex(ImageType image_type, gfx::ImageSkia GetImageForIndex(ImageType image_type,
IconType icon_type, IconType icon_type,
int index) { int index) {
return gfx::CanvasImageSource::MakeImageSkia<SignalStrengthImageSource>( return gfx::CanvasImageSource::MakeImageSkia<SignalStrengthImageSource>(
image_type, GetDefaultColorForIconType(icon_type), image_type, GetDefaultColorForIconType(icon_type),
GetSizeForIconType(icon_type), index); GetSizeForIconType(icon_type), index, GetPaddingForIconType(icon_type));
} }
// Returns an image to represent either a fully connected network or a // Returns an image to represent either a fully connected network or a
......
...@@ -98,6 +98,10 @@ constexpr int kTrayIconSize = 16; ...@@ -98,6 +98,10 @@ constexpr int kTrayIconSize = 16;
extern const SkColor kTrayIconColor; extern const SkColor kTrayIconColor;
extern const SkColor kOobeTrayIconColor; extern const SkColor kOobeTrayIconColor;
// The padding around network tray icon in dip.
constexpr int kTrayNetworkIconPadding = 2;
constexpr int kUnifiedTrayNetworkIconPadding = 4;
// The total visual padding at the start and end of the icon/label section // The total visual padding at the start and end of the icon/label section
// of the tray. // of the tray.
constexpr int kTrayEdgePadding = 6; constexpr int kTrayEdgePadding = 6;
...@@ -169,6 +173,7 @@ constexpr gfx::Insets kUnifiedSliderPadding(0, 16); ...@@ -169,6 +173,7 @@ constexpr gfx::Insets kUnifiedSliderPadding(0, 16);
constexpr int kUnifiedMenuVerticalPadding = 8; constexpr int kUnifiedMenuVerticalPadding = 8;
constexpr int kUnifiedNotificationCenterSpacing = 16; constexpr int kUnifiedNotificationCenterSpacing = 16;
constexpr int kUnifiedTrayIconSize = 20; constexpr int kUnifiedTrayIconSize = 20;
constexpr int kUnifiedTraySpacingBetweenIcons = 2;
constexpr int kUnifiedTrayCornerRadius = 20; constexpr int kUnifiedTrayCornerRadius = 20;
constexpr int kUnifiedTrayContentPadding = 5; constexpr int kUnifiedTrayContentPadding = 5;
constexpr int kUnifiedTopShortcutSpacing = 16; constexpr int kUnifiedTopShortcutSpacing = 16;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <utility> #include <utility>
#include "ash/public/cpp/ash_features.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_constants.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
...@@ -84,7 +85,9 @@ void TrayContainer::UpdateLayout() { ...@@ -84,7 +85,9 @@ void TrayContainer::UpdateLayout() {
std::swap(horizontal_margin, vertical_margin); std::swap(horizontal_margin, vertical_margin);
auto layout = std::make_unique<views::BoxLayout>( auto layout = std::make_unique<views::BoxLayout>(
orientation, gfx::Insets(vertical_margin, horizontal_margin), 0); orientation, gfx::Insets(vertical_margin, horizontal_margin),
features::IsSystemTrayUnifiedEnabled() ? kUnifiedTraySpacingBetweenIcons
: 0);
layout->set_minimum_cross_axis_size(kTrayItemSize); layout->set_minimum_cross_axis_size(kTrayItemSize);
views::View::SetLayoutManager(std::move(layout)); views::View::SetLayoutManager(std::move(layout));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment