| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/scrollbar/native_scroll_bar_views.h" | 5 #include "ui/views/controls/scrollbar/native_scroll_bar_views.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/events/keycodes/keyboard_codes.h" | 8 #include "ui/events/keycodes/keyboard_codes.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/path.h" | 10 #include "ui/gfx/path.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 gfx::Rect bounds(GetPreferredSize()); | 89 gfx::Rect bounds(GetPreferredSize()); |
| 90 GetNativeTheme()->Paint(canvas->sk_canvas(), GetNativeThemePart(), | 90 GetNativeTheme()->Paint(canvas->sk_canvas(), GetNativeThemePart(), |
| 91 GetNativeThemeState(), bounds, | 91 GetNativeThemeState(), bounds, |
| 92 GetNativeThemeParams()); | 92 GetNativeThemeParams()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 ui::NativeTheme::ExtraParams | 95 ui::NativeTheme::ExtraParams |
| 96 ScrollBarButton::GetNativeThemeParams() const { | 96 ScrollBarButton::GetNativeThemeParams() const { |
| 97 ui::NativeTheme::ExtraParams params; | 97 ui::NativeTheme::ExtraParams params; |
| 98 | 98 |
| 99 switch (state_) { | 99 switch (state()) { |
| 100 case CustomButton::STATE_HOVERED: | 100 case CustomButton::STATE_HOVERED: |
| 101 params.scrollbar_arrow.is_hovering = true; | 101 params.scrollbar_arrow.is_hovering = true; |
| 102 break; | 102 break; |
| 103 default: | 103 default: |
| 104 params.scrollbar_arrow.is_hovering = false; | 104 params.scrollbar_arrow.is_hovering = false; |
| 105 break; | 105 break; |
| 106 } | 106 } |
| 107 | 107 |
| 108 return params; | 108 return params; |
| 109 } | 109 } |
| 110 | 110 |
| 111 ui::NativeTheme::Part | 111 ui::NativeTheme::Part |
| 112 ScrollBarButton::GetNativeThemePart() const { | 112 ScrollBarButton::GetNativeThemePart() const { |
| 113 switch (type_) { | 113 switch (type_) { |
| 114 case UP: | 114 case UP: |
| 115 return ui::NativeTheme::kScrollbarUpArrow; | 115 return ui::NativeTheme::kScrollbarUpArrow; |
| 116 case DOWN: | 116 case DOWN: |
| 117 return ui::NativeTheme::kScrollbarDownArrow; | 117 return ui::NativeTheme::kScrollbarDownArrow; |
| 118 case LEFT: | 118 case LEFT: |
| 119 return ui::NativeTheme::kScrollbarLeftArrow; | 119 return ui::NativeTheme::kScrollbarLeftArrow; |
| 120 case RIGHT: | 120 case RIGHT: |
| 121 return ui::NativeTheme::kScrollbarRightArrow; | 121 return ui::NativeTheme::kScrollbarRightArrow; |
| 122 default: | 122 default: |
| 123 return ui::NativeTheme::kScrollbarUpArrow; | 123 return ui::NativeTheme::kScrollbarUpArrow; |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 ui::NativeTheme::State | 127 ui::NativeTheme::State |
| 128 ScrollBarButton::GetNativeThemeState() const { | 128 ScrollBarButton::GetNativeThemeState() const { |
| 129 ui::NativeTheme::State state; | 129 switch (state()) { |
| 130 | |
| 131 switch (state_) { | |
| 132 case CustomButton::STATE_HOVERED: | 130 case CustomButton::STATE_HOVERED: |
| 133 state = ui::NativeTheme::kHovered; | 131 return ui::NativeTheme::kHovered; |
| 134 break; | |
| 135 case CustomButton::STATE_PRESSED: | 132 case CustomButton::STATE_PRESSED: |
| 136 state = ui::NativeTheme::kPressed; | 133 return ui::NativeTheme::kPressed; |
| 137 break; | |
| 138 case CustomButton::STATE_DISABLED: | 134 case CustomButton::STATE_DISABLED: |
| 139 state = ui::NativeTheme::kDisabled; | 135 return ui::NativeTheme::kDisabled; |
| 140 break; | |
| 141 case CustomButton::STATE_NORMAL: | 136 case CustomButton::STATE_NORMAL: |
| 142 default: | 137 default: |
| 143 state = ui::NativeTheme::kNormal; | 138 return ui::NativeTheme::kNormal; |
| 144 break; | |
| 145 } | 139 } |
| 146 | |
| 147 return state; | |
| 148 } | 140 } |
| 149 | 141 |
| 150 ///////////////////////////////////////////////////////////////////////////// | 142 ///////////////////////////////////////////////////////////////////////////// |
| 151 // ScrollBarThumb | 143 // ScrollBarThumb |
| 152 | 144 |
| 153 ScrollBarThumb::ScrollBarThumb(BaseScrollBar* scroll_bar) | 145 ScrollBarThumb::ScrollBarThumb(BaseScrollBar* scroll_bar) |
| 154 : BaseScrollBarThumb(scroll_bar), | 146 : BaseScrollBarThumb(scroll_bar), |
| 155 scroll_bar_(scroll_bar) { | 147 scroll_bar_(scroll_bar) { |
| 156 SetFocusable(false); | 148 SetFocusable(false); |
| 157 SetAccessibilityFocusable(false); | 149 SetAccessibilityFocusable(false); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return params; | 182 return params; |
| 191 } | 183 } |
| 192 | 184 |
| 193 ui::NativeTheme::Part ScrollBarThumb::GetNativeThemePart() const { | 185 ui::NativeTheme::Part ScrollBarThumb::GetNativeThemePart() const { |
| 194 if (scroll_bar_->IsHorizontal()) | 186 if (scroll_bar_->IsHorizontal()) |
| 195 return ui::NativeTheme::kScrollbarHorizontalThumb; | 187 return ui::NativeTheme::kScrollbarHorizontalThumb; |
| 196 return ui::NativeTheme::kScrollbarVerticalThumb; | 188 return ui::NativeTheme::kScrollbarVerticalThumb; |
| 197 } | 189 } |
| 198 | 190 |
| 199 ui::NativeTheme::State ScrollBarThumb::GetNativeThemeState() const { | 191 ui::NativeTheme::State ScrollBarThumb::GetNativeThemeState() const { |
| 200 ui::NativeTheme::State state; | |
| 201 | |
| 202 switch (GetState()) { | 192 switch (GetState()) { |
| 203 case CustomButton::STATE_HOVERED: | 193 case CustomButton::STATE_HOVERED: |
| 204 state = ui::NativeTheme::kHovered; | 194 return ui::NativeTheme::kHovered; |
| 205 break; | |
| 206 case CustomButton::STATE_PRESSED: | 195 case CustomButton::STATE_PRESSED: |
| 207 state = ui::NativeTheme::kPressed; | 196 return ui::NativeTheme::kPressed; |
| 208 break; | |
| 209 case CustomButton::STATE_DISABLED: | 197 case CustomButton::STATE_DISABLED: |
| 210 state = ui::NativeTheme::kDisabled; | 198 return ui::NativeTheme::kDisabled; |
| 211 break; | |
| 212 case CustomButton::STATE_NORMAL: | 199 case CustomButton::STATE_NORMAL: |
| 213 default: | 200 default: |
| 214 state = ui::NativeTheme::kNormal; | 201 return ui::NativeTheme::kNormal; |
| 215 break; | |
| 216 } | 202 } |
| 217 | |
| 218 return state; | |
| 219 } | 203 } |
| 220 | 204 |
| 221 } // namespace | 205 } // namespace |
| 222 | 206 |
| 223 //////////////////////////////////////////////////////////////////////////////// | 207 //////////////////////////////////////////////////////////////////////////////// |
| 224 // NativeScrollBarViews, public: | 208 // NativeScrollBarViews, public: |
| 225 | 209 |
| 226 const char NativeScrollBarViews::kViewClassName[] = "NativeScrollBarViews"; | 210 const char NativeScrollBarViews::kViewClassName[] = "NativeScrollBarViews"; |
| 227 | 211 |
| 228 NativeScrollBarViews::NativeScrollBarViews(NativeScrollBar* scroll_bar) | 212 NativeScrollBarViews::NativeScrollBarViews(NativeScrollBar* scroll_bar) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 thumb_params.scrollbar_thumb.is_hovering = false; | 391 thumb_params.scrollbar_thumb.is_hovering = false; |
| 408 gfx::Size track_size = theme->GetPartSize( | 392 gfx::Size track_size = theme->GetPartSize( |
| 409 ui::NativeTheme::kScrollbarVerticalThumb, | 393 ui::NativeTheme::kScrollbarVerticalThumb, |
| 410 ui::NativeTheme::kNormal, | 394 ui::NativeTheme::kNormal, |
| 411 thumb_params); | 395 thumb_params); |
| 412 | 396 |
| 413 return std::max(track_size.width(), button_size.width()); | 397 return std::max(track_size.width(), button_size.width()); |
| 414 } | 398 } |
| 415 | 399 |
| 416 } // namespace views | 400 } // namespace views |
| OLD | NEW |