Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_DRAG_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_DRAG_CONTROLLER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #import <Cocoa/Cocoa.h> | |
| 10 #include <map> | |
| 11 | |
| 12 @class TabController; | |
| 13 @class TabStripController; | |
| 14 @class TabWindowController; | |
| 15 | |
| 16 //////////////////////////////////////////////////////////////////////////////// | |
| 17 | |
| 18 // This protocol is used to carry mouse events to the TabStripDragController, | |
| 19 // which manages the logic for actually dragging tabs. | |
| 20 @protocol TabDraggingEventTarget | |
| 21 | |
| 22 // Returns YES if the tab represented by the controller can be dragged. | |
| 23 - (BOOL)tabCanBeDragged:(TabController*)tab; | |
| 24 | |
| 25 // Initiates a dragging session with a mouseDown event. The tab controller | |
| 26 // passed here is the one used for the rest of the dragging session. | |
| 27 - (void)maybeStartDrag:(NSEvent*)event forTab:(TabController*)tab; | |
| 28 | |
| 29 // Updates the dragging state with a mouseDragged event. | |
| 30 - (void)continueDrag:(NSEvent*)event; | |
| 31 | |
| 32 // Ends a dragging session with a mouseUp event. | |
| 33 - (void)endDrag:(NSEvent*)event; | |
| 34 | |
| 35 @end | |
| 36 | |
| 37 //////////////////////////////////////////////////////////////////////////////// | |
| 38 | |
| 39 // This controller is owned by the TabStripController and is used to delegate | |
| 40 // all the logic for tab dragging from the TabView's events. | |
| 41 @interface TabStripDragController : NSObject<TabDraggingEventTarget> { | |
| 42 @private | |
| 43 TabStripController* tabStrip_; // Weak; owns this. | |
| 44 | |
| 45 // These are released on mouseUp: | |
| 46 BOOL moveWindowOnDrag_; // Set if the only tab of a window is dragged. | |
| 47 BOOL tabWasDragged_; // Has the tab been dragged? | |
| 48 BOOL draggingWithinTabStrip_; // Did drag stay in the current tab strip? | |
| 49 BOOL chromeIsVisible_; | |
| 50 | |
| 51 NSTimeInterval tearTime_; // Time since tear happened | |
| 52 NSPoint tearOrigin_; // Origin of the tear rect | |
| 53 NSPoint dragOrigin_; // Origin point of the drag | |
| 54 // TODO(alcor): these references may need to be strong to avoid crashes | |
|
pink (ping after 24hrs)
2011/06/03 14:24:49
you can probably remove this TODO at this point.
| |
| 55 // due to JS closing windows | |
| 56 TabWindowController* sourceController_; // weak. controller starting the drag | |
| 57 NSWindow* sourceWindow_; // weak. The window starting the drag | |
| 58 NSRect sourceWindowFrame_; | |
| 59 NSRect sourceTabFrame_; | |
| 60 | |
| 61 TabController* draggedTab_; // weak. The tab controller being dragged. | |
| 62 | |
| 63 TabWindowController* draggedController_; // weak. Controller being dragged. | |
| 64 NSWindow* dragWindow_; // weak. The window being dragged | |
| 65 NSWindow* dragOverlay_; // weak. The overlay being dragged | |
| 66 // Cache workspace IDs per-drag because computing them on 10.5 with | |
| 67 // CGWindowListCreateDescriptionFromArray is expensive. | |
| 68 // resetDragControllers clears this cache. | |
| 69 // | |
| 70 // TODO(davidben): When 10.5 becomes unsupported, remove this. | |
| 71 std::map<CGWindowID, int> workspaceIDCache_; | |
| 72 | |
| 73 TabWindowController* targetController_; // weak. Controller being targeted | |
| 74 } | |
| 75 | |
| 76 // Designated initializer. | |
| 77 - (id)initWithTabStripController:(TabStripController*)controller; | |
| 78 | |
| 79 // TabDraggingEventTarget methods are also implemented. | |
| 80 | |
| 81 @end | |
| 82 | |
| 83 #endif // CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_DRAG_CONTROLLER_H_ | |
| OLD | NEW |