| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ | 5 #ifndef UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ |
| 6 #define UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ | 6 #define UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "ui/gfx/animation/animation_delegate.h" | 11 #include "ui/gfx/animation/animation_delegate.h" |
| 12 #include "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 15 #include "ui/message_center/message_center_export.h" | 15 #include "ui/message_center/message_center_export.h" |
| 16 #include "ui/message_center/views/message_center_controller.h" | 16 #include "ui/message_center/views/message_center_controller.h" |
| 17 #include "ui/views/widget/widget_delegate.h" | 17 #include "ui/views/widget/widget_delegate.h" |
| 18 #include "ui/views/widget/widget_observer.h" |
| 18 | 19 |
| 19 namespace gfx { | 20 namespace gfx { |
| 20 class Animation; | 21 class Animation; |
| 21 class SlideAnimation; | 22 class SlideAnimation; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace views { | 25 namespace views { |
| 25 class View; | 26 class View; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace message_center { | 29 namespace message_center { |
| 29 | 30 |
| 30 namespace test { | 31 namespace test { |
| 31 class MessagePopupCollectionTest; | 32 class MessagePopupCollectionTest; |
| 32 } | 33 } |
| 33 | 34 |
| 34 class MessagePopupCollection; | 35 class MessagePopupCollection; |
| 35 class MessageView; | 36 class MessageView; |
| 36 class Notification; | 37 class Notification; |
| 37 class PopupAlignmentDelegate; | 38 class PopupAlignmentDelegate; |
| 38 | 39 |
| 39 // The widget host for a popup. Also implements MessageCenterController | 40 // The widget host for a popup. Also implements MessageCenterController |
| 40 // which delegates over to MessagePopupCollection, but takes care about | 41 // which delegates over to MessagePopupCollection, but takes care about |
| 41 // checking the weakref since MessagePopupCollection may disappear before | 42 // checking the weakref since MessagePopupCollection may disappear before |
| 42 // widget/views are closed/destructed. | 43 // widget/views are closed/destructed. |
| 43 class MESSAGE_CENTER_EXPORT ToastContentsView | 44 class MESSAGE_CENTER_EXPORT ToastContentsView |
| 44 : public views::WidgetDelegateView, | 45 : public views::WidgetDelegateView, |
| 46 public views::WidgetObserver, |
| 45 public MessageCenterController, | 47 public MessageCenterController, |
| 46 public gfx::AnimationDelegate { | 48 public gfx::AnimationDelegate { |
| 47 public: | 49 public: |
| 48 static const char kViewClassName[]; | 50 static const char kViewClassName[]; |
| 49 | 51 |
| 50 // Computes the size of a toast assuming it will host the given view. | 52 // Computes the size of a toast assuming it will host the given view. |
| 51 static gfx::Size GetToastSizeForView(const views::View* view); | 53 static gfx::Size GetToastSizeForView(const views::View* view); |
| 52 | 54 |
| 53 ToastContentsView(const std::string& notification_id, | 55 ToastContentsView(const std::string& notification_id, |
| 54 PopupAlignmentDelegate* alignment_delegate, | 56 PopupAlignmentDelegate* alignment_delegate, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // Overridden from gfx::AnimationDelegate: | 112 // Overridden from gfx::AnimationDelegate: |
| 111 void AnimationProgressed(const gfx::Animation* animation) override; | 113 void AnimationProgressed(const gfx::Animation* animation) override; |
| 112 void AnimationEnded(const gfx::Animation* animation) override; | 114 void AnimationEnded(const gfx::Animation* animation) override; |
| 113 void AnimationCanceled(const gfx::Animation* animation) override; | 115 void AnimationCanceled(const gfx::Animation* animation) override; |
| 114 | 116 |
| 115 // Overridden from views::WidgetDelegate: | 117 // Overridden from views::WidgetDelegate: |
| 116 void WindowClosing() override; | 118 void WindowClosing() override; |
| 117 void OnDisplayChanged() override; | 119 void OnDisplayChanged() override; |
| 118 void OnWorkAreaChanged() override; | 120 void OnWorkAreaChanged() override; |
| 119 | 121 |
| 122 // Overridden from views::WidgetObserver: |
| 123 void OnWidgetActivationChanged(views::Widget* widget, bool active) override; |
| 124 |
| 120 // Recalculates preferred size from underlying view and notifies about it. | 125 // Recalculates preferred size from underlying view and notifies about it. |
| 121 void UpdatePreferredSize(); | 126 void UpdatePreferredSize(); |
| 122 | 127 |
| 123 // Initialization and update. | 128 // Initialization and update. |
| 124 void CreateWidget(PopupAlignmentDelegate* alignment_delegate); | 129 void CreateWidget(PopupAlignmentDelegate* alignment_delegate); |
| 125 | 130 |
| 126 // Immediately moves the toast without any sort of delay or animation. | 131 // Immediately moves the toast without any sort of delay or animation. |
| 127 void SetBoundsInstantly(gfx::Rect new_bounds); | 132 void SetBoundsInstantly(gfx::Rect new_bounds); |
| 128 | 133 |
| 129 // Given the bounds of a toast on the screen, compute the bounds for that | 134 // Given the bounds of a toast on the screen, compute the bounds for that |
| (...skipping 23 matching lines...) Expand all Loading... |
| 153 | 158 |
| 154 gfx::Point origin_; | 159 gfx::Point origin_; |
| 155 gfx::Size preferred_size_; | 160 gfx::Size preferred_size_; |
| 156 | 161 |
| 157 DISALLOW_COPY_AND_ASSIGN(ToastContentsView); | 162 DISALLOW_COPY_AND_ASSIGN(ToastContentsView); |
| 158 }; | 163 }; |
| 159 | 164 |
| 160 } // namespace message_center | 165 } // namespace message_center |
| 161 | 166 |
| 162 #endif // UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ | 167 #endif // UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ |
| OLD | NEW |