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/views/tabs/tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 if (drop_before) | 664 if (drop_before) |
665 center_x = tab->x() - (kTabHOffset / 2); | 665 center_x = tab->x() - (kTabHOffset / 2); |
666 else | 666 else |
667 center_x = tab->x() + (tab->width() / 2); | 667 center_x = tab->x() + (tab->width() / 2); |
668 } else { | 668 } else { |
669 Tab* last_tab = GetTabAtTabDataIndex(drop_index - 1); | 669 Tab* last_tab = GetTabAtTabDataIndex(drop_index - 1); |
670 center_x = last_tab->x() + last_tab->width() + (kTabHOffset / 2); | 670 center_x = last_tab->x() + last_tab->width() + (kTabHOffset / 2); |
671 } | 671 } |
672 | 672 |
673 // Mirror the center point if necessary. | 673 // Mirror the center point if necessary. |
674 center_x = MirroredXCoordinateInsideView(center_x); | 674 center_x = GetMirroredXInView(center_x); |
675 | 675 |
676 // Determine the screen bounds. | 676 // Determine the screen bounds. |
677 gfx::Point drop_loc(center_x - drop_indicator_width / 2, | 677 gfx::Point drop_loc(center_x - drop_indicator_width / 2, |
678 -drop_indicator_height); | 678 -drop_indicator_height); |
679 ConvertPointToScreen(this, &drop_loc); | 679 ConvertPointToScreen(this, &drop_loc); |
680 gfx::Rect drop_bounds(drop_loc.x(), drop_loc.y(), drop_indicator_width, | 680 gfx::Rect drop_bounds(drop_loc.x(), drop_loc.y(), drop_indicator_width, |
681 drop_indicator_height); | 681 drop_indicator_height); |
682 | 682 |
683 // If the rect doesn't fit on the monitor, push the arrow to the bottom. | 683 // If the rect doesn't fit on the monitor, push the arrow to the bottom. |
684 #if defined(OS_WIN) | 684 #if defined(OS_WIN) |
685 gfx::Rect monitor_bounds = views::GetMonitorBoundsForRect(drop_bounds); | 685 gfx::Rect monitor_bounds = views::GetMonitorBoundsForRect(drop_bounds); |
686 *is_beneath = (monitor_bounds.IsEmpty() || | 686 *is_beneath = (monitor_bounds.IsEmpty() || |
687 !monitor_bounds.Contains(drop_bounds)); | 687 !monitor_bounds.Contains(drop_bounds)); |
688 #else | 688 #else |
689 *is_beneath = false; | 689 *is_beneath = false; |
690 NOTIMPLEMENTED(); | 690 NOTIMPLEMENTED(); |
691 #endif | 691 #endif |
692 if (*is_beneath) | 692 if (*is_beneath) |
693 drop_bounds.Offset(0, drop_bounds.height() + height()); | 693 drop_bounds.Offset(0, drop_bounds.height() + height()); |
694 | 694 |
695 return drop_bounds; | 695 return drop_bounds; |
696 } | 696 } |
697 | 697 |
698 void TabStrip::UpdateDropIndex(const DropTargetEvent& event) { | 698 void TabStrip::UpdateDropIndex(const DropTargetEvent& event) { |
699 // If the UI layout is right-to-left, we need to mirror the mouse | 699 // If the UI layout is right-to-left, we need to mirror the mouse |
700 // coordinates since we calculate the drop index based on the | 700 // coordinates since we calculate the drop index based on the |
701 // original (and therefore non-mirrored) positions of the tabs. | 701 // original (and therefore non-mirrored) positions of the tabs. |
702 const int x = MirroredXCoordinateInsideView(event.x()); | 702 const int x = GetMirroredXInView(event.x()); |
703 // We don't allow replacing the urls of mini-tabs. | 703 // We don't allow replacing the urls of mini-tabs. |
704 for (int i = GetMiniTabCount(); i < tab_count(); ++i) { | 704 for (int i = GetMiniTabCount(); i < tab_count(); ++i) { |
705 Tab* tab = GetTabAtTabDataIndex(i); | 705 Tab* tab = GetTabAtTabDataIndex(i); |
706 const int tab_max_x = tab->x() + tab->width(); | 706 const int tab_max_x = tab->x() + tab->width(); |
707 const int hot_width = tab->width() / 3; | 707 const int hot_width = tab->width() / 3; |
708 if (x < tab_max_x) { | 708 if (x < tab_max_x) { |
709 if (x < tab->x() + hot_width) | 709 if (x < tab->x() + hot_width) |
710 SetDropIndex(i, true); | 710 SetDropIndex(i, true); |
711 else if (x >= tab_max_x - hot_width) | 711 else if (x >= tab_max_x - hot_width) |
712 SetDropIndex(i + 1, true); | 712 SetDropIndex(i + 1, true); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 int TabStrip::GetAvailableWidthForTabs(Tab* last_tab) const { | 949 int TabStrip::GetAvailableWidthForTabs(Tab* last_tab) const { |
950 return last_tab->x() + last_tab->width(); | 950 return last_tab->x() + last_tab->width(); |
951 } | 951 } |
952 | 952 |
953 bool TabStrip::IsPointInTab(Tab* tab, | 953 bool TabStrip::IsPointInTab(Tab* tab, |
954 const gfx::Point& point_in_tabstrip_coords) { | 954 const gfx::Point& point_in_tabstrip_coords) { |
955 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); | 955 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); |
956 View::ConvertPointToView(this, tab, &point_in_tab_coords); | 956 View::ConvertPointToView(this, tab, &point_in_tab_coords); |
957 return tab->HitTest(point_in_tab_coords); | 957 return tab->HitTest(point_in_tab_coords); |
958 } | 958 } |
OLD | NEW |