diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-24 22:34:31 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-24 22:34:31 +0000 |
commit | c4f9dd6d1d39d075917b8a1f8c40d4f9e721bde6 (patch) | |
tree | c4a8d3e986c39d576499d500b2b09afc747c54ad /chrome/browser/gtk | |
parent | e58a8acb42751e1eb535e0dab8362ccf6d3b9145 (diff) | |
download | chromium_src-c4f9dd6d1d39d075917b8a1f8c40d4f9e721bde6.zip chromium_src-c4f9dd6d1d39d075917b8a1f8c40d4f9e721bde6.tar.gz chromium_src-c4f9dd6d1d39d075917b8a1f8c40d4f9e721bde6.tar.bz2 |
GTK: Mirror the close button when on the left.
There is a small notch in the top right corner of the button when it is on the
left so mirror it so the notch is on the left when the button is on the left.
BUG=44647
TEST=none
Review URL: http://codereview.chromium.org/2086023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/browser_titlebar.cc | 1 | ||||
-rw-r--r-- | chrome/browser/gtk/custom_button.cc | 9 | ||||
-rw-r--r-- | chrome/browser/gtk/custom_button.h | 13 |
3 files changed, 22 insertions, 1 deletions
diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc index 7b9576f..f3d0fa0 100644 --- a/chrome/browser/gtk/browser_titlebar.cc +++ b/chrome/browser/gtk/browser_titlebar.cc @@ -346,6 +346,7 @@ void BrowserTitlebar::BuildButtons(const std::string& button_string) { BuildTitlebarButton(IDR_CLOSE, IDR_CLOSE_P, IDR_CLOSE_H, parent_box, IDS_XPFRAME_CLOSE_TOOLTIP)); + close_button_->set_flipped(left_side); gtk_widget_size_request(close_button_->widget(), &close_button_req_); } diff --git a/chrome/browser/gtk/custom_button.cc b/chrome/browser/gtk/custom_button.cc index 22bdb6c..fd7b21c 100644 --- a/chrome/browser/gtk/custom_button.cc +++ b/chrome/browser/gtk/custom_button.cc @@ -27,7 +27,8 @@ CustomDrawButtonBase::CustomDrawButtonBase(GtkThemeProvider* theme_provider, highlight_id_(highlight_id), depressed_id_(depressed_id), button_background_id_(background_id), - theme_provider_(theme_provider) { + theme_provider_(theme_provider), + flipped_(false) { for (int i = 0; i < (GTK_STATE_INSENSITIVE + 1); ++i) surfaces_[i].reset(new CairoCachedSurface); background_image_.reset(new CairoCachedSurface); @@ -89,6 +90,12 @@ gboolean CustomDrawButtonBase::OnExpose(GtkWidget* widget, cairo_t* cairo_context = gdk_cairo_create(GDK_DRAWABLE(widget->window)); cairo_translate(cairo_context, widget->allocation.x, widget->allocation.y); + if (flipped_) { + // Horizontally flip the image for non-LTR/RTL reasons. + cairo_translate(cairo_context, widget->allocation.width, 0.0f); + cairo_scale(cairo_context, -1.0f, 1.0f); + } + // The widget might be larger than the pixbuf. Paint the pixbuf flush with the // start of the widget (left for LTR, right for RTL) and its bottom. gfx::Rect bounds = gfx::Rect(0, 0, pixbuf->Width(), 0); diff --git a/chrome/browser/gtk/custom_button.h b/chrome/browser/gtk/custom_button.h index 239d7c1..8a4ed6a7d 100644 --- a/chrome/browser/gtk/custom_button.h +++ b/chrome/browser/gtk/custom_button.h @@ -39,6 +39,10 @@ class CustomDrawButtonBase : public NotificationObserver { ~CustomDrawButtonBase(); + // Flip the image horizontally. Not to be used for RTL/LTR reasons. (In RTL + // mode, this will unflip the image.) + void set_flipped(bool flipped) { flipped_ = flipped; } + // Returns the dimensions of the first surface. int Width() const; int Height() const; @@ -79,6 +83,11 @@ class CustomDrawButtonBase : public NotificationObserver { int button_background_id_; GtkThemeProvider* theme_provider_; + // Whether the button is flipped horizontally. Not used for RTL (we get + // flipped versions from the theme provider). Used for the flipped window + // buttons. + bool flipped_; + // Used to listen for theme change notifications. NotificationRegistrar registrar_; @@ -140,6 +149,10 @@ class CustomDrawButton : public NotificationObserver { void Init(); + // Flip the image horizontally. Not to be used for RTL/LTR reasons. (In RTL + // mode, this will unflip the image.) + void set_flipped(bool flipped) { button_base_.set_flipped(flipped); } + GtkWidget* widget() const { return widget_.get(); } gfx::Rect bounds() const { |