Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: ui/views/controls/scrollbar/native_scroll_bar_views.cc

Issue 1534303002: CustomButton cleanup: make protected members private, create accessors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dont move declaration randomly Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('k') | ui/views/views.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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:
123 return ui::NativeTheme::kScrollbarUpArrow;
124 } 122 }
123
124 NOTREACHED();
125 return ui::NativeTheme::kScrollbarUpArrow;
125 } 126 }
126 127
127 ui::NativeTheme::State 128 ui::NativeTheme::State
128 ScrollBarButton::GetNativeThemeState() const { 129 ScrollBarButton::GetNativeThemeState() const {
129 ui::NativeTheme::State state; 130 switch (state()) {
130
131 switch (state_) {
132 case CustomButton::STATE_HOVERED: 131 case CustomButton::STATE_HOVERED:
133 state = ui::NativeTheme::kHovered; 132 return ui::NativeTheme::kHovered;
134 break;
135 case CustomButton::STATE_PRESSED: 133 case CustomButton::STATE_PRESSED:
136 state = ui::NativeTheme::kPressed; 134 return ui::NativeTheme::kPressed;
137 break;
138 case CustomButton::STATE_DISABLED: 135 case CustomButton::STATE_DISABLED:
139 state = ui::NativeTheme::kDisabled; 136 return ui::NativeTheme::kDisabled;
140 break;
141 case CustomButton::STATE_NORMAL: 137 case CustomButton::STATE_NORMAL:
142 default: 138 return ui::NativeTheme::kNormal;
143 state = ui::NativeTheme::kNormal; 139 case CustomButton::STATE_COUNT:
144 break; 140 break;
145 } 141 }
146 142
147 return state; 143 NOTREACHED();
144 return ui::NativeTheme::kNormal;
148 } 145 }
149 146
150 ///////////////////////////////////////////////////////////////////////////// 147 /////////////////////////////////////////////////////////////////////////////
151 // ScrollBarThumb 148 // ScrollBarThumb
152 149
153 ScrollBarThumb::ScrollBarThumb(BaseScrollBar* scroll_bar) 150 ScrollBarThumb::ScrollBarThumb(BaseScrollBar* scroll_bar)
154 : BaseScrollBarThumb(scroll_bar), 151 : BaseScrollBarThumb(scroll_bar),
155 scroll_bar_(scroll_bar) { 152 scroll_bar_(scroll_bar) {
156 SetFocusable(false); 153 SetFocusable(false);
157 SetAccessibilityFocusable(false); 154 SetAccessibilityFocusable(false);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return params; 187 return params;
191 } 188 }
192 189
193 ui::NativeTheme::Part ScrollBarThumb::GetNativeThemePart() const { 190 ui::NativeTheme::Part ScrollBarThumb::GetNativeThemePart() const {
194 if (scroll_bar_->IsHorizontal()) 191 if (scroll_bar_->IsHorizontal())
195 return ui::NativeTheme::kScrollbarHorizontalThumb; 192 return ui::NativeTheme::kScrollbarHorizontalThumb;
196 return ui::NativeTheme::kScrollbarVerticalThumb; 193 return ui::NativeTheme::kScrollbarVerticalThumb;
197 } 194 }
198 195
199 ui::NativeTheme::State ScrollBarThumb::GetNativeThemeState() const { 196 ui::NativeTheme::State ScrollBarThumb::GetNativeThemeState() const {
200 ui::NativeTheme::State state;
201
202 switch (GetState()) { 197 switch (GetState()) {
203 case CustomButton::STATE_HOVERED: 198 case CustomButton::STATE_HOVERED:
204 state = ui::NativeTheme::kHovered; 199 return ui::NativeTheme::kHovered;
205 break;
206 case CustomButton::STATE_PRESSED: 200 case CustomButton::STATE_PRESSED:
207 state = ui::NativeTheme::kPressed; 201 return ui::NativeTheme::kPressed;
208 break;
209 case CustomButton::STATE_DISABLED: 202 case CustomButton::STATE_DISABLED:
210 state = ui::NativeTheme::kDisabled; 203 return ui::NativeTheme::kDisabled;
211 break;
212 case CustomButton::STATE_NORMAL: 204 case CustomButton::STATE_NORMAL:
213 default: 205 return ui::NativeTheme::kNormal;
214 state = ui::NativeTheme::kNormal; 206 case CustomButton::STATE_COUNT:
215 break; 207 break;
216 } 208 }
217 209
218 return state; 210 NOTREACHED();
211 return ui::NativeTheme::kNormal;
219 } 212 }
220 213
221 } // namespace 214 } // namespace
222 215
223 //////////////////////////////////////////////////////////////////////////////// 216 ////////////////////////////////////////////////////////////////////////////////
224 // NativeScrollBarViews, public: 217 // NativeScrollBarViews, public:
225 218
226 const char NativeScrollBarViews::kViewClassName[] = "NativeScrollBarViews"; 219 const char NativeScrollBarViews::kViewClassName[] = "NativeScrollBarViews";
227 220
228 NativeScrollBarViews::NativeScrollBarViews(NativeScrollBar* scroll_bar) 221 NativeScrollBarViews::NativeScrollBarViews(NativeScrollBar* scroll_bar)
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 thumb_params.scrollbar_thumb.is_hovering = false; 400 thumb_params.scrollbar_thumb.is_hovering = false;
408 gfx::Size track_size = theme->GetPartSize( 401 gfx::Size track_size = theme->GetPartSize(
409 ui::NativeTheme::kScrollbarVerticalThumb, 402 ui::NativeTheme::kScrollbarVerticalThumb,
410 ui::NativeTheme::kNormal, 403 ui::NativeTheme::kNormal,
411 thumb_params); 404 thumb_params);
412 405
413 return std::max(track_size.width(), button_size.width()); 406 return std::max(track_size.width(), button_size.width());
414 } 407 }
415 408
416 } // namespace views 409 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698