Commit 4c1813b4 authored by Min Chen's avatar Min Chen Committed by Commit Bot

Add RippleAttributes in AshColorProvider.

Add RippleAttributes and corresponding get function in AshColorProvider
for ripple.

Bug: 972162
Change-Id: I49ffb4cb2a01600f210a57f2e7adb3bf21088513
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1686790
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680156}
parent ff8609c8
...@@ -9,11 +9,16 @@ ...@@ -9,11 +9,16 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "ui/gfx/color_palette.h" #include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
namespace ash { namespace ash {
namespace { namespace {
// Opacity of the light/dark ink ripple.
constexpr float kLightInkRippleOpacity = 0.08f;
constexpr float kDarkInkRippleOpacity = 0.06f;
// Gets the color mode value from feature flag "--ash-color-mode". // Gets the color mode value from feature flag "--ash-color-mode".
AshColorProvider::AshColorMode GetColorModeFromCommandLine() { AshColorProvider::AshColorMode GetColorModeFromCommandLine() {
const base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); const base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
...@@ -98,6 +103,15 @@ SkColor AshColorProvider::GetControlsLayerColor(ControlsLayerType type) const { ...@@ -98,6 +103,15 @@ SkColor AshColorProvider::GetControlsLayerColor(ControlsLayerType type) const {
return SelectColorOnMode(light_color, dark_color); return SelectColorOnMode(light_color, dark_color);
} }
AshColorProvider::RippleAttributes AshColorProvider::GetRippleAttributes(
SkColor bg_color) const {
const SkColor base_color = color_utils::GetColorWithMaxContrast(bg_color);
const float opacity = color_utils::IsDark(base_color)
? kDarkInkRippleOpacity
: kLightInkRippleOpacity;
return RippleAttributes(base_color, opacity, opacity);
}
SkColor AshColorProvider::SelectColorOnMode(SkColor light_color, SkColor AshColorProvider::SelectColorOnMode(SkColor light_color,
SkColor dark_color) const { SkColor dark_color) const {
if (color_mode_ == AshColorMode::kLight) if (color_mode_ == AshColorMode::kLight)
......
...@@ -62,6 +62,20 @@ class AshColorProvider { ...@@ -62,6 +62,20 @@ class AshColorProvider {
kFocusRing, kFocusRing,
}; };
// Attributes of ripple, includes the base color, opacity of inkdrop and
// highlight.
struct RippleAttributes {
RippleAttributes(SkColor color,
float opacity_of_inkdrop,
float opacity_of_highlight)
: base_color(color),
inkdrop_opacity(opacity_of_inkdrop),
highlight_opacity(opacity_of_highlight) {}
const SkColor base_color;
const float inkdrop_opacity;
const float highlight_opacity;
};
AshColorProvider(); AshColorProvider();
~AshColorProvider(); ~AshColorProvider();
...@@ -70,6 +84,10 @@ class AshColorProvider { ...@@ -70,6 +84,10 @@ class AshColorProvider {
SkColor GetBaseLayerColor(BaseLayerType type) const; SkColor GetBaseLayerColor(BaseLayerType type) const;
SkColor GetControlsLayerColor(ControlsLayerType type) const; SkColor GetControlsLayerColor(ControlsLayerType type) const;
// Gets the attributes of ripple on |bg_color|. |bg_color| is the background
// color of the UI element that wants to show inkdrop.
RippleAttributes GetRippleAttributes(SkColor bg_color) const;
AshColorMode color_mode() const { return color_mode_; } AshColorMode color_mode() const { return color_mode_; }
private: private:
......
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