Chromium Code Reviews| 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::Vector2d parent_offset = ui::GetWidgetScreenOffset(parent); |
| 97 gfx::Point widget_pos = ui::GetWidgetScreenPosition(widget); | 97 gfx::Vector2d widget_offset = ui::GetWidgetScreenOffset(widget); |
| 98 gfx::Vector2d offset_from_parent = widget_offset - parent_offset; | |
| 98 | 99 |
| 99 GtkAllocation allocation; | 100 GtkAllocation allocation; |
| 100 gtk_widget_get_allocation(widget, &allocation); | 101 gtk_widget_get_allocation(widget, &allocation); |
| 101 | 102 |
| 102 return gfx::Rect(widget_pos.x() - parent_pos.x(), | 103 return gfx::Rect(gfx::PointAtOffsetFromOrigin(offset_from_parent), |
| 103 widget_pos.y() - parent_pos.y(), | 104 gfx::Size(allocation.width, allocation.height)); |
|
Peter Kasting
2012/10/29 23:06:33
Nit: Assuming your earlier use of GetWidgetScreenB
danakj
2012/10/29 23:21:41
Done.
| |
| 104 allocation.width, allocation.height); | |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace | 107 } // namespace |
| 108 | 108 |
| 109 TabRendererGtk::LoadingAnimation::Data::Data( | 109 TabRendererGtk::LoadingAnimation::Data::Data( |
| 110 GtkThemeService* theme_service) { | 110 GtkThemeService* theme_service) { |
| 111 // The loading animation image is a strip of states. Each state must be | 111 // The loading animation image is a strip of states. Each state must be |
| 112 // square, so the height must divide the width evenly. | 112 // square, so the height must divide the width evenly. |
| 113 SkBitmap loading_animation_frames = | 113 SkBitmap loading_animation_frames = |
| 114 theme_service->GetImageNamed(IDR_THROBBER).AsBitmap(); | 114 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(); | 1121 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); |
| 1122 close_button_width_ = gdk_pixbuf_get_width(tab_close); | 1122 close_button_width_ = gdk_pixbuf_get_width(tab_close); |
| 1123 close_button_height_ = gdk_pixbuf_get_height(tab_close); | 1123 close_button_height_ = gdk_pixbuf_get_height(tab_close); |
| 1124 | 1124 |
| 1125 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | 1125 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); |
| 1126 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1126 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
| 1127 title_font_height_ = title_font_->GetHeight(); | 1127 title_font_height_ = title_font_->GetHeight(); |
| 1128 | 1128 |
| 1129 initialized_ = true; | 1129 initialized_ = true; |
| 1130 } | 1130 } |
| OLD | NEW |