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); | |
24 virtual ~UsernameView() {} | 23 virtual ~UsernameView() {} |
25 | 24 |
26 // Overriden from views::Label. | 25 // Overriden from views::Label. |
27 virtual void Paint(gfx::Canvas* canvas); | 26 virtual void Paint(gfx::Canvas* canvas); |
28 | 27 |
| 28 // Returns the shaped username view to be used on the login screen. If |
| 29 // |user_small_shape| is true, then one pixel margins are used. This is done |
| 30 // to match the shape of the scaled frame of the user image. The caller gets |
| 31 // the ownership. |
| 32 static UsernameView* CreateShapedUsernameView(const std::wstring& username, |
| 33 bool use_small_shape); |
| 34 |
| 35 protected: |
| 36 // Constructs username view for the given |username|. Consider using |
| 37 // |CreateShapedUsernameView| to match the login page style. |
| 38 explicit UsernameView(const std::wstring& username); |
| 39 |
29 private: | 40 private: |
| 41 |
30 // Paints username to the bitmap with the bounds given. | 42 // Paints username to the bitmap with the bounds given. |
31 void PaintUsername(const gfx::Rect& bounds); | 43 void PaintUsername(const gfx::Rect& bounds); |
32 | 44 |
33 // Holds painted username. | 45 // Holds painted username. |
34 scoped_ptr<SkBitmap> text_image_; | 46 scoped_ptr<SkBitmap> text_image_; |
35 | 47 |
36 // Holds width of the text drawn. | |
37 int text_width_; | |
38 | |
39 // Holds margins width (depends on the height). | 48 // Holds margins width (depends on the height). |
40 int margin_width_; | 49 int margin_width_; |
41 | 50 |
42 DISALLOW_COPY_AND_ASSIGN(UsernameView); | 51 DISALLOW_COPY_AND_ASSIGN(UsernameView); |
43 }; | 52 }; |
44 | 53 |
45 } // namespace chromeos | 54 } // namespace chromeos |
46 | 55 |
47 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERNAME_VIEW_H_ | 56 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERNAME_VIEW_H_ |
OLD | NEW |