Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 12660016: Make long press & release to trigger context menu on tab (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix for comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
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
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());
2497 int active_tab_index = touch_layout_->active_index();
2498 Tab* tab = NULL; 2506 Tab* tab = NULL;
sky 2013/03/20 14:21:25 Nuke 'tab' and return where necessary, eg 2514 sho
Yufeng Shen (Slow to review) 2013/03/20 16:15:24 Done.
2499 if (active_tab_index != -1) { 2507 if (touch_layout_.get()) {
2500 tab = FindTabForEventFrom(point, active_tab_index, -1); 2508 int active_tab_index = touch_layout_->active_index();
2501 if (!tab) 2509 if (active_tab_index != -1) {
2502 tab = FindTabForEventFrom(point, active_tab_index + 1, 1); 2510 tab = FindTabForEventFrom(point, active_tab_index, -1);
2503 } else if (tab_count()) { 2511 if (!tab)
2504 tab = FindTabForEventFrom(point, 0, 1); 2512 tab = FindTabForEventFrom(point, active_tab_index + 1, 1);
2513 } else if (tab_count()) {
2514 tab = FindTabForEventFrom(point, 0, 1);
2515 }
2516 } else {
2517 for (int i = 0; i < tab_count(); ++i) {
2518 if (IsPointInTab(tab_at(i), point)) {
2519 tab = tab_at(i);
2520 break;
2521 }
2522 }
2505 } 2523 }
2506 return tab; 2524 return tab;
2507 } 2525 }
2508 2526
2509 Tab* TabStrip::FindTabForEventFrom(const gfx::Point& point, 2527 Tab* TabStrip::FindTabForEventFrom(const gfx::Point& point,
2510 int start, 2528 int start,
2511 int delta) { 2529 int delta) {
2512 // |start| equals tab_count() when there are only pinned tabs. 2530 // |start| equals tab_count() when there are only pinned tabs.
2513 if (start == tab_count()) 2531 if (start == tab_count())
2514 start += delta; 2532 start += delta;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2593 if (!adjust_layout_) 2611 if (!adjust_layout_)
2594 return false; 2612 return false;
2595 2613
2596 #if !defined(OS_CHROMEOS) 2614 #if !defined(OS_CHROMEOS)
2597 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) 2615 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH)
2598 return false; 2616 return false;
2599 #endif 2617 #endif
2600 2618
2601 return true; 2619 return true;
2602 } 2620 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698