| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "ui/base/material_design/material_design_controller.h" | 8 #include "ui/base/material_design/material_design_controller.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/shadow_value.h" |
| 11 #include "ui/native_theme/native_theme.h" |
| 10 #include "ui/resources/grit/ui_resources.h" | 12 #include "ui/resources/grit/ui_resources.h" |
| 11 #include "ui/views/background.h" | 13 #include "ui/views/background.h" |
| 12 #include "ui/views/controls/button/label_button.h" | 14 #include "ui/views/controls/button/label_button.h" |
| 13 #include "ui/views/controls/button/label_button_border.h" | 15 #include "ui/views/controls/button/label_button_border.h" |
| 14 #include "ui/views/controls/focusable_border.h" | 16 #include "ui/views/controls/focusable_border.h" |
| 15 #include "ui/views/controls/scrollbar/native_scroll_bar.h" | 17 #include "ui/views/controls/scrollbar/native_scroll_bar.h" |
| 16 | 18 |
| 19 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 20 #define DESKTOP_LINUX |
| 21 #endif |
| 22 |
| 17 namespace views { | 23 namespace views { |
| 24 namespace { |
| 25 |
| 26 #if !defined(DESKTOP_LINUX) && !defined(OS_MACOSX) |
| 27 // Default text and shadow colors for STYLE_BUTTON. |
| 28 const SkColor kStyleButtonTextColor = SK_ColorBLACK; |
| 29 const SkColor kStyleButtonShadowColor = SK_ColorWHITE; |
| 30 #endif |
| 31 |
| 32 } // namespace |
| 18 | 33 |
| 19 #if !defined(OS_MACOSX) | 34 #if !defined(OS_MACOSX) |
| 20 | 35 |
| 36 const int PlatformStyle::kMinLabelButtonWidth = 70; |
| 37 const int PlatformStyle::kMinLabelButtonHeight = 33; |
| 38 const bool PlatformStyle::kDefaultLabelButtonHasBoldFont = true; |
| 39 |
| 21 // static | 40 // static |
| 22 gfx::ImageSkia PlatformStyle::CreateComboboxArrow(bool is_enabled, | 41 gfx::ImageSkia PlatformStyle::CreateComboboxArrow(bool is_enabled, |
| 23 Combobox::Style style) { | 42 Combobox::Style style) { |
| 24 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 43 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 25 return *rb.GetImageSkiaNamed(IDR_MENU_DROPARROW); | 44 return *rb.GetImageSkiaNamed(IDR_MENU_DROPARROW); |
| 26 } | 45 } |
| 27 | 46 |
| 28 // static | 47 // static |
| 29 scoped_ptr<FocusableBorder> PlatformStyle::CreateComboboxBorder() { | 48 scoped_ptr<FocusableBorder> PlatformStyle::CreateComboboxBorder() { |
| 30 return make_scoped_ptr(new FocusableBorder()); | 49 return make_scoped_ptr(new FocusableBorder()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 46 scoped_ptr<LabelButtonBorder> border(new views::LabelButtonBorder()); | 65 scoped_ptr<LabelButtonBorder> border(new views::LabelButtonBorder()); |
| 47 border->set_insets(views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( | 66 border->set_insets(views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( |
| 48 Button::STYLE_TEXTBUTTON)); | 67 Button::STYLE_TEXTBUTTON)); |
| 49 return border; | 68 return border; |
| 50 } | 69 } |
| 51 | 70 |
| 52 // static | 71 // static |
| 53 scoped_ptr<ScrollBar> PlatformStyle::CreateScrollBar(bool is_horizontal) { | 72 scoped_ptr<ScrollBar> PlatformStyle::CreateScrollBar(bool is_horizontal) { |
| 54 return make_scoped_ptr(new NativeScrollBar(is_horizontal)); | 73 return make_scoped_ptr(new NativeScrollBar(is_horizontal)); |
| 55 } | 74 } |
| 75 |
| 76 // static |
| 77 SkColor PlatformStyle::TextColorForButton( |
| 78 const ButtonColorByState& color_by_state, |
| 79 const LabelButton& button) { |
| 80 return color_by_state[button.state()]; |
| 81 } |
| 82 |
| 83 #endif // OS_MACOSX |
| 84 |
| 85 #if !defined(DESKTOP_LINUX) && !defined(OS_MACOSX) |
| 86 // static |
| 87 void PlatformStyle::ApplyLabelButtonTextStyle( |
| 88 Label* label, |
| 89 ButtonColorByState* color_by_state) { |
| 90 ButtonColorByState& colors = *color_by_state; |
| 91 colors[Button::STATE_NORMAL] = kStyleButtonTextColor; |
| 92 colors[Button::STATE_HOVERED] = kStyleButtonTextColor; |
| 93 colors[Button::STATE_PRESSED] = kStyleButtonTextColor; |
| 94 |
| 95 const ui::NativeTheme* theme = label->GetNativeTheme(); |
| 96 label->SetBackgroundColor( |
| 97 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonBackgroundColor)); |
| 98 label->SetAutoColorReadabilityEnabled(false); |
| 99 label->SetShadows(gfx::ShadowValues( |
| 100 1, gfx::ShadowValue(gfx::Vector2d(0, 1), 0, kStyleButtonShadowColor))); |
| 101 } |
| 56 #endif | 102 #endif |
| 57 | 103 |
| 58 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) | 104 #if !defined(DESKTOP_LINUX) |
| 59 // static | 105 // static |
| 60 scoped_ptr<Border> PlatformStyle::CreateThemedLabelButtonBorder( | 106 scoped_ptr<Border> PlatformStyle::CreateThemedLabelButtonBorder( |
| 61 LabelButton* button) { | 107 LabelButton* button) { |
| 62 return button->CreateDefaultBorder(); | 108 return button->CreateDefaultBorder(); |
| 63 } | 109 } |
| 64 #endif | 110 #endif |
| 65 | 111 |
| 66 } // namespace views | 112 } // namespace views |
| OLD | NEW |