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

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

Issue 961993007: Pull MessageListView into its own file for easier testing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build Created 5 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
(Empty)
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_LIST_VIEW_H_
6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_LIST_VIEW_H_
7
8 #include <list>
9 #include <set>
10
11 #include "ui/compositor/paint_context.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "ui/message_center/notification.h"
15 #include "ui/views/animation/bounds_animator_observer.h"
16 #include "ui/views/view.h"
17
18 namespace gfx {
19 class Canvas;
20 }
21
22 namespace ui {
23 class Layer;
24 }
25
26 namespace views {
27 class BoundsAnimator;
28 }
29
30 namespace message_center {
31
32 class MessageCenterView;
33 class MessageView;
34
35 // Displays a list of messages for rich notifications. Functions as an array of
36 // MessageViews and animates them on transitions. It also supports
37 // repositioning.
38 class MessageListView : public views::View,
39 public views::BoundsAnimatorObserver {
40 public:
41 explicit MessageListView(MessageCenterView* message_center_view,
42 bool top_down);
43 ~MessageListView() override;
44
45 void AddNotificationAt(MessageView* view, int i);
46 void RemoveNotification(MessageView* view);
47 void UpdateNotification(MessageView* view, const Notification& notification);
48 void SetRepositionTarget(const gfx::Rect& target_rect);
49 void ResetRepositionSession();
50 void ClearAllNotifications(const gfx::Rect& visible_scroll_rect);
51
52 protected:
53 // Overridden from views::View.
54 void Layout() override;
55 gfx::Size GetPreferredSize() const override;
56 int GetHeightForWidth(int width) const override;
57 void PaintChildren(const ui::PaintContext& context) override;
58 void ReorderChildLayers(ui::Layer* parent_layer) override;
59
60 // Overridden from views::BoundsAnimatorObserver.
61 void OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) override;
62 void OnBoundsAnimatorDone(views::BoundsAnimator* animator) override;
63
64 private:
65 bool IsValidChild(const views::View* child) const;
66 void DoUpdateIfPossible();
67
68 // Animates all notifications below target upwards to align with the top of
69 // the last closed notification.
70 void AnimateNotificationsBelowTarget();
71 // Animates all notifications above target downwards to align with the top of
72 // the last closed notification.
73 void AnimateNotificationsAboveTarget();
74
75 // Schedules animation for a child to the specified position. Returns false
76 // if |child| will disappear after the animation.
77 bool AnimateChild(views::View* child, int top, int height);
78
79 // Animate clearing one notification.
80 void AnimateClearingOneNotification();
81 MessageCenterView* message_center_view() const {
82 return message_center_view_;
83 }
84
85 MessageCenterView* message_center_view_; // Weak reference.
86 // The top position of the reposition target rectangle.
87 int reposition_top_;
88 int fixed_height_;
89 bool has_deferred_task_;
90 bool clear_all_started_;
91 bool top_down_;
92 std::set<views::View*> adding_views_;
93 std::set<views::View*> deleting_views_;
94 std::set<views::View*> deleted_when_done_;
95 std::list<views::View*> clearing_all_views_;
96 scoped_ptr<views::BoundsAnimator> animator_;
97 base::WeakPtrFactory<MessageListView> weak_ptr_factory_;
98
99 DISALLOW_COPY_AND_ASSIGN(MessageListView);
100 };
101
102 } // namespace message_center
103 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_LIST_VIEW_H_
OLDNEW
« no previous file with comments | « ui/message_center/views/message_center_view.cc ('k') | ui/message_center/views/message_list_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698