diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 19:57:00 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 19:57:00 +0000 |
commit | 1ba48dd0630846f6c7e9ebd3ec16335fbb7b8c58 (patch) | |
tree | 2b83df446bac218feb31d62e42978be4315d9157 /chrome/browser/gtk | |
parent | 8e0dffdf956edcebcee147e4f7df472fb9bde567 (diff) | |
download | chromium_src-1ba48dd0630846f6c7e9ebd3ec16335fbb7b8c58.zip chromium_src-1ba48dd0630846f6c7e9ebd3ec16335fbb7b8c58.tar.gz chromium_src-1ba48dd0630846f6c7e9ebd3ec16335fbb7b8c58.tar.bz2 |
Findbar stuff:
- change dialog shape correctly when theme changes
- vertically center the match label in gtk theme mode
- update the match label colors when theme changes
BUG=19726
Review URL: http://codereview.chromium.org/173176
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24001 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/download_shelf_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.cc | 22 | ||||
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.h | 3 | ||||
-rw-r--r-- | chrome/browser/gtk/infobar_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/slide_animator_gtk.cc | 12 | ||||
-rw-r--r-- | chrome/browser/gtk/slide_animator_gtk.h | 1 |
6 files changed, 31 insertions, 11 deletions
diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc index e628cf2..7917c21 100644 --- a/chrome/browser/gtk/download_shelf_gtk.cc +++ b/chrome/browser/gtk/download_shelf_gtk.cc @@ -120,7 +120,7 @@ DownloadShelfGtk::DownloadShelfGtk(Browser* browser, GtkWidget* parent) slide_widget_.reset(new SlideAnimatorGtk(shelf_.get(), SlideAnimatorGtk::UP, kShelfAnimationDurationMs, - false, NULL)); + false, true, NULL)); theme_provider_->InitThemesFor(this); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index 2097c67..1d097e4 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -146,6 +146,7 @@ FindBarGtk::FindBarGtk(Browser* browser) theme_provider_(GtkThemeProvider::GetFrom(browser->profile())), container_width_(-1), container_height_(-1), + match_label_failure_(false), ignore_changed_signal_(false), current_fixed_width_(-1) { InitWidgets(); @@ -194,7 +195,7 @@ void FindBarGtk::InitWidgets() { slide_widget_.reset(new SlideAnimatorGtk(container_, SlideAnimatorGtk::DOWN, - 0, false, NULL)); + 0, false, false, NULL)); // |fixed_| has to be at least one pixel tall. We color this pixel the same // color as the border that separates the toolbar from the tab contents. @@ -246,16 +247,12 @@ void FindBarGtk::InitWidgets() { // This line adds padding on the sides so that the label has even padding on // all edges. gtk_misc_set_padding(GTK_MISC(match_count_label_), 2, 0); - // This line makes sure the baseline of the label text matches the baseline of - // the entry text. - gtk_misc_set_alignment(GTK_MISC(match_count_label_), 0.5, 1.0); match_count_event_box_ = gtk_event_box_new(); GtkWidget* match_count_centerer = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(match_count_centerer), match_count_event_box_, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(match_count_centerer), 1); gtk_container_add(GTK_CONTAINER(match_count_event_box_), match_count_label_); - UpdateMatchLabelAppearance(false); // Until we switch to vector graphics, force the font size. gtk_util::ForceFontSizePixels(text_entry_, 13.4); // 13.4px == 10pt @ 96dpi @@ -459,6 +456,8 @@ void FindBarGtk::Observe(NotificationType type, gtk_widget_modify_bg(border_bin_, GTK_STATE_NORMAL, NULL); gtk_widget_modify_bg(border_bin_aa_, GTK_STATE_NORMAL, NULL); + + gtk_misc_set_alignment(GTK_MISC(match_count_label_), 0.5, 0.5); } else { gtk_widget_modify_bg(border_, GTK_STATE_NORMAL, &kFrameBorderColor); @@ -476,7 +475,11 @@ void FindBarGtk::Observe(NotificationType type, gtk_widget_modify_bg(border_bin_, GTK_STATE_NORMAL, &kTextBorderColor); gtk_widget_modify_bg(border_bin_aa_, GTK_STATE_NORMAL, &kTextBorderColorAA); + + gtk_misc_set_alignment(GTK_MISC(match_count_label_), 0.5, 1.0); } + + UpdateMatchLabelAppearance(match_label_failure_); } bool FindBarGtk::GetFindBarWindowInfo(gfx::Point* position, @@ -504,6 +507,7 @@ void FindBarGtk::FindEntryTextInContents(bool forward_search) { } void FindBarGtk::UpdateMatchLabelAppearance(bool failure) { + match_label_failure_ = failure; bool use_gtk = theme_provider_->UseGtkTheme(); gtk_widget_modify_bg(match_count_event_box_, GTK_STATE_NORMAL, @@ -624,6 +628,10 @@ void FindBarGtk::OnFixedSizeAllocate(GtkWidget* fixed, // Used to handle custom painting of |container_|. gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, FindBarGtk* bar) { + GtkRequisition req; + gtk_widget_size_request(widget, &req); + gtk_widget_set_size_request(bar->slide_widget(), req.width, -1); + if (bar->theme_provider_->UseGtkTheme()) { if (bar->container_width_ != widget->allocation.width || bar->container_height_ != widget->allocation.height) { @@ -632,6 +640,8 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, GdkRegion* mask_region = gdk_region_polygon(&mask_points[0], mask_points.size(), GDK_EVEN_ODD_RULE); + // Reset the shape. + gdk_window_shape_combine_region(widget->window, NULL, 0, 0); gdk_window_shape_combine_region(widget->window, mask_region, 0, 0); gdk_region_destroy(mask_region); @@ -653,6 +663,8 @@ gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, } else { if (bar->container_width_ != widget->allocation.width || bar->container_height_ != widget->allocation.height) { + // Reset the shape. + gdk_window_shape_combine_region(widget->window, NULL, 0, 0); SetDialogShape(bar->container_); bar->container_width_ = widget->allocation.width; diff --git a/chrome/browser/gtk/find_bar_gtk.h b/chrome/browser/gtk/find_bar_gtk.h index aa8dc93..407e86f 100644 --- a/chrome/browser/gtk/find_bar_gtk.h +++ b/chrome/browser/gtk/find_bar_gtk.h @@ -160,6 +160,9 @@ class FindBarGtk : public FindBar, // The GtkLabel listing how many results were found. GtkWidget* match_count_label_; GtkWidget* match_count_event_box_; + // Cache whether the match count label is showing failure or not so that + // we can update its appearance without changing its semantics. + bool match_label_failure_; // The X to close the find bar. scoped_ptr<CustomDrawButton> close_button_; diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc index 5ca91ea..b3c0da0 100644 --- a/chrome/browser/gtk/infobar_gtk.cc +++ b/chrome/browser/gtk/infobar_gtk.cc @@ -100,7 +100,7 @@ InfoBar::InfoBar(InfoBarDelegate* delegate) slide_widget_.reset(new SlideAnimatorGtk(border_bin_.get(), SlideAnimatorGtk::DOWN, - 0, true, this)); + 0, true, true, this)); // We store a pointer back to |this| so we can refer to it from the infobar // container. g_object_set_data(G_OBJECT(slide_widget_->widget()), "info-bar", this); diff --git a/chrome/browser/gtk/slide_animator_gtk.cc b/chrome/browser/gtk/slide_animator_gtk.cc index 2d66043..866aca5 100644 --- a/chrome/browser/gtk/slide_animator_gtk.cc +++ b/chrome/browser/gtk/slide_animator_gtk.cc @@ -24,6 +24,7 @@ SlideAnimatorGtk::SlideAnimatorGtk(GtkWidget* child, Direction direction, int duration, bool linear, + bool control_child_size, Delegate* delegate) : child_(child), direction_(direction), @@ -32,10 +33,13 @@ SlideAnimatorGtk::SlideAnimatorGtk(GtkWidget* child, widget_.Own(gtk_fixed_new()); gtk_fixed_put(GTK_FIXED(widget_.get()), child, 0, 0); gtk_widget_set_size_request(widget_.get(), -1, 0); - // We have to manually set the size request for |child_| every time the - // GtkFixed changes sizes. - g_signal_connect(widget_.get(), "size-allocate", - G_CALLBACK(OnFixedSizeAllocate), child_); + if (control_child_size) { + // If the child requests it, we will manually set the size request for + // |child_| every time the GtkFixed changes sizes. This is mainly useful + // for bars, where we want the child to expand to fill all available space. + g_signal_connect(widget_.get(), "size-allocate", + G_CALLBACK(OnFixedSizeAllocate), child_); + } // The size of the GtkFixed widget is set during animation. When we open // without showing the animation, we have to call AnimationProgressed diff --git a/chrome/browser/gtk/slide_animator_gtk.h b/chrome/browser/gtk/slide_animator_gtk.h index 8c4fd98..a4cf657 100644 --- a/chrome/browser/gtk/slide_animator_gtk.h +++ b/chrome/browser/gtk/slide_animator_gtk.h @@ -46,6 +46,7 @@ class SlideAnimatorGtk : public AnimationDelegate { Direction direction, int duration, bool linear, + bool control_child_size, Delegate* delegate); virtual ~SlideAnimatorGtk(); |