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_SPEECH_SPEECH_INPUT_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ |
6 #define CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ | 6 #define CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/task.h" | 13 #include "base/task.h" |
14 | 14 |
15 namespace gfx { | 15 namespace gfx { |
16 class Canvas; | |
16 class Rect; | 17 class Rect; |
17 } | 18 } |
18 class SkBitmap; | 19 class SkBitmap; |
20 class SkCanvas; | |
19 class TabContents; | 21 class TabContents; |
20 | 22 |
21 // SpeechInputBubble displays a popup info bubble during speech recognition, | 23 // SpeechInputBubble displays a popup info bubble during speech recognition, |
22 // points to the html element which requested speech input and shows recognition | 24 // points to the html element which requested speech input and shows recognition |
23 // progress events. The popup is closed by the user clicking anywhere outside | 25 // progress events. The popup is closed by the user clicking anywhere outside |
24 // the popup window, or by the caller destroying this object. | 26 // the popup window, or by the caller destroying this object. |
25 class SpeechInputBubble { | 27 class SpeechInputBubble { |
26 public: | 28 public: |
27 // The various buttons which may be part of the bubble. | 29 // The various buttons which may be part of the bubble. |
28 enum Button { | 30 enum Button { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // bubble is hidden, |Show| must be called to make it appear on screen. | 91 // bubble is hidden, |Show| must be called to make it appear on screen. |
90 virtual void SetMessage(const string16& text) = 0; | 92 virtual void SetMessage(const string16& text) = 0; |
91 | 93 |
92 // Brings up the bubble on screen. | 94 // Brings up the bubble on screen. |
93 virtual void Show() = 0; | 95 virtual void Show() = 0; |
94 | 96 |
95 // Hides the info bubble, resulting in a call to | 97 // Hides the info bubble, resulting in a call to |
96 // |Delegate::InfoBubbleFocusChanged| as well. | 98 // |Delegate::InfoBubbleFocusChanged| as well. |
97 virtual void Hide() = 0; | 99 virtual void Hide() = 0; |
98 | 100 |
99 // Updates the current captured audio volume displayed on screen. | 101 // Updates the current captured audio volume displayed on screen. |
bulach
2011/03/01 17:39:04
perhaps "Updates and draws the current..."
| |
100 virtual void SetInputVolume(float volume) = 0; | 102 virtual void SetInputVolume(float volume, float noise_volume) = 0; |
101 | 103 |
102 // Returns the TabContents for which this bubble gets displayed. | 104 // Returns the TabContents for which this bubble gets displayed. |
103 virtual TabContents* tab_contents() = 0; | 105 virtual TabContents* tab_contents() = 0; |
104 | 106 |
105 // The horizontal distance between the start of the html widget and the speech | 107 // The horizontal distance between the start of the html widget and the speech |
106 // bubble's arrow. | 108 // bubble's arrow. |
107 static const int kBubbleTargetOffsetX; | 109 static const int kBubbleTargetOffsetX; |
108 | 110 |
109 private: | 111 private: |
110 static FactoryMethod factory_; | 112 static FactoryMethod factory_; |
(...skipping 11 matching lines...) Expand all Loading... | |
122 DISPLAY_MODE_MESSAGE | 124 DISPLAY_MODE_MESSAGE |
123 }; | 125 }; |
124 | 126 |
125 explicit SpeechInputBubbleBase(TabContents* tab_contents); | 127 explicit SpeechInputBubbleBase(TabContents* tab_contents); |
126 virtual ~SpeechInputBubbleBase(); | 128 virtual ~SpeechInputBubbleBase(); |
127 | 129 |
128 // SpeechInputBubble methods | 130 // SpeechInputBubble methods |
129 virtual void SetRecordingMode(); | 131 virtual void SetRecordingMode(); |
130 virtual void SetRecognizingMode(); | 132 virtual void SetRecognizingMode(); |
131 virtual void SetMessage(const string16& text); | 133 virtual void SetMessage(const string16& text); |
132 virtual void SetInputVolume(float volume); | 134 virtual void SetInputVolume(float volume, float noise_volume); |
133 virtual TabContents* tab_contents(); | 135 virtual TabContents* tab_contents(); |
134 | 136 |
135 protected: | 137 protected: |
136 // Updates the platform specific UI layout for the current display mode. | 138 // Updates the platform specific UI layout for the current display mode. |
137 virtual void UpdateLayout() = 0; | 139 virtual void UpdateLayout() = 0; |
138 | 140 |
139 // Sets the given image as the image to display in the speech bubble. | 141 // Sets the given image as the image to display in the speech bubble. |
140 // TODO(satish): Make the SetRecognizingMode call use this to show an | 142 // TODO(satish): Make the SetRecognizingMode call use this to show an |
141 // animation while waiting for results. | 143 // animation while waiting for results. |
142 virtual void SetImage(const SkBitmap& image) = 0; | 144 virtual void SetImage(const SkBitmap& image) = 0; |
143 | 145 |
144 DisplayMode display_mode() { | 146 DisplayMode display_mode() { |
145 return display_mode_; | 147 return display_mode_; |
146 } | 148 } |
147 | 149 |
148 string16 message_text() { | 150 string16 message_text() { |
149 return message_text_; | 151 return message_text_; |
150 } | 152 } |
151 | 153 |
152 private: | 154 private: |
153 void DoRecognizingAnimationStep(); | 155 void DoRecognizingAnimationStep(); |
154 | 156 |
157 void DrawVolumeOverlay(SkCanvas& canvas, SkBitmap* bitmap, float volume); | |
hans
2011/03/01 17:25:25
nit: spontaneously, i would have made |bitmap| a c
bulach
2011/03/01 17:39:04
either SkCanvas* or const SkCanvas&
| |
158 | |
155 // Task factory used for animation timer. | 159 // Task factory used for animation timer. |
156 ScopedRunnableMethodFactory<SpeechInputBubbleBase> task_factory_; | 160 ScopedRunnableMethodFactory<SpeechInputBubbleBase> task_factory_; |
157 int animation_step_; // Current index/step of the animation. | 161 int animation_step_; // Current index/step of the animation. |
158 std::vector<SkBitmap> animation_frames_; | 162 std::vector<SkBitmap> animation_frames_; |
159 | 163 |
160 DisplayMode display_mode_; | 164 DisplayMode display_mode_; |
161 string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE | 165 string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE |
162 // The current microphone image with volume level indication. | 166 // The current microphone image with volume level indication. |
163 scoped_ptr<SkBitmap> mic_image_; | 167 scoped_ptr<SkBitmap> mic_image_; |
164 // A temporary buffer image used in creating the above mic image. | 168 // A temporary buffer image used in creating the above mic image. |
165 scoped_ptr<SkBitmap> buffer_image_; | 169 scoped_ptr<SkBitmap> buffer_image_; |
166 // TabContents in which this this bubble gets displayed. | 170 // TabContents in which this this bubble gets displayed. |
167 TabContents* tab_contents_; | 171 TabContents* tab_contents_; |
168 | 172 |
169 static SkBitmap* mic_full_; // Mic image with full volume. | 173 static SkBitmap* mic_full_; // Mic image with full volume. |
174 static SkBitmap* mic_noise_; // Mic image with full noise volume. | |
170 static SkBitmap* mic_empty_; // Mic image with zero volume. | 175 static SkBitmap* mic_empty_; // Mic image with zero volume. |
171 static SkBitmap* mic_mask_; // Gradient mask used by the volume indicator. | 176 static SkBitmap* mic_mask_; // Gradient mask used by the volume indicator. |
172 static SkBitmap* spinner_; // Spinner image for the progress animation. | 177 static SkBitmap* spinner_; // Spinner image for the progress animation. |
173 static const int kRecognizingAnimationStepMs; | 178 static const int kRecognizingAnimationStepMs; |
174 }; | 179 }; |
175 | 180 |
176 // This typedef is to workaround the issue with certain versions of | 181 // This typedef is to workaround the issue with certain versions of |
177 // Visual Studio where it gets confused between multiple Delegate | 182 // Visual Studio where it gets confused between multiple Delegate |
178 // classes and gives a C2500 error. (I saw this error on the try bots - | 183 // classes and gives a C2500 error. (I saw this error on the try bots - |
179 // the workaround was not needed for my machine). | 184 // the workaround was not needed for my machine). |
180 typedef SpeechInputBubble::Delegate SpeechInputBubbleDelegate; | 185 typedef SpeechInputBubble::Delegate SpeechInputBubbleDelegate; |
181 | 186 |
182 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ | 187 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ |
OLD | NEW |