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

Side by Side Diff: chrome/browser/chromeos/login/username_view.cc

Issue 5158006: Convert SizeStringInt from taking a wstring to a string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac Created 10 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 | « no previous file | chrome/browser/ui/views/sad_tab_view.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser/chromeos/login/username_view.h" 5 #include "chrome/browser/chromeos/login/username_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h"
8 #include "gfx/canvas.h" 9 #include "gfx/canvas.h"
9 #include "gfx/canvas_skia.h" 10 #include "gfx/canvas_skia.h"
10 #include "gfx/rect.h" 11 #include "gfx/rect.h"
11 #include "third_party/skia/include/core/SkComposeShader.h" 12 #include "third_party/skia/include/core/SkComposeShader.h"
12 #include "third_party/skia/include/effects/SkGradientShader.h" 13 #include "third_party/skia/include/effects/SkGradientShader.h"
13 #include "views/background.h" 14 #include "views/background.h"
14 15
15 namespace { 16 namespace {
16 // Username label background color. 17 // Username label background color.
17 const SkColor kLabelBackgoundColor = 0x55000000; 18 const SkColor kLabelBackgoundColor = 0x55000000;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 void UsernameView::PaintUsername(const gfx::Rect& bounds) { 72 void UsernameView::PaintUsername(const gfx::Rect& bounds) {
72 margin_width_ = bounds.height() * kMarginRatio; 73 margin_width_ = bounds.height() * kMarginRatio;
73 gfx::CanvasSkia canvas(bounds.width(), bounds.height(), false); 74 gfx::CanvasSkia canvas(bounds.width(), bounds.height(), false);
74 // Draw background. 75 // Draw background.
75 canvas.drawColor(kLabelBackgoundColor); 76 canvas.drawColor(kLabelBackgoundColor);
76 // Calculate needed space. 77 // Calculate needed space.
77 int flags = gfx::Canvas::TEXT_ALIGN_LEFT | 78 int flags = gfx::Canvas::TEXT_ALIGN_LEFT |
78 gfx::Canvas::TEXT_VALIGN_MIDDLE | 79 gfx::Canvas::TEXT_VALIGN_MIDDLE |
79 gfx::Canvas::NO_ELLIPSIS; 80 gfx::Canvas::NO_ELLIPSIS;
80 int text_height; 81 int text_height;
81 gfx::CanvasSkia::SizeStringInt(GetText(), font(), 82 gfx::CanvasSkia::SizeStringInt(WideToUTF16Hack(GetText()), font(),
82 &text_width_, &text_height, 83 &text_width_, &text_height,
83 flags); 84 flags);
84 text_width_ = std::min(text_width_, bounds.width() - margin_width_); 85 text_width_ = std::min(text_width_, bounds.width() - margin_width_);
85 // Draw the text. 86 // Draw the text.
86 canvas.DrawStringInt(GetText(), font(), GetColor(), 87 canvas.DrawStringInt(GetText(), font(), GetColor(),
87 bounds.x() + margin_width_, bounds.y(), 88 bounds.x() + margin_width_, bounds.y(),
88 bounds.width() - margin_width_, bounds.height(), 89 bounds.width() - margin_width_, bounds.height(),
89 flags); 90 flags);
90 91
91 text_image_.reset(new SkBitmap(canvas.ExtractBitmap())); 92 text_image_.reset(new SkBitmap(canvas.ExtractBitmap()));
92 text_image_->buildMipMap(false); 93 text_image_->buildMipMap(false);
93 } 94 }
94 95
95 } // namespace chromeos 96 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/sad_tab_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698