Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: chrome/browser/speech/speech_input_bubble.h

Issue 6597071: Add a noise indicator to the speech bubble volume indicator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed all review comments. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 and draws the current captured audio volume displayed on screen.
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
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,
158 const SkBitmap& bitmap,
159 float volume);
160
155 // Task factory used for animation timer. 161 // Task factory used for animation timer.
156 ScopedRunnableMethodFactory<SpeechInputBubbleBase> task_factory_; 162 ScopedRunnableMethodFactory<SpeechInputBubbleBase> task_factory_;
157 int animation_step_; // Current index/step of the animation. 163 int animation_step_; // Current index/step of the animation.
158 std::vector<SkBitmap> animation_frames_; 164 std::vector<SkBitmap> animation_frames_;
159 165
160 DisplayMode display_mode_; 166 DisplayMode display_mode_;
161 string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE 167 string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE
162 // The current microphone image with volume level indication. 168 // The current microphone image with volume level indication.
163 scoped_ptr<SkBitmap> mic_image_; 169 scoped_ptr<SkBitmap> mic_image_;
164 // A temporary buffer image used in creating the above mic image. 170 // A temporary buffer image used in creating the above mic image.
165 scoped_ptr<SkBitmap> buffer_image_; 171 scoped_ptr<SkBitmap> buffer_image_;
166 // TabContents in which this this bubble gets displayed. 172 // TabContents in which this this bubble gets displayed.
167 TabContents* tab_contents_; 173 TabContents* tab_contents_;
168 174
169 static SkBitmap* mic_full_; // Mic image with full volume. 175 static SkBitmap* mic_full_; // Mic image with full volume.
176 static SkBitmap* mic_noise_; // Mic image with full noise volume.
170 static SkBitmap* mic_empty_; // Mic image with zero volume. 177 static SkBitmap* mic_empty_; // Mic image with zero volume.
171 static SkBitmap* mic_mask_; // Gradient mask used by the volume indicator. 178 static SkBitmap* mic_mask_; // Gradient mask used by the volume indicator.
172 static SkBitmap* spinner_; // Spinner image for the progress animation. 179 static SkBitmap* spinner_; // Spinner image for the progress animation.
173 static const int kRecognizingAnimationStepMs; 180 static const int kRecognizingAnimationStepMs;
174 }; 181 };
175 182
176 // This typedef is to workaround the issue with certain versions of 183 // This typedef is to workaround the issue with certain versions of
177 // Visual Studio where it gets confused between multiple Delegate 184 // Visual Studio where it gets confused between multiple Delegate
178 // classes and gives a C2500 error. (I saw this error on the try bots - 185 // classes and gives a C2500 error. (I saw this error on the try bots -
179 // the workaround was not needed for my machine). 186 // the workaround was not needed for my machine).
180 typedef SpeechInputBubble::Delegate SpeechInputBubbleDelegate; 187 typedef SpeechInputBubble::Delegate SpeechInputBubbleDelegate;
181 188
182 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ 189 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698