| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/tabs/tab_renderer_gtk.h" | 5 #include "chrome/browser/gtk/tabs/tab_renderer_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "app/gfx/canvas_paint.h" | 10 #include "app/gfx/canvas_paint.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 //////////////////////////////////////////////////////////////////////////////// | 230 //////////////////////////////////////////////////////////////////////////////// |
| 231 // TabRendererGtk, public: | 231 // TabRendererGtk, public: |
| 232 | 232 |
| 233 TabRendererGtk::TabRendererGtk(ThemeProvider* theme_provider) | 233 TabRendererGtk::TabRendererGtk(ThemeProvider* theme_provider) |
| 234 : showing_icon_(false), | 234 : showing_icon_(false), |
| 235 showing_close_button_(false), | 235 showing_close_button_(false), |
| 236 fav_icon_hiding_offset_(0), | 236 fav_icon_hiding_offset_(0), |
| 237 should_display_crashed_favicon_(false), | 237 should_display_crashed_favicon_(false), |
| 238 loading_animation_(theme_provider), | 238 loading_animation_(theme_provider), |
| 239 // Zero is not a valid SkColor. It'll be replaced by the | 239 close_button_color_(NULL) { |
| 240 // theme tab_text_color. | |
| 241 close_button_color_(0u) { | |
| 242 InitResources(); | 240 InitResources(); |
| 243 | 241 |
| 244 data_.pinned = false; | 242 data_.pinned = false; |
| 245 | 243 |
| 246 tab_.Own(gtk_fixed_new()); | 244 tab_.Own(gtk_fixed_new()); |
| 247 gtk_widget_set_app_paintable(tab_.get(), TRUE); | 245 gtk_widget_set_app_paintable(tab_.get(), TRUE); |
| 248 g_signal_connect(G_OBJECT(tab_.get()), "expose-event", | 246 g_signal_connect(G_OBJECT(tab_.get()), "expose-event", |
| 249 G_CALLBACK(OnExposeEvent), this); | 247 G_CALLBACK(OnExposeEvent), this); |
| 250 g_signal_connect(G_OBJECT(tab_.get()), "size-allocate", | 248 g_signal_connect(G_OBJECT(tab_.get()), "size-allocate", |
| 251 G_CALLBACK(OnSizeAllocate), this); | 249 G_CALLBACK(OnSizeAllocate), this); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 kTopPadding + kCloseButtonVertFuzz + | 583 kTopPadding + kCloseButtonVertFuzz + |
| 586 (content_height - close_button_height_) / 2; | 584 (content_height - close_button_height_) / 2; |
| 587 close_button_bounds_.SetRect(local_bounds.width() + kCloseButtonHorzFuzz, | 585 close_button_bounds_.SetRect(local_bounds.width() + kCloseButtonHorzFuzz, |
| 588 close_button_top, close_button_width_, | 586 close_button_top, close_button_width_, |
| 589 close_button_height_); | 587 close_button_height_); |
| 590 | 588 |
| 591 // If the close button color has changed, generate a new one. | 589 // If the close button color has changed, generate a new one. |
| 592 if (theme_provider_) { | 590 if (theme_provider_) { |
| 593 SkColor tab_text_color = | 591 SkColor tab_text_color = |
| 594 theme_provider_->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT); | 592 theme_provider_->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT); |
| 595 if (close_button_color_ == 0u || tab_text_color != close_button_color_) { | 593 if (!close_button_color_ || tab_text_color != close_button_color_) { |
| 596 close_button_color_ = tab_text_color; | 594 close_button_color_ = tab_text_color; |
| 597 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 595 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 598 close_button_->SetBackground(close_button_color_, | 596 close_button_->SetBackground(close_button_color_, |
| 599 rb.GetBitmapNamed(IDR_TAB_CLOSE), | 597 rb.GetBitmapNamed(IDR_TAB_CLOSE), |
| 600 rb.GetBitmapNamed(IDR_TAB_CLOSE_MASK)); | 598 rb.GetBitmapNamed(IDR_TAB_CLOSE_MASK)); |
| 601 } | 599 } |
| 602 } | 600 } |
| 603 } else { | 601 } else { |
| 604 close_button_bounds_.SetRect(0, 0, 0, 0); | 602 close_button_bounds_.SetRect(0, 0, 0, 0); |
| 605 } | 603 } |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 // Force the font size to 9pt, which matches Windows' default font size | 987 // Force the font size to 9pt, which matches Windows' default font size |
| 990 // (taken from the system). | 988 // (taken from the system). |
| 991 gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont); | 989 gfx::Font base_font = rb.GetFont(ResourceBundle::BaseFont); |
| 992 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9)); | 990 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9)); |
| 993 title_font_height_ = title_font_->height(); | 991 title_font_height_ = title_font_->height(); |
| 994 | 992 |
| 995 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); | 993 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); |
| 996 | 994 |
| 997 initialized_ = true; | 995 initialized_ = true; |
| 998 } | 996 } |
| OLD | NEW |