Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1220)

Side by Side Diff: chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc

Issue 11034002: fix position of close buttons in linux tabs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: kick try bots Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 // Selected (but not active) tabs have their throb value scaled down by this. 81 // Selected (but not active) tabs have their throb value scaled down by this.
82 const double kSelectedTabThrobScale = 0.5; 82 const double kSelectedTabThrobScale = 0.5;
83 83
84 // Max opacity for the mini-tab title change animation. 84 // Max opacity for the mini-tab title change animation.
85 const double kMiniTitleChangeThrobOpacity = 0.75; 85 const double kMiniTitleChangeThrobOpacity = 0.75;
86 86
87 // Duration for when the title of an inactive mini-tab changes. 87 // Duration for when the title of an inactive mini-tab changes.
88 const int kMiniTitleChangeThrobDuration = 1000; 88 const int kMiniTitleChangeThrobDuration = 1000;
89 89
90 // The vertical and horizontal offset used to position the close button 90 // The horizontal offset used to position the close button in the tab.
91 // in the tab. TODO(jhawkins): Ask pkasting what the Fuzz is about. 91 const int kCloseButtonHorzFuzz = 4;
92 const int kCloseButtonVertFuzz = 0;
93 const int kCloseButtonHorzFuzz = 5;
94 92
95 // Gets the bounds of |widget| relative to |parent|. 93 // Gets the bounds of |widget| relative to |parent|.
96 gfx::Rect GetWidgetBoundsRelativeToParent(GtkWidget* parent, 94 gfx::Rect GetWidgetBoundsRelativeToParent(GtkWidget* parent,
97 GtkWidget* widget) { 95 GtkWidget* widget) {
98 gfx::Point parent_pos = ui::GetWidgetScreenPosition(parent); 96 gfx::Point parent_pos = ui::GetWidgetScreenPosition(parent);
99 gfx::Point widget_pos = ui::GetWidgetScreenPosition(widget); 97 gfx::Point widget_pos = ui::GetWidgetScreenPosition(widget);
100 98
101 GtkAllocation allocation; 99 GtkAllocation allocation;
102 gtk_widget_get_allocation(widget, &allocation); 100 gtk_widget_get_allocation(widget, &allocation);
103 101
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 favicon_bounds_.set_x(x); 735 favicon_bounds_.set_x(x);
738 } 736 }
739 } 737 }
740 } else { 738 } else {
741 favicon_bounds_.SetRect(local_bounds.x(), local_bounds.y(), 0, 0); 739 favicon_bounds_.SetRect(local_bounds.x(), local_bounds.y(), 0, 0);
742 } 740 }
743 741
744 // Size the Close button. 742 // Size the Close button.
745 showing_close_button_ = ShouldShowCloseBox(); 743 showing_close_button_ = ShouldShowCloseBox();
746 if (showing_close_button_) { 744 if (showing_close_button_) {
747 int close_button_top = 745 int close_button_top = kTopPadding +
748 kTopPadding + kCloseButtonVertFuzz +
749 (content_height - close_button_height_) / 2; 746 (content_height - close_button_height_) / 2;
750 close_button_bounds_.SetRect(local_bounds.width() + kCloseButtonHorzFuzz, 747 int close_button_left =
751 close_button_top, close_button_width_, 748 local_bounds.right() - close_button_width_ + kCloseButtonHorzFuzz;
749 close_button_bounds_.SetRect(close_button_left,
750 close_button_top,
751 close_button_width_,
752 close_button_height_); 752 close_button_height_);
753 753
754 // If the close button color has changed, generate a new one. 754 // If the close button color has changed, generate a new one.
755 if (theme_service_) { 755 if (theme_service_) {
756 SkColor tab_text_color = 756 SkColor tab_text_color =
757 theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT); 757 theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT);
758 if (!close_button_color_ || tab_text_color != close_button_color_) { 758 if (!close_button_color_ || tab_text_color != close_button_color_) {
759 close_button_color_ = tab_text_color; 759 close_button_color_ = tab_text_color;
760 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 760 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
761 close_button_->SetBackground(close_button_color_, 761 close_button_->SetBackground(close_button_color_,
762 rb.GetImageNamed(IDR_TAB_CLOSE).AsBitmap(), 762 rb.GetImageNamed(IDR_TAB_CLOSE).AsBitmap(),
763 rb.GetImageNamed(IDR_TAB_CLOSE_MASK).AsBitmap()); 763 rb.GetImageNamed(IDR_TAB_CLOSE_MASK).AsBitmap());
764 } 764 }
765 } 765 }
766 } else { 766 } else {
767 close_button_bounds_.SetRect(0, 0, 0, 0); 767 close_button_bounds_.SetRect(0, 0, 0, 0);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 } 1007 }
1008 1008
1009 bool TabRendererGtk::ShouldShowCloseBox() const { 1009 bool TabRendererGtk::ShouldShowCloseBox() const {
1010 // The selected tab never clips close button. 1010 // The selected tab never clips close button.
1011 return !mini() && (IsActive() || IconCapacity() >= 3); 1011 return !mini() && (IsActive() || IconCapacity() >= 3);
1012 } 1012 }
1013 1013
1014 CustomDrawButton* TabRendererGtk::MakeCloseButton() { 1014 CustomDrawButton* TabRendererGtk::MakeCloseButton() {
1015 CustomDrawButton* button = new CustomDrawButton(IDR_TAB_CLOSE, 1015 CustomDrawButton* button = new CustomDrawButton(IDR_TAB_CLOSE,
1016 IDR_TAB_CLOSE_P, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE); 1016 IDR_TAB_CLOSE_P, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE);
1017 button->ForceChromeTheme();
1017 1018
1018 g_signal_connect(button->widget(), "clicked", 1019 g_signal_connect(button->widget(), "clicked",
1019 G_CALLBACK(OnCloseButtonClickedThunk), this); 1020 G_CALLBACK(OnCloseButtonClickedThunk), this);
1020 g_signal_connect(button->widget(), "button-release-event", 1021 g_signal_connect(button->widget(), "button-release-event",
1021 G_CALLBACK(OnCloseButtonMouseReleaseThunk), this); 1022 G_CALLBACK(OnCloseButtonMouseReleaseThunk), this);
1022 g_signal_connect(button->widget(), "enter-notify-event", 1023 g_signal_connect(button->widget(), "enter-notify-event",
1023 G_CALLBACK(OnEnterNotifyEventThunk), this); 1024 G_CALLBACK(OnEnterNotifyEventThunk), this);
1024 g_signal_connect(button->widget(), "leave-notify-event", 1025 g_signal_connect(button->widget(), "leave-notify-event",
1025 G_CALLBACK(OnLeaveNotifyEventThunk), this); 1026 G_CALLBACK(OnLeaveNotifyEventThunk), this);
1026 gtk_widget_set_can_focus(button->widget(), FALSE); 1027 gtk_widget_set_can_focus(button->widget(), FALSE);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); 1121 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf();
1121 close_button_width_ = gdk_pixbuf_get_width(tab_close); 1122 close_button_width_ = gdk_pixbuf_get_width(tab_close);
1122 close_button_height_ = gdk_pixbuf_get_height(tab_close); 1123 close_button_height_ = gdk_pixbuf_get_height(tab_close);
1123 1124
1124 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); 1125 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont);
1125 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); 1126 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize);
1126 title_font_height_ = title_font_->GetHeight(); 1127 title_font_height_ = title_font_->GetHeight();
1127 1128
1128 initialized_ = true; 1129 initialized_ = true;
1129 } 1130 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698