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

Side by Side Diff: chrome/common/extensions/extension_action.cc

Issue 366029: Initial change for the implementation of browser actions on the mac.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « chrome/chrome.gyp ('k') | no next file » | 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) 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 "chrome/common/extensions/extension_action.h" 5 #include "chrome/common/extensions/extension_action.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/font.h" 8 #include "app/gfx/font.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/gfx/rect.h" 10 #include "base/gfx/rect.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/app/chrome_dll_resource.h" 12 #include "chrome/app/chrome_dll_resource.h"
13 #include "grit/app_resources.h" 13 #include "grit/app_resources.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "third_party/skia/include/core/SkTypeface.h" 15 #include "third_party/skia/include/core/SkTypeface.h"
16 #include "third_party/skia/include/effects/SkGradientShader.h" 16 #include "third_party/skia/include/effects/SkGradientShader.h"
17 17
18 namespace { 18 namespace {
19 19
20 // Different platforms need slightly different constants to look good. 20 // Different platforms need slightly different constants to look good.
21 #if defined(OS_LINUX) 21 #if defined(OS_LINUX)
22 const int kTextSize = 9; 22 const int kTextSize = 9;
23 const int kBottomMargin = 0; 23 const int kBottomMargin = 0;
24 const int kPadding = 2; 24 const int kPadding = 2;
25 const int kTopTextPadding = 0; 25 const int kTopTextPadding = 0;
26 const int kBadgeHeight = 11; 26 #elif defined(OS_MACOSX)
27 const int kMaxTextWidth = 23; 27 const int kTextSize = 9;
28 // The minimum width for center-aligning the badge. 28 const int kBottomMargin = 5;
29 const int kCenterAlignThreshold = 20; 29 const int kPadding = 2;
30 const int kTopTextPadding = 0;
30 #else 31 #else
31 const int kTextSize = 8; 32 const int kTextSize = 8;
32 const int kBottomMargin = 5; 33 const int kBottomMargin = 5;
33 const int kPadding = 2; 34 const int kPadding = 2;
34 // The padding between the top of the badge and the top of the text. 35 // The padding between the top of the badge and the top of the text.
35 const int kTopTextPadding = 1; 36 const int kTopTextPadding = 1;
37 #endif
38
36 const int kBadgeHeight = 11; 39 const int kBadgeHeight = 11;
37 const int kMaxTextWidth = 23; 40 const int kMaxTextWidth = 23;
38 // The minimum width for center-aligning the badge. 41 // The minimum width for center-aligning the badge.
39 const int kCenterAlignThreshold = 20; 42 const int kCenterAlignThreshold = 20;
40 #endif
41 43
42 #if defined(OS_MACOSX) 44 #if defined(OS_MACOSX)
43 const char kPreferredTypeface[] = "Helvetica"; 45 const char kPreferredTypeface[] = "Helvetica Bold";
44 #else 46 #else
45 const char kPreferredTypeface[] = "Arial"; 47 const char kPreferredTypeface[] = "Arial";
46 #endif 48 #endif
47 49
48 SkPaint* GetTextPaint() { 50 SkPaint* GetTextPaint() {
49 static SkPaint* text_paint = NULL; 51 static SkPaint* text_paint = NULL;
50 if (!text_paint) { 52 if (!text_paint) {
51 text_paint = new SkPaint; 53 text_paint = new SkPaint;
52 text_paint->setAntiAlias(true); 54 text_paint->setAntiAlias(true);
53 55
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // text was too large. 174 // text was too large.
173 rect.fLeft += kPadding; 175 rect.fLeft += kPadding;
174 rect.fRight -= kPadding; 176 rect.fRight -= kPadding;
175 canvas->clipRect(rect); 177 canvas->clipRect(rect);
176 canvas->drawText(text.c_str(), text.size(), 178 canvas->drawText(text.c_str(), text.size(),
177 rect.fLeft + (rect.width() - text_width) / 2, 179 rect.fLeft + (rect.width() - text_width) / 2,
178 rect.fTop + kTextSize + kTopTextPadding, 180 rect.fTop + kTextSize + kTopTextPadding,
179 *text_paint); 181 *text_paint);
180 canvas->restore(); 182 canvas->restore();
181 } 183 }
OLDNEW
« no previous file with comments | « chrome/chrome.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698