OLD | NEW |
| (Empty) |
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 | |
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 | |
8 #include "base/compiler_specific.h" | |
9 #include "ui/base/animation/animation_delegate.h" | |
10 #include "ui/views/controls/label.h" | |
11 | |
12 class OmniboxEditModel; | |
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 SuggestedTextView(OmniboxEditModel* edit_model, | |
21 bool instant_extended_api_enabled); | |
22 virtual ~SuggestedTextView(); | |
23 | |
24 // Starts the animation. If the animation is currently running it is stopped | |
25 // and restarted. The animation transitions the suggested text to look like | |
26 // selected text. When the animation completes |OnCommitSuggestedText| is | |
27 // invoked on the LocationBar. | |
28 void StartAnimation(); | |
29 | |
30 // Stops the animation. | |
31 void StopAnimation(); | |
32 | |
33 // View overrides: | |
34 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; | |
35 | |
36 // AnimationDelegate overrides: | |
37 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | |
38 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | |
39 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; | |
40 | |
41 private: | |
42 // Creates the animation to use. | |
43 ui::Animation* CreateAnimation(); | |
44 | |
45 // Resets the background color. | |
46 void UpdateBackgroundColor(); | |
47 | |
48 OmniboxEditModel* edit_model_; | |
49 | |
50 // True if Instant Extended API is enabled. | |
51 const bool instant_extended_api_enabled_; | |
52 | |
53 scoped_ptr<ui::Animation> animation_; | |
54 | |
55 SkColor bg_color_; | |
56 DISALLOW_COPY_AND_ASSIGN(SuggestedTextView); | |
57 }; | |
58 | |
59 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SUGGESTED_TEXT_VIEW_H_ | |
OLD | NEW |