OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/gfx/canvas.h" | 5 #include "app/gfx/canvas.h" |
6 #include "app/resource_bundle.h" | 6 #include "app/resource_bundle.h" |
7 #include "base/gfx/rect.h" | 7 #include "base/gfx/rect.h" |
8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
9 #include "chrome/common/extensions/extension_action.h" | 9 #include "chrome/common/extensions/extension_action.h" |
10 #include "grit/app_resources.h" | 10 #include "grit/app_resources.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 const int kBottomMargin = 5; | 47 const int kBottomMargin = 5; |
48 const int kPadding = 2; | 48 const int kPadding = 2; |
49 const int kBadgeHeight = 11; | 49 const int kBadgeHeight = 11; |
50 const int kMaxTextWidth = 23; | 50 const int kMaxTextWidth = 23; |
51 // The minimum width for center-aligning the badge. | 51 // The minimum width for center-aligning the badge. |
52 const int kCenterAlignThreshold = 20; | 52 const int kCenterAlignThreshold = 20; |
53 #endif | 53 #endif |
54 | 54 |
55 canvas->save(); | 55 canvas->save(); |
56 | 56 |
| 57 #if defined(OS_MACOSX) |
| 58 SkTypeface* typeface = |
| 59 SkTypeface::CreateFromName("Helvetica", SkTypeface::kBold); |
| 60 #else |
57 SkTypeface* typeface = SkTypeface::CreateFromName("Arial", SkTypeface::kBold); | 61 SkTypeface* typeface = SkTypeface::CreateFromName("Arial", SkTypeface::kBold); |
| 62 #endif |
58 SkPaint text_paint; | 63 SkPaint text_paint; |
59 text_paint.setAntiAlias(true); | 64 text_paint.setAntiAlias(true); |
60 text_paint.setColor(text_color); | 65 text_paint.setColor(text_color); |
61 text_paint.setFakeBoldText(true); | 66 text_paint.setFakeBoldText(true); |
62 text_paint.setTextAlign(SkPaint::kLeft_Align); | 67 text_paint.setTextAlign(SkPaint::kLeft_Align); |
63 text_paint.setTextSize(SkIntToScalar(kTextSize)); | 68 text_paint.setTextSize(SkIntToScalar(kTextSize)); |
64 text_paint.setTypeface(typeface); | 69 text_paint.setTypeface(typeface); |
65 | 70 |
66 // Calculate text width. We clamp it to a max size. | 71 // Calculate text width. We clamp it to a max size. |
67 SkScalar text_width = text_paint.measureText(text.c_str(), text.size()); | 72 SkScalar text_width = text_paint.measureText(text.c_str(), text.size()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // text was too large. | 120 // text was too large. |
116 rect.fLeft += kPadding; | 121 rect.fLeft += kPadding; |
117 rect.fRight -= kPadding; | 122 rect.fRight -= kPadding; |
118 canvas->clipRect(rect); | 123 canvas->clipRect(rect); |
119 canvas->drawText(text.c_str(), text.size(), | 124 canvas->drawText(text.c_str(), text.size(), |
120 rect.fLeft + (rect.width() - text_width) / 2, | 125 rect.fLeft + (rect.width() - text_width) / 2, |
121 rect.fTop + kTextSize + 1, | 126 rect.fTop + kTextSize + 1, |
122 text_paint); | 127 text_paint); |
123 canvas->restore(); | 128 canvas->restore(); |
124 } | 129 } |
OLD | NEW |