diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-06 11:11:14 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-06 11:11:14 +0000 |
commit | 6383460160eb17dcb87c3cd74b0924f83471c192 (patch) | |
tree | 54b3b8727f04364ef87882a816a8ce224679187e /chrome/browser/speech | |
parent | 464c1e2dc81262c924391affc940a2e122132091 (diff) | |
download | chromium_src-6383460160eb17dcb87c3cd74b0924f83471c192.zip chromium_src-6383460160eb17dcb87c3cd74b0924f83471c192.tar.gz chromium_src-6383460160eb17dcb87c3cd74b0924f83471c192.tar.bz2 |
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=none
TEST=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
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/speech')
-rw-r--r-- | chrome/browser/speech/speech_input_bubble_gtk.cc | 39 |
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 06bdbb0..0fab31d 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_); } } |