| 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 "base/memory/ptr_util.h" |
| 8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
| 9 #include "ui/gfx/paint_vector_icon.h" | 9 #include "ui/gfx/paint_vector_icon.h" |
| 10 #include "ui/gfx/vector_icons.h" | 10 #include "ui/gfx/vector_icons.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 31 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 32 return *rb.GetImageSkiaNamed(IDR_MENU_DROPARROW); | 32 return *rb.GetImageSkiaNamed(IDR_MENU_DROPARROW); |
| 33 } | 33 } |
| 34 const int kComboboxArrowWidth = 13; | 34 const int kComboboxArrowWidth = 13; |
| 35 return gfx::CreateVectorIcon(gfx::VectorIconId::COMBOBOX_ARROW_MAC, | 35 return gfx::CreateVectorIcon(gfx::VectorIconId::COMBOBOX_ARROW_MAC, |
| 36 kComboboxArrowWidth, | 36 kComboboxArrowWidth, |
| 37 is_enabled ? SK_ColorWHITE : SK_ColorBLACK); | 37 is_enabled ? SK_ColorWHITE : SK_ColorBLACK); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // static | 40 // static |
| 41 gfx::ImageSkia PlatformStyle::CreateMenuButtonArrow(bool is_enabled) { |
| 42 const int kMenuButtonArrowWidth = 13; |
| 43 return gfx::CreateVectorIcon(gfx::VectorIconId::MENU_BUTTON_ARROW_MAC, |
| 44 kMenuButtonArrowWidth, |
| 45 is_enabled ? SK_ColorWHITE : SK_ColorBLACK); |
| 46 } |
| 47 |
| 48 // static |
| 41 std::unique_ptr<FocusableBorder> PlatformStyle::CreateComboboxBorder() { | 49 std::unique_ptr<FocusableBorder> PlatformStyle::CreateComboboxBorder() { |
| 42 return base::WrapUnique(new FocusableRoundedBorder); | 50 return base::WrapUnique(new FocusableRoundedBorder); |
| 43 } | 51 } |
| 44 | 52 |
| 45 // static | 53 // static |
| 46 std::unique_ptr<Background> PlatformStyle::CreateComboboxBackground() { | 54 std::unique_ptr<Background> PlatformStyle::CreateComboboxBackground() { |
| 47 return base::WrapUnique(new ComboboxBackgroundMac); | 55 // When creating the background, this function always assumes the combobox is |
| 56 // in STYLE_NORMAL. Comboboxes do not paint their backgrounds in STYLE_ACTION, |
| 57 // so that assumption is safe. |
| 58 return base::WrapUnique(new ComboboxBackgroundMac( |
| 59 GetComboboxShoulderWidth(Combobox::STYLE_NORMAL))); |
| 48 } | 60 } |
| 49 | 61 |
| 50 // static | 62 // static |
| 63 std::unique_ptr<FocusableBorder> PlatformStyle::CreateMenuButtonBorder() { |
| 64 return base::WrapUnique(new FocusableRoundedBorder); |
| 65 } |
| 66 |
| 67 // static |
| 68 std::unique_ptr<Background> PlatformStyle::CreateMenuButtonBackground() { |
| 69 return base::WrapUnique( |
| 70 new ComboboxBackgroundMac(GetMenuButtonShoulderWidth())); |
| 71 } |
| 72 |
| 73 // static |
| 51 std::unique_ptr<LabelButtonBorder> PlatformStyle::CreateLabelButtonBorder( | 74 std::unique_ptr<LabelButtonBorder> PlatformStyle::CreateLabelButtonBorder( |
| 52 Button::ButtonStyle style) { | 75 Button::ButtonStyle style) { |
| 53 if (style == Button::STYLE_BUTTON) | 76 if (style == Button::STYLE_BUTTON) |
| 54 return base::WrapUnique(new DialogButtonBorderMac()); | 77 return base::WrapUnique(new DialogButtonBorderMac()); |
| 55 | 78 |
| 56 return base::WrapUnique(new LabelButtonAssetBorder(style)); | 79 return base::WrapUnique(new LabelButtonAssetBorder(style)); |
| 57 } | 80 } |
| 58 | 81 |
| 59 // static | 82 // static |
| 60 std::unique_ptr<ScrollBar> PlatformStyle::CreateScrollBar(bool is_horizontal) { | 83 std::unique_ptr<ScrollBar> PlatformStyle::CreateScrollBar(bool is_horizontal) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 79 void PlatformStyle::ApplyLabelButtonTextStyle( | 102 void PlatformStyle::ApplyLabelButtonTextStyle( |
| 80 views::Label* label, | 103 views::Label* label, |
| 81 ButtonColorByState* color_by_state) { | 104 ButtonColorByState* color_by_state) { |
| 82 const ui::NativeTheme* theme = label->GetNativeTheme(); | 105 const ui::NativeTheme* theme = label->GetNativeTheme(); |
| 83 ButtonColorByState& colors = *color_by_state; | 106 ButtonColorByState& colors = *color_by_state; |
| 84 colors[Button::STATE_PRESSED] = | 107 colors[Button::STATE_PRESSED] = |
| 85 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHighlightColor); | 108 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHighlightColor); |
| 86 } | 109 } |
| 87 | 110 |
| 88 } // namespace views | 111 } // namespace views |
| OLD | NEW |