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 {
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.).
// See https://crbug.com/623987 and https://crbug.com/632827
constexpr int kSignalStrengthImageBgAlpha = 0x4D;
......@@ -102,11 +98,13 @@ bool NetworkIconImageSource::HasRepresentationAtAllScales() const {
SignalStrengthImageSource::SignalStrengthImageSource(ImageType image_type,
SkColor color,
const gfx::Size& size,
int signal_strength)
int signal_strength,
int padding)
: CanvasImageSource(size, false /* is_opaque */),
image_type_(image_type),
color_(color),
signal_strength_(signal_strength) {
signal_strength_(signal_strength),
padding_(padding) {
if (image_type_ == NONE)
image_type_ = ARCS;
......@@ -130,7 +128,7 @@ bool SignalStrengthImageSource::HasRepresentationAtAllScales() const {
void SignalStrengthImageSource::DrawArcs(gfx::Canvas* canvas) {
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
// bottom center.
oval_bounds.Inset(-oval_bounds.width() / 2, 0, -oval_bounds.width() / 2,
......@@ -174,12 +172,11 @@ void SignalStrengthImageSource::DrawBars(gfx::Canvas* canvas) {
// Length of short side of an isosceles right triangle, in dip.
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;
triangle.moveTo(scale(kSignalStrengthImageInset),
scale(kSignalStrengthImageInset + kFullTriangleSide));
triangle.moveTo(scale(padding_), scale(padding_ + kFullTriangleSide));
triangle.rLineTo(scale(side), 0);
triangle.rLineTo(0, -scale(side));
triangle.close();
......
......@@ -70,7 +70,8 @@ class ASH_PUBLIC_EXPORT SignalStrengthImageSource
SignalStrengthImageSource(ImageType image_type,
SkColor color,
const gfx::Size& size,
int signal_strength);
int signal_strength,
int padding = 2);
~SignalStrengthImageSource() override;
......@@ -88,6 +89,10 @@ class ASH_PUBLIC_EXPORT SignalStrengthImageSource
// On a scale of 0 to kNumNetworkImages - 1, how connected we are.
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);
};
......
......@@ -250,12 +250,18 @@ gfx::Size GetSizeForIconType(IconType icon_type) {
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,
IconType icon_type,
int index) {
return gfx::CanvasImageSource::MakeImageSkia<SignalStrengthImageSource>(
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
......
......@@ -98,6 +98,10 @@ constexpr int kTrayIconSize = 16;
extern const SkColor kTrayIconColor;
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
// of the tray.
constexpr int kTrayEdgePadding = 6;
......@@ -169,6 +173,7 @@ constexpr gfx::Insets kUnifiedSliderPadding(0, 16);
constexpr int kUnifiedMenuVerticalPadding = 8;
constexpr int kUnifiedNotificationCenterSpacing = 16;
constexpr int kUnifiedTrayIconSize = 20;
constexpr int kUnifiedTraySpacingBetweenIcons = 2;
constexpr int kUnifiedTrayCornerRadius = 20;
constexpr int kUnifiedTrayContentPadding = 5;
constexpr int kUnifiedTopShortcutSpacing = 16;
......
......@@ -6,6 +6,7 @@
#include <utility>
#include "ash/public/cpp/ash_features.h"
#include "ash/shelf/shelf.h"
#include "ash/system/tray/tray_constants.h"
#include "ui/gfx/geometry/insets.h"
......@@ -84,7 +85,9 @@ void TrayContainer::UpdateLayout() {
std::swap(horizontal_margin, vertical_margin);
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);
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