| 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 #include "chrome/browser/chromeos/login/user_view.h" | 5 #include "chrome/browser/chromeos/login/user_view.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "chrome/browser/chromeos/login/helper.h" | 9 #include "chrome/browser/chromeos/login/helper.h" |
| 10 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 10 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 SkBitmap icon_; | 207 SkBitmap icon_; |
| 208 std::wstring text_; | 208 std::wstring text_; |
| 209 gfx::Point top_right_; | 209 gfx::Point top_right_; |
| 210 bool was_first_click_; | 210 bool was_first_click_; |
| 211 | 211 |
| 212 DISALLOW_COPY_AND_ASSIGN(RemoveButton); | 212 DISALLOW_COPY_AND_ASSIGN(RemoveButton); |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 class PodImageView : public views::ImageView { | 215 class PodImageView : public views::ImageView { |
| 216 public: | 216 public: |
| 217 PodImageView() { } | 217 PodImageView(const UserView::Delegate* delegate) : delegate_(delegate) { } |
| 218 | 218 |
| 219 void SetImage(const SkBitmap& image, const SkBitmap& image_hot) { | 219 void SetImage(const SkBitmap& image, const SkBitmap& image_hot) { |
| 220 image_ = image; | 220 image_ = image; |
| 221 image_hot_ = image_hot; | 221 image_hot_ = image_hot; |
| 222 views::ImageView::SetImage(image_); | 222 views::ImageView::SetImage(image_); |
| 223 } | 223 } |
| 224 | 224 |
| 225 protected: | 225 protected: |
| 226 // Overridden from View: | 226 // Overridden from View: |
| 227 virtual void OnMouseEntered(const views::MouseEvent& event) { | 227 virtual void OnMouseEntered(const views::MouseEvent& event) { |
| 228 views::ImageView::SetImage(image_hot_); | 228 views::ImageView::SetImage(image_hot_); |
| 229 } | 229 } |
| 230 | 230 |
| 231 virtual void OnMouseExited(const views::MouseEvent& event) { | 231 virtual void OnMouseExited(const views::MouseEvent& event) { |
| 232 views::ImageView::SetImage(image_); | 232 views::ImageView::SetImage(image_); |
| 233 } | 233 } |
| 234 | 234 |
| 235 gfx::NativeCursor GetCursorForPoint( | 235 gfx::NativeCursor GetCursorForPoint( |
| 236 views::Event::EventType event_type, | 236 views::Event::EventType event_type, |
| 237 const gfx::Point& p) { | 237 const gfx::Point& p) { |
| 238 return gfx::GetCursor(GDK_HAND2); | 238 return (delegate_->is_user_selected()) ? NULL : gfx::GetCursor(GDK_HAND2); |
| 239 } | 239 } |
| 240 | 240 |
| 241 private: | 241 private: |
| 242 const UserView::Delegate* delegate_; |
| 243 |
| 242 SkBitmap image_; | 244 SkBitmap image_; |
| 243 SkBitmap image_hot_; | 245 SkBitmap image_hot_; |
| 244 | 246 |
| 245 DISALLOW_COPY_AND_ASSIGN(PodImageView); | 247 DISALLOW_COPY_AND_ASSIGN(PodImageView); |
| 246 }; | 248 }; |
| 247 | 249 |
| 248 UserView::UserView(Delegate* delegate, bool is_login, bool need_background) | 250 UserView::UserView(Delegate* delegate, bool is_login, bool need_background) |
| 249 : delegate_(delegate), | 251 : delegate_(delegate), |
| 250 signout_view_(NULL), | 252 signout_view_(NULL), |
| 251 image_view_(NULL), | 253 image_view_(NULL), |
| 252 remove_button_(NULL) { | 254 remove_button_(NULL) { |
| 253 DCHECK(delegate); | 255 DCHECK(delegate); |
| 254 if (!is_login) | 256 if (!is_login) |
| 255 signout_view_ = new SignoutView(this); | 257 signout_view_ = new SignoutView(this); |
| 256 | 258 |
| 257 if (need_background) | 259 if (need_background) |
| 258 image_view_ = new RoundedView<PodImageView>; | 260 image_view_ = new RoundedView<PodImageView>(delegate); |
| 259 else | 261 else |
| 260 image_view_ = new PodImageView; | 262 image_view_ = new PodImageView(delegate); |
| 261 | 263 |
| 262 Init(need_background); | 264 Init(need_background); |
| 263 } | 265 } |
| 264 | 266 |
| 265 void UserView::Init(bool need_background) { | 267 void UserView::Init(bool need_background) { |
| 266 if (need_background) { | 268 if (need_background) { |
| 267 image_view_->set_background( | 269 image_view_->set_background( |
| 268 views::Background::CreateSolidBackground(kBackgroundColor)); | 270 views::Background::CreateSolidBackground(kBackgroundColor)); |
| 269 } | 271 } |
| 270 | 272 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 DCHECK(delegate_); | 331 DCHECK(delegate_); |
| 330 if (remove_button_ == sender) | 332 if (remove_button_ == sender) |
| 331 delegate_->OnRemoveUser(); | 333 delegate_->OnRemoveUser(); |
| 332 } | 334 } |
| 333 | 335 |
| 334 void UserView::OnLocaleChanged() { | 336 void UserView::OnLocaleChanged() { |
| 335 remove_button_->SetText(l10n_util::GetString(IDS_LOGIN_REMOVE)); | 337 remove_button_->SetText(l10n_util::GetString(IDS_LOGIN_REMOVE)); |
| 336 } | 338 } |
| 337 | 339 |
| 338 } // namespace chromeos | 340 } // namespace chromeos |
| OLD | NEW |