Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: ui/message_center/views/toast_contents_view.h

Issue 1913433004: Supporting shrinking/enlarging for notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compilation: stl variations Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.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 18
19 namespace gfx { 19 namespace gfx {
20 class Animation; 20 class Animation;
21 class SlideAnimation; 21 class SlideAnimation;
22 } 22 }
23 23
24 namespace views { 24 namespace views {
25 class View; 25 class View;
26 } 26 }
27 27
28 namespace message_center { 28 namespace message_center {
29 29
30 namespace test {
31 class MessagePopupCollectionTest;
32 }
33
30 class MessagePopupCollection; 34 class MessagePopupCollection;
31 class MessageView; 35 class MessageView;
32 class Notification; 36 class Notification;
33 37
34 // The widget host for a popup. Also implements MessageCenterController 38 // The widget host for a popup. Also implements MessageCenterController
35 // which delegates over to MessagePopupCollection, but takes care about 39 // which delegates over to MessagePopupCollection, but takes care about
36 // checking the weakref since MessagePopupCollection may disappear before 40 // checking the weakref since MessagePopupCollection may disappear before
37 // widget/views are closed/destructed. 41 // widget/views are closed/destructed.
38 class ToastContentsView : public views::WidgetDelegateView, 42 class ToastContentsView : public views::WidgetDelegateView,
39 public MessageCenterController, 43 public MessageCenterController,
(...skipping 22 matching lines...) Expand all
62 // an animation. Once animation finishes, closes the widget. 66 // an animation. Once animation finishes, closes the widget.
63 void CloseWithAnimation(); 67 void CloseWithAnimation();
64 68
65 void SetBoundsWithAnimation(gfx::Rect new_bounds); 69 void SetBoundsWithAnimation(gfx::Rect new_bounds);
66 70
67 // Origin and bounds are not 'instant', but rather 'current stable values', 71 // Origin and bounds are not 'instant', but rather 'current stable values',
68 // there could be animation in progress that targets these values. 72 // there could be animation in progress that targets these values.
69 gfx::Point origin() { return origin_; } 73 gfx::Point origin() { return origin_; }
70 gfx::Rect bounds() { return gfx::Rect(origin_, preferred_size_); } 74 gfx::Rect bounds() { return gfx::Rect(origin_, preferred_size_); }
71 75
72 const std::string& id() { return id_; } 76 const std::string& id() const { return id_; }
73 77
74 // Overridden from views::View: 78 // Overridden from views::View:
75 void OnMouseEntered(const ui::MouseEvent& event) override; 79 void OnMouseEntered(const ui::MouseEvent& event) override;
76 void OnMouseExited(const ui::MouseEvent& event) override; 80 void OnMouseExited(const ui::MouseEvent& event) override;
77 void Layout() override; 81 void Layout() override;
78 gfx::Size GetPreferredSize() const override; 82 gfx::Size GetPreferredSize() const override;
79 void GetAccessibleState(ui::AXViewState* state) override; 83 void GetAccessibleState(ui::AXViewState* state) override;
80 84
81 private: 85 private:
86 friend class test::MessagePopupCollectionTest;
87
82 // Overridden from MessageCenterController: 88 // Overridden from MessageCenterController:
83 void ClickOnNotification(const std::string& notification_id) override; 89 void ClickOnNotification(const std::string& notification_id) override;
84 void RemoveNotification(const std::string& notification_id, 90 void RemoveNotification(const std::string& notification_id,
85 bool by_user) override; 91 bool by_user) override;
86 std::unique_ptr<ui::MenuModel> CreateMenuModel( 92 std::unique_ptr<ui::MenuModel> CreateMenuModel(
87 const NotifierId& notifier_id, 93 const NotifierId& notifier_id,
88 const base::string16& display_source) override; 94 const base::string16& display_source) override;
89 bool HasClickedListener(const std::string& notification_id) override; 95 bool HasClickedListener(const std::string& notification_id) override;
90 void ClickOnNotificationButton(const std::string& notification_id, 96 void ClickOnNotificationButton(const std::string& notification_id,
91 int button_index) override; 97 int button_index) override;
92 void ClickOnSettingsButton(const std::string& notification_id) override; 98 void ClickOnSettingsButton(const std::string& notification_id) override;
93 99
94 // Overridden from gfx::AnimationDelegate: 100 // Overridden from gfx::AnimationDelegate:
95 void AnimationProgressed(const gfx::Animation* animation) override; 101 void AnimationProgressed(const gfx::Animation* animation) override;
96 void AnimationEnded(const gfx::Animation* animation) override; 102 void AnimationEnded(const gfx::Animation* animation) override;
97 void AnimationCanceled(const gfx::Animation* animation) override; 103 void AnimationCanceled(const gfx::Animation* animation) override;
98 104
99 // Overridden from views::WidgetDelegate: 105 // Overridden from views::WidgetDelegate:
100 views::View* GetContentsView() override; 106 views::View* GetContentsView() override;
101 void WindowClosing() override; 107 void WindowClosing() override;
102 void OnDisplayChanged() override; 108 void OnDisplayChanged() override;
103 void OnWorkAreaChanged() override; 109 void OnWorkAreaChanged() override;
104 110
111 // Recalculates preferred size from underlying view and notifies about it.
112 void UpdatePreferredSize();
113
105 // Initialization and update. 114 // Initialization and update.
106 void CreateWidget(gfx::NativeView parent); 115 void CreateWidget(gfx::NativeView parent);
107 116
108 // Immediately moves the toast without any sort of delay or animation. 117 // Immediately moves the toast without any sort of delay or animation.
109 void SetBoundsInstantly(gfx::Rect new_bounds); 118 void SetBoundsInstantly(gfx::Rect new_bounds);
110 119
111 // Given the bounds of a toast on the screen, compute the bouds for that 120 // Given the bounds of a toast on the screen, compute the bouds for that
112 // toast in 'closed' state. The 'closed' state is used as origin/destination 121 // toast in 'closed' state. The 'closed' state is used as origin/destination
113 // in reveal/closing animations. 122 // in reveal/closing animations.
114 gfx::Rect GetClosedToastBounds(gfx::Rect bounds); 123 gfx::Rect GetClosedToastBounds(gfx::Rect bounds);
(...skipping 20 matching lines...) Expand all
135 144
136 gfx::Point origin_; 145 gfx::Point origin_;
137 gfx::Size preferred_size_; 146 gfx::Size preferred_size_;
138 147
139 DISALLOW_COPY_AND_ASSIGN(ToastContentsView); 148 DISALLOW_COPY_AND_ASSIGN(ToastContentsView);
140 }; 149 };
141 150
142 } // namespace message_center 151 } // namespace message_center
143 152
144 #endif // UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_ 153 #endif // UI_MESSAGE_CENTER_VIEWS_TOAST_CONTENTS_VIEW_H_
OLDNEW
« no previous file with comments | « ui/message_center/views/message_popup_collection_unittest.cc ('k') | ui/message_center/views/toast_contents_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698