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

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

Issue 2639203007: Update SetPaintToLayer to accept LayerType (Closed)
Patch Set: Refactor Created 3 years, 11 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
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 "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "ui/base/material_design/material_design_controller.h" 9 #include "ui/base/material_design/material_design_controller.h"
10 #include "ui/compositor/layer_type.h"
10 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/color_palette.h" 12 #include "ui/gfx/color_palette.h"
12 #include "ui/gfx/color_utils.h" 13 #include "ui/gfx/color_utils.h"
13 #include "ui/native_theme/native_theme.h" 14 #include "ui/native_theme/native_theme.h"
14 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 15 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
15 #include "ui/views/animation/ink_drop_highlight.h" 16 #include "ui/views/animation/ink_drop_highlight.h"
16 #include "ui/views/animation/ink_drop_impl.h" 17 #include "ui/views/animation/ink_drop_impl.h"
17 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" 18 #include "ui/views/animation/ink_drop_painted_layer_delegates.h"
18 #include "ui/views/background.h" 19 #include "ui/views/background.h"
19 #include "ui/views/border.h" 20 #include "ui/views/border.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 SetMinSize(gfx::Size(kMinWidth, 0)); 199 SetMinSize(gfx::Size(kMinWidth, 0));
199 SetFocusPainter(nullptr); 200 SetFocusPainter(nullptr);
200 label()->SetAutoColorReadabilityEnabled(false); 201 label()->SetAutoColorReadabilityEnabled(false);
201 set_request_focus_on_press(false); 202 set_request_focus_on_press(false);
202 LabelButton::SetFontList(GetMdFontList()); 203 LabelButton::SetFontList(GetMdFontList());
203 204
204 set_animate_on_state_change(true); 205 set_animate_on_state_change(true);
205 206
206 // Paint to a layer so that the canvas is snapped to pixel boundaries (useful 207 // Paint to a layer so that the canvas is snapped to pixel boundaries (useful
207 // for fractional DSF). 208 // for fractional DSF).
208 SetPaintToLayer(true); 209 SetPaintToLayer(ui::LAYER_TEXTURED);
209 layer()->SetFillsBoundsOpaquely(false); 210 layer()->SetFillsBoundsOpaquely(false);
210 } 211 }
211 212
212 void MdTextButton::UpdatePadding() { 213 void MdTextButton::UpdatePadding() {
213 // Don't use font-based padding when there's no text visible. 214 // Don't use font-based padding when there's no text visible.
214 if (GetText().empty()) { 215 if (GetText().empty()) {
215 SetBorder(NullBorder()); 216 SetBorder(NullBorder());
216 return; 217 return;
217 } 218 }
218 219
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 stroke_color, gfx::kDisabledControlAlpha); 298 stroke_color, gfx::kDisabledControlAlpha);
298 } 299 }
299 300
300 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); 301 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color)));
301 set_background(Background::CreateBackgroundPainter( 302 set_background(Background::CreateBackgroundPainter(
302 Painter::CreateRoundRectWith1PxBorderPainter(bg_color, stroke_color, 303 Painter::CreateRoundRectWith1PxBorderPainter(bg_color, stroke_color,
303 kInkDropSmallCornerRadius))); 304 kInkDropSmallCornerRadius)));
304 } 305 }
305 306
306 } // namespace views 307 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698