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

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

Issue 12041085: Fix menu corners: the menu background was being painted as a rect when in fact, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/native_theme/native_theme_aura.h ('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 "base/logging.h" 7 #include "base/logging.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "ui/base/layout.h" 9 #include "ui/base/layout.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/gfx/image/image_skia.h" 11 #include "ui/gfx/image/image_skia.h"
12 #include "ui/gfx/path.h"
12 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
13 #include "ui/gfx/size.h" 14 #include "ui/gfx/size.h"
14 #include "ui/gfx/skbitmap_operations.h" 15 #include "ui/gfx/skbitmap_operations.h"
15 #include "ui/native_theme/common_theme.h" 16 #include "ui/native_theme/common_theme.h"
16 17
17 namespace { 18 namespace {
18 19
19 const SkColor kMenuBackgroundColor = SK_ColorWHITE; 20 const SkColor kMenuBackgroundColor = SK_ColorWHITE;
20 21
21 // Theme colors returned by GetSystemColor(). 22 // Theme colors returned by GetSystemColor().
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 187
187 case kColorId_MenuBackgroundColor: 188 case kColorId_MenuBackgroundColor:
188 case kColorId_MenuBorderColor: 189 case kColorId_MenuBorderColor:
189 NOTREACHED(); 190 NOTREACHED();
190 break; 191 break;
191 } 192 }
192 193
193 return kInvalidColorIdColor; 194 return kInvalidColorIdColor;
194 } 195 }
195 196
196 void NativeThemeAura::PaintMenuPopupBackground(SkCanvas* canvas, 197 void NativeThemeAura::PaintMenuPopupBackground(
197 const gfx::Size& size) const { 198 SkCanvas* canvas,
198 canvas->drawColor(kMenuBackgroundColor, SkXfermode::kSrc_Mode); 199 const gfx::Size& size,
200 const MenuBackgroundExtraParams& menu_background) const {
201 if (menu_background.corner_radius > 0) {
202 SkPaint paint;
203 paint.setStyle(SkPaint::kFill_Style);
204 paint.setFlags(SkPaint::kAntiAlias_Flag);
205 paint.setColor(kMenuBackgroundColor);
206
207 gfx::Path path;
208 SkRect rect = SkRect::MakeWH(SkIntToScalar(size.width()),
209 SkIntToScalar(size.height()));
210 SkScalar radius = SkIntToScalar(menu_background.corner_radius);
211 SkScalar radii[8] = {radius, radius, radius, radius,
212 radius, radius, radius, radius};
213 path.addRoundRect(rect, radii);
214
215 canvas->drawPath(path, paint);
216 } else {
217 canvas->drawColor(kMenuBackgroundColor, SkXfermode::kSrc_Mode);
218 }
199 } 219 }
200 220
201 void NativeThemeAura::PaintScrollbarTrack( 221 void NativeThemeAura::PaintScrollbarTrack(
202 SkCanvas* canvas, 222 SkCanvas* canvas,
203 Part part, 223 Part part,
204 State state, 224 State state,
205 const ScrollbarTrackExtraParams& extra_params, 225 const ScrollbarTrackExtraParams& extra_params,
206 const gfx::Rect& rect) const { 226 const gfx::Rect& rect) const {
207 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 227 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
208 if (part == kScrollbarVerticalTrack) { 228 if (part == kScrollbarVerticalTrack) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 DrawTiledImage(canvas, *center, 364 DrawTiledImage(canvas, *center,
345 0, 0, 1.0, 1.0, 365 0, 0, 1.0, 1.0,
346 rect.x() + left->width(), rect.y(), 366 rect.x() + left->width(), rect.y(),
347 rect.width() - left->width() - right->width(), 367 rect.width() - left->width() - right->width(),
348 center->height()); 368 center->height());
349 } 369 }
350 } 370 }
351 } 371 }
352 372
353 } // namespace ui 373 } // namespace ui
OLDNEW
« no previous file with comments | « ui/native_theme/native_theme_aura.h ('k') | ui/native_theme/native_theme_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698