OLD | NEW |
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 #ifndef VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 5 #ifndef VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
6 #define VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 6 #define VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "ui/base/animation/animation_delegate.h" | 10 #include "ui/base/animation/animation_delegate.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 // BubbleDelegateView creates frame and client views for bubble Widgets. | 23 // BubbleDelegateView creates frame and client views for bubble Widgets. |
24 // BubbleDelegateView itself is the client's contents view. | 24 // BubbleDelegateView itself is the client's contents view. |
25 // | 25 // |
26 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
27 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, | 27 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, |
28 public ui::AnimationDelegate, | 28 public ui::AnimationDelegate, |
29 public Widget::Observer { | 29 public Widget::Observer { |
30 public: | 30 public: |
31 BubbleDelegateView(); | 31 BubbleDelegateView(); |
32 BubbleDelegateView(const gfx::Point& anchor_point, | 32 BubbleDelegateView(View* anchor_view, |
33 BubbleBorder::ArrowLocation arrow_location, | 33 BubbleBorder::ArrowLocation arrow_location, |
34 const SkColor& color); | 34 const SkColor& color); |
35 virtual ~BubbleDelegateView(); | 35 virtual ~BubbleDelegateView(); |
36 | 36 |
37 // Create and initialize the bubble Widget(s) with proper bounds. | 37 // Create and initialize the bubble Widget(s) with proper bounds. |
38 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate, | 38 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); |
39 Widget* parent_widget); | |
40 | 39 |
41 // WidgetDelegate overrides: | 40 // WidgetDelegate overrides: |
42 virtual View* GetInitiallyFocusedView() OVERRIDE; | 41 virtual View* GetInitiallyFocusedView() OVERRIDE; |
43 virtual BubbleDelegateView* AsBubbleDelegate() OVERRIDE; | 42 virtual BubbleDelegateView* AsBubbleDelegate() OVERRIDE; |
44 virtual View* GetContentsView() OVERRIDE; | 43 virtual View* GetContentsView() OVERRIDE; |
45 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | 44 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; |
46 | 45 |
47 // Widget::Observer overrides: | 46 // Widget::Observer overrides: |
48 virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; | 47 virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; |
49 | 48 |
50 bool close_on_esc() const { return close_on_esc_; } | 49 bool close_on_esc() const { return close_on_esc_; } |
51 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } | 50 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } |
52 | 51 |
53 bool close_on_deactivate() const { return close_on_deactivate_; } | 52 bool close_on_deactivate() const { return close_on_deactivate_; } |
54 void set_close_on_deactivate(bool close_on_deactivate) { | 53 void set_close_on_deactivate(bool close_on_deactivate) { |
55 close_on_deactivate_ = close_on_deactivate; | 54 close_on_deactivate_ = close_on_deactivate; |
56 } | 55 } |
57 | 56 |
58 bool allow_bubble_offscreen() const { return allow_bubble_offscreen_; } | 57 bool allow_bubble_offscreen() const { return allow_bubble_offscreen_; } |
59 void set_allow_bubble_offscreen(bool allow_bubble_offscreen) { | 58 void set_allow_bubble_offscreen(bool allow_bubble_offscreen) { |
60 allow_bubble_offscreen_ = allow_bubble_offscreen; | 59 allow_bubble_offscreen_ = allow_bubble_offscreen; |
61 } | 60 } |
62 | 61 |
| 62 View* anchor_view() const { return anchor_view_; } |
| 63 |
63 bool use_focusless() const { return use_focusless_; } | 64 bool use_focusless() const { return use_focusless_; } |
64 void set_use_focusless(bool use_focusless) { | 65 void set_use_focusless(bool use_focusless) { |
65 use_focusless_ = use_focusless; | 66 use_focusless_ = use_focusless; |
66 } | 67 } |
67 | 68 |
68 // Get the arrow's anchor point in screen space. | 69 // Get the arrow's anchor point in screen space. |
69 virtual gfx::Point GetAnchorPoint(); | 70 virtual gfx::Point GetAnchorPoint(); |
70 | 71 |
71 // Get the arrow's location on the bubble. | 72 // Get the arrow's location on the bubble. |
72 virtual BubbleBorder::ArrowLocation GetArrowLocation() const; | 73 virtual BubbleBorder::ArrowLocation GetArrowLocation() const; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 scoped_ptr<ui::SlideAnimation> fade_animation_; | 118 scoped_ptr<ui::SlideAnimation> fade_animation_; |
118 | 119 |
119 // Flags controlling bubble closure on the escape key and deactivation. | 120 // Flags controlling bubble closure on the escape key and deactivation. |
120 bool close_on_esc_; | 121 bool close_on_esc_; |
121 bool close_on_deactivate_; | 122 bool close_on_deactivate_; |
122 | 123 |
123 // Whether the bubble is allowed to be displayed offscreen, or if auto | 124 // Whether the bubble is allowed to be displayed offscreen, or if auto |
124 // re-positioning should be performed. | 125 // re-positioning should be performed. |
125 bool allow_bubble_offscreen_; | 126 bool allow_bubble_offscreen_; |
126 | 127 |
127 // The screen point where this bubble's arrow is anchored. | 128 // The view hosting this bubble; the arrow is anchored to this view. |
128 gfx::Point anchor_point_; | 129 View* anchor_view_; |
129 | 130 |
130 // The arrow's location on the bubble. | 131 // The arrow's location on the bubble. |
131 BubbleBorder::ArrowLocation arrow_location_; | 132 BubbleBorder::ArrowLocation arrow_location_; |
132 | 133 |
133 // The background color of the bubble. | 134 // The background color of the bubble. |
134 SkColor color_; | 135 SkColor color_; |
135 | 136 |
136 // Original opacity of the bubble. | 137 // Original opacity of the bubble. |
137 int original_opacity_; | 138 int original_opacity_; |
138 | 139 |
139 // The widget hosting the border for this bubble (non-Aura Windows only). | 140 // The widget hosting the border for this bubble (non-Aura Windows only). |
140 Widget* border_widget_; | 141 Widget* border_widget_; |
141 | 142 |
142 // Create a popup window for focusless bubbles on Linux/ChromeOS. | 143 // Create a popup window for focusless bubbles on Linux/ChromeOS. |
143 // These bubbles are not interactive and should not gain focus. | 144 // These bubbles are not interactive and should not gain focus. |
144 bool use_focusless_; | 145 bool use_focusless_; |
145 | 146 |
146 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 147 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); |
147 }; | 148 }; |
148 | 149 |
149 } // namespace views | 150 } // namespace views |
150 | 151 |
151 #endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 152 #endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
OLD | NEW |