OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/autofill/autofill_dialog_views.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 views::Checkbox* checkbox_; | 384 views::Checkbox* checkbox_; |
385 | 385 |
386 DISALLOW_COPY_AND_ASSIGN(NotificationView); | 386 DISALLOW_COPY_AND_ASSIGN(NotificationView); |
387 }; | 387 }; |
388 | 388 |
389 // A view that displays a loading message with some dancing dots. | 389 // A view that displays a loading message with some dancing dots. |
390 class LoadingAnimationView : public views::View, | 390 class LoadingAnimationView : public views::View, |
391 public gfx::AnimationDelegate { | 391 public gfx::AnimationDelegate { |
392 public: | 392 public: |
393 explicit LoadingAnimationView(const base::string16& text) : | 393 explicit LoadingAnimationView(const base::string16& text) : |
394 container_(new views::View()), | 394 container_(new views::View()) { |
395 animation_(this) { | |
396 | |
397 set_background(views::Background::CreateSolidBackground( | 395 set_background(views::Background::CreateSolidBackground( |
398 GetNativeTheme()->GetSystemColor( | 396 GetNativeTheme()->GetSystemColor( |
399 ui::NativeTheme::kColorId_DialogBackground))); | 397 ui::NativeTheme::kColorId_DialogBackground))); |
400 | 398 |
401 AddChildView(container_); | 399 AddChildView(container_); |
402 container_->SetLayoutManager( | 400 container_->SetLayoutManager( |
403 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 401 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
404 | 402 |
405 gfx::Font font = ui::ResourceBundle::GetSharedInstance().GetFont( | 403 gfx::Font font = ui::ResourceBundle::GetSharedInstance().GetFont( |
406 ui::ResourceBundle::BaseFont).DeriveFont(8); | 404 ui::ResourceBundle::BaseFont).DeriveFont(8); |
405 animation_.reset(new LoadingAnimation(this, font.GetHeight())) | |
Evan Stade
2013/11/16 01:20:48
nit: the documentation for LoadingAnimation says y
Ilya Sherman
2013/11/16 01:46:54
Done.
| |
407 | 406 |
408 views::Label* label = new views::Label(); | 407 views::Label* label = new views::Label(); |
409 label->SetText(text); | 408 label->SetText(text); |
410 label->SetFont(font); | 409 label->SetFont(font); |
411 container_->AddChildView(label); | 410 container_->AddChildView(label); |
412 | 411 |
413 for (size_t i = 0; i < 3; ++i) { | 412 for (size_t i = 0; i < 3; ++i) { |
414 views::Label* dot = new views::Label(); | 413 views::Label* dot = new views::Label(); |
415 dot->SetText(ASCIIToUTF16(".")); | 414 dot->SetText(ASCIIToUTF16(".")); |
416 dot->SetFont(font); | 415 dot->SetFont(font); |
417 container_->AddChildView(dot); | 416 container_->AddChildView(dot); |
418 } | 417 } |
419 } | 418 } |
420 | 419 |
421 virtual ~LoadingAnimationView() {} | 420 virtual ~LoadingAnimationView() {} |
422 | 421 |
423 // views::View implementation. | 422 // views::View implementation. |
424 virtual void SetVisible(bool visible) OVERRIDE { | 423 virtual void SetVisible(bool visible) OVERRIDE { |
425 if (visible) | 424 if (visible) |
426 animation_.Start(); | 425 animation_->Start(); |
427 else | 426 else |
428 animation_.Reset(); | 427 animation_->Reset(); |
429 | 428 |
430 views::View::SetVisible(visible); | 429 views::View::SetVisible(visible); |
431 } | 430 } |
432 | 431 |
433 virtual void Layout() OVERRIDE { | 432 virtual void Layout() OVERRIDE { |
434 gfx::Size container_size = container_->GetPreferredSize(); | 433 gfx::Size container_size = container_->GetPreferredSize(); |
435 gfx::Rect container_bounds((width() - container_size.width()) / 2, | 434 gfx::Rect container_bounds((width() - container_size.width()) / 2, |
436 (height() - container_size.height()) / 2, | 435 (height() - container_size.height()) / 2, |
437 container_size.width(), | 436 container_size.width(), |
438 container_size.height()); | 437 container_size.height()); |
439 container_->SetBoundsRect(container_bounds); | 438 container_->SetBoundsRect(container_bounds); |
440 container_->Layout(); | 439 container_->Layout(); |
441 | 440 |
442 for (size_t i = 0; i < 3; ++i) { | 441 for (size_t i = 0; i < 3; ++i) { |
443 views::View* dot = container_->child_at(i + 1); | 442 views::View* dot = container_->child_at(i + 1); |
444 dot->SetY(dot->y() + animation_.GetCurrentValueForDot(i) * 10.0); | 443 dot->SetY(dot->y() + animation_->GetCurrentValueForDot(i)); |
445 } | 444 } |
446 } | 445 } |
447 | 446 |
448 // gfx::AnimationDelegate implementation. | 447 // gfx::AnimationDelegate implementation. |
449 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE { | 448 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE { |
450 DCHECK_EQ(animation, &animation_); | 449 DCHECK_EQ(animation, animation_.get()); |
451 Layout(); | 450 Layout(); |
452 } | 451 } |
453 | 452 |
454 private: | 453 private: |
455 // Contains the "Loading" label and the dots. | 454 // Contains the "Loading" label and the dots. |
456 views::View* container_; | 455 views::View* container_; |
457 | 456 |
458 LoadingAnimation animation_; | 457 scoped_ptr<LoadingAnimation> animation_; |
459 | 458 |
460 DISALLOW_COPY_AND_ASSIGN(LoadingAnimationView); | 459 DISALLOW_COPY_AND_ASSIGN(LoadingAnimationView); |
461 }; | 460 }; |
462 | 461 |
463 } // namespace | 462 } // namespace |
464 | 463 |
465 // AutofillDialogViews::AccountChooser ----------------------------------------- | 464 // AutofillDialogViews::AccountChooser ----------------------------------------- |
466 | 465 |
467 AutofillDialogViews::AccountChooser::AccountChooser( | 466 AutofillDialogViews::AccountChooser::AccountChooser( |
468 AutofillDialogViewDelegate* delegate) | 467 AutofillDialogViewDelegate* delegate) |
(...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2446 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2445 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
2447 : section(section), | 2446 : section(section), |
2448 container(NULL), | 2447 container(NULL), |
2449 manual_input(NULL), | 2448 manual_input(NULL), |
2450 suggested_info(NULL), | 2449 suggested_info(NULL), |
2451 suggested_button(NULL) {} | 2450 suggested_button(NULL) {} |
2452 | 2451 |
2453 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2452 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
2454 | 2453 |
2455 } // namespace autofill | 2454 } // namespace autofill |
OLD | NEW |