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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SUGGESTED_TEXT_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SUGGESTED_TEXT_VIEW_H_ 7 #pragma once 8 9 #include "ui/base/animation/animation_delegate.h" 10 #include "views/controls/label.h" 11 12 class AutocompleteEditModel; 13 14 // SuggestedTextView is used to show the suggest text in the LocationBar. 15 // Invoke |StartAnimation| to start an animation that when done invokes 16 // |CommitSuggestedText| on the AutocompleteEdit to commit the suggested text. 17 class SuggestedTextView : public views::Label, 18 public ui::AnimationDelegate { 19 public: 20 explicit SuggestedTextView(AutocompleteEditModel* edit_model); 21 virtual ~SuggestedTextView(); 22 23 // Starts the animation. If the animation is currently running it is stopped 24 // and restarted. The animation transitions the suggested text to look like 25 // selected text. When the animation completes |OnCommitSuggestedText| is 26 // invoked on the LocationBar. 27 void StartAnimation(); 28 29 // Stops the animation. 30 void StopAnimation(); 31 32 // View overrides: 33 virtual void OnPaintBackground(gfx::Canvas* canvas); 34 35 // AnimationDelegate overrides: 36 virtual void AnimationEnded(const ui::Animation* animation); 37 virtual void AnimationProgressed(const ui::Animation* animation); 38 virtual void AnimationCanceled(const ui::Animation* animation); 39 40 private: 41 // Creates the animation to use. 42 ui::Animation* CreateAnimation(); 43 44 // Resets the background color. 45 void UpdateBackgroundColor(); 46 47 AutocompleteEditModel* edit_model_; 48 49 scoped_ptr<ui::Animation> animation_; 50 51 SkColor bg_color_; 52 53 DISALLOW_COPY_AND_ASSIGN(SuggestedTextView); 54 }; 55 56 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SUGGESTED_TEXT_VIEW_H_ 57