Chromium Code Reviews| Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| index f01cfb8b184c7f2ae23de3f8beb2efba7d7bfcbf..0a8300abfc8ecefc07afaa05c388b9dfdb1320b8 100644 |
| --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| @@ -39,6 +39,7 @@ |
| #include "ui/base/models/simple_menu_model.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/events/event.h" |
| +#include "ui/gfx/animation/slide_animation.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/font_list.h" |
| #include "ui/gfx/selection_model.h" |
| @@ -178,6 +179,29 @@ void OmniboxViewViews::Init() { |
| chromeos::input_method::InputMethodManager::Get()-> |
| AddCandidateWindowObserver(this); |
| #endif |
| + |
| + fade_in_animation_.reset(new gfx::SlideAnimation(this)); |
| + fade_in_animation_->SetTweenType(gfx::Tween::LINEAR); |
| + fade_in_animation_->SetSlideDuration(300); |
| +} |
| + |
| +void OmniboxViewViews::FadeIn() { |
| + fade_in_animation_->Show(); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// OmniboxViewViews, gfx::AnimationDelegate implementation: |
| + |
| +void OmniboxViewViews::AnimationProgressed(const gfx::Animation* animation) { |
| + if (animation == fade_in_animation_.get()) { |
|
Peter Kasting
2014/03/21 21:22:10
Nit: No {} (2 places)
Justin Donnelly
2014/03/24 22:59:37
Done. Although this one actually doesn't need the
|
| + SchedulePaint(); |
| + } |
| +} |
| + |
| +void OmniboxViewViews::AnimationEnded(const gfx::Animation* animation) { |
| + if (animation == fade_in_animation_.get()) { |
| + fade_in_animation_->Reset(); |
| + } |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -187,6 +211,17 @@ const char* OmniboxViewViews::GetClassName() const { |
| return kViewClassName; |
| } |
| +void OmniboxViewViews::OnPaint(gfx::Canvas* canvas) { |
| + if (fade_in_animation_->is_animating()) { |
| + canvas->SaveLayerAlpha(static_cast<uint8>( |
| + fade_in_animation_->CurrentValueBetween(0, 255))); |
| + views::Textfield::OnPaint(canvas); |
| + canvas->Restore(); |
| + } else { |
| + views::Textfield::OnPaint(canvas); |
| + } |
| +} |
| + |
| bool OmniboxViewViews::OnMousePressed(const ui::MouseEvent& event) { |
| select_all_on_mouse_release_ = |
| (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) && |
| @@ -406,10 +441,10 @@ void OmniboxViewViews::OnBlur() { |
| // Tell the model to reset itself. |
| model()->OnKillFocus(); |
| - OnDidKillFocus(); |
| - |
| // Make sure the beginning of the text is visible. |
| SelectRange(gfx::Range(0)); |
| + |
| + OnDidKillFocus(); |
|
Peter Kasting
2014/03/21 21:22:10
Does the order of these last two statements matter
Justin Donnelly
2014/03/24 22:59:37
Not really, no. I was trying to deal with the fac
|
| } |
| base::string16 OmniboxViewViews::GetSelectionClipboardText() const { |
| @@ -745,7 +780,7 @@ void OmniboxViewViews::ExecuteCommand(int command_id, int event_flags) { |
| model()->PasteAndGo(GetClipboardText()); |
| break; |
| case IDS_SHOW_URL: |
| - ShowURL(); |
| + controller()->ShowURL(); |
| break; |
| case IDC_EDIT_SEARCH_ENGINES: |
| command_updater()->ExecuteCommand(command_id); |