summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-05 19:46:29 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-05 19:46:29 +0000
commitefc3315b53e2c3cc6d6aecfa04738447b701f806 (patch)
tree3c8818d78cc967f788a68a9fc996ee2551c1845e
parentbdbdc8bc11eb6e2e70a758c4fc6953055bab13a8 (diff)
downloadchromium_src-efc3315b53e2c3cc6d6aecfa04738447b701f806.zip
chromium_src-efc3315b53e2c3cc6d6aecfa04738447b701f806.tar.gz
chromium_src-efc3315b53e2c3cc6d6aecfa04738447b701f806.tar.bz2
Add some spacing to titlebar buttons.
Review URL: http://codereview.chromium.org/160593 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22515 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/browser_titlebar.cc49
-rw-r--r--chrome/browser/gtk/browser_titlebar.h14
-rw-r--r--chrome/browser/gtk/custom_button.cc7
3 files changed, 52 insertions, 18 deletions
diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc
index 05520d0..26a57d1 100644
--- a/chrome/browser/gtk/browser_titlebar.cc
+++ b/chrome/browser/gtk/browser_titlebar.cc
@@ -67,6 +67,12 @@ const int kAppModePaddingLeft = 2;
// account for kClientEdgeThickness.
const int kTabStripLeftPadding = 1;
+// Spacing between buttons of the titlebar.
+const int kButtonSpacing = 2;
+
+// Spacing around outside of titlebar buttons.
+const int kButtonOuterPadding = 2;
+
gboolean OnMouseMoveEvent(GtkWidget* widget, GdkEventMotion* event,
BrowserWindowGtk* browser_window) {
// Reset to the default mouse cursor.
@@ -100,7 +106,8 @@ void BrowserTitlebar::Init() {
// +- EventBox (container_) -------------------------------------------------+
// +- HBox (container_hbox) -------------------------------------------------+
// |+- Algn. -++- Alignment --------------++- VBox (titlebar_buttons_box_) -+|
- // ||+ Image +|| (titlebar_alignment_) ||+- HBox -----------------------+||
+ // ||+ Image +|| (titlebar_alignment_) ||+ - Fixed (top_padding_) ------+||
+ // ||| ||| ||+- HBox -----------------------+||
// |||spy_guy||| |||+- button -++- button -+ |||
// ||| |||+- TabStripGtk ---------+|||| minimize || restore | ... |||
// ||| )8\ |||| tab tab tabclose ||||+----------++----------+ |||
@@ -185,9 +192,13 @@ void BrowserTitlebar::Init() {
}
// We put the min/max/restore/close buttons in a vbox so they are top aligned
- // and don't vertically stretch.
+ // (up to padding) and don't vertically stretch.
titlebar_buttons_box_ = gtk_vbox_new(FALSE, 0);
- GtkWidget* buttons_hbox = gtk_hbox_new(FALSE, 0);
+ GtkWidget* buttons_hbox = gtk_hbox_new(FALSE, kButtonSpacing);
+ top_padding_ = gtk_fixed_new();
+ gtk_widget_set_size_request(top_padding_, -1, kButtonOuterPadding);
+ gtk_box_pack_start(GTK_BOX(titlebar_buttons_box_), top_padding_, FALSE, FALSE,
+ 0);
gtk_box_pack_start(GTK_BOX(titlebar_buttons_box_), buttons_hbox, FALSE,
FALSE, 0);
@@ -210,9 +221,9 @@ void BrowserTitlebar::Init() {
IDR_MINIMIZE_H, buttons_hbox,
IDS_XPFRAME_MINIMIZE_TOOLTIP));
- GtkRequisition req;
- gtk_widget_size_request(close_button_->widget(), &req);
- close_button_default_width_ = req.width;
+ gtk_widget_size_request(close_button_->widget(), &close_button_req_);
+ gtk_widget_size_request(minimize_button_->widget(), &minimize_button_req_);
+ gtk_widget_size_request(restore_button_->widget(), &restore_button_req_);
gtk_box_pack_end(GTK_BOX(container_hbox), titlebar_buttons_box_, FALSE,
FALSE, 0);
@@ -302,10 +313,28 @@ void BrowserTitlebar::UpdateTitlebarAlignment() {
}
}
- int close_button_width = close_button_default_width_;
- if (using_custom_frame_ && browser_window_->IsMaximized())
- close_button_width += kFrameBorderThickness;
- gtk_widget_set_size_request(close_button_->widget(), close_button_width, -1);
+ // Resize the buttons so that the clickable area extends all the way to the
+ // edge of the browser window.
+ GtkRequisition close_button_req = close_button_req_;
+ GtkRequisition minimize_button_req = minimize_button_req_;
+ GtkRequisition restore_button_req = restore_button_req_;
+ if (using_custom_frame_ && browser_window_->IsMaximized()) {
+ close_button_req.width += kButtonOuterPadding;
+ close_button_req.height += kButtonOuterPadding;
+ minimize_button_req.height += kButtonOuterPadding;
+ restore_button_req.height += kButtonOuterPadding;
+ gtk_widget_hide(top_padding_);
+ } else {
+ gtk_widget_show(top_padding_);
+ }
+ gtk_widget_set_size_request(close_button_->widget(),
+ close_button_req.width, close_button_req.height);
+ gtk_widget_set_size_request(minimize_button_->widget(),
+ minimize_button_req.width,
+ minimize_button_req.height);
+ gtk_widget_set_size_request(restore_button_->widget(),
+ restore_button_req.width,
+ restore_button_req.height);
}
// static
diff --git a/chrome/browser/gtk/browser_titlebar.h b/chrome/browser/gtk/browser_titlebar.h
index 88e17af..98a56ab 100644
--- a/chrome/browser/gtk/browser_titlebar.h
+++ b/chrome/browser/gtk/browser_titlebar.h
@@ -111,6 +111,10 @@ class BrowserTitlebar : public MenuGtk::Delegate {
// manager decorations, we draw this taller.
GtkWidget* titlebar_alignment_;
+ // Padding between the titlebar buttons and the top of the screen. Only show
+ // when not maximized.
+ GtkWidget* top_padding_;
+
// The favicon and page title used when in app mode or popup mode.
GtkWidget* app_mode_favicon_;
GtkWidget* app_mode_title_;
@@ -118,11 +122,11 @@ class BrowserTitlebar : public MenuGtk::Delegate {
// Whether we are using a custom frame.
bool using_custom_frame_;
- // The normal width of the close button (the width it appears to the user)
- // which is determined by the width of the bitmap we use to paint it. Its
- // actual clickable width may differ if we are showing a custom frame and the
- // window is maximized.
- int close_button_default_width_;
+ // We change the size of these three buttons when the window is maximized, so
+ // we use these structs to keep track of their original size.
+ GtkRequisition close_button_req_;
+ GtkRequisition minimize_button_req_;
+ GtkRequisition restore_button_req_;
// Maximize and restore widgets in the titlebar.
scoped_ptr<CustomDrawButton> minimize_button_;
diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc
index f27e01b..276393a 100644
--- a/chrome/browser/gtk/custom_button.cc
+++ b/chrome/browser/gtk/custom_button.cc
@@ -70,16 +70,17 @@ gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, GdkEventExpose* e) {
cairo_translate(cairo_context, widget->allocation.x, widget->allocation.y);
// The widget might be larger than the pixbuf. Paint the pixbuf flush with the
- // start of the widget (left for LTR, right for RTL).
+ // start of the widget (left for LTR, right for RTL) and its bottom.
gfx::Rect bounds = gfx::Rect(0, 0, gdk_pixbuf_get_width(pixbuf), 0);
int x = gtk_util::MirroredLeftPointForRect(widget, bounds);
+ int y = widget->allocation.height - gdk_pixbuf_get_height(pixbuf);
if (background_image_) {
- gdk_cairo_set_source_pixbuf(cairo_context, background_image_, x, 0);
+ gdk_cairo_set_source_pixbuf(cairo_context, background_image_, x, y);
cairo_paint(cairo_context);
}
- gdk_cairo_set_source_pixbuf(cairo_context, pixbuf, x, 0);
+ gdk_cairo_set_source_pixbuf(cairo_context, pixbuf, x, y);
cairo_paint(cairo_context);
cairo_destroy(cairo_context);