| 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_TRAY_BUBBLE_VIEW_H_ | 5 #ifndef UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ |
| 6 #define UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ | 6 #define UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "ui/views/bubble/bubble_delegate.h" | 9 #include "ui/views/bubble/bubble_delegate.h" |
| 10 #include "ui/views/views_export.h" | 10 #include "ui/views/views_export.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 DISALLOW_COPY_AND_ASSIGN(Delegate); | 77 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 struct VIEWS_EXPORT InitParams { | 80 struct VIEWS_EXPORT InitParams { |
| 81 static const int kArrowDefaultOffset; | 81 static const int kArrowDefaultOffset; |
| 82 | 82 |
| 83 InitParams(AnchorType anchor_type, | 83 InitParams(AnchorType anchor_type, |
| 84 AnchorAlignment anchor_alignment, | 84 AnchorAlignment anchor_alignment, |
| 85 int bubble_width); | 85 int min_width, |
| 86 int max_width); |
| 86 AnchorType anchor_type; | 87 AnchorType anchor_type; |
| 87 AnchorAlignment anchor_alignment; | 88 AnchorAlignment anchor_alignment; |
| 88 int bubble_width; | 89 int min_width; |
| 90 int max_width; |
| 89 int max_height; | 91 int max_height; |
| 90 bool can_activate; | 92 bool can_activate; |
| 91 bool close_on_deactivate; | 93 bool close_on_deactivate; |
| 92 SkColor arrow_color; | 94 SkColor arrow_color; |
| 93 views::BubbleBorder::ArrowLocation arrow_location; | 95 views::BubbleBorder::ArrowLocation arrow_location; |
| 94 int arrow_offset; | 96 int arrow_offset; |
| 95 views::BubbleBorder::Shadow shadow; | 97 views::BubbleBorder::Shadow shadow; |
| 96 }; | 98 }; |
| 97 | 99 |
| 98 // Constructs and returns a TrayBubbleView. init_params may be modified. | 100 // Constructs and returns a TrayBubbleView. init_params may be modified. |
| 99 static TrayBubbleView* Create(gfx::NativeView parent_window, | 101 static TrayBubbleView* Create(gfx::NativeView parent_window, |
| 100 views::View* anchor, | 102 views::View* anchor, |
| 101 Delegate* delegate, | 103 Delegate* delegate, |
| 102 InitParams* init_params); | 104 InitParams* init_params); |
| 103 | 105 |
| 104 virtual ~TrayBubbleView(); | 106 virtual ~TrayBubbleView(); |
| 105 | 107 |
| 106 // Sets up animations, and show the bubble. Must occur after CreateBubble() | 108 // Sets up animations, and show the bubble. Must occur after CreateBubble() |
| 107 // is called. | 109 // is called. |
| 108 void InitializeAndShowBubble(); | 110 void InitializeAndShowBubble(); |
| 109 | 111 |
| 110 // Called whenever the bubble size or location may have changed. | 112 // Called whenever the bubble size or location may have changed. |
| 111 void UpdateBubble(); | 113 void UpdateBubble(); |
| 112 | 114 |
| 113 // Sets the maximum bubble height and resizes the bubble. | 115 // Sets the maximum bubble height and resizes the bubble. |
| 114 void SetMaxHeight(int height); | 116 void SetMaxHeight(int height); |
| 115 | 117 |
| 118 // Sets the bubble width. |
| 119 void SetWidth(int width); |
| 120 |
| 116 // Sets whether or not to paint the bubble border arrow. | 121 // Sets whether or not to paint the bubble border arrow. |
| 117 void SetPaintArrow(bool paint_arrow); | 122 void SetPaintArrow(bool paint_arrow); |
| 118 | 123 |
| 119 // Returns the border insets. Called by TrayEventFilter. | 124 // Returns the border insets. Called by TrayEventFilter. |
| 120 gfx::Insets GetBorderInsets() const; | 125 gfx::Insets GetBorderInsets() const; |
| 121 | 126 |
| 122 // Called when the delegate is destroyed. | 127 // Called when the delegate is destroyed. |
| 123 void reset_delegate() { delegate_ = NULL; } | 128 void reset_delegate() { delegate_ = NULL; } |
| 124 | 129 |
| 125 Delegate* delegate() { return delegate_; } | 130 Delegate* delegate() { return delegate_; } |
| 126 | 131 |
| 127 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; } | 132 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; } |
| 128 bool is_gesture_dragging() const { return is_gesture_dragging_; } | 133 bool is_gesture_dragging() const { return is_gesture_dragging_; } |
| 129 | 134 |
| 130 // Overridden from views::WidgetDelegate. | 135 // Overridden from views::WidgetDelegate. |
| 131 virtual bool CanActivate() const OVERRIDE; | 136 virtual bool CanActivate() const OVERRIDE; |
| 132 virtual views::NonClientFrameView* CreateNonClientFrameView( | 137 virtual views::NonClientFrameView* CreateNonClientFrameView( |
| 133 views::Widget* widget) OVERRIDE; | 138 views::Widget* widget) OVERRIDE; |
| 134 virtual bool WidgetHasHitTestMask() const OVERRIDE; | 139 virtual bool WidgetHasHitTestMask() const OVERRIDE; |
| 135 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE; | 140 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE; |
| 136 | 141 |
| 137 // Overridden from views::BubbleDelegateView. | 142 // Overridden from views::BubbleDelegateView. |
| 138 virtual gfx::Rect GetAnchorRect() OVERRIDE; | 143 virtual gfx::Rect GetAnchorRect() OVERRIDE; |
| 139 | 144 |
| 140 // Overridden from views::View. | 145 // Overridden from views::View. |
| 141 virtual gfx::Size GetPreferredSize() OVERRIDE; | 146 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 147 virtual gfx::Size GetMaximumSize() OVERRIDE; |
| 142 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 148 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
| 143 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 149 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
| 144 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 150 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 145 | 151 |
| 146 protected: | 152 protected: |
| 147 TrayBubbleView(gfx::NativeView parent_window, | 153 TrayBubbleView(gfx::NativeView parent_window, |
| 148 views::View* anchor, | 154 views::View* anchor, |
| 149 Delegate* delegate, | 155 Delegate* delegate, |
| 150 const InitParams& init_params); | 156 const InitParams& init_params); |
| 151 | 157 |
| 152 // Overridden from views::BubbleDelegateView. | 158 // Overridden from views::BubbleDelegateView. |
| 153 virtual void Init() OVERRIDE; | 159 virtual void Init() OVERRIDE; |
| 154 | 160 |
| 155 // Overridden from views::View. | 161 // Overridden from views::View. |
| 156 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 162 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; |
| 157 virtual void ViewHierarchyChanged(bool is_add, | 163 virtual void ViewHierarchyChanged(bool is_add, |
| 158 views::View* parent, | 164 views::View* parent, |
| 159 views::View* child) OVERRIDE; | 165 views::View* child) OVERRIDE; |
| 160 | 166 |
| 161 private: | 167 private: |
| 162 InitParams params_; | 168 InitParams params_; |
| 163 Delegate* delegate_; | 169 Delegate* delegate_; |
| 170 int preferred_width_; |
| 164 internal::TrayBubbleBorder* bubble_border_; | 171 internal::TrayBubbleBorder* bubble_border_; |
| 165 scoped_ptr<internal::TrayBubbleContentMask> bubble_content_mask_; | 172 scoped_ptr<internal::TrayBubbleContentMask> bubble_content_mask_; |
| 166 bool is_gesture_dragging_; | 173 bool is_gesture_dragging_; |
| 167 | 174 |
| 168 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView); | 175 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView); |
| 169 }; | 176 }; |
| 170 | 177 |
| 171 } // namespace views | 178 } // namespace views |
| 172 | 179 |
| 173 #endif // UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ | 180 #endif // UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ |
| OLD | NEW |