| 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 "grit/theme_resources.h" | 8 #include "grit/theme_resources.h" |
| 9 #include "chrome/browser/metrics/user_metrics.h" | 9 #include "chrome/browser/metrics/user_metrics.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } | 522 } |
| 523 | 523 |
| 524 bool TabStrip::PointIsWithinWindowCaption(const gfx::Point& point) { | 524 bool TabStrip::PointIsWithinWindowCaption(const gfx::Point& point) { |
| 525 views::View* v = GetViewForPoint(point); | 525 views::View* v = GetViewForPoint(point); |
| 526 | 526 |
| 527 // If there is no control at this location, claim the hit was in the title | 527 // If there is no control at this location, claim the hit was in the title |
| 528 // bar to get a move action. | 528 // bar to get a move action. |
| 529 if (v == this) | 529 if (v == this) |
| 530 return true; | 530 return true; |
| 531 | 531 |
| 532 // If the point is within the bounds of a Tab, the point can be considered | |
| 533 // part of the caption if there are no available drag operations for the Tab. | |
| 534 if (v->GetClassName() == Tab::kTabClassName && !HasAvailableDragActions()) | |
| 535 return true; | |
| 536 | |
| 537 // Check to see if the point is within the non-button parts of the new tab | 532 // Check to see if the point is within the non-button parts of the new tab |
| 538 // button. The button has a non-rectangular shape, so if it's not in the | 533 // button. The button has a non-rectangular shape, so if it's not in the |
| 539 // visual portions of the button we treat it as a click to the caption. | 534 // visual portions of the button we treat it as a click to the caption. |
| 540 gfx::Point point_in_newtab_coords(point); | 535 gfx::Point point_in_newtab_coords(point); |
| 541 View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords); | 536 View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords); |
| 542 if (newtab_button_->bounds().Contains(point) && | 537 if (newtab_button_->bounds().Contains(point) && |
| 543 !newtab_button_->HitTest(point_in_newtab_coords)) { | 538 !newtab_button_->HitTest(point_in_newtab_coords)) { |
| 544 return true; | 539 return true; |
| 545 } | 540 } |
| 546 | 541 |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 // a TabStrip animation when the mouse button is down. In this case we should | 1015 // a TabStrip animation when the mouse button is down. In this case we should |
| 1021 // _not_ continue the drag because it can lead to weird bugs. | 1016 // _not_ continue the drag because it can lead to weird bugs. |
| 1022 if (drag_controller_.get()) | 1017 if (drag_controller_.get()) |
| 1023 drag_controller_->Drag(); | 1018 drag_controller_->Drag(); |
| 1024 } | 1019 } |
| 1025 | 1020 |
| 1026 bool TabStrip::EndDrag(bool canceled) { | 1021 bool TabStrip::EndDrag(bool canceled) { |
| 1027 return drag_controller_.get() ? drag_controller_->EndDrag(canceled) : false; | 1022 return drag_controller_.get() ? drag_controller_->EndDrag(canceled) : false; |
| 1028 } | 1023 } |
| 1029 | 1024 |
| 1025 bool TabStrip::ContainsExactlyOneTab() const { |
| 1026 return GetTabCount() == 1; |
| 1027 } |
| 1028 |
| 1030 /////////////////////////////////////////////////////////////////////////////// | 1029 /////////////////////////////////////////////////////////////////////////////// |
| 1031 // TabStrip, views::BaseButton::ButtonListener implementation: | 1030 // TabStrip, views::BaseButton::ButtonListener implementation: |
| 1032 | 1031 |
| 1033 void TabStrip::ButtonPressed(views::BaseButton* sender) { | 1032 void TabStrip::ButtonPressed(views::BaseButton* sender) { |
| 1034 if (sender == newtab_button_) | 1033 if (sender == newtab_button_) |
| 1035 model_->AddBlankTab(true); | 1034 model_->AddBlankTab(true); |
| 1036 } | 1035 } |
| 1037 | 1036 |
| 1038 /////////////////////////////////////////////////////////////////////////////// | 1037 /////////////////////////////////////////////////////////////////////////////// |
| 1039 // TabStrip, MessageLoop::Observer implementation: | 1038 // TabStrip, MessageLoop::Observer implementation: |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 return last_tab->x() + last_tab->width(); | 1532 return last_tab->x() + last_tab->width(); |
| 1534 } | 1533 } |
| 1535 | 1534 |
| 1536 bool TabStrip::IsPointInTab(Tab* tab, | 1535 bool TabStrip::IsPointInTab(Tab* tab, |
| 1537 const gfx::Point& point_in_tabstrip_coords) { | 1536 const gfx::Point& point_in_tabstrip_coords) { |
| 1538 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); | 1537 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); |
| 1539 View::ConvertPointToView(this, tab, &point_in_tab_coords); | 1538 View::ConvertPointToView(this, tab, &point_in_tab_coords); |
| 1540 return tab->HitTest(point_in_tab_coords); | 1539 return tab->HitTest(point_in_tab_coords); |
| 1541 } | 1540 } |
| 1542 | 1541 |
| OLD | NEW |