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

Side by Side Diff: ui/views/controls/button/md_text_button.cc

Issue 2395843003: views: fix MdTextButton stroke alpha (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/button/md_text_button.h" 5 #include "ui/views/controls/button/md_text_button.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "ui/base/material_design/material_design_controller.h" 8 #include "ui/base/material_design/material_design_controller.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/color_palette.h" 10 #include "ui/gfx/color_palette.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 bg_color = color_utils::BlendTowardOppositeLuma( 257 bg_color = color_utils::BlendTowardOppositeLuma(
258 bg_color, gfx::kDisabledControlAlpha); 258 bg_color, gfx::kDisabledControlAlpha);
259 } 259 }
260 260
261 if (state() == STATE_PRESSED) { 261 if (state() == STATE_PRESSED) {
262 SkColor shade = 262 SkColor shade =
263 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonPressedShade); 263 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonPressedShade);
264 bg_color = color_utils::GetResultingPaintColor(shade, bg_color); 264 bg_color = color_utils::GetResultingPaintColor(shade, bg_color);
265 } 265 }
266 266
267 const SkAlpha kStrokeOpacity = 0x1A; 267 // Prominent buttons have no outside stroke at all. Fake it by using zero
268 SkColor stroke_color = (is_prominent_ || color_utils::IsDark(text_color)) 268 // opacity so the code below can still use
269 // CreateRoundRectWith1PxBorderPainter().
270 const SkAlpha kStrokeOpacity = is_prominent_ ? 0x00 : 0x33;
271 SkColor stroke_color = color_utils::IsDark(text_color)
269 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) 272 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity)
270 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); 273 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity);
271 274
272 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); 275 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color)));
273 set_background(Background::CreateBackgroundPainter( 276 set_background(Background::CreateBackgroundPainter(
274 true, Painter::CreateRoundRectWith1PxBorderPainter( 277 true, Painter::CreateRoundRectWith1PxBorderPainter(
275 bg_color, stroke_color, kInkDropSmallCornerRadius))); 278 bg_color, stroke_color, kInkDropSmallCornerRadius)));
276 } 279 }
277 280
278 } // namespace views 281 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698