Commit 62c021b9 authored by estade@chromium.org's avatar estade@chromium.org

GTK: Allow resizing the findbar when the window is narrow.

BUG=none
TEST=manual (made sure it pixel-matched the old find bar, in both normal and GTK+ theme modes)

Review URL: http://codereview.chromium.org/6992017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86637 0039d316-1c4b-4281-b951-d872f2087c98
parent b3faec4d
...@@ -65,8 +65,9 @@ const int kBarPaddingRight = 4; ...@@ -65,8 +65,9 @@ const int kBarPaddingRight = 4;
// images. // images.
const int kFindBarHeight = 32; const int kFindBarHeight = 32;
// The width of the text entry field. // The default width of the findbar dialog. It may get smaller if the window
const int kTextEntryWidth = 220; // is narrow.
const int kFindBarWidth = 303;
// The size of the "rounded" corners. // The size of the "rounded" corners.
const int kCornerSize = 3; const int kCornerSize = 3;
...@@ -157,14 +158,10 @@ const NineBox* GetDialogBorder() { ...@@ -157,14 +158,10 @@ const NineBox* GetDialogBorder() {
// returns both the event box and the alignment so we can modify it during its // returns both the event box and the alignment so we can modify it during its
// lifetime (i.e. during a theme change). // lifetime (i.e. during a theme change).
void BuildBorder(GtkWidget* child, void BuildBorder(GtkWidget* child,
bool center,
int padding_top, int padding_bottom, int padding_left, int padding_top, int padding_bottom, int padding_left,
int padding_right, int padding_right,
GtkWidget** ebox, GtkWidget** alignment) { GtkWidget** ebox, GtkWidget** alignment) {
*ebox = gtk_event_box_new(); *ebox = gtk_event_box_new();
if (center)
*alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
else
*alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); *alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
gtk_alignment_set_padding(GTK_ALIGNMENT(*alignment), gtk_alignment_set_padding(GTK_ALIGNMENT(*alignment),
padding_top, padding_bottom, padding_left, padding_top, padding_bottom, padding_left,
...@@ -230,12 +227,13 @@ void FindBarGtk::InitWidgets() { ...@@ -230,12 +227,13 @@ void FindBarGtk::InitWidgets() {
container_ = gtk_util::CreateGtkBorderBin(hbox, NULL, container_ = gtk_util::CreateGtkBorderBin(hbox, NULL,
kBarPaddingTopBottom, kBarPaddingTopBottom, kBarPaddingTopBottom, kBarPaddingTopBottom,
kEntryPaddingLeft, kBarPaddingRight); kEntryPaddingLeft, kBarPaddingRight);
gtk_widget_set_size_request(container_, kFindBarWidth, -1);
ViewIDUtil::SetID(container_, VIEW_ID_FIND_IN_PAGE); ViewIDUtil::SetID(container_, VIEW_ID_FIND_IN_PAGE);
gtk_widget_set_app_paintable(container_, TRUE); gtk_widget_set_app_paintable(container_, TRUE);
slide_widget_.reset(new SlideAnimatorGtk(container_, slide_widget_.reset(new SlideAnimatorGtk(container_,
SlideAnimatorGtk::DOWN, SlideAnimatorGtk::DOWN,
0, false, false, NULL)); 0, false, true, NULL));
close_button_.reset(CustomDrawButton::CloseButton(theme_service_)); close_button_.reset(CustomDrawButton::CloseButton(theme_service_));
gtk_util::CenterWidgetInHBox(hbox, close_button_->widget(), true, gtk_util::CenterWidgetInHBox(hbox, close_button_->widget(), true,
...@@ -265,11 +263,8 @@ void FindBarGtk::InitWidgets() { ...@@ -265,11 +263,8 @@ void FindBarGtk::InitWidgets() {
gtk_box_pack_end(GTK_BOX(hbox), find_previous_button_->widget(), gtk_box_pack_end(GTK_BOX(hbox), find_previous_button_->widget(),
FALSE, FALSE, 0); FALSE, FALSE, 0);
// Make a box for the edit and match count widgets. This is fixed size since // Make a box for the edit and match count widgets.
// we want the widgets inside to resize themselves rather than making the
// dialog bigger.
GtkWidget* content_hbox = gtk_hbox_new(FALSE, 0); GtkWidget* content_hbox = gtk_hbox_new(FALSE, 0);
gtk_widget_set_size_request(content_hbox, kTextEntryWidth, -1);
text_entry_ = gtk_entry_new(); text_entry_ = gtk_entry_new();
gtk_entry_set_has_frame(GTK_ENTRY(text_entry_), FALSE); gtk_entry_set_has_frame(GTK_ENTRY(text_entry_), FALSE);
...@@ -291,7 +286,7 @@ void FindBarGtk::InitWidgets() { ...@@ -291,7 +286,7 @@ void FindBarGtk::InitWidgets() {
// This event box is necessary to color in the area above and below the match // This event box is necessary to color in the area above and below the match
// count label, and is where we draw the entry background onto in GTK mode. // count label, and is where we draw the entry background onto in GTK mode.
BuildBorder(content_hbox, true, 0, 0, 0, 0, BuildBorder(content_hbox, 0, 0, 0, 0,
&content_event_box_, &content_alignment_); &content_event_box_, &content_alignment_);
gtk_widget_set_app_paintable(content_event_box_, TRUE); gtk_widget_set_app_paintable(content_event_box_, TRUE);
g_signal_connect(content_event_box_, "expose-event", g_signal_connect(content_event_box_, "expose-event",
...@@ -300,9 +295,9 @@ void FindBarGtk::InitWidgets() { ...@@ -300,9 +295,9 @@ void FindBarGtk::InitWidgets() {
// This alignment isn't centered and is used for spacing in chrome theme // This alignment isn't centered and is used for spacing in chrome theme
// mode. (It's also used in GTK mode for padding because left padding doesn't // mode. (It's also used in GTK mode for padding because left padding doesn't
// equal bottom padding naturally.) // equal bottom padding naturally.)
BuildBorder(content_event_box_, false, 2, 2, 2, 0, BuildBorder(content_event_box_, 2, 2, 2, 0,
&border_bin_, &border_bin_alignment_); &border_bin_, &border_bin_alignment_);
gtk_util::CenterWidgetInHBox(hbox, border_bin_, true, 0); gtk_box_pack_end(GTK_BOX(hbox), border_bin_, TRUE, TRUE, 0);
theme_service_->InitThemesFor(this); theme_service_->InitThemesFor(this);
registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
...@@ -835,10 +830,6 @@ gboolean FindBarGtk::OnContentEventBoxExpose(GtkWidget* widget, ...@@ -835,10 +830,6 @@ gboolean FindBarGtk::OnContentEventBoxExpose(GtkWidget* widget,
// Used to handle custom painting of |container_|. // Used to handle custom painting of |container_|.
gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e,
FindBarGtk* bar) { FindBarGtk* bar) {
GtkRequisition req;
gtk_widget_size_request(widget, &req);
gtk_widget_set_size_request(bar->widget(), req.width, -1);
if (bar->theme_service_->UsingNativeTheme()) { if (bar->theme_service_->UsingNativeTheme()) {
if (bar->container_width_ != widget->allocation.width || if (bar->container_width_ != widget->allocation.width ||
bar->container_height_ != widget->allocation.height) { bar->container_height_ != widget->allocation.height) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment