Chromium Code Reviews| 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 #ifndef UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
| 6 #define UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 6 #define UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "ui/views/bubble/bubble_border.h" | 10 #include "ui/views/bubble/bubble_border.h" |
| 11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 12 #include "ui/views/widget/widget_delegate.h" | 12 #include "ui/views/widget/widget_delegate.h" |
| 13 #include "ui/views/widget/widget_observer.h" | 13 #include "ui/views/widget/widget_observer.h" |
| 14 #include "ui/views/widget/widget_observer_view.h" | |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 class FontList; | 17 class FontList; |
| 17 class Rect; | 18 class Rect; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 | 22 |
| 22 class BubbleFrameView; | 23 class BubbleFrameView; |
| 23 | 24 |
| 24 // BubbleDelegateView creates frame and client views for bubble Widgets. | 25 // BubbleDelegateView creates frame and client views for bubble Widgets. |
| 25 // BubbleDelegateView itself is the client's contents view. | 26 // BubbleDelegateView itself is the client's contents view. |
| 26 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, | 27 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, |
| 27 public WidgetObserver { | 28 public WidgetObserver { |
| 28 public: | 29 public: |
| 29 // Internal class name. | 30 // Internal class name. |
| 30 static const char kViewClassName[]; | 31 static const char kViewClassName[]; |
| 31 | 32 |
| 32 enum class CloseReason { | 33 enum class CloseReason { |
| 33 DEACTIVATION, | 34 DEACTIVATION, |
| 34 ESCAPE, | 35 ESCAPE, |
| 35 CLOSE_BUTTON, | 36 CLOSE_BUTTON, |
| 36 UNKNOWN, | 37 UNKNOWN, |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 BubbleDelegateView(); | 40 BubbleDelegateView(); |
| 41 BubbleDelegateView(WidgetObserverView* anchor_view, | |
|
varkha
2016/01/28 00:11:10
msw@, pkasting@, did you have in mind something li
| |
| 42 BubbleBorder::Arrow arrow); | |
| 40 BubbleDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); | 43 BubbleDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); |
| 41 ~BubbleDelegateView() override; | 44 ~BubbleDelegateView() override; |
| 42 | 45 |
| 43 // Create and initialize the bubble Widget(s) with proper bounds. | 46 // Create and initialize the bubble Widget(s) with proper bounds. |
| 44 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); | 47 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); |
| 45 | 48 |
| 46 // WidgetDelegateView overrides: | 49 // WidgetDelegateView overrides: |
| 47 BubbleDelegateView* AsBubbleDelegate() override; | 50 BubbleDelegateView* AsBubbleDelegate() override; |
| 48 bool ShouldShowCloseButton() const override; | 51 bool ShouldShowCloseButton() const override; |
| 49 View* GetContentsView() override; | 52 View* GetContentsView() override; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 // Flags controlling bubble closure on the escape key and deactivation. | 169 // Flags controlling bubble closure on the escape key and deactivation. |
| 167 bool close_on_esc_; | 170 bool close_on_esc_; |
| 168 bool close_on_deactivate_; | 171 bool close_on_deactivate_; |
| 169 | 172 |
| 170 // The view and widget to which this bubble is anchored. Since an anchor view | 173 // The view and widget to which this bubble is anchored. Since an anchor view |
| 171 // can be deleted without notice, we store it in the ViewStorage and retrieve | 174 // can be deleted without notice, we store it in the ViewStorage and retrieve |
| 172 // it from there. It will make sure that the view is still valid. | 175 // it from there. It will make sure that the view is still valid. |
| 173 const int anchor_view_storage_id_; | 176 const int anchor_view_storage_id_; |
| 174 Widget* anchor_widget_; | 177 Widget* anchor_widget_; |
| 175 | 178 |
| 179 // True if anchor_view_storage_id_ refers to a View that implements | |
| 180 // WidgetObserver; | |
| 181 bool anchor_view_has_widget_observer_; | |
| 182 | |
| 176 // The anchor rect used in the absence of an anchor view. | 183 // The anchor rect used in the absence of an anchor view. |
| 177 mutable gfx::Rect anchor_rect_; | 184 mutable gfx::Rect anchor_rect_; |
| 178 | 185 |
| 179 // The arrow's location on the bubble. | 186 // The arrow's location on the bubble. |
| 180 BubbleBorder::Arrow arrow_; | 187 BubbleBorder::Arrow arrow_; |
| 181 | 188 |
| 182 // Bubble border shadow to use. | 189 // Bubble border shadow to use. |
| 183 BubbleBorder::Shadow shadow_; | 190 BubbleBorder::Shadow shadow_; |
| 184 | 191 |
| 185 // The background color of the bubble; and flag for when it's explicitly set. | 192 // The background color of the bubble; and flag for when it's explicitly set. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 204 gfx::NativeView parent_window_; | 211 gfx::NativeView parent_window_; |
| 205 | 212 |
| 206 CloseReason close_reason_; | 213 CloseReason close_reason_; |
| 207 | 214 |
| 208 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 215 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); |
| 209 }; | 216 }; |
| 210 | 217 |
| 211 } // namespace views | 218 } // namespace views |
| 212 | 219 |
| 213 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 220 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
| OLD | NEW |