Commit 9ca8fd49 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Touchable Chrome: update caption buttons icons colors

BUG=805267

Change-Id: I39a7b31ad3f796cd059bafece3fa851da3e25049
Reviewed-on: https://chromium-review.googlesource.com/954066
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542194}
parent aae81411
......@@ -18,6 +18,8 @@ const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe);
const float kInactiveFrameButtonIconAlphaRatio = 0.2f;
const float kInactiveFrameButtonIconAlphaRatioTouch = 0.43f;
const SkColor kFocusBorderColor = SkColorSetA(gfx::kGoogleBlue500, 0x99);
const int kFocusBorderThickness = 2;
......
......@@ -29,6 +29,9 @@ extern const SkColor kChromeOsBootColor;
// The alpha to draw inactive browser frame icons with.
ASH_EXPORT extern const float kInactiveFrameButtonIconAlphaRatio;
// Similar to the above but for touch-optimized UI.
ASH_EXPORT extern const float kInactiveFrameButtonIconAlphaRatioTouch;
// The border color of keyboard focus for launcher items and system tray.
extern const SkColor kFocusBorderColor;
extern const int kFocusBorderThickness;
......
......@@ -5,6 +5,7 @@
#include "ash/frame/caption_buttons/frame_caption_button.h"
#include "ash/ash_constants.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/animation/throb_animation.h"
#include "ui/gfx/canvas.h"
......@@ -56,9 +57,19 @@ FrameCaptionButton::~FrameCaptionButton() = default;
// static
SkColor FrameCaptionButton::GetButtonColor(bool use_light_images) {
if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
return use_light_images ? gfx::kGoogleGrey100 : gfx::kGoogleGrey800;
return use_light_images ? SK_ColorWHITE : gfx::kChromeIconGrey;
}
// static
float FrameCaptionButton::GetInactiveButtonColorAlphaRatio() {
return ui::MaterialDesignController::IsTouchOptimizedUiEnabled()
? kInactiveFrameButtonIconAlphaRatioTouch
: kInactiveFrameButtonIconAlphaRatio;
}
void FrameCaptionButton::SetImage(CaptionButtonIcon icon,
Animate animate,
const gfx::VectorIcon& icon_definition) {
......@@ -185,7 +196,7 @@ int FrameCaptionButton::GetAlphaForIcon(int base_alpha) const {
return base_alpha;
// Paint icons as active when they are hovered over or pressed.
double inactive_alpha = kInactiveFrameButtonIconAlphaRatio;
double inactive_alpha = GetInactiveButtonColorAlphaRatio();
if (hover_animation().is_animating()) {
inactive_alpha =
......
......@@ -34,6 +34,9 @@ class ASH_EXPORT FrameCaptionButton : public views::Button {
// Gets the color to use for a frame caption button.
static SkColor GetButtonColor(bool use_light_images);
// Gets the alpha ratio for the colors of inactive frame caption buttons.
static float GetInactiveButtonColorAlphaRatio();
// Sets the image to use to paint the button. If |animate| is ANIMATE_YES,
// the button crossfades to the new visuals. If the image matches the one
// currently used by the button and |animate| is ANIMATE_NO, the crossfade
......
......@@ -572,10 +572,11 @@ BrowserNonClientFrameViewAsh::CreateFrameHeader() {
// Add the container for extra hosted app buttons (e.g app menu button).
SkColor button_color = ash::FrameCaptionButton::GetButtonColor(
default_frame_header->ShouldUseLightImages());
const float inactive_alpha_ratio =
ash::FrameCaptionButton::GetInactiveButtonColorAlphaRatio();
hosted_app_button_container_ = new HostedAppButtonContainer(
browser_view(), button_color,
SkColorSetA(button_color,
255 * ash::kInactiveFrameButtonIconAlphaRatio));
SkColorSetA(button_color, 255 * inactive_alpha_ratio));
caption_button_container_->AddChildViewAt(hosted_app_button_container_, 0);
} else if (!browser->is_app()) {
// For non app (i.e. WebUI) windows (e.g. Settings) use MD frame color.
......
......@@ -61,6 +61,7 @@
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
#include "ui/gfx/color_palette.h"
#include "ui/views/widget/widget.h"
namespace {
......@@ -558,7 +559,13 @@ IN_PROC_BROWSER_TEST_P(HostedAppNonClientFrameViewAshTest, HostedAppFrame) {
static_cast<ash::DefaultFrameHeader*>(frame_view->frame_header_.get());
EXPECT_EQ(SK_ColorBLUE, frame_header->GetActiveFrameColor());
EXPECT_EQ(SK_ColorBLUE, frame_header->GetInactiveFrameColor());
EXPECT_EQ(SK_ColorWHITE, button_container->active_icon_color_);
// TODO(afakhry): Figure out the right way to test this (i.e. are we testing
// that the caption colors are light since the frame color is dark? Or are we
// testing that the colors are contrasting?). Do this while working on themes
// in https://crbug.com/820495.
const SkColor expected_active_icon_color =
GetParam() ? gfx::kGoogleGrey100 : SK_ColorWHITE;
EXPECT_EQ(expected_active_icon_color, button_container->active_icon_color_);
// Show a content setting icon.
auto& content_setting_views =
......
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