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

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

Issue 2361063002: MdTextButton: get rid of distinct "default" styling and make all (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 | ui/views/window/dialog_client_view.cc » ('j') | 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 LabelButton::SetText(text); 208 LabelButton::SetText(text);
209 UpdatePadding(); 209 UpdatePadding();
210 } 210 }
211 211
212 void MdTextButton::AdjustFontSize(int size_delta) { 212 void MdTextButton::AdjustFontSize(int size_delta) {
213 LabelButton::AdjustFontSize(size_delta); 213 LabelButton::AdjustFontSize(size_delta);
214 UpdatePadding(); 214 UpdatePadding();
215 } 215 }
216 216
217 void MdTextButton::UpdateStyleToIndicateDefaultStatus() { 217 void MdTextButton::UpdateStyleToIndicateDefaultStatus() {
218 is_cta_ = is_cta_ || is_default();
218 UpdateColors(); 219 UpdateColors();
219 } 220 }
220 221
221 void MdTextButton::SetFontList(const gfx::FontList& font_list) { 222 void MdTextButton::SetFontList(const gfx::FontList& font_list) {
222 NOTREACHED() 223 NOTREACHED()
223 << "Don't call MdTextButton::SetFontList (it will soon be protected)"; 224 << "Don't call MdTextButton::SetFontList (it will soon be protected)";
224 } 225 }
225 226
226 MdTextButton::MdTextButton(ButtonListener* listener) 227 MdTextButton::MdTextButton(ButtonListener* listener)
227 : LabelButton(listener, base::string16()), 228 : LabelButton(listener, base::string16()),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); 304 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground);
304 305
305 if (bg_color_override_) { 306 if (bg_color_override_) {
306 bg_color = *bg_color_override_; 307 bg_color = *bg_color_override_;
307 } else if (is_cta_) { 308 } else if (is_cta_) {
308 bg_color = theme->GetSystemColor( 309 bg_color = theme->GetSystemColor(
309 ui::NativeTheme::kColorId_CallToActionColor); 310 ui::NativeTheme::kColorId_CallToActionColor);
310 if (state() == STATE_DISABLED) 311 if (state() == STATE_DISABLED)
311 bg_color = color_utils::BlendTowardOppositeLuma( 312 bg_color = color_utils::BlendTowardOppositeLuma(
312 bg_color, gfx::kDisabledControlAlpha); 313 bg_color, gfx::kDisabledControlAlpha);
313 } else if (is_default()) {
314 bg_color = color_utils::BlendTowardOppositeLuma(text_color, 0xD8);
315 } 314 }
316 315
317 if (state() == STATE_PRESSED) { 316 if (state() == STATE_PRESSED) {
318 SkColor shade = 317 SkColor shade =
319 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonPressedShade); 318 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonPressedShade);
320 bg_color = color_utils::GetResultingPaintColor(shade, bg_color); 319 bg_color = color_utils::GetResultingPaintColor(shade, bg_color);
321 } 320 }
322 321
323 const SkAlpha kStrokeOpacity = 0x1A; 322 const SkAlpha kStrokeOpacity = 0x1A;
324 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) 323 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color))
325 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) 324 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity)
326 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); 325 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity);
327 326
328 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); 327 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color)));
329 set_background(Background::CreateBackgroundPainter( 328 set_background(Background::CreateBackgroundPainter(
330 true, Painter::CreateRoundRectWith1PxBorderPainter( 329 true, Painter::CreateRoundRectWith1PxBorderPainter(
331 bg_color, stroke_color, kInkDropSmallCornerRadius))); 330 bg_color, stroke_color, kInkDropSmallCornerRadius)));
332 } 331 }
333 332
334 } // namespace views 333 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/window/dialog_client_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698