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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_view.mm

Issue 6821003: [Mac] First pass at multiple selection in the tabstrip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase ToT Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
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 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/mac_util.h" 8 #import "base/mac/mac_util.h"
9 #include "base/mac/scoped_cftyperef.h" 9 #include "base/mac/scoped_cftyperef.h"
10 #include "chrome/browser/themes/theme_service.h" 10 #include "chrome/browser/themes/theme_service.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // don't have to worry about mouse ups. 251 // don't have to worry about mouse ups.
252 if (closeButtonActive && [controller_ inRapidClosureMode]) { 252 if (closeButtonActive && [controller_ inRapidClosureMode]) {
253 NSPoint hitLocation = [[self superview] convertPoint:downLocation 253 NSPoint hitLocation = [[self superview] convertPoint:downLocation
254 fromView:nil]; 254 fromView:nil];
255 if ([self hitTest:hitLocation] == closeButton_) { 255 if ([self hitTest:hitLocation] == closeButton_) {
256 [closeButton_ mouseDown:theEvent]; 256 [closeButton_ mouseDown:theEvent];
257 return; 257 return;
258 } 258 }
259 } 259 }
260 260
261 // Fire the action to select the tab.
262 if ([[controller_ target] respondsToSelector:[controller_ action]])
263 [[controller_ target] performSelector:[controller_ action]
264 withObject:self];
265
266 [self resetDragControllers]; 261 [self resetDragControllers];
267 262
268 // Resolve overlay back to original window. 263 // Resolve overlay back to original window.
269 sourceWindow_ = [self window]; 264 sourceWindow_ = [self window];
270 if ([sourceWindow_ isKindOfClass:[NSPanel class]]) { 265 if ([sourceWindow_ isKindOfClass:[NSPanel class]]) {
271 sourceWindow_ = [sourceWindow_ parentWindow]; 266 sourceWindow_ = [sourceWindow_ parentWindow];
272 } 267 }
273 268
274 sourceWindowFrame_ = [sourceWindow_ frame]; 269 sourceWindowFrame_ = [sourceWindow_ frame];
275 sourceTabFrame_ = [self frame]; 270 sourceTabFrame_ = [self frame];
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 // a placeholder so it appears like it's part of that window. 534 // a placeholder so it appears like it's part of that window.
540 if (targetController_) { 535 if (targetController_) {
541 if (![[targetController_ window] isKeyWindow]) { 536 if (![[targetController_ window] isKeyWindow]) {
542 // && ([targetDwellDate timeIntervalSinceNow] < -REQUIRED_DWELL)) { 537 // && ([targetDwellDate timeIntervalSinceNow] < -REQUIRED_DWELL)) {
543 [[targetController_ window] orderFront:nil]; 538 [[targetController_ window] orderFront:nil];
544 targetDwellDate = nil; 539 targetDwellDate = nil;
545 } 540 }
546 541
547 // Compute where placeholder should go and insert it into the 542 // Compute where placeholder should go and insert it into the
548 // destination tab strip. 543 // destination tab strip.
549 TabView* draggedTabView = (TabView*)[draggedController_ selectedTabView]; 544 TabView* draggedTabView = (TabView*)[draggedController_ activeTabView];
550 NSRect tabFrame = [draggedTabView frame]; 545 NSRect tabFrame = [draggedTabView frame];
551 tabFrame.origin = [dragWindow_ convertBaseToScreen:tabFrame.origin]; 546 tabFrame.origin = [dragWindow_ convertBaseToScreen:tabFrame.origin];
552 tabFrame.origin = [[targetController_ window] 547 tabFrame.origin = [[targetController_ window]
553 convertScreenToBase:tabFrame.origin]; 548 convertScreenToBase:tabFrame.origin];
554 tabFrame = [[targetController_ tabStripView] 549 tabFrame = [[targetController_ tabStripView]
555 convertRect:tabFrame fromView:nil]; 550 convertRect:tabFrame fromView:nil];
556 [targetController_ insertPlaceholderForTab:self 551 [targetController_ insertPlaceholderForTab:self
557 frame:tabFrame 552 frame:tabFrame
558 yStretchiness:0]; 553 yStretchiness:0];
559 [targetController_ layoutTabs]; 554 [targetController_ layoutTabs];
560 } else { 555 } else {
561 [dragWindow_ makeKeyAndOrderFront:nil]; 556 [dragWindow_ makeKeyAndOrderFront:nil];
562 } 557 }
563 558
564 // Adjust the visibility of the window background. If there is a drop target, 559 // Adjust the visibility of the window background. If there is a drop target,
565 // we want to hide the window background so the tab stands out for 560 // we want to hide the window background so the tab stands out for
566 // positioning. If not, we want to show it so it looks like a new window will 561 // positioning. If not, we want to show it so it looks like a new window will
567 // be realized. 562 // be realized.
568 BOOL chromeShouldBeVisible = targetController_ == nil; 563 BOOL chromeShouldBeVisible = targetController_ == nil;
569 [self setWindowBackgroundVisibility:chromeShouldBeVisible]; 564 [self setWindowBackgroundVisibility:chromeShouldBeVisible];
570 } 565 }
571 566
572 - (void)mouseUp:(NSEvent*)theEvent { 567 - (void)mouseUp:(NSEvent*)theEvent {
573 // The drag/click is done. If the user dragged the mouse, finalize the drag 568 // The drag/click is done. If the user dragged the mouse, finalize the drag
574 // and clean up. 569 // and clean up.
575 570
571 // Fire the action to select the tab.
572 if ([[controller_ target] respondsToSelector:[controller_ action]])
573 [[controller_ target] performSelector:[controller_ action]
574 withObject:self];
575
576 // Special-case this to keep the logic below simpler. 576 // Special-case this to keep the logic below simpler.
577 if (moveWindowOnDrag_) 577 if (moveWindowOnDrag_)
578 return; 578 return;
579 579
580 // Cancel any delayed -mouseDragged: requests that may still be pending. 580 // Cancel any delayed -mouseDragged: requests that may still be pending.
581 [NSObject cancelPreviousPerformRequestsWithTarget:self]; 581 [NSObject cancelPreviousPerformRequestsWithTarget:self];
582 582
583 // TODO(pinkerton): http://crbug.com/25682 demonstrates a way to get here by 583 // TODO(pinkerton): http://crbug.com/25682 demonstrates a way to get here by
584 // some weird circumstance that doesn't first go through mouseDown:. We 584 // some weird circumstance that doesn't first go through mouseDown:. We
585 // really shouldn't go any farther. 585 // really shouldn't go any farther.
586 if (!sourceController_) 586 if (!sourceController_)
587 return; 587 return;
588 588
589 // We are now free to re-display the new tab button in the window we're 589 // We are now free to re-display the new tab button in the window we're
590 // dragging. It will show when the next call to -layoutTabs (which happens 590 // dragging. It will show when the next call to -layoutTabs (which happens
591 // indrectly by several of the calls below, such as removing the placeholder). 591 // indrectly by several of the calls below, such as removing the placeholder).
592 [draggedController_ showNewTabButton:YES]; 592 [draggedController_ showNewTabButton:YES];
593 593
594 if (draggingWithinTabStrip_) { 594 if (draggingWithinTabStrip_) {
595 if (tabWasDragged_) { 595 if (tabWasDragged_) {
596 // Move tab to new location. 596 // Move tab to new location.
597 DCHECK([sourceController_ numberOfTabs]); 597 DCHECK([sourceController_ numberOfTabs]);
598 TabWindowController* dropController = sourceController_; 598 TabWindowController* dropController = sourceController_;
599 [dropController moveTabView:[dropController selectedTabView] 599 [dropController moveTabView:[dropController activeTabView]
600 fromController:nil]; 600 fromController:nil];
601 } 601 }
602 } else if (targetController_) { 602 } else if (targetController_) {
603 // Move between windows. If |targetController_| is nil, we're not dropping 603 // Move between windows. If |targetController_| is nil, we're not dropping
604 // into any existing window. 604 // into any existing window.
605 NSView* draggedTabView = [draggedController_ selectedTabView]; 605 NSView* draggedTabView = [draggedController_ activeTabView];
606 [targetController_ moveTabView:draggedTabView 606 [targetController_ moveTabView:draggedTabView
607 fromController:draggedController_]; 607 fromController:draggedController_];
608 // Force redraw to avoid flashes of old content before returning to event 608 // Force redraw to avoid flashes of old content before returning to event
609 // loop. 609 // loop.
610 [[targetController_ window] display]; 610 [[targetController_ window] display];
611 [targetController_ showWindow:nil]; 611 [targetController_ showWindow:nil];
612 [draggedController_ removeOverlay]; 612 [draggedController_ removeOverlay];
613 } else { 613 } else {
614 // Only move the window around on screen. Make sure it's set back to 614 // Only move the window around on screen. Make sure it's set back to
615 // normal state (fully opaque, has shadow, has key, etc). 615 // normal state (fully opaque, has shadow, has key, etc).
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 768
769 // Draw the top stroke. 769 // Draw the top stroke.
770 [context saveGraphicsState]; 770 [context saveGraphicsState];
771 [borderColor set]; 771 [borderColor set];
772 [path setLineWidth:lineWidth]; 772 [path setLineWidth:lineWidth];
773 [path stroke]; 773 [path stroke];
774 [context restoreGraphicsState]; 774 [context restoreGraphicsState];
775 775
776 // Mimic the tab strip's bottom border, which consists of a dark border 776 // Mimic the tab strip's bottom border, which consists of a dark border
777 // and light highlight. 777 // and light highlight.
778 if (!selected) { 778 if (![controller_ active]) {
779 [path addClip]; 779 [path addClip];
780 NSRect borderRect = rect; 780 NSRect borderRect = rect;
781 borderRect.origin.y = lineWidth; 781 borderRect.origin.y = lineWidth;
782 borderRect.size.height = lineWidth; 782 borderRect.size.height = lineWidth;
783 [borderColor set]; 783 [borderColor set];
784 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); 784 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver);
785 785
786 borderRect.origin.y = 0; 786 borderRect.origin.y = 0;
787 [highlightColor set]; 787 [highlightColor set];
788 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); 788 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 topRight.y) 1060 topRight.y)
1061 controlPoint2:NSMakePoint(bottomRight.x - baseControlPointOutset, 1061 controlPoint2:NSMakePoint(bottomRight.x - baseControlPointOutset,
1062 bottomRight.y)]; 1062 bottomRight.y)];
1063 [path lineToPoint:NSMakePoint(bottomRight.x + lineWidth, bottomRight.y)]; 1063 [path lineToPoint:NSMakePoint(bottomRight.x + lineWidth, bottomRight.y)];
1064 [path lineToPoint:NSMakePoint(bottomRight.x + lineWidth, 1064 [path lineToPoint:NSMakePoint(bottomRight.x + lineWidth,
1065 bottomRight.y - (2 * lineWidth))]; 1065 bottomRight.y - (2 * lineWidth))];
1066 return path; 1066 return path;
1067 } 1067 }
1068 1068
1069 @end // @implementation TabView(Private) 1069 @end // @implementation TabView(Private)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.mm ('k') | chrome/browser/ui/cocoa/tabs/tab_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698