OLD | NEW |
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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERNAME_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERNAME_VIEW_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERNAME_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERNAME_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "views/controls/label.h" | 11 #include "views/controls/label.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
13 | 13 |
14 // Forward declaration. | 14 // Forward declaration. |
15 namespace gfx { | 15 namespace gfx { |
16 class Rect; | 16 class Rect; |
17 } | 17 } |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
20 // Label with customized paddings and long text fade out. | 20 // Label with customized paddings and long text fade out. |
21 class UsernameView : public views::Label { | 21 class UsernameView : public views::Label { |
22 public: | 22 public: |
23 UsernameView(const std::wstring& username); | 23 // Constructs username view for the given |username|. Consider using |
| 24 // |CreateShapedUsernameView| to match the login page style. |
| 25 explicit UsernameView(const std::wstring& username); |
| 26 |
24 virtual ~UsernameView() {} | 27 virtual ~UsernameView() {} |
25 | 28 |
26 // Overriden from views::Label. | 29 // Overriden from views::Label. |
27 virtual void Paint(gfx::Canvas* canvas); | 30 virtual void Paint(gfx::Canvas* canvas); |
28 | 31 |
| 32 // Returns the shaped username view to be used on the login screen. The caller |
| 33 // gets the ownership. |
| 34 static UsernameView* CreateShapedUsernameView(const std::wstring& username); |
| 35 |
29 private: | 36 private: |
30 // Paints username to the bitmap with the bounds given. | 37 // Paints username to the bitmap with the bounds given. |
31 void PaintUsername(const gfx::Rect& bounds); | 38 void PaintUsername(const gfx::Rect& bounds); |
32 | 39 |
33 // Holds painted username. | 40 // Holds painted username. |
34 scoped_ptr<SkBitmap> text_image_; | 41 scoped_ptr<SkBitmap> text_image_; |
35 | 42 |
36 // Holds width of the text drawn. | |
37 int text_width_; | |
38 | |
39 // Holds margins width (depends on the height). | 43 // Holds margins width (depends on the height). |
40 int margin_width_; | 44 int margin_width_; |
41 | 45 |
42 DISALLOW_COPY_AND_ASSIGN(UsernameView); | 46 DISALLOW_COPY_AND_ASSIGN(UsernameView); |
43 }; | 47 }; |
44 | 48 |
45 } // namespace chromeos | 49 } // namespace chromeos |
46 | 50 |
47 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERNAME_VIEW_H_ | 51 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERNAME_VIEW_H_ |
OLD | NEW |