summaryrefslogtreecommitdiffstats
path: root/chrome/browser/speech/speech_input_bubble_views.cc
diff options
context:
space:
mode:
authorsatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 12:07:57 +0000
committersatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 12:07:57 +0000
commitfc89d8ae5916652cce7a00f5adac4d0e812b5c16 (patch)
treed728195ba6ca3244adb47ff9e21dc971abb5f625 /chrome/browser/speech/speech_input_bubble_views.cc
parentfda165787a252f0fd424f7137619f0bf0c1482dd (diff)
downloadchromium_src-fc89d8ae5916652cce7a00f5adac4d0e812b5c16.zip
chromium_src-fc89d8ae5916652cce7a00f5adac4d0e812b5c16.tar.gz
chromium_src-fc89d8ae5916652cce7a00f5adac4d0e812b5c16.tar.bz2
Show a volume indicator as audio is being recorded.
Per UX input from Cole, this matches the implementation in the android voice actions app. Changes in this CL: - Instead of the old mic icon use the recently added mic-volume-empty, mic-volume-full and mask images for the volume indicator. - Extended the endpointer code to return the audio RMS level (copied from the original source). - SpeechRecognizer receives the above calculated RMS level and computes a volume level in the [0.0-1.0] range. - SpeechInputManager receives the above computed volume level and passes it to SpeechInputBubbleController for display, which passes it to SpeechInputBubble. - SpeechInputBubbleBase creates the appropriate skia bitmap for the volume indicator and passes to the platform specific code for display. - As part of the above SpeechInputBubbleController addition for volume level, I wrote a single function to process all calls received by it and handled in the UI thread for simplicity. BUG=53598 TEST=updated existing tests. Also test manually, use speech input and verify the audio level changes appropriately in the UI as mic is moved near and far. Review URL: http://codereview.chromium.org/3384005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/speech/speech_input_bubble_views.cc')
-rw-r--r--chrome/browser/speech/speech_input_bubble_views.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/chrome/browser/speech/speech_input_bubble_views.cc b/chrome/browser/speech/speech_input_bubble_views.cc
index a3dd616..d41c79b 100644
--- a/chrome/browser/speech/speech_input_bubble_views.cc
+++ b/chrome/browser/speech/speech_input_bubble_views.cc
@@ -40,6 +40,7 @@ class ContentView
void UpdateLayout(SpeechInputBubbleBase::DisplayMode mode,
const string16& message_text);
+ void SetImage(const SkBitmap& image);
// views::ButtonListener methods.
virtual void ButtonPressed(views::Button* source, const views::Event& event);
@@ -78,7 +79,7 @@ ContentView::ContentView(SpeechInputBubbleDelegate* delegate)
icon_ = new views::ImageView();
icon_->SetImage(*ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_SPEECH_INPUT_RECORDING));
+ IDR_SPEECH_INPUT_MIC_EMPTY));
icon_->SetHorizontalAlignment(views::ImageView::CENTER);
AddChildView(icon_);
@@ -104,10 +105,14 @@ void ContentView::UpdateLayout(SpeechInputBubbleBase::DisplayMode mode,
} else {
icon_->SetImage(*ResourceBundle::GetSharedInstance().GetBitmapNamed(
(mode == SpeechInputBubbleBase::DISPLAY_MODE_RECORDING) ?
- IDR_SPEECH_INPUT_RECORDING : IDR_SPEECH_INPUT_PROCESSING));
+ IDR_SPEECH_INPUT_MIC_EMPTY : IDR_SPEECH_INPUT_PROCESSING));
}
}
+void ContentView::SetImage(const SkBitmap& image) {
+ icon_->SetImage(image);
+}
+
void ContentView::ButtonPressed(views::Button* source,
const views::Event& event) {
if (source == cancel_) {
@@ -203,6 +208,7 @@ class SpeechInputBubbleImpl
// SpeechInputBubbleBase methods.
virtual void UpdateLayout();
+ virtual void SetImage(const SkBitmap& image);
// Returns the screen rectangle to use as the info bubble's target.
// |element_rect| is the html element's bounds in page coordinates.
@@ -324,6 +330,11 @@ void SpeechInputBubbleImpl::UpdateLayout() {
info_bubble_->SizeToContents();
}
+void SpeechInputBubbleImpl::SetImage(const SkBitmap& image) {
+ if (bubble_content_)
+ bubble_content_->SetImage(image);
+}
+
} // namespace
SpeechInputBubble* SpeechInputBubble::CreateNativeBubble(