| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_VIEWS_BROWSER_BUBBLE_ | 5 #ifndef CHROME_BROWSER_VIEWS_BROWSER_BUBBLE_ |
| 6 #define CHROME_BROWSER_VIEWS_BROWSER_BUBBLE_ | 6 #define CHROME_BROWSER_VIEWS_BROWSER_BUBBLE_ |
| 7 | 7 |
| 8 #include "views/view.h" | 8 #include "views/view.h" |
| 9 #include "views/widget/widget.h" | 9 #include "views/widget/widget.h" |
| 10 | 10 |
| 11 // A class for creating a floating window that is "attached" to a particular | 11 // A class for creating a floating window that is "attached" to a particular |
| 12 // Browser. If you don't install a delegate, the bubble will hide | 12 // Browser. If you don't install a delegate, the bubble will hide |
| 13 // automatically when the browser moves. The bubble is only shown manually. | 13 // automatically when the browser moves. The bubble is only shown manually. |
| 14 // Users are expected to delete the bubble when finished with it. | 14 // Users are expected to delete the bubble when finished with it. |
| 15 // Class assumes that RTL related mirroring is done by the view. | 15 // Class assumes that RTL related mirroring is done by the view. |
| 16 class BrowserBubble { | 16 class BrowserBubble { |
| 17 public: | 17 public: |
| 18 // Delegate to browser bubble events. | 18 // Delegate to browser bubble events. |
| 19 class Delegate { | 19 class Delegate { |
| 20 public: | 20 public: |
| 21 // Called when the Browser Window that this bubble is attached to moves. | 21 // Called when the Browser Window that this bubble is attached to moves. |
| 22 virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble) = 0; | 22 virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble) = 0; |
| 23 virtual void BubbleBrowserWindowClosed(BrowserBubble* bubble) = 0; | 23 |
| 24 // Called with the Browser Window that this bubble is attached to is |
| 25 // about to close. |
| 26 virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble) = 0; |
| 24 }; | 27 }; |
| 25 | 28 |
| 26 // Note that the bubble will size itself to the preferred size of |view|. | 29 // Note that the bubble will size itself to the preferred size of |view|. |
| 27 // |view| is the embedded view, |frame| is widget that the bubble is being | 30 // |view| is the embedded view, |frame| is widget that the bubble is being |
| 28 // positioned relative to, |origin| is the location that the bubble will | 31 // positioned relative to, |origin| is the location that the bubble will |
| 29 // be positioned relative to |frame|. | 32 // be positioned relative to |frame|. |
| 30 BrowserBubble(views::View* view, views::Widget* frame, | 33 BrowserBubble(views::View* view, views::Widget* frame, |
| 31 const gfx::Point& origin); | 34 const gfx::Point& origin); |
| 32 virtual ~BrowserBubble(); | 35 virtual ~BrowserBubble(); |
| 33 | 36 |
| 34 // Call manually if you need to detach the bubble from tracking the browser's | 37 // Call manually if you need to detach the bubble from tracking the browser's |
| 35 // position. Note that you must call this manually before deleting this | 38 // position. Note that you must call this manually before deleting this |
| 36 // object since it can't be safely called from the destructor. | 39 // object since it can't be safely called from the destructor. |
| 37 void DetachFromBrowser(); | 40 void DetachFromBrowser(); |
| 38 | 41 |
| 39 // Normally called automatically during construction, but if DetachFromBrowser | 42 // Normally called automatically during construction, but if DetachFromBrowser |
| 40 // has been called manually, then this call will reattach. | 43 // has been called manually, then this call will reattach. |
| 41 void AttachToBrowser(); | 44 void AttachToBrowser(); |
| 42 bool attached() const { return attached_; } | 45 bool attached() const { return attached_; } |
| 43 | 46 |
| 44 // Get/Set the delegate. | 47 // Get/Set the delegate. |
| 45 Delegate* delegate() const { return delegate_; } | 48 Delegate* delegate() const { return delegate_; } |
| 46 void set_delegate(Delegate* del) { delegate_ = del; } | 49 void set_delegate(Delegate* del) { delegate_ = del; } |
| 47 | 50 |
| 48 // Notifications from BrowserView. | 51 // Notifications from BrowserView. |
| 49 // With no delegate, both of these default to Hiding the bubble. | 52 // With no delegate, both of these default to Hiding the bubble. |
| 50 virtual void BrowserWindowMoved(); | 53 virtual void BrowserWindowMoved(); |
| 51 virtual void BrowserWindowClosed(); | 54 virtual void BrowserWindowClosing(); |
| 52 | 55 |
| 53 // Show or hide the bubble. | 56 // Show or hide the bubble. |
| 54 void Show(); | 57 void Show(); |
| 55 void Hide(); | 58 void Hide(); |
| 56 bool visible() const { return visible_; } | 59 bool visible() const { return visible_; } |
| 57 | 60 |
| 58 // The contained view. | 61 // The contained view. |
| 59 views::View* view() const { return view_; } | 62 views::View* view() const { return view_; } |
| 60 | 63 |
| 61 // Set the bounds of the bubble relative to the browser window. | 64 // Set the bounds of the bubble relative to the browser window. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // The delegate isn't owned by the bubble. | 101 // The delegate isn't owned by the bubble. |
| 99 Delegate* delegate_; | 102 Delegate* delegate_; |
| 100 | 103 |
| 101 // Is the bubble attached to a Browser window. | 104 // Is the bubble attached to a Browser window. |
| 102 bool attached_; | 105 bool attached_; |
| 103 | 106 |
| 104 DISALLOW_COPY_AND_ASSIGN(BrowserBubble); | 107 DISALLOW_COPY_AND_ASSIGN(BrowserBubble); |
| 105 }; | 108 }; |
| 106 | 109 |
| 107 #endif // CHROME_BROWSER_VIEWS_BROWSER_BUBBLE_ | 110 #endif // CHROME_BROWSER_VIEWS_BROWSER_BUBBLE_ |
| OLD | NEW |