Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "ui/views/style/platform_style.h" | 24 #include "ui/views/style/platform_style.h" |
| 25 #include "ui/views/style/typography.h" | 25 #include "ui/views/style/typography.h" |
| 26 | 26 |
| 27 namespace views { | 27 namespace views { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 LabelButton* CreateButton(ButtonListener* listener, | 31 LabelButton* CreateButton(ButtonListener* listener, |
| 32 const base::string16& text, | 32 const base::string16& text, |
| 33 bool md) { | 33 bool md) { |
| 34 #if !defined(OS_MACOSX) | |
| 34 if (md) | 35 if (md) |
| 36 #endif // !defined(OS_MACOSX) | |
|
tapted
2017/06/09 01:43:48
I try to avoid #ifdefs intertwining with branching
Peter Kasting
2017/06/09 02:21:47
This, but I would call it UseMaterialSecondaryButt
afakhry
2017/06/09 17:32:10
Done.
afakhry
2017/06/09 17:32:10
Done.
| |
| 35 return MdTextButton::Create(listener, text, style::CONTEXT_BUTTON_MD); | 37 return MdTextButton::Create(listener, text, style::CONTEXT_BUTTON_MD); |
| 36 | 38 |
| 39 #if !defined(OS_MACOSX) | |
| 37 LabelButton* button = new LabelButton(listener, text, style::CONTEXT_BUTTON); | 40 LabelButton* button = new LabelButton(listener, text, style::CONTEXT_BUTTON); |
| 38 button->SetStyleDeprecated(CustomButton::STYLE_BUTTON); | 41 button->SetStyleDeprecated(CustomButton::STYLE_BUTTON); |
| 39 return button; | 42 return button; |
| 43 #endif // !defined(OS_MACOSX) | |
| 40 } | 44 } |
| 41 | 45 |
| 42 } // namespace | 46 } // namespace |
| 43 | 47 |
| 44 // static | 48 // static |
| 45 LabelButton* MdTextButton::CreateSecondaryUiButton(ButtonListener* listener, | 49 LabelButton* MdTextButton::CreateSecondaryUiButton(ButtonListener* listener, |
| 46 const base::string16& text) { | 50 const base::string16& text) { |
| 47 return CreateButton(listener, text, | 51 return CreateButton(listener, text, |
| 48 ui::MaterialDesignController::IsSecondaryUiMaterial()); | 52 ui::MaterialDesignController::IsSecondaryUiMaterial()); |
|
tapted
2017/06/09 01:43:48
and here pass IsMaterialDefault()
afakhry
2017/06/09 17:32:10
Done.
| |
| 49 } | 53 } |
| 50 | 54 |
| 51 // static | 55 // static |
| 52 LabelButton* MdTextButton::CreateSecondaryUiBlueButton( | 56 LabelButton* MdTextButton::CreateSecondaryUiBlueButton( |
| 53 ButtonListener* listener, | 57 ButtonListener* listener, |
| 54 const base::string16& text) { | 58 const base::string16& text) { |
| 59 #if !defined(OS_MACOSX) | |
| 55 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 60 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
|
tapted
2017/06/09 01:43:48
also here. Then remove all the #if.
afakhry
2017/06/09 17:32:10
Done.
| |
| 61 #endif // !defined(OS_MACOSX) | |
| 56 MdTextButton* md_button = | 62 MdTextButton* md_button = |
| 57 MdTextButton::Create(listener, text, style::CONTEXT_BUTTON_MD); | 63 MdTextButton::Create(listener, text, style::CONTEXT_BUTTON_MD); |
| 58 md_button->SetProminent(true); | 64 md_button->SetProminent(true); |
| 59 return md_button; | 65 return md_button; |
| 66 #if !defined(OS_MACOSX) | |
| 60 } | 67 } |
| 61 | 68 |
| 62 return new BlueButton(listener, text); | 69 return new BlueButton(listener, text); |
| 70 #endif // !defined(OS_MACOSX) | |
| 63 } | 71 } |
| 64 | 72 |
| 65 // static | 73 // static |
| 66 MdTextButton* MdTextButton::Create(ButtonListener* listener, | 74 MdTextButton* MdTextButton::Create(ButtonListener* listener, |
| 67 const base::string16& text, | 75 const base::string16& text, |
| 68 int button_context) { | 76 int button_context) { |
| 69 MdTextButton* button = new MdTextButton(listener, button_context); | 77 MdTextButton* button = new MdTextButton(listener, button_context); |
| 70 button->SetText(text); | 78 button->SetText(text); |
| 71 button->SetFocusForPlatform(); | 79 button->SetFocusForPlatform(); |
| 72 return button; | 80 return button; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 } | 291 } |
| 284 | 292 |
| 285 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); | 293 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); |
| 286 SetBackground( | 294 SetBackground( |
| 287 CreateBackgroundFromPainter(Painter::CreateRoundRectWith1PxBorderPainter( | 295 CreateBackgroundFromPainter(Painter::CreateRoundRectWith1PxBorderPainter( |
| 288 bg_color, stroke_color, kInkDropSmallCornerRadius))); | 296 bg_color, stroke_color, kInkDropSmallCornerRadius))); |
| 289 SchedulePaint(); | 297 SchedulePaint(); |
| 290 } | 298 } |
| 291 | 299 |
| 292 } // namespace views | 300 } // namespace views |
| OLD | NEW |