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

Side by Side Diff: ui/native_theme/native_theme_aura.cc

Issue 2680943002: ui: Clean up naming of paint-related identifiers (Closed)
Patch Set: Created 3 years, 10 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/native_theme/common_theme.cc ('k') | ui/native_theme/native_theme_base.h » ('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/native_theme/native_theme_aura.h" 5 #include "ui/native_theme/native_theme_aura.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 SkColor NativeThemeAura::GetSystemColor(ColorId color_id) const { 95 SkColor NativeThemeAura::GetSystemColor(ColorId color_id) const {
96 return GetAuraColor(color_id, this); 96 return GetAuraColor(color_id, this);
97 } 97 }
98 98
99 void NativeThemeAura::PaintMenuPopupBackground( 99 void NativeThemeAura::PaintMenuPopupBackground(
100 cc::PaintCanvas* canvas, 100 cc::PaintCanvas* canvas,
101 const gfx::Size& size, 101 const gfx::Size& size,
102 const MenuBackgroundExtraParams& menu_background) const { 102 const MenuBackgroundExtraParams& menu_background) const {
103 SkColor color = GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor); 103 SkColor color = GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor);
104 if (menu_background.corner_radius > 0) { 104 if (menu_background.corner_radius > 0) {
105 cc::PaintFlags paint; 105 cc::PaintFlags flags;
106 paint.setStyle(cc::PaintFlags::kFill_Style); 106 flags.setStyle(cc::PaintFlags::kFill_Style);
107 paint.setAntiAlias(true); 107 flags.setAntiAlias(true);
108 paint.setColor(color); 108 flags.setColor(color);
109 109
110 gfx::Path path; 110 gfx::Path path;
111 SkRect rect = SkRect::MakeWH(SkIntToScalar(size.width()), 111 SkRect rect = SkRect::MakeWH(SkIntToScalar(size.width()),
112 SkIntToScalar(size.height())); 112 SkIntToScalar(size.height()));
113 SkScalar radius = SkIntToScalar(menu_background.corner_radius); 113 SkScalar radius = SkIntToScalar(menu_background.corner_radius);
114 SkScalar radii[8] = {radius, radius, radius, radius, 114 SkScalar radii[8] = {radius, radius, radius, radius,
115 radius, radius, radius, radius}; 115 radius, radius, radius, radius};
116 path.addRoundRect(rect, radii); 116 path.addRoundRect(rect, radii);
117 117
118 canvas->drawPath(path, paint); 118 canvas->drawPath(path, flags);
119 } else { 119 } else {
120 canvas->drawColor(color, SkBlendMode::kSrc); 120 canvas->drawColor(color, SkBlendMode::kSrc);
121 } 121 }
122 } 122 }
123 123
124 void NativeThemeAura::PaintMenuItemBackground( 124 void NativeThemeAura::PaintMenuItemBackground(
125 cc::PaintCanvas* canvas, 125 cc::PaintCanvas* canvas,
126 State state, 126 State state,
127 const gfx::Rect& rect, 127 const gfx::Rect& rect,
128 const MenuItemExtraParams& menu_item) const { 128 const MenuItemExtraParams& menu_item) const {
(...skipping 19 matching lines...) Expand all
148 break; 148 break;
149 case kPressed: 149 case kPressed:
150 bg_color = SkColorSetRGB(0x78, 0x78, 0x78); 150 bg_color = SkColorSetRGB(0x78, 0x78, 0x78);
151 arrow_color = SK_ColorWHITE; 151 arrow_color = SK_ColorWHITE;
152 break; 152 break;
153 case kNumStates: 153 case kNumStates:
154 break; 154 break;
155 } 155 }
156 DCHECK_NE(arrow_color, gfx::kPlaceholderColor); 156 DCHECK_NE(arrow_color, gfx::kPlaceholderColor);
157 157
158 cc::PaintFlags paint; 158 cc::PaintFlags flags;
159 paint.setColor(bg_color); 159 flags.setColor(bg_color);
160 canvas->drawIRect(gfx::RectToSkIRect(rect), paint); 160 canvas->drawIRect(gfx::RectToSkIRect(rect), flags);
161 161
162 PaintArrow(canvas, rect, direction, arrow_color); 162 PaintArrow(canvas, rect, direction, arrow_color);
163 } 163 }
164 164
165 void NativeThemeAura::PaintScrollbarTrack( 165 void NativeThemeAura::PaintScrollbarTrack(
166 cc::PaintCanvas* canvas, 166 cc::PaintCanvas* canvas,
167 Part part, 167 Part part,
168 State state, 168 State state,
169 const ScrollbarTrackExtraParams& extra_params, 169 const ScrollbarTrackExtraParams& extra_params,
170 const gfx::Rect& rect) const { 170 const gfx::Rect& rect) const {
171 // Overlay Scrollbar should never paint a scrollbar track. 171 // Overlay Scrollbar should never paint a scrollbar track.
172 DCHECK(!use_overlay_scrollbars_); 172 DCHECK(!use_overlay_scrollbars_);
173 cc::PaintFlags paint; 173 cc::PaintFlags flags;
174 paint.setColor(kTrackColor); 174 flags.setColor(kTrackColor);
175 canvas->drawIRect(gfx::RectToSkIRect(rect), paint); 175 canvas->drawIRect(gfx::RectToSkIRect(rect), flags);
176 } 176 }
177 177
178 void NativeThemeAura::PaintScrollbarThumb( 178 void NativeThemeAura::PaintScrollbarThumb(
179 cc::PaintCanvas* canvas, 179 cc::PaintCanvas* canvas,
180 Part part, 180 Part part,
181 State state, 181 State state,
182 const gfx::Rect& rect, 182 const gfx::Rect& rect,
183 ScrollbarOverlayColorTheme theme) const { 183 ScrollbarOverlayColorTheme theme) const {
184 // Do not paint if state is disabled. 184 // Do not paint if state is disabled.
185 if (state == kDisabled) 185 if (state == kDisabled)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 thumb_alpha = kOverlayScrollbarFillAlphaPressed; 226 thumb_alpha = kOverlayScrollbarFillAlphaPressed;
227 stroke_alpha = kOverlayScrollbarStrokeAlphaPressed; 227 stroke_alpha = kOverlayScrollbarStrokeAlphaPressed;
228 break; 228 break;
229 case NativeTheme::kNumStates: 229 case NativeTheme::kNumStates:
230 NOTREACHED(); 230 NOTREACHED();
231 break; 231 break;
232 } 232 }
233 233
234 // In overlay mode, draw a stroke (border). 234 // In overlay mode, draw a stroke (border).
235 constexpr int kStrokeWidth = kOverlayScrollbarStrokeWidth; 235 constexpr int kStrokeWidth = kOverlayScrollbarStrokeWidth;
236 cc::PaintFlags paint; 236 cc::PaintFlags flags;
237 paint.setColor( 237 flags.setColor(
238 SkColorSetA(kOverlayScrollbarStrokeColor[theme], stroke_alpha)); 238 SkColorSetA(kOverlayScrollbarStrokeColor[theme], stroke_alpha));
239 paint.setStyle(cc::PaintFlags::kStroke_Style); 239 flags.setStyle(cc::PaintFlags::kStroke_Style);
240 paint.setStrokeWidth(kStrokeWidth); 240 flags.setStrokeWidth(kStrokeWidth);
241 241
242 gfx::RectF stroke_rect(thumb_rect); 242 gfx::RectF stroke_rect(thumb_rect);
243 constexpr float kHalfStrokeWidth = kStrokeWidth / 2.f; 243 constexpr float kHalfStrokeWidth = kStrokeWidth / 2.f;
244 stroke_rect.Inset(kHalfStrokeWidth, kHalfStrokeWidth); 244 stroke_rect.Inset(kHalfStrokeWidth, kHalfStrokeWidth);
245 canvas->drawRect(gfx::RectFToSkRect(stroke_rect), paint); 245 canvas->drawRect(gfx::RectFToSkRect(stroke_rect), flags);
246 246
247 // Inset the all the edges edges so we fill-in the stroke below. 247 // Inset the all the edges edges so we fill-in the stroke below.
248 thumb_rect.Inset(kStrokeWidth, kStrokeWidth); 248 thumb_rect.Inset(kStrokeWidth, kStrokeWidth);
249 } else { 249 } else {
250 switch (state) { 250 switch (state) {
251 case NativeTheme::kDisabled: 251 case NativeTheme::kDisabled:
252 thumb_alpha = SK_AlphaTRANSPARENT; 252 thumb_alpha = SK_AlphaTRANSPARENT;
253 break; 253 break;
254 case NativeTheme::kHovered: 254 case NativeTheme::kHovered:
255 thumb_alpha = 0x4D; 255 thumb_alpha = 0x4D;
(...skipping 14 matching lines...) Expand all
270 const int extra_padding = 270 const int extra_padding =
271 (scrollbar_button_length() == 0) ? kThumbPadding : 0; 271 (scrollbar_button_length() == 0) ? kThumbPadding : 0;
272 if (part == NativeTheme::kScrollbarVerticalThumb) 272 if (part == NativeTheme::kScrollbarVerticalThumb)
273 thumb_rect.Inset(kThumbPadding, extra_padding); 273 thumb_rect.Inset(kThumbPadding, extra_padding);
274 else 274 else
275 thumb_rect.Inset(extra_padding, kThumbPadding); 275 thumb_rect.Inset(extra_padding, kThumbPadding);
276 276
277 thumb_color = SK_ColorBLACK; 277 thumb_color = SK_ColorBLACK;
278 } 278 }
279 279
280 cc::PaintFlags paint; 280 cc::PaintFlags flags;
281 paint.setColor(SkColorSetA(thumb_color, thumb_alpha)); 281 flags.setColor(SkColorSetA(thumb_color, thumb_alpha));
282 canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), paint); 282 canvas->drawIRect(gfx::RectToSkIRect(thumb_rect), flags);
283 } 283 }
284 284
285 void NativeThemeAura::PaintScrollbarCorner(cc::PaintCanvas* canvas, 285 void NativeThemeAura::PaintScrollbarCorner(cc::PaintCanvas* canvas,
286 State state, 286 State state,
287 const gfx::Rect& rect) const { 287 const gfx::Rect& rect) const {
288 // Overlay Scrollbar should never paint a scrollbar corner. 288 // Overlay Scrollbar should never paint a scrollbar corner.
289 DCHECK(!use_overlay_scrollbars_); 289 DCHECK(!use_overlay_scrollbars_);
290 cc::PaintFlags paint; 290 cc::PaintFlags flags;
291 paint.setColor(SkColorSetRGB(0xDC, 0xDC, 0xDC)); 291 flags.setColor(SkColorSetRGB(0xDC, 0xDC, 0xDC));
292 canvas->drawIRect(RectToSkIRect(rect), paint); 292 canvas->drawIRect(RectToSkIRect(rect), flags);
293 } 293 }
294 294
295 gfx::Size NativeThemeAura::GetPartSize(Part part, 295 gfx::Size NativeThemeAura::GetPartSize(Part part,
296 State state, 296 State state,
297 const ExtraParams& extra) const { 297 const ExtraParams& extra) const {
298 if (use_overlay_scrollbars_) { 298 if (use_overlay_scrollbars_) {
299 constexpr int minimum_length = 299 constexpr int minimum_length =
300 kOverlayScrollbarMinimumLength + 2 * kOverlayScrollbarStrokeWidth; 300 kOverlayScrollbarMinimumLength + 2 * kOverlayScrollbarStrokeWidth;
301 301
302 // Aura overlay scrollbars need a slight tweak from the base sizes. 302 // Aura overlay scrollbars need a slight tweak from the base sizes.
303 switch (part) { 303 switch (part) {
304 case kScrollbarHorizontalThumb: 304 case kScrollbarHorizontalThumb:
305 return gfx::Size(minimum_length, scrollbar_width_); 305 return gfx::Size(minimum_length, scrollbar_width_);
306 case kScrollbarVerticalThumb: 306 case kScrollbarVerticalThumb:
307 return gfx::Size(scrollbar_width_, minimum_length); 307 return gfx::Size(scrollbar_width_, minimum_length);
308 308
309 default: 309 default:
310 // TODO(bokan): We should probably make sure code using overlay 310 // TODO(bokan): We should probably make sure code using overlay
311 // scrollbars isn't asking for part sizes that don't exist. 311 // scrollbars isn't asking for part sizes that don't exist.
312 // crbug.com/657159. 312 // crbug.com/657159.
313 break; 313 break;
314 } 314 }
315 } 315 }
316 316
317 return NativeThemeBase::GetPartSize(part, state, extra); 317 return NativeThemeBase::GetPartSize(part, state, extra);
318 } 318 }
319 319
320 } // namespace ui 320 } // namespace ui
OLDNEW
« no previous file with comments | « ui/native_theme/common_theme.cc ('k') | ui/native_theme/native_theme_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698