| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 | 1444 |
| 1445 int y = is_maximized ? 0 : kNewTabButtonVOffset; | 1445 int y = is_maximized ? 0 : kNewTabButtonVOffset; |
| 1446 int height = newtab_surface_bounds_.height() + kNewTabButtonVOffset - y; | 1446 int height = newtab_surface_bounds_.height() + kNewTabButtonVOffset - y; |
| 1447 | 1447 |
| 1448 gfx::Rect bounds(0, y, newtab_surface_bounds_.width(), height); | 1448 gfx::Rect bounds(0, y, newtab_surface_bounds_.width(), height); |
| 1449 int delta = abs(Round(unselected_width) - TabGtk::GetStandardSize().width()); | 1449 int delta = abs(Round(unselected_width) - TabGtk::GetStandardSize().width()); |
| 1450 if (delta > 1 && !needs_resize_layout_) { | 1450 if (delta > 1 && !needs_resize_layout_) { |
| 1451 // We're shrinking tabs, so we need to anchor the New Tab button to the | 1451 // We're shrinking tabs, so we need to anchor the New Tab button to the |
| 1452 // right edge of the TabStrip's bounds, rather than the right edge of the | 1452 // right edge of the TabStrip's bounds, rather than the right edge of the |
| 1453 // right-most Tab, otherwise it'll bounce when animating. | 1453 // right-most Tab, otherwise it'll bounce when animating. |
| 1454 bounds.set_x(bounds_.width() - newtab_button_->width()); | 1454 bounds.set_x(bounds_.width() - newtab_button_->WidgetWidth()); |
| 1455 } else { | 1455 } else { |
| 1456 bounds.set_x(Round(last_tab_right - kTabHOffset) + kNewTabButtonHOffset); | 1456 bounds.set_x(Round(last_tab_right - kTabHOffset) + kNewTabButtonHOffset); |
| 1457 } | 1457 } |
| 1458 bounds.set_x(gtk_util::MirroredLeftPointForRect(tabstrip_.get(), bounds)); | 1458 bounds.set_x(gtk_util::MirroredLeftPointForRect(tabstrip_.get(), bounds)); |
| 1459 | 1459 |
| 1460 gtk_fixed_move(GTK_FIXED(tabstrip_.get()), newtab_button_->widget(), | 1460 gtk_fixed_move(GTK_FIXED(tabstrip_.get()), newtab_button_->widget(), |
| 1461 bounds.x(), bounds.y()); | 1461 bounds.x(), bounds.y()); |
| 1462 gtk_widget_set_size_request(newtab_button_->widget(), bounds.width(), | 1462 gtk_widget_set_size_request(newtab_button_->widget(), bounds.width(), |
| 1463 bounds.height()); | 1463 bounds.height()); |
| 1464 } | 1464 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1479 if (tab_count == 0) { | 1479 if (tab_count == 0) { |
| 1480 // Return immediately to avoid divide-by-zero below. | 1480 // Return immediately to avoid divide-by-zero below. |
| 1481 return; | 1481 return; |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 // Determine how much space we can actually allocate to tabs. | 1484 // Determine how much space we can actually allocate to tabs. |
| 1485 int available_width = tabstrip_->allocation.width; | 1485 int available_width = tabstrip_->allocation.width; |
| 1486 if (available_width_for_tabs_ < 0) { | 1486 if (available_width_for_tabs_ < 0) { |
| 1487 available_width = bounds_.width(); | 1487 available_width = bounds_.width(); |
| 1488 available_width -= | 1488 available_width -= |
| 1489 (kNewTabButtonHOffset + newtab_button_->width()); | 1489 (kNewTabButtonHOffset + newtab_button_->WidgetWidth()); |
| 1490 } else { | 1490 } else { |
| 1491 // Interesting corner case: if |available_width_for_tabs_| > the result | 1491 // Interesting corner case: if |available_width_for_tabs_| > the result |
| 1492 // of the calculation in the conditional arm above, the strip is in | 1492 // of the calculation in the conditional arm above, the strip is in |
| 1493 // overflow. We can either use the specified width or the true available | 1493 // overflow. We can either use the specified width or the true available |
| 1494 // width here; the first preserves the consistent "leave the last tab under | 1494 // width here; the first preserves the consistent "leave the last tab under |
| 1495 // the user's mouse so they can close many tabs" behavior at the cost of | 1495 // the user's mouse so they can close many tabs" behavior at the cost of |
| 1496 // prolonging the glitchy appearance of the overflow state, while the second | 1496 // prolonging the glitchy appearance of the overflow state, while the second |
| 1497 // gets us out of overflow as soon as possible but forces the user to move | 1497 // gets us out of overflow as soon as possible but forces the user to move |
| 1498 // their mouse for a few tabs' worth of closing. We choose visual | 1498 // their mouse for a few tabs' worth of closing. We choose visual |
| 1499 // imperfection over behavioral imperfection and select the first option. | 1499 // imperfection over behavioral imperfection and select the first option. |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2230 } | 2230 } |
| 2231 | 2231 |
| 2232 void TabStripGtk::SetNewTabButtonBackground() { | 2232 void TabStripGtk::SetNewTabButtonBackground() { |
| 2233 SkColor color = theme_service_->GetColor( | 2233 SkColor color = theme_service_->GetColor( |
| 2234 ThemeService::COLOR_BUTTON_BACKGROUND); | 2234 ThemeService::COLOR_BUTTON_BACKGROUND); |
| 2235 SkBitmap* background = theme_service_->GetBitmapNamed( | 2235 SkBitmap* background = theme_service_->GetBitmapNamed( |
| 2236 IDR_THEME_WINDOW_CONTROL_BACKGROUND); | 2236 IDR_THEME_WINDOW_CONTROL_BACKGROUND); |
| 2237 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK); | 2237 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK); |
| 2238 newtab_button_->SetBackground(color, background, mask); | 2238 newtab_button_->SetBackground(color, background, mask); |
| 2239 } | 2239 } |
| OLD | NEW |