Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Unified Diff: ui/views/controls/button/md_text_button.cc

Issue 2400563004: Adjust shadow and stroke of MdTextButton. (Closed)
Patch Set: dont schedule paint, add a lot of consts Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/button/md_text_button.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/md_text_button.cc
diff --git a/ui/views/controls/button/md_text_button.cc b/ui/views/controls/button/md_text_button.cc
index 43d7b153fc274eb01c463d866b5be109677c3bb3..9b3d05986a6469e9d7ec436c6575f13065149d8d 100644
--- a/ui/views/controls/button/md_text_button.cc
+++ b/ui/views/controls/button/md_text_button.cc
@@ -86,6 +86,11 @@ void MdTextButton::SetProminent(bool is_prominent) {
UpdateColors();
}
+void MdTextButton::SetBgColorOverride(const base::Optional<SkColor>& color) {
+ bg_color_override_ = color;
+ UpdateColors();
+}
+
void MdTextButton::OnFocus() {
LabelButton::OnFocus();
FocusRing::Install(this);
@@ -122,12 +127,11 @@ std::unique_ptr<views::InkDropHighlight> MdTextButton::CreateInkDropHighlight()
const {
if (!ShouldShowInkDropHighlight())
return nullptr;
- if (!is_prominent_)
- return LabelButton::CreateInkDropHighlight();
// The prominent button hover effect is a shadow.
const int kYOffset = 1;
- const int kSkiaBlurRadius = 1;
+ const int kSkiaBlurRadius = 2;
+ const int shadow_alpha = is_prominent_ ? 0x3D : 0x1A;
std::vector<gfx::ShadowValue> shadows;
// The notion of blur that gfx::ShadowValue uses is twice the Skia/CSS value.
// Skia counts the number of pixels outside the mask area whereas
@@ -135,11 +139,13 @@ std::unique_ptr<views::InkDropHighlight> MdTextButton::CreateInkDropHighlight()
// the mask bounds.
shadows.push_back(gfx::ShadowValue(gfx::Vector2d(0, kYOffset),
2 * kSkiaBlurRadius,
- SkColorSetA(SK_ColorBLACK, 0x3D)));
+ SkColorSetA(SK_ColorBLACK, shadow_alpha)));
+ const SkColor fill_color =
+ SkColorSetA(SK_ColorWHITE, is_prominent_ ? 0x0D : 0x05);
return base::MakeUnique<InkDropHighlight>(
gfx::RectF(GetLocalBounds()).CenterPoint(),
base::WrapUnique(new BorderShadowLayerDelegate(
- shadows, GetLocalBounds(), kInkDropSmallCornerRadius)));
+ shadows, GetLocalBounds(), fill_color, kInkDropSmallCornerRadius)));
}
bool MdTextButton::ShouldShowInkDropForFocus() const {
@@ -264,11 +270,8 @@ void MdTextButton::UpdateColors() {
bg_color = color_utils::GetResultingPaintColor(shade, bg_color);
}
- const SkAlpha kStrokeOpacity = 0x1A;
- SkColor stroke_color = (is_prominent_ || color_utils::IsDark(text_color))
- ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity)
- : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity);
-
+ SkColor stroke_color =
+ is_prominent_ ? SK_ColorTRANSPARENT : SkColorSetA(text_color, 0x33);
DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color)));
set_background(Background::CreateBackgroundPainter(
true, Painter::CreateRoundRectWith1PxBorderPainter(
« no previous file with comments | « ui/views/controls/button/md_text_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698