Chromium Code Reviews| 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" |
| 11 #include "views/bubble/bubble_border.h" | 11 #include "views/bubble/bubble_border.h" |
| 12 #include "views/focus/widget_focus_manager.h" | |
| 12 #include "views/widget/widget_delegate.h" | 13 #include "views/widget/widget_delegate.h" |
| 13 | 14 |
| 14 namespace ui { | 15 namespace ui { |
| 15 class SlideAnimation; | 16 class SlideAnimation; |
| 16 } // namespace ui | 17 } // namespace ui |
| 17 | 18 |
| 18 namespace views { | 19 namespace views { |
| 19 | 20 |
| 20 class BubbleFrameView; | 21 class BubbleFrameView; |
| 21 | 22 |
| 22 // BubbleDelegateView creates frame and client views for bubble Widgets. | 23 // BubbleDelegateView creates frame and client views for bubble Widgets. |
| 23 // BubbleDelegateView itself is the client's contents view. | 24 // BubbleDelegateView itself is the client's contents view. |
| 24 // | 25 // |
| 25 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 26 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, | 27 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, |
| 27 public ui::AnimationDelegate { | 28 public ui::AnimationDelegate, |
| 29 public WidgetFocusChangeListener { | |
| 28 public: | 30 public: |
| 29 BubbleDelegateView(); | 31 BubbleDelegateView(); |
| 30 BubbleDelegateView(const gfx::Point& anchor_point, | 32 BubbleDelegateView(const gfx::Point& anchor_point, |
| 31 BubbleBorder::ArrowLocation arrow_location, | 33 BubbleBorder::ArrowLocation arrow_location, |
| 32 const SkColor& color); | 34 const SkColor& color); |
| 33 virtual ~BubbleDelegateView(); | 35 virtual ~BubbleDelegateView(); |
| 34 | 36 |
| 35 // Create and initialize the bubble Widget(s) with proper bounds. | 37 // Create and initialize the bubble Widget(s) with proper bounds. |
| 36 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate, | 38 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate, |
| 37 Widget* parent_widget); | 39 Widget* parent_widget); |
| 38 | 40 |
| 39 // WidgetDelegate overrides: | 41 // WidgetDelegate overrides: |
| 40 virtual View* GetInitiallyFocusedView() OVERRIDE; | 42 virtual View* GetInitiallyFocusedView() OVERRIDE; |
| 41 virtual View* GetContentsView() OVERRIDE; | 43 virtual View* GetContentsView() OVERRIDE; |
| 42 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | 44 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; |
| 43 | 45 |
| 46 // WidgetFocusChangeListener overrides: | |
| 47 virtual void NativeFocusWillChange(gfx::NativeView focused_before, | |
| 48 gfx::NativeView focused_now) OVERRIDE; | |
| 49 | |
| 44 bool close_on_esc() const { return close_on_esc_; } | 50 bool close_on_esc() const { return close_on_esc_; } |
| 45 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } | 51 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } |
| 46 | 52 |
| 53 bool close_on_blur() const { return close_on_blur_; } | |
|
Ben Goodger (Google)
2011/11/01 23:54:56
should be close_on_deactivate
msw
2011/11/05 03:22:24
Done.
| |
| 54 void set_close_on_blur(bool close_on_blur) { close_on_blur_ = close_on_blur; } | |
| 55 | |
| 47 // Get the arrow's anchor point in screen space. | 56 // Get the arrow's anchor point in screen space. |
| 48 virtual gfx::Point GetAnchorPoint(); | 57 virtual gfx::Point GetAnchorPoint(); |
| 49 | 58 |
| 50 // Get the arrow's location on the bubble. | 59 // Get the arrow's location on the bubble. |
| 51 virtual BubbleBorder::ArrowLocation GetArrowLocation() const; | 60 virtual BubbleBorder::ArrowLocation GetArrowLocation() const; |
| 52 | 61 |
| 53 // Get the color used for the background and border. | 62 // Get the color used for the background and border. |
| 54 virtual SkColor GetColor() const; | 63 virtual SkColor GetColor() const; |
| 55 | 64 |
| 56 // Show the bubble's widget (and |border_widget_| on Windows). | 65 // Show the bubble's widget (and |border_widget_| on Windows). |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 // Initialize the border widget needed for Windows native control hosting. | 97 // Initialize the border widget needed for Windows native control hosting. |
| 89 void InitializeBorderWidget(Widget* parent_widget); | 98 void InitializeBorderWidget(Widget* parent_widget); |
| 90 | 99 |
| 91 // Get bounds for the Windows-only widget that hosts the bubble's contents. | 100 // Get bounds for the Windows-only widget that hosts the bubble's contents. |
| 92 gfx::Rect GetBubbleClientBounds() const; | 101 gfx::Rect GetBubbleClientBounds() const; |
| 93 #endif | 102 #endif |
| 94 | 103 |
| 95 // Fade animation for bubble. | 104 // Fade animation for bubble. |
| 96 scoped_ptr<ui::SlideAnimation> fade_animation_; | 105 scoped_ptr<ui::SlideAnimation> fade_animation_; |
| 97 | 106 |
| 98 // Should this bubble close on the escape key? | 107 // Flags controlling bubble closure on the escape key and loss of focus. |
| 99 bool close_on_esc_; | 108 bool close_on_esc_; |
| 109 bool close_on_blur_; | |
| 100 | 110 |
| 101 // The screen point where this bubble's arrow is anchored. | 111 // The screen point where this bubble's arrow is anchored. |
| 102 gfx::Point anchor_point_; | 112 gfx::Point anchor_point_; |
| 103 | 113 |
| 104 // The arrow's location on the bubble. | 114 // The arrow's location on the bubble. |
| 105 BubbleBorder::ArrowLocation arrow_location_; | 115 BubbleBorder::ArrowLocation arrow_location_; |
| 106 | 116 |
| 107 // The background color of the bubble. | 117 // The background color of the bubble. |
| 108 SkColor color_; | 118 SkColor color_; |
| 109 | 119 |
| 110 // Original opacity of the bubble. | 120 // Original opacity of the bubble. |
| 111 int original_opacity_; | 121 int original_opacity_; |
| 112 | 122 |
| 113 // The widget hosting the border for this bubble (non-Aura Windows only). | 123 // The widget hosting the border for this bubble (non-Aura Windows only). |
| 114 Widget* border_widget_; | 124 Widget* border_widget_; |
| 115 | 125 |
| 116 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 126 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); |
| 117 }; | 127 }; |
| 118 | 128 |
| 119 } // namespace views | 129 } // namespace views |
| 120 | 130 |
| 121 #endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 131 #endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
| OLD | NEW |