| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/tabs/tab_strip.h" | 5 #include "chrome/browser/views/tabs/tab_strip.h" |
| 6 | 6 |
| 7 #include "base/gfx/size.h" | 7 #include "base/gfx/size.h" |
| 8 #include "chrome/app/theme/theme_resources.h" | 8 #include "chrome/app/theme/theme_resources.h" |
| 9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/browser/tab_contents.h" | 10 #include "chrome/browser/tab_contents.h" |
| (...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 void TabStrip::StartResizeLayoutAnimation() { | 1465 void TabStrip::StartResizeLayoutAnimation() { |
| 1466 if (active_animation_.get()) | 1466 if (active_animation_.get()) |
| 1467 active_animation_->Stop(); | 1467 active_animation_->Stop(); |
| 1468 active_animation_.reset(new ResizeLayoutAnimation(this)); | 1468 active_animation_.reset(new ResizeLayoutAnimation(this)); |
| 1469 active_animation_->Start(); | 1469 active_animation_->Start(); |
| 1470 } | 1470 } |
| 1471 | 1471 |
| 1472 void TabStrip::StartInsertTabAnimation(int index) { | 1472 void TabStrip::StartInsertTabAnimation(int index) { |
| 1473 // The TabStrip can now use its entire width to lay out Tabs. | 1473 // Don't shock users by letting all tabs move when they are focused |
| 1474 available_width_for_tabs_ = -1; | 1474 // on the tab-strip. Wait for later, when they aren't looking. |
| 1475 int last_tab_index = GetTabCount() - 2; |
| 1476 if (last_tab_index > 0) { |
| 1477 Tab* last_tab = GetTabAt(last_tab_index); |
| 1478 » available_width_for_tabs_ = std::min( |
| 1479 » » GetAvailableWidthForTabs(last_tab) + last_tab->width(), |
| 1480 » » width() - (kNewTabButtonHOffset + newtab_button_size_.width())
); |
| 1481 } else { |
| 1482 available_width_for_tabs_ = -1; |
| 1483 } |
| 1475 if (active_animation_.get()) | 1484 if (active_animation_.get()) |
| 1476 active_animation_->Stop(); | 1485 active_animation_->Stop(); |
| 1477 active_animation_.reset(new InsertTabAnimation(this, index)); | 1486 active_animation_.reset(new InsertTabAnimation(this, index)); |
| 1478 active_animation_->Start(); | 1487 active_animation_->Start(); |
| 1479 } | 1488 } |
| 1480 | 1489 |
| 1481 void TabStrip::StartRemoveTabAnimation(int index, TabContents* contents) { | 1490 void TabStrip::StartRemoveTabAnimation(int index, TabContents* contents) { |
| 1482 if (active_animation_.get()) { | 1491 if (active_animation_.get()) { |
| 1483 // Some animations (e.g. MoveTabAnimation) cause there to be a Layout when | 1492 // Some animations (e.g. MoveTabAnimation) cause there to be a Layout when |
| 1484 // they're completed (which includes canceled). Since |tab_data_| is now | 1493 // they're completed (which includes canceled). Since |tab_data_| is now |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 return last_tab->x() + last_tab->width(); | 1542 return last_tab->x() + last_tab->width(); |
| 1534 } | 1543 } |
| 1535 | 1544 |
| 1536 bool TabStrip::IsPointInTab(Tab* tab, | 1545 bool TabStrip::IsPointInTab(Tab* tab, |
| 1537 const gfx::Point& point_in_tabstrip_coords) { | 1546 const gfx::Point& point_in_tabstrip_coords) { |
| 1538 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); | 1547 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); |
| 1539 View::ConvertPointToView(this, tab, &point_in_tab_coords); | 1548 View::ConvertPointToView(this, tab, &point_in_tab_coords); |
| 1540 return tab->HitTest(point_in_tab_coords); | 1549 return tab->HitTest(point_in_tab_coords); |
| 1541 } | 1550 } |
| 1542 | 1551 |
| OLD | NEW |