| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "base/mac/cocoa_protocols.h" | 7 #import "base/mac/cocoa_protocols.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 | 9 |
| 10 namespace BaseBubbleControllerInternal { | 10 namespace BaseBubbleControllerInternal { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // 2. Create a subclass of BaseBubbleController. | 24 // 2. Create a subclass of BaseBubbleController. |
| 25 // 3. Change the xib's File Owner to your subclass. | 25 // 3. Change the xib's File Owner to your subclass. |
| 26 // 4. Hook up the File Owner's |bubble_| to the InfoBubbleView in the xib. | 26 // 4. Hook up the File Owner's |bubble_| to the InfoBubbleView in the xib. |
| 27 @interface BaseBubbleController : NSWindowController<NSWindowDelegate> { | 27 @interface BaseBubbleController : NSWindowController<NSWindowDelegate> { |
| 28 @private | 28 @private |
| 29 NSWindow* parentWindow_; // weak | 29 NSWindow* parentWindow_; // weak |
| 30 NSPoint anchor_; | 30 NSPoint anchor_; |
| 31 IBOutlet InfoBubbleView* bubble_; // to set arrow position | 31 IBOutlet InfoBubbleView* bubble_; // to set arrow position |
| 32 // Bridge that listens for notifications. | 32 // Bridge that listens for notifications. |
| 33 scoped_ptr<BaseBubbleControllerInternal::Bridge> baseBridge_; | 33 scoped_ptr<BaseBubbleControllerInternal::Bridge> baseBridge_; |
| 34 |
| 35 // Non-nil only on 10.7+. Both weak, owned by AppKit. |
| 36 // A local event tap that will dismiss the bubble when a click is delivered |
| 37 // outside the window. This is needed because the window shares first |
| 38 // responder with its parent. |
| 39 id eventTap_; |
| 40 // A notification observer that gets triggered when any window resigns key. |
| 41 id resignationObserver_; |
| 34 } | 42 } |
| 35 | 43 |
| 36 @property(nonatomic, readonly) NSWindow* parentWindow; | 44 @property(nonatomic, readonly) NSWindow* parentWindow; |
| 37 // The point in base screen coordinates at which the bubble should open and the | 45 // The point in base screen coordinates at which the bubble should open and the |
| 38 // arrow tip points. | 46 // arrow tip points. |
| 39 @property(nonatomic, assign) NSPoint anchorPoint; | 47 @property(nonatomic, assign) NSPoint anchorPoint; |
| 40 @property(nonatomic, readonly) InfoBubbleView* bubble; | 48 @property(nonatomic, readonly) InfoBubbleView* bubble; |
| 41 | 49 |
| 42 // Creates a bubble. |nibPath| is just the basename, e.g. @"FirstRunBubble". | 50 // Creates a bubble. |nibPath| is just the basename, e.g. @"FirstRunBubble". |
| 43 // |anchoredAt| is in screen space. You need to call -showWindow: to make the | 51 // |anchoredAt| is in screen space. You need to call -showWindow: to make the |
| (...skipping 20 matching lines...) Expand all Loading... |
| 64 // contentView with an instance of InfoBubbleView. | 72 // contentView with an instance of InfoBubbleView. |
| 65 - (id)initWithWindow:(NSWindow*)theWindow | 73 - (id)initWithWindow:(NSWindow*)theWindow |
| 66 parentWindow:(NSWindow*)parentWindow | 74 parentWindow:(NSWindow*)parentWindow |
| 67 anchoredAt:(NSPoint)anchoredAt; | 75 anchoredAt:(NSPoint)anchoredAt; |
| 68 | 76 |
| 69 // Creates an autoreleased separator view with a given frame. The height of the | 77 // Creates an autoreleased separator view with a given frame. The height of the |
| 70 // frame is ignored. | 78 // frame is ignored. |
| 71 - (NSBox*)separatorWithFrame:(NSRect)frame; | 79 - (NSBox*)separatorWithFrame:(NSRect)frame; |
| 72 | 80 |
| 73 @end | 81 @end |
| 82 |
| 83 // Methods for use by subclasses. |
| 84 @interface BaseBubbleController (Protected) |
| 85 // Registers event taps *after* the window is shown so that the bubble is |
| 86 // dismissed when it resigns key. This only needs to be called if |
| 87 // |-showWindow:| is overriden and does not call super. Noop on OSes <10.7. |
| 88 - (void)registerKeyStateEventTap; |
| 89 @end |
| OLD | NEW |