OLD | NEW |
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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 close_button_height_); | 813 close_button_height_); |
814 | 814 |
815 // If the close button color has changed, generate a new one. | 815 // If the close button color has changed, generate a new one. |
816 if (theme_service_) { | 816 if (theme_service_) { |
817 SkColor tab_text_color = | 817 SkColor tab_text_color = |
818 theme_service_->GetColor(ThemeProperties::COLOR_TAB_TEXT); | 818 theme_service_->GetColor(ThemeProperties::COLOR_TAB_TEXT); |
819 if (!close_button_color_ || tab_text_color != close_button_color_) { | 819 if (!close_button_color_ || tab_text_color != close_button_color_) { |
820 close_button_color_ = tab_text_color; | 820 close_button_color_ = tab_text_color; |
821 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 821 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
822 close_button_->SetBackground(close_button_color_, | 822 close_button_->SetBackground(close_button_color_, |
823 rb.GetImageNamed(IDR_TAB_CLOSE).AsBitmap(), | 823 rb.GetImageNamed(IDR_CLOSE_1).AsBitmap(), |
824 rb.GetImageNamed(IDR_TAB_CLOSE_MASK).AsBitmap()); | 824 rb.GetImageNamed(IDR_CLOSE_1_MASK).AsBitmap()); |
825 } | 825 } |
826 } | 826 } |
827 } else { | 827 } else { |
828 close_button_bounds_.SetRect(0, 0, 0, 0); | 828 close_button_bounds_.SetRect(0, 0, 0, 0); |
829 } | 829 } |
830 | 830 |
831 if (!mini() || width() >= kMiniTabRendererAsNormalTabWidth) { | 831 if (!mini() || width() >= kMiniTabRendererAsNormalTabWidth) { |
832 // Size the Title text to fill the remaining space. | 832 // Size the Title text to fill the remaining space. |
833 int title_left = favicon_bounds_.right() + kFaviconTitleSpacing; | 833 int title_left = favicon_bounds_.right() + kFaviconTitleSpacing; |
834 int title_top = kTopPadding; | 834 int title_top = kTopPadding; |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 return 0; | 1133 return 0; |
1134 return (width() - kLeftPadding - kRightPadding) / gfx::kFaviconSize; | 1134 return (width() - kLeftPadding - kRightPadding) / gfx::kFaviconSize; |
1135 } | 1135 } |
1136 | 1136 |
1137 bool TabRendererGtk::ShouldShowCloseBox() const { | 1137 bool TabRendererGtk::ShouldShowCloseBox() const { |
1138 // The selected tab never clips close button. | 1138 // The selected tab never clips close button. |
1139 return !mini() && (IsActive() || IconCapacity() >= 3); | 1139 return !mini() && (IsActive() || IconCapacity() >= 3); |
1140 } | 1140 } |
1141 | 1141 |
1142 CustomDrawButton* TabRendererGtk::MakeCloseButton() { | 1142 CustomDrawButton* TabRendererGtk::MakeCloseButton() { |
1143 CustomDrawButton* button = new CustomDrawButton(IDR_TAB_CLOSE, | 1143 CustomDrawButton* button = CustomDrawButton::CloseButtonBar(theme_service_); |
1144 IDR_TAB_CLOSE_P, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE); | |
1145 button->ForceChromeTheme(); | 1144 button->ForceChromeTheme(); |
1146 | 1145 |
1147 g_signal_connect(button->widget(), "clicked", | 1146 g_signal_connect(button->widget(), "clicked", |
1148 G_CALLBACK(OnCloseButtonClickedThunk), this); | 1147 G_CALLBACK(OnCloseButtonClickedThunk), this); |
1149 g_signal_connect(button->widget(), "button-release-event", | 1148 g_signal_connect(button->widget(), "button-release-event", |
1150 G_CALLBACK(OnCloseButtonMouseReleaseThunk), this); | 1149 G_CALLBACK(OnCloseButtonMouseReleaseThunk), this); |
1151 g_signal_connect(button->widget(), "enter-notify-event", | 1150 g_signal_connect(button->widget(), "enter-notify-event", |
1152 G_CALLBACK(OnEnterNotifyEventThunk), this); | 1151 G_CALLBACK(OnEnterNotifyEventThunk), this); |
1153 g_signal_connect(button->widget(), "leave-notify-event", | 1152 g_signal_connect(button->widget(), "leave-notify-event", |
1154 G_CALLBACK(OnLeaveNotifyEventThunk), this); | 1153 G_CALLBACK(OnLeaveNotifyEventThunk), this); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1238 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
1240 GdkPixbuf* tab_active_l = rb.GetNativeImageNamed( | 1239 GdkPixbuf* tab_active_l = rb.GetNativeImageNamed( |
1241 IDR_TAB_ACTIVE_LEFT).ToGdkPixbuf(); | 1240 IDR_TAB_ACTIVE_LEFT).ToGdkPixbuf(); |
1242 tab_active_l_width_ = gdk_pixbuf_get_width(tab_active_l); | 1241 tab_active_l_width_ = gdk_pixbuf_get_width(tab_active_l); |
1243 tab_active_l_height_ = gdk_pixbuf_get_height(tab_active_l); | 1242 tab_active_l_height_ = gdk_pixbuf_get_height(tab_active_l); |
1244 | 1243 |
1245 GdkPixbuf* tab_inactive_l = rb.GetNativeImageNamed( | 1244 GdkPixbuf* tab_inactive_l = rb.GetNativeImageNamed( |
1246 IDR_TAB_INACTIVE_LEFT).ToGdkPixbuf(); | 1245 IDR_TAB_INACTIVE_LEFT).ToGdkPixbuf(); |
1247 tab_inactive_l_height_ = gdk_pixbuf_get_height(tab_inactive_l); | 1246 tab_inactive_l_height_ = gdk_pixbuf_get_height(tab_inactive_l); |
1248 | 1247 |
1249 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); | 1248 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_CLOSE_1).ToGdkPixbuf(); |
1250 close_button_width_ = gdk_pixbuf_get_width(tab_close); | 1249 close_button_width_ = gdk_pixbuf_get_width(tab_close); |
1251 close_button_height_ = gdk_pixbuf_get_height(tab_close); | 1250 close_button_height_ = gdk_pixbuf_get_height(tab_close); |
1252 | 1251 |
1253 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | 1252 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); |
1254 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1253 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
1255 title_font_height_ = title_font_->GetHeight(); | 1254 title_font_height_ = title_font_->GetHeight(); |
1256 | 1255 |
1257 initialized_ = true; | 1256 initialized_ = true; |
1258 } | 1257 } |
OLD | NEW |