summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-06 12:51:54 +0000
committersatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-06 12:51:54 +0000
commitf185e4a3182b2d0dc823153cc655450fabd0c72c (patch)
treead1967d499d385b324671de15f7a80c6a14cecc7
parent6d3f2ea5514cb22b653a06fca6889b4167440edb (diff)
downloadchromium_src-f185e4a3182b2d0dc823153cc655450fabd0c72c.zip
chromium_src-f185e4a3182b2d0dc823153cc655450fabd0c72c.tar.gz
chromium_src-f185e4a3182b2d0dc823153cc655450fabd0c72c.tar.bz2
Merge 80603 - Set the linux speech bubble to be the same size in warm up and recording modes.This is already the case in mac and windows, this CL fixes the linux version to match them.BUG=noneTEST=manual, click on the speech button and verify that the bubble stays same size between warm up and recording states.Review URL: http://codereview.chromium.org/6800011
TBR=satish@chromium.org Review URL: http://codereview.chromium.org/6801009 git-svn-id: svn://svn.chromium.org/chrome/branches/696/src@80611 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/speech/speech_input_bubble_gtk.cc39
1 files changed, 32 insertions, 7 deletions
diff --git a/chrome/browser/speech/speech_input_bubble_gtk.cc b/chrome/browser/speech/speech_input_bubble_gtk.cc
index dfe00ae..55e06a2 100644
--- a/chrome/browser/speech/speech_input_bubble_gtk.cc
+++ b/chrome/browser/speech/speech_input_bubble_gtk.cc
@@ -64,6 +64,7 @@ class SpeechInputBubbleGtk
GtkWidget* cancel_button_;
GtkWidget* try_again_button_;
GtkWidget* icon_;
+ GtkWidget* icon_container_;
GtkWidget* mic_settings_;
DISALLOW_COPY_AND_ASSIGN(SpeechInputBubbleGtk);
@@ -81,6 +82,7 @@ SpeechInputBubbleGtk::SpeechInputBubbleGtk(TabContents* tab_contents,
cancel_button_(NULL),
try_again_button_(NULL),
icon_(NULL),
+ icon_container_(NULL),
mic_settings_(NULL) {
}
@@ -122,12 +124,10 @@ void SpeechInputBubbleGtk::Show() {
GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
// The icon with a some padding on the left and right.
- GtkWidget* icon_container = gtk_alignment_new(0, 0, 0, 0);
- gtk_alignment_set_padding(GTK_ALIGNMENT(icon_container), 0, 0,
- kIconHorizontalPadding, kIconHorizontalPadding);
+ icon_container_ = gtk_alignment_new(0, 0, 0, 0);
icon_ = gtk_image_new();
- gtk_container_add(GTK_CONTAINER(icon_container), icon_);
- gtk_box_pack_start(GTK_BOX(vbox), icon_container, FALSE, FALSE,
+ gtk_container_add(GTK_CONTAINER(icon_container_), icon_);
+ gtk_box_pack_start(GTK_BOX(vbox), icon_container_, FALSE, FALSE,
kBubbleControlVerticalSpacing);
label_ = gtk_label_new(NULL);
@@ -205,9 +205,9 @@ void SpeechInputBubbleGtk::UpdateLayout() {
} else {
// Heading text, icon and cancel button are visible, hide the Try Again
// button.
+ gtk_label_set_text(GTK_LABEL(label_),
+ l10n_util::GetStringUTF8(IDS_SPEECH_INPUT_BUBBLE_HEADING).c_str());
if (display_mode() == DISPLAY_MODE_RECORDING) {
- gtk_label_set_text(GTK_LABEL(label_),
- l10n_util::GetStringUTF8(IDS_SPEECH_INPUT_BUBBLE_HEADING).c_str());
gtk_widget_show(label_);
} else {
gtk_widget_hide(label_);
@@ -219,7 +219,32 @@ void SpeechInputBubbleGtk::UpdateLayout() {
gtk_widget_hide(mic_settings_);
if (display_mode() == DISPLAY_MODE_WARM_UP) {
gtk_widget_hide(cancel_button_);
+
+ // The text label and cancel button are hidden in this mode, but we want
+ // the popup to appear the same size as it would once recording starts,
+ // so as to reduce UI jank when recording starts. So we calculate the
+ // difference in size between the two sets of controls and add that as
+ // padding around the icon here.
+ GtkRequisition cancel_size;
+ gtk_widget_get_child_requisition(cancel_button_, &cancel_size);
+ GtkRequisition label_size;
+ gtk_widget_get_child_requisition(label_, &label_size);
+ SkBitmap* volume = ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_SPEECH_INPUT_MIC_EMPTY);
+ int desired_width = std::max(volume->width(), cancel_size.width) +
+ kIconHorizontalPadding * 2;
+ int desired_height = volume->height() + label_size.height +
+ cancel_size.height +
+ kBubbleControlVerticalSpacing * 2;
+ int diff_width = desired_width - icon_image().width();
+ int diff_height = desired_height - icon_image().height();
+ gtk_alignment_set_padding(GTK_ALIGNMENT(icon_container_),
+ diff_height / 2, diff_height - diff_height / 2,
+ diff_width / 2, diff_width - diff_width / 2);
} else {
+ // Reset the padding done above.
+ gtk_alignment_set_padding(GTK_ALIGNMENT(icon_container_), 0, 0,
+ kIconHorizontalPadding, kIconHorizontalPadding);
gtk_widget_show(cancel_button_);
}
}