OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1500 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true); | 1500 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true); |
1501 controller_->LayoutTypeMaybeChanged(); | 1501 controller_->LayoutTypeMaybeChanged(); |
1502 } | 1502 } |
1503 break; | 1503 break; |
1504 | 1504 |
1505 case ui::ET_GESTURE_LONG_PRESS: | 1505 case ui::ET_GESTURE_LONG_PRESS: |
1506 if (drag_controller_.get()) | 1506 if (drag_controller_.get()) |
1507 drag_controller_->SetMoveBehavior(TabDragController::REORDER); | 1507 drag_controller_->SetMoveBehavior(TabDragController::REORDER); |
1508 break; | 1508 break; |
1509 | 1509 |
1510 case ui::ET_GESTURE_LONG_TAP: { | |
1511 gfx::Point local_point = event->location(); | |
sky
2013/03/20 16:42:08
One more question. If we get here, is drag_control
Yufeng Shen (Slow to review)
2013/03/20 17:18:29
I assume if you get LONG_TAP, it means you did not
| |
1512 Tab* tab = FindTabForEvent(local_point); | |
1513 if (tab) { | |
1514 ConvertPointToScreen(this, &local_point); | |
1515 ShowContextMenuForTab(tab, local_point); | |
1516 } | |
1517 break; | |
1518 } | |
1519 | |
1510 case ui::ET_GESTURE_SCROLL_UPDATE: | 1520 case ui::ET_GESTURE_SCROLL_UPDATE: |
1511 ContinueDrag(this, *event); | 1521 ContinueDrag(this, *event); |
1512 break; | 1522 break; |
1513 | 1523 |
1514 case ui::ET_GESTURE_BEGIN: | 1524 case ui::ET_GESTURE_BEGIN: |
1515 EndDrag(END_DRAG_CANCEL); | 1525 EndDrag(END_DRAG_CANCEL); |
1516 break; | 1526 break; |
1517 | 1527 |
1518 default: | 1528 default: |
1519 break; | 1529 break; |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2486 | 2496 |
2487 int TabStrip::GetStartXForNormalTabs() const { | 2497 int TabStrip::GetStartXForNormalTabs() const { |
2488 int mini_tab_count = GetMiniTabCount(); | 2498 int mini_tab_count = GetMiniTabCount(); |
2489 if (mini_tab_count == 0) | 2499 if (mini_tab_count == 0) |
2490 return 0; | 2500 return 0; |
2491 return mini_tab_count * (Tab::GetMiniWidth() + tab_h_offset()) + | 2501 return mini_tab_count * (Tab::GetMiniWidth() + tab_h_offset()) + |
2492 kMiniToNonMiniGap; | 2502 kMiniToNonMiniGap; |
2493 } | 2503 } |
2494 | 2504 |
2495 Tab* TabStrip::FindTabForEvent(const gfx::Point& point) { | 2505 Tab* TabStrip::FindTabForEvent(const gfx::Point& point) { |
2496 DCHECK(touch_layout_.get()); | 2506 if (touch_layout_.get()) { |
2497 int active_tab_index = touch_layout_->active_index(); | 2507 int active_tab_index = touch_layout_->active_index(); |
2498 Tab* tab = NULL; | 2508 if (active_tab_index != -1) { |
2499 if (active_tab_index != -1) { | 2509 Tab* tab = FindTabForEventFrom(point, active_tab_index, -1); |
2500 tab = FindTabForEventFrom(point, active_tab_index, -1); | 2510 if (!tab) |
2501 if (!tab) | 2511 tab = FindTabForEventFrom(point, active_tab_index + 1, 1); |
2502 tab = FindTabForEventFrom(point, active_tab_index + 1, 1); | 2512 return tab; |
2503 } else if (tab_count()) { | 2513 } else if (tab_count()) { |
2504 tab = FindTabForEventFrom(point, 0, 1); | 2514 return FindTabForEventFrom(point, 0, 1); |
2515 } | |
2516 } else { | |
2517 for (int i = 0; i < tab_count(); ++i) { | |
2518 if (IsPointInTab(tab_at(i), point)) | |
2519 return tab_at(i); | |
2520 } | |
2505 } | 2521 } |
2506 return tab; | 2522 return NULL; |
2507 } | 2523 } |
2508 | 2524 |
2509 Tab* TabStrip::FindTabForEventFrom(const gfx::Point& point, | 2525 Tab* TabStrip::FindTabForEventFrom(const gfx::Point& point, |
2510 int start, | 2526 int start, |
2511 int delta) { | 2527 int delta) { |
2512 // |start| equals tab_count() when there are only pinned tabs. | 2528 // |start| equals tab_count() when there are only pinned tabs. |
2513 if (start == tab_count()) | 2529 if (start == tab_count()) |
2514 start += delta; | 2530 start += delta; |
2515 for (int i = start; i >= 0 && i < tab_count(); i += delta) { | 2531 for (int i = start; i >= 0 && i < tab_count(); i += delta) { |
2516 if (IsPointInTab(tab_at(i), point)) | 2532 if (IsPointInTab(tab_at(i), point)) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2593 if (!adjust_layout_) | 2609 if (!adjust_layout_) |
2594 return false; | 2610 return false; |
2595 | 2611 |
2596 #if !defined(OS_CHROMEOS) | 2612 #if !defined(OS_CHROMEOS) |
2597 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) | 2613 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) |
2598 return false; | 2614 return false; |
2599 #endif | 2615 #endif |
2600 | 2616 |
2601 return true; | 2617 return true; |
2602 } | 2618 } |
OLD | NEW |