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

Side by Side Diff: ui/native_theme/native_theme_mac.mm

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/native_theme_base.cc ('k') | ui/native_theme/native_theme_win.cc » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_mac.h" 5 #include "ui/native_theme/native_theme_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 default: 249 default:
250 // TODO(tapted): Handle all values and remove the default case. 250 // TODO(tapted): Handle all values and remove the default case.
251 return GetAuraColor(color_id, this); 251 return GetAuraColor(color_id, this);
252 } 252 }
253 } 253 }
254 254
255 void NativeThemeMac::PaintMenuPopupBackground( 255 void NativeThemeMac::PaintMenuPopupBackground(
256 cc::PaintCanvas* canvas, 256 cc::PaintCanvas* canvas,
257 const gfx::Size& size, 257 const gfx::Size& size,
258 const MenuBackgroundExtraParams& menu_background) const { 258 const MenuBackgroundExtraParams& menu_background) const {
259 cc::PaintFlags paint; 259 cc::PaintFlags flags;
260 paint.setAntiAlias(true); 260 flags.setAntiAlias(true);
261 if (base::mac::IsOS10_9()) 261 if (base::mac::IsOS10_9())
262 paint.setColor(kMenuPopupBackgroundColorMavericks); 262 flags.setColor(kMenuPopupBackgroundColorMavericks);
263 else 263 else
264 paint.setColor(kMenuPopupBackgroundColor); 264 flags.setColor(kMenuPopupBackgroundColor);
265 const SkScalar radius = SkIntToScalar(menu_background.corner_radius); 265 const SkScalar radius = SkIntToScalar(menu_background.corner_radius);
266 SkRect rect = gfx::RectToSkRect(gfx::Rect(size)); 266 SkRect rect = gfx::RectToSkRect(gfx::Rect(size));
267 canvas->drawRoundRect(rect, radius, radius, paint); 267 canvas->drawRoundRect(rect, radius, radius, flags);
268 } 268 }
269 269
270 void NativeThemeMac::PaintMenuItemBackground( 270 void NativeThemeMac::PaintMenuItemBackground(
271 cc::PaintCanvas* canvas, 271 cc::PaintCanvas* canvas,
272 State state, 272 State state,
273 const gfx::Rect& rect, 273 const gfx::Rect& rect,
274 const MenuItemExtraParams& menu_item) const { 274 const MenuItemExtraParams& menu_item) const {
275 cc::PaintFlags paint; 275 cc::PaintFlags flags;
276 switch (state) { 276 switch (state) {
277 case NativeTheme::kNormal: 277 case NativeTheme::kNormal:
278 case NativeTheme::kDisabled: 278 case NativeTheme::kDisabled:
279 // Draw nothing over the regular background. 279 // Draw nothing over the regular background.
280 break; 280 break;
281 case NativeTheme::kHovered: 281 case NativeTheme::kHovered:
282 // TODO(tapted): Draw a gradient, and use [NSColor currentControlTint] to 282 // TODO(tapted): Draw a gradient, and use [NSColor currentControlTint] to
283 // pick colors. The System color "selectedMenuItemColor" is actually still 283 // pick colors. The System color "selectedMenuItemColor" is actually still
284 // blue for Graphite. And while "keyboardFocusIndicatorColor" does change, 284 // blue for Graphite. And while "keyboardFocusIndicatorColor" does change,
285 // and is a good shade of gray, it's not blue enough for the Blue theme. 285 // and is a good shade of gray, it's not blue enough for the Blue theme.
286 paint.setColor(GetSystemColor(kColorId_FocusedMenuItemBackgroundColor)); 286 flags.setColor(GetSystemColor(kColorId_FocusedMenuItemBackgroundColor));
287 canvas->drawRect(gfx::RectToSkRect(rect), paint); 287 canvas->drawRect(gfx::RectToSkRect(rect), flags);
288 break; 288 break;
289 default: 289 default:
290 NOTREACHED(); 290 NOTREACHED();
291 break; 291 break;
292 } 292 }
293 } 293 }
294 294
295 // static 295 // static
296 sk_sp<SkShader> NativeThemeMac::GetButtonBackgroundShader( 296 sk_sp<SkShader> NativeThemeMac::GetButtonBackgroundShader(
297 ButtonBackgroundType type, 297 ButtonBackgroundType type,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 SkRRect shape; 402 SkRRect shape;
403 if (round_left && round_right) 403 if (round_left && round_right)
404 shape.setRectXY(bounds, kButtonCornerRadius, kButtonCornerRadius); 404 shape.setRectXY(bounds, kButtonCornerRadius, kButtonCornerRadius);
405 else if (round_left) 405 else if (round_left)
406 shape.setRectRadii(bounds, kLeftCurves); 406 shape.setRectRadii(bounds, kLeftCurves);
407 else if (round_right) 407 else if (round_right)
408 shape.setRectRadii(bounds, kRightCurves); 408 shape.setRectRadii(bounds, kRightCurves);
409 else 409 else
410 shape.setRect(bounds); 410 shape.setRect(bounds);
411 411
412 cc::PaintFlags paint; 412 cc::PaintFlags flags;
413 paint.setStyle(cc::PaintFlags::kFill_Style); 413 flags.setStyle(cc::PaintFlags::kFill_Style);
414 paint.setAntiAlias(true); 414 flags.setAntiAlias(true);
415 415
416 // First draw the darker "outer" border, with its gradient and shadow. Inside 416 // First draw the darker "outer" border, with its gradient and shadow. Inside
417 // a tab strip, this will draw over the outer border and inner separator. 417 // a tab strip, this will draw over the outer border and inner separator.
418 paint.setLooper(gfx::CreateShadowDrawLooper(shadows)); 418 flags.setLooper(gfx::CreateShadowDrawLooper(shadows));
419 paint.setShader( 419 flags.setShader(
420 cc::WrapSkShader(GetButtonBorderShader(type, shape.height()))); 420 cc::WrapSkShader(GetButtonBorderShader(type, shape.height())));
421 canvas->drawRRect(shape, paint); 421 canvas->drawRRect(shape, flags);
422 422
423 // Then, inset the rounded rect and draw over that with the inner gradient. 423 // Then, inset the rounded rect and draw over that with the inner gradient.
424 shape.inset(kBorderThickness, kBorderThickness); 424 shape.inset(kBorderThickness, kBorderThickness);
425 paint.setLooper(nullptr); 425 flags.setLooper(nullptr);
426 paint.setShader( 426 flags.setShader(
427 cc::WrapSkShader(GetButtonBackgroundShader(type, shape.height()))); 427 cc::WrapSkShader(GetButtonBackgroundShader(type, shape.height())));
428 canvas->drawRRect(shape, paint); 428 canvas->drawRRect(shape, flags);
429 429
430 if (!focus) 430 if (!focus)
431 return; 431 return;
432 432
433 SkRRect outer_shape; 433 SkRRect outer_shape;
434 shape.outset(kFocusRingThickness, kFocusRingThickness, &outer_shape); 434 shape.outset(kFocusRingThickness, kFocusRingThickness, &outer_shape);
435 paint.setShader(nullptr); 435 flags.setShader(nullptr);
436 paint.setColor(kFocusRingColor); 436 flags.setColor(kFocusRingColor);
437 canvas->drawDRRect(outer_shape, shape, paint); 437 canvas->drawDRRect(outer_shape, shape, flags);
438 } 438 }
439 439
440 NativeThemeMac::NativeThemeMac() { 440 NativeThemeMac::NativeThemeMac() {
441 } 441 }
442 442
443 NativeThemeMac::~NativeThemeMac() { 443 NativeThemeMac::~NativeThemeMac() {
444 } 444 }
445 445
446 } // namespace ui 446 } // namespace ui
OLDNEW
« no previous file with comments | « ui/native_theme/native_theme_base.cc ('k') | ui/native_theme/native_theme_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698