OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SUGGESTED_TEXT_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SUGGESTED_TEXT_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SUGGESTED_TEXT_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SUGGESTED_TEXT_VIEW_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "ui/base/animation/animation_delegate.h" | |
10 #include "ui/views/controls/label.h" | 9 #include "ui/views/controls/label.h" |
11 | 10 |
12 class OmniboxEditModel; | |
13 | |
14 // SuggestedTextView is used to show the suggest text in the LocationBar. | 11 // SuggestedTextView is used to show the suggest text in the LocationBar. |
15 // Invoke |StartAnimation| to start an animation that when done invokes | 12 class SuggestedTextView : public views::Label { |
16 // |CommitSuggestedText| on the AutocompleteEdit to commit the suggested text. | |
17 class SuggestedTextView : public views::Label, | |
18 public ui::AnimationDelegate { | |
19 public: | 13 public: |
20 SuggestedTextView(OmniboxEditModel* edit_model, | 14 explicit SuggestedTextView(bool instant_extended_api_enabled); |
sky
2012/10/24 21:40:40
Can we get rid of this class entirely now?
sreeram
2012/10/24 22:16:14
Done.
| |
21 bool instant_extended_api_enabled); | |
22 virtual ~SuggestedTextView(); | 15 virtual ~SuggestedTextView(); |
23 | 16 |
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: | 17 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); | 18 DISALLOW_COPY_AND_ASSIGN(SuggestedTextView); |
57 }; | 19 }; |
58 | 20 |
59 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SUGGESTED_TEXT_VIEW_H_ | 21 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SUGGESTED_TEXT_VIEW_H_ |
OLD | NEW |