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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 horizontal offset used to position the close button in the tab. | 90 // The horizontal offset used to position the close button in the tab. |
91 const int kCloseButtonHorzFuzz = 4; | 91 const int kCloseButtonHorzFuzz = 4; |
92 | 92 |
93 // Gets the bounds of |widget| relative to |parent|. | 93 // Gets the bounds of |widget| relative to |parent|. |
94 gfx::Rect GetWidgetBoundsRelativeToParent(GtkWidget* parent, | 94 gfx::Rect GetWidgetBoundsRelativeToParent(GtkWidget* parent, |
95 GtkWidget* widget) { | 95 GtkWidget* widget) { |
96 gfx::Point parent_pos = ui::GetWidgetScreenPosition(parent); | 96 gfx::Rect bounds = ui::GetWidgetScreenBounds(widget); |
97 gfx::Point widget_pos = ui::GetWidgetScreenPosition(widget); | 97 bounds.Offset(-ui::GetWidgetScreenOffset(parent)); |
98 | 98 return bounds; |
99 GtkAllocation allocation; | |
100 gtk_widget_get_allocation(widget, &allocation); | |
101 | |
102 return gfx::Rect(widget_pos.x() - parent_pos.x(), | |
103 widget_pos.y() - parent_pos.y(), | |
104 allocation.width, allocation.height); | |
105 } | 99 } |
106 | 100 |
107 } // namespace | 101 } // namespace |
108 | 102 |
109 TabRendererGtk::LoadingAnimation::Data::Data( | 103 TabRendererGtk::LoadingAnimation::Data::Data( |
110 GtkThemeService* theme_service) { | 104 GtkThemeService* theme_service) { |
111 // The loading animation image is a strip of states. Each state must be | 105 // The loading animation image is a strip of states. Each state must be |
112 // square, so the height must divide the width evenly. | 106 // square, so the height must divide the width evenly. |
113 SkBitmap loading_animation_frames = | 107 SkBitmap loading_animation_frames = |
114 theme_service->GetImageNamed(IDR_THROBBER).AsBitmap(); | 108 theme_service->GetImageNamed(IDR_THROBBER).AsBitmap(); |
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); | 1115 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); |
1122 close_button_width_ = gdk_pixbuf_get_width(tab_close); | 1116 close_button_width_ = gdk_pixbuf_get_width(tab_close); |
1123 close_button_height_ = gdk_pixbuf_get_height(tab_close); | 1117 close_button_height_ = gdk_pixbuf_get_height(tab_close); |
1124 | 1118 |
1125 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | 1119 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); |
1126 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1120 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
1127 title_font_height_ = title_font_->GetHeight(); | 1121 title_font_height_ = title_font_->GetHeight(); |
1128 | 1122 |
1129 initialized_ = true; | 1123 initialized_ = true; |
1130 } | 1124 } |
OLD | NEW |