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 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "components/bubble/bubble_reference.h" |
8 | 9 |
9 @class InfoBubbleView; | 10 @class InfoBubbleView; |
10 class TabStripModelObserverBridge; | 11 class TabStripModelObserverBridge; |
11 | 12 |
12 // Base class for bubble controllers. Manages a xib that contains an | 13 // Base class for bubble controllers. Manages a xib that contains an |
13 // InfoBubbleWindow which contains an InfoBubbleView. Contains code to close | 14 // InfoBubbleWindow which contains an InfoBubbleView. Contains code to close |
14 // the bubble window on clicks outside of the window, and the like. | 15 // the bubble window on clicks outside of the window, and the like. |
15 // To use this class: | 16 // To use this class: |
16 // 1. Create a new xib that contains a window. Change the window's class to | 17 // 1. Create a new xib that contains a window. Change the window's class to |
17 // InfoBubbleWindow. Give it a child view that autosizes to the window's full | 18 // InfoBubbleWindow. Give it a child view that autosizes to the window's full |
(...skipping 20 matching lines...) Expand all Loading... |
38 // outside the window. This is needed because the window shares first | 39 // outside the window. This is needed because the window shares first |
39 // responder with its parent. | 40 // responder with its parent. |
40 id eventTap_; | 41 id eventTap_; |
41 // A notification observer that gets triggered when any window resigns key. | 42 // A notification observer that gets triggered when any window resigns key. |
42 id resignationObserver_; | 43 id resignationObserver_; |
43 // The controlled window should be the key window when it's opened. True by | 44 // The controlled window should be the key window when it's opened. True by |
44 // default. | 45 // default. |
45 BOOL shouldOpenAsKeyWindow_; | 46 BOOL shouldOpenAsKeyWindow_; |
46 // The bubble window should close if it (or its parent) resigns key status. | 47 // The bubble window should close if it (or its parent) resigns key status. |
47 BOOL shouldCloseOnResignKey_; | 48 BOOL shouldCloseOnResignKey_; |
| 49 BubbleReference bubbleReference_; |
48 } | 50 } |
49 | 51 |
50 @property(nonatomic, assign) NSWindow* parentWindow; | 52 @property(nonatomic, assign) NSWindow* parentWindow; |
51 // The point in base screen coordinates at which the bubble should open and the | 53 // The point in base screen coordinates at which the bubble should open and the |
52 // arrow tip points. | 54 // arrow tip points. |
53 @property(nonatomic, assign) NSPoint anchorPoint; | 55 @property(nonatomic, assign) NSPoint anchorPoint; |
54 @property(nonatomic, readonly) InfoBubbleView* bubble; | 56 @property(nonatomic, readonly) InfoBubbleView* bubble; |
55 @property(nonatomic, assign) BOOL shouldOpenAsKeyWindow; | 57 @property(nonatomic, assign) BOOL shouldOpenAsKeyWindow; |
56 // Controls if the bubble auto-closes if the user clicks outside the bubble. | 58 // Controls if the bubble auto-closes if the user clicks outside the bubble. |
57 @property(nonatomic, assign) BOOL shouldCloseOnResignKey; | 59 @property(nonatomic, assign) BOOL shouldCloseOnResignKey; |
| 60 // A reference for bubbles that are managed by the BubbleManager. |
| 61 @property(nonatomic, assign) BubbleReference bubbleReference; |
58 | 62 |
59 // Creates a bubble. |nibPath| is just the basename, e.g. @"FirstRunBubble". | 63 // Creates a bubble. |nibPath| is just the basename, e.g. @"FirstRunBubble". |
60 // |anchoredAt| is in screen space. You need to call -showWindow: to make the | 64 // |anchoredAt| is in screen space. You need to call -showWindow: to make the |
61 // bubble visible. It will autorelease itself when the user dismisses the | 65 // bubble visible. It will autorelease itself when the user dismisses the |
62 // bubble. | 66 // bubble. |
63 // This is the designated initializer. | 67 // This is the designated initializer. |
64 - (id)initWithWindowNibPath:(NSString*)nibPath | 68 - (id)initWithWindowNibPath:(NSString*)nibPath |
65 parentWindow:(NSWindow*)parentWindow | 69 parentWindow:(NSWindow*)parentWindow |
66 anchoredAt:(NSPoint)anchoredAt; | 70 anchoredAt:(NSPoint)anchoredAt; |
67 | 71 |
(...skipping 26 matching lines...) Expand all Loading... |
94 | 98 |
95 @end | 99 @end |
96 | 100 |
97 // Methods for use by subclasses. | 101 // Methods for use by subclasses. |
98 @interface BaseBubbleController (Protected) | 102 @interface BaseBubbleController (Protected) |
99 // Registers event taps *after* the window is shown so that the bubble is | 103 // Registers event taps *after* the window is shown so that the bubble is |
100 // dismissed when it resigns key. This only needs to be called if | 104 // dismissed when it resigns key. This only needs to be called if |
101 // |-showWindow:| is overriden and does not call super. Noop on OSes <10.7. | 105 // |-showWindow:| is overriden and does not call super. Noop on OSes <10.7. |
102 - (void)registerKeyStateEventTap; | 106 - (void)registerKeyStateEventTap; |
103 @end | 107 @end |
OLD | NEW |