| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_strip_gtk.h" | 5 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 return tab_data_.at(index).ideal_bounds; | 914 return tab_data_.at(index).ideal_bounds; |
| 915 } | 915 } |
| 916 | 916 |
| 917 void TabStripGtk::SetVerticalOffset(int offset) { | 917 void TabStripGtk::SetVerticalOffset(int offset) { |
| 918 tab_vertical_offset_ = offset; | 918 tab_vertical_offset_ = offset; |
| 919 Layout(); | 919 Layout(); |
| 920 } | 920 } |
| 921 | 921 |
| 922 gfx::Point TabStripGtk::GetTabStripOriginForWidget(GtkWidget* target) { | 922 gfx::Point TabStripGtk::GetTabStripOriginForWidget(GtkWidget* target) { |
| 923 int x, y; | 923 int x, y; |
| 924 GtkAllocation widget_allocation; |
| 925 gtk_widget_get_allocation(widget(), &widget_allocation); |
| 924 if (!gtk_widget_translate_coordinates(widget(), target, | 926 if (!gtk_widget_translate_coordinates(widget(), target, |
| 925 -widget()->allocation.x, 0, &x, &y)) { | 927 -widget_allocation.x, 0, &x, &y)) { |
| 926 // If the tab strip isn't showing, give the coordinates relative to the | 928 // If the tab strip isn't showing, give the coordinates relative to the |
| 927 // toplevel instead. | 929 // toplevel instead. |
| 928 if (!gtk_widget_translate_coordinates( | 930 if (!gtk_widget_translate_coordinates( |
| 929 gtk_widget_get_toplevel(widget()), target, 0, 0, &x, &y)) { | 931 gtk_widget_get_toplevel(widget()), target, 0, 0, &x, &y)) { |
| 930 NOTREACHED(); | 932 NOTREACHED(); |
| 931 } | 933 } |
| 932 } | 934 } |
| 933 if (!gtk_widget_get_has_window(target)) { | 935 if (!gtk_widget_get_has_window(target)) { |
| 934 GtkAllocation allocation; | 936 GtkAllocation target_allocation; |
| 935 gtk_widget_get_allocation(target, &allocation); | 937 gtk_widget_get_allocation(target, &target_allocation); |
| 936 x += allocation.x; | 938 x += target_allocation.x; |
| 937 y += allocation.y; | 939 y += target_allocation.y; |
| 938 } | 940 } |
| 939 return gfx::Point(x, y); | 941 return gfx::Point(x, y); |
| 940 } | 942 } |
| 941 | 943 |
| 942 //////////////////////////////////////////////////////////////////////////////// | 944 //////////////////////////////////////////////////////////////////////////////// |
| 943 // ViewIDUtil::Delegate implementation | 945 // ViewIDUtil::Delegate implementation |
| 944 | 946 |
| 945 GtkWidget* TabStripGtk::GetWidgetForViewID(ViewID view_id) { | 947 GtkWidget* TabStripGtk::GetWidgetForViewID(ViewID view_id) { |
| 946 if (GetTabCount() > 0) { | 948 if (GetTabCount() > 0) { |
| 947 if (view_id == VIEW_ID_TAB_LAST) { | 949 if (view_id == VIEW_ID_TAB_LAST) { |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 | 1484 |
| 1483 *unselected_width = min_unselected_width; | 1485 *unselected_width = min_unselected_width; |
| 1484 *selected_width = min_selected_width; | 1486 *selected_width = min_selected_width; |
| 1485 | 1487 |
| 1486 if (tab_count == 0) { | 1488 if (tab_count == 0) { |
| 1487 // Return immediately to avoid divide-by-zero below. | 1489 // Return immediately to avoid divide-by-zero below. |
| 1488 return; | 1490 return; |
| 1489 } | 1491 } |
| 1490 | 1492 |
| 1491 // Determine how much space we can actually allocate to tabs. | 1493 // Determine how much space we can actually allocate to tabs. |
| 1492 int available_width = tabstrip_->allocation.width; | 1494 GtkAllocation tabstrip_allocation; |
| 1495 gtk_widget_get_allocation(tabstrip_.get(), &tabstrip_allocation); |
| 1496 int available_width = tabstrip_allocation.width; |
| 1493 if (available_width_for_tabs_ < 0) { | 1497 if (available_width_for_tabs_ < 0) { |
| 1494 available_width = bounds_.width(); | 1498 available_width = bounds_.width(); |
| 1495 available_width -= | 1499 available_width -= |
| 1496 (kNewTabButtonHOffset + newtab_button_->WidgetWidth()); | 1500 (kNewTabButtonHOffset + newtab_button_->WidgetWidth()); |
| 1497 } else { | 1501 } else { |
| 1498 // Interesting corner case: if |available_width_for_tabs_| > the result | 1502 // Interesting corner case: if |available_width_for_tabs_| > the result |
| 1499 // of the calculation in the conditional arm above, the strip is in | 1503 // of the calculation in the conditional arm above, the strip is in |
| 1500 // overflow. We can either use the specified width or the true available | 1504 // overflow. We can either use the specified width or the true available |
| 1501 // width here; the first preserves the consistent "leave the last tab under | 1505 // width here; the first preserves the consistent "leave the last tab under |
| 1502 // the user's mouse so they can close many tabs" behavior at the cost of | 1506 // the user's mouse so they can close many tabs" behavior at the cost of |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2240 } | 2244 } |
| 2241 | 2245 |
| 2242 void TabStripGtk::SetNewTabButtonBackground() { | 2246 void TabStripGtk::SetNewTabButtonBackground() { |
| 2243 SkColor color = theme_service_->GetColor( | 2247 SkColor color = theme_service_->GetColor( |
| 2244 ThemeService::COLOR_BUTTON_BACKGROUND); | 2248 ThemeService::COLOR_BUTTON_BACKGROUND); |
| 2245 SkBitmap* background = theme_service_->GetBitmapNamed( | 2249 SkBitmap* background = theme_service_->GetBitmapNamed( |
| 2246 IDR_THEME_WINDOW_CONTROL_BACKGROUND); | 2250 IDR_THEME_WINDOW_CONTROL_BACKGROUND); |
| 2247 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK); | 2251 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK); |
| 2248 newtab_button_->SetBackground(color, background, mask); | 2252 newtab_button_->SetBackground(color, background, mask); |
| 2249 } | 2253 } |
| OLD | NEW |