| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/user_view.h" | 5 #include "chrome/browser/chromeos/login/user_view.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/chromeos/login/helper.h" | 8 #include "chrome/browser/chromeos/login/helper.h" |
| 9 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 9 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
| 10 #include "chrome/browser/chromeos/login/rounded_view.h" | |
| 11 #include "chrome/browser/chromeos/view_ids.h" | 10 #include "chrome/browser/chromeos/view_ids.h" |
| 12 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 13 #include "grit/theme_resources_standard.h" | 12 #include "grit/theme_resources_standard.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/canvas_skia.h" | 16 #include "ui/gfx/canvas_skia.h" |
| 18 #include "ui/gfx/gtk_util.h" | 17 #include "ui/gfx/gtk_util.h" |
| 19 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
| 20 #include "views/background.h" | 19 #include "views/background.h" |
| 21 #include "views/controls/button/text_button.h" | 20 #include "views/controls/button/text_button.h" |
| 22 #include "views/controls/image_view.h" | 21 #include "views/controls/image_view.h" |
| 23 #include "views/controls/label.h" | 22 #include "views/controls/label.h" |
| 24 #include "views/controls/link.h" | 23 #include "views/controls/link.h" |
| 25 #include "views/controls/link_listener.h" | 24 #include "views/controls/link_listener.h" |
| 26 #include "views/painter.h" | 25 #include "views/painter.h" |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| 30 // Background color and corner radius of the login status label and | 29 // Background color and corner radius of the login status label and |
| 31 // signout button. | 30 // signout button. |
| 32 const SkColor kSignoutBackgroundColor = 0xFF007700; | 31 const SkColor kSignoutBackgroundColor = 0xFF007700; |
| 33 const int kSignoutBackgroundCornerRadius = 4; | |
| 34 | 32 |
| 35 // Horiz/Vert insets for Signout view. | 33 // Horiz/Vert insets for Signout view. |
| 36 const int kSignoutViewHorizontalInsets = 10; | 34 const int kSignoutViewHorizontalInsets = 10; |
| 37 const int kSignoutViewVerticalInsets = 5; | 35 const int kSignoutViewVerticalInsets = 5; |
| 38 const int kMinControlHeight = 16; | 36 const int kMinControlHeight = 16; |
| 39 | 37 |
| 38 // 1x Border around image pod. |
| 39 const SkColor kImageBorderColor = 0xFFCCCCCC; |
| 40 |
| 40 // Padding between remove button and top right image corner. | 41 // Padding between remove button and top right image corner. |
| 41 const int kRemoveButtonPadding = 3; | 42 const int kRemoveButtonPadding = 3; |
| 42 | 43 |
| 43 // Draws green-ish background for signout view with | 44 // Draws green-ish background for signout view with |
| 44 // rounded corners at the bottom. | 45 // rounded corners at the bottom. |
| 45 class SignoutBackgroundPainter : public views::Painter { | 46 class SignoutBackgroundPainter : public views::Painter { |
| 46 virtual void Paint(int w, int h, gfx::Canvas* canvas) { | 47 virtual void Paint(int w, int h, gfx::Canvas* canvas) { |
| 47 SkRect rect = {0, 0, w, h}; | 48 SkRect rect = {0, 0, w, h}; |
| 48 SkPath path; | 49 SkPath path; |
| 49 path.addRoundRect(rect, | 50 path.addRect(rect); |
| 50 kSignoutBackgroundCornerRadius, kSignoutBackgroundCornerRadius); | |
| 51 SkPaint paint; | 51 SkPaint paint; |
| 52 paint.setStyle(SkPaint::kFill_Style); | 52 paint.setStyle(SkPaint::kFill_Style); |
| 53 paint.setFlags(SkPaint::kAntiAlias_Flag); | 53 paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 54 paint.setColor(kSignoutBackgroundColor); | 54 paint.setColor(kSignoutBackgroundColor); |
| 55 canvas->AsCanvasSkia()->drawPath(path, paint); | 55 canvas->AsCanvasSkia()->drawPath(path, paint); |
| 56 } | 56 } |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 UserView::UserView(Delegate* delegate, bool is_login, bool need_background) | 251 UserView::UserView(Delegate* delegate, bool is_login, bool need_background) |
| 252 : delegate_(delegate), | 252 : delegate_(delegate), |
| 253 signout_view_(NULL), | 253 signout_view_(NULL), |
| 254 ignore_signout_click_(false), | 254 ignore_signout_click_(false), |
| 255 image_view_(NULL), | 255 image_view_(NULL), |
| 256 remove_button_(NULL) { | 256 remove_button_(NULL) { |
| 257 DCHECK(delegate); | 257 DCHECK(delegate); |
| 258 if (!is_login) | 258 if (!is_login) |
| 259 signout_view_ = new SignoutView(this); | 259 signout_view_ = new SignoutView(this); |
| 260 | 260 |
| 261 if (need_background) | 261 image_view_ = new PodImageView(delegate); |
| 262 image_view_ = new RoundedView<PodImageView>(delegate); | 262 image_view_->set_border( |
| 263 else | 263 views::Border::CreateSolidBorder(1, kImageBorderColor)); |
| 264 image_view_ = new PodImageView(delegate); | |
| 265 | 264 |
| 266 Init(need_background); | 265 Init(need_background); |
| 267 } | 266 } |
| 268 | 267 |
| 269 void UserView::Init(bool need_background) { | 268 void UserView::Init(bool need_background) { |
| 270 if (need_background) { | 269 if (need_background) { |
| 271 image_view_->set_background( | 270 image_view_->set_background( |
| 272 views::Background::CreateSolidBackground(kBackgroundColor)); | 271 views::Background::CreateSolidBackground(kBackgroundColor)); |
| 273 } | 272 } |
| 274 | 273 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 delegate_->OnRemoveUser(); | 333 delegate_->OnRemoveUser(); |
| 335 } | 334 } |
| 336 | 335 |
| 337 void UserView::OnLocaleChanged() { | 336 void UserView::OnLocaleChanged() { |
| 338 remove_button_->SetText( | 337 remove_button_->SetText( |
| 339 UTF16ToWide(l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE))); | 338 UTF16ToWide(l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE))); |
| 340 delegate_->OnLocaleChanged(); | 339 delegate_->OnLocaleChanged(); |
| 341 } | 340 } |
| 342 | 341 |
| 343 } // namespace chromeos | 342 } // namespace chromeos |
| OLD | NEW |