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/style/platform_style.h" | 5 #include "ui/views/style/platform_style.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "build/build_config.h" | 8 #include "build/build_config.h" |
8 #include "ui/base/material_design/material_design_controller.h" | 9 #include "ui/base/material_design/material_design_controller.h" |
9 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/shadow_value.h" | 11 #include "ui/gfx/shadow_value.h" |
11 #include "ui/native_theme/native_theme.h" | 12 #include "ui/native_theme/native_theme.h" |
12 #include "ui/resources/grit/ui_resources.h" | 13 #include "ui/resources/grit/ui_resources.h" |
13 #include "ui/views/background.h" | 14 #include "ui/views/background.h" |
14 #include "ui/views/controls/button/label_button.h" | 15 #include "ui/views/controls/button/label_button.h" |
15 #include "ui/views/controls/button/label_button_border.h" | 16 #include "ui/views/controls/button/label_button_border.h" |
16 #include "ui/views/controls/focusable_border.h" | 17 #include "ui/views/controls/focusable_border.h" |
(...skipping 21 matching lines...) Expand all Loading... |
38 const bool PlatformStyle::kDefaultLabelButtonHasBoldFont = true; | 39 const bool PlatformStyle::kDefaultLabelButtonHasBoldFont = true; |
39 | 40 |
40 // static | 41 // static |
41 gfx::ImageSkia PlatformStyle::CreateComboboxArrow(bool is_enabled, | 42 gfx::ImageSkia PlatformStyle::CreateComboboxArrow(bool is_enabled, |
42 Combobox::Style style) { | 43 Combobox::Style style) { |
43 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 44 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
44 return *rb.GetImageSkiaNamed(IDR_MENU_DROPARROW); | 45 return *rb.GetImageSkiaNamed(IDR_MENU_DROPARROW); |
45 } | 46 } |
46 | 47 |
47 // static | 48 // static |
48 scoped_ptr<FocusableBorder> PlatformStyle::CreateComboboxBorder() { | 49 std::unique_ptr<FocusableBorder> PlatformStyle::CreateComboboxBorder() { |
49 return make_scoped_ptr(new FocusableBorder()); | 50 return base::WrapUnique(new FocusableBorder()); |
50 } | 51 } |
51 | 52 |
52 // static | 53 // static |
53 scoped_ptr<Background> PlatformStyle::CreateComboboxBackground() { | 54 std::unique_ptr<Background> PlatformStyle::CreateComboboxBackground() { |
54 return nullptr; | 55 return nullptr; |
55 } | 56 } |
56 | 57 |
57 // static | 58 // static |
58 scoped_ptr<LabelButtonBorder> PlatformStyle::CreateLabelButtonBorder( | 59 std::unique_ptr<LabelButtonBorder> PlatformStyle::CreateLabelButtonBorder( |
59 Button::ButtonStyle style) { | 60 Button::ButtonStyle style) { |
60 if (!ui::MaterialDesignController::IsModeMaterial() || | 61 if (!ui::MaterialDesignController::IsModeMaterial() || |
61 style != Button::STYLE_TEXTBUTTON) { | 62 style != Button::STYLE_TEXTBUTTON) { |
62 return make_scoped_ptr(new LabelButtonAssetBorder(style)); | 63 return base::WrapUnique(new LabelButtonAssetBorder(style)); |
63 } | 64 } |
64 | 65 |
65 scoped_ptr<LabelButtonBorder> border(new views::LabelButtonBorder()); | 66 std::unique_ptr<LabelButtonBorder> border(new views::LabelButtonBorder()); |
66 border->set_insets(views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( | 67 border->set_insets(views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( |
67 Button::STYLE_TEXTBUTTON)); | 68 Button::STYLE_TEXTBUTTON)); |
68 return border; | 69 return border; |
69 } | 70 } |
70 | 71 |
71 // static | 72 // static |
72 scoped_ptr<ScrollBar> PlatformStyle::CreateScrollBar(bool is_horizontal) { | 73 std::unique_ptr<ScrollBar> PlatformStyle::CreateScrollBar(bool is_horizontal) { |
73 return make_scoped_ptr(new NativeScrollBar(is_horizontal)); | 74 return base::WrapUnique(new NativeScrollBar(is_horizontal)); |
74 } | 75 } |
75 | 76 |
76 // static | 77 // static |
77 SkColor PlatformStyle::TextColorForButton( | 78 SkColor PlatformStyle::TextColorForButton( |
78 const ButtonColorByState& color_by_state, | 79 const ButtonColorByState& color_by_state, |
79 const LabelButton& button) { | 80 const LabelButton& button) { |
80 return color_by_state[button.state()]; | 81 return color_by_state[button.state()]; |
81 } | 82 } |
82 | 83 |
83 #endif // OS_MACOSX | 84 #endif // OS_MACOSX |
(...skipping 12 matching lines...) Expand all Loading... |
96 label->SetBackgroundColor( | 97 label->SetBackgroundColor( |
97 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonBackgroundColor)); | 98 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonBackgroundColor)); |
98 label->SetAutoColorReadabilityEnabled(false); | 99 label->SetAutoColorReadabilityEnabled(false); |
99 label->SetShadows(gfx::ShadowValues( | 100 label->SetShadows(gfx::ShadowValues( |
100 1, gfx::ShadowValue(gfx::Vector2d(0, 1), 0, kStyleButtonShadowColor))); | 101 1, gfx::ShadowValue(gfx::Vector2d(0, 1), 0, kStyleButtonShadowColor))); |
101 } | 102 } |
102 #endif | 103 #endif |
103 | 104 |
104 #if !defined(DESKTOP_LINUX) | 105 #if !defined(DESKTOP_LINUX) |
105 // static | 106 // static |
106 scoped_ptr<Border> PlatformStyle::CreateThemedLabelButtonBorder( | 107 std::unique_ptr<Border> PlatformStyle::CreateThemedLabelButtonBorder( |
107 LabelButton* button) { | 108 LabelButton* button) { |
108 return button->CreateDefaultBorder(); | 109 return button->CreateDefaultBorder(); |
109 } | 110 } |
110 #endif | 111 #endif |
111 | 112 |
112 } // namespace views | 113 } // namespace views |
OLD | NEW |