| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 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 | 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_MESSAGE_LIST_VIEW_H_ | 5 #ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_LIST_VIEW_H_ |
| 6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_LIST_VIEW_H_ | 6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_LIST_VIEW_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "ui/compositor/paint_context.h" | 13 #include "ui/compositor/paint_context.h" |
| 14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
| 15 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 16 #include "ui/message_center/message_center_export.h" | 16 #include "ui/message_center/message_center_export.h" |
| 17 #include "ui/message_center/notification.h" | 17 #include "ui/message_center/notification.h" |
| 18 #include "ui/views/animation/bounds_animator.h" | 18 #include "ui/views/animation/bounds_animator.h" |
| 19 #include "ui/views/animation/bounds_animator_observer.h" | 19 #include "ui/views/animation/bounds_animator_observer.h" |
| 20 #include "ui/views/controls/scroll_view.h" |
| 20 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
| 21 | 22 |
| 22 namespace ui { | 23 namespace ui { |
| 23 class Layer; | 24 class Layer; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace message_center { | 27 namespace message_center { |
| 27 | 28 |
| 28 class MessageView; | 29 class MessageView; |
| 29 | 30 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 void SetRepositionTarget(const gfx::Rect& target_rect); | 49 void SetRepositionTarget(const gfx::Rect& target_rect); |
| 49 void ResetRepositionSession(); | 50 void ResetRepositionSession(); |
| 50 void ClearAllClosableNotifications(const gfx::Rect& visible_scroll_rect); | 51 void ClearAllClosableNotifications(const gfx::Rect& visible_scroll_rect); |
| 51 | 52 |
| 52 void AddObserver(Observer* observer); | 53 void AddObserver(Observer* observer); |
| 53 void RemoveObserver(Observer* observer); | 54 void RemoveObserver(Observer* observer); |
| 54 | 55 |
| 55 void SetRepositionTargetForTest( | 56 void SetRepositionTargetForTest( |
| 56 const gfx::Rect& target_rect); | 57 const gfx::Rect& target_rect); |
| 57 | 58 |
| 59 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } |
| 60 |
| 58 protected: | 61 protected: |
| 59 // Overridden from views::View. | 62 // Overridden from views::View. |
| 60 void Layout() override; | 63 void Layout() override; |
| 61 gfx::Size GetPreferredSize() const override; | 64 gfx::Size GetPreferredSize() const override; |
| 62 int GetHeightForWidth(int width) const override; | 65 int GetHeightForWidth(int width) const override; |
| 63 void PaintChildren(const ui::PaintContext& context) override; | 66 void PaintChildren(const ui::PaintContext& context) override; |
| 64 void ReorderChildLayers(ui::Layer* parent_layer) override; | 67 void ReorderChildLayers(ui::Layer* parent_layer) override; |
| 65 | 68 |
| 66 // Overridden from views::BoundsAnimatorObserver. | 69 // Overridden from views::BoundsAnimatorObserver. |
| 67 void OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) override; | 70 void OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) override; |
| 68 void OnBoundsAnimatorDone(views::BoundsAnimator* animator) override; | 71 void OnBoundsAnimatorDone(views::BoundsAnimator* animator) override; |
| 69 | 72 |
| 70 private: | 73 private: |
| 71 friend class MessageCenterViewTest; | 74 friend class MessageCenterViewTest; |
| 72 friend class MessageListViewTest; | 75 friend class MessageListViewTest; |
| 73 | 76 |
| 74 bool IsValidChild(const views::View* child) const; | 77 bool IsValidChild(const views::View* child) const; |
| 75 void DoUpdateIfPossible(); | 78 void DoUpdateIfPossible(); |
| 76 | 79 |
| 77 // Animates all notifications below target upwards to align with the top of | 80 // Animates all notifications below target upwards to align with the top of |
| 78 // the last closed notification. | 81 // the last closed notification. |
| 79 void AnimateNotificationsBelowTarget(); | 82 void AnimateNotificationsBelowTarget(); |
| 80 // Animates all notifications above target downwards to align with the top of | 83 // Animates all notifications to align with the top of the last closed |
| 81 // the last closed notification. | 84 // notification. |
| 82 void AnimateNotificationsAboveTarget(); | 85 void AnimateNotifications(); |
| 83 // Computes reposition offsets for |AnimateNotificationsAboveTarget|. | 86 // Computes reposition offsets for |AnimateNotificationsAboveTarget|. |
| 84 std::vector<int> ComputeRepositionOffsets(const std::vector<int>& heights, | 87 std::vector<int> ComputeRepositionOffsets(const std::vector<int>& heights, |
| 85 const std::vector<bool>& deleting, | 88 const std::vector<bool>& deleting, |
| 86 int target_index, | 89 int target_index, |
| 87 int padding); | 90 int padding); |
| 88 | 91 |
| 89 // Schedules animation for a child to the specified position. Returns false | 92 // Schedules animation for a child to the specified position. Returns false |
| 90 // if |child| will disappear after the animation. | 93 // if |child| will disappear after the animation. |
| 91 bool AnimateChild(views::View* child, | 94 bool AnimateChild(views::View* child, |
| 92 int top, | 95 int top, |
| 93 int height, | 96 int height, |
| 94 bool animate_even_on_move); | 97 bool animate_even_on_move); |
| 95 | 98 |
| 99 // Calculate the new fixed height and update with it. |requested_height| |
| 100 // is the minimum height, and actual fixed height should be more than it. |
| 101 void UpdateFixedHeight(int requested_height, bool prevent_scroll); |
| 102 |
| 96 // Animate clearing one notification. | 103 // Animate clearing one notification. |
| 97 void AnimateClearingOneNotification(); | 104 void AnimateClearingOneNotification(); |
| 98 | 105 |
| 99 // List of MessageListView::Observer | 106 // List of MessageListView::Observer |
| 100 base::ObserverList<Observer> observers_; | 107 base::ObserverList<Observer> observers_; |
| 101 | 108 |
| 102 // The top position of the reposition target rectangle. | 109 // The top position of the reposition target rectangle. |
| 103 int reposition_top_; | 110 int reposition_top_; |
| 104 int fixed_height_; | 111 int fixed_height_; |
| 105 bool has_deferred_task_; | 112 bool has_deferred_task_; |
| 106 bool clear_all_started_; | 113 bool clear_all_started_; |
| 107 std::set<views::View*> adding_views_; | 114 std::set<views::View*> adding_views_; |
| 108 std::set<views::View*> deleting_views_; | 115 std::set<views::View*> deleting_views_; |
| 109 std::set<views::View*> deleted_when_done_; | 116 std::set<views::View*> deleted_when_done_; |
| 110 std::list<views::View*> clearing_all_views_; | 117 std::list<views::View*> clearing_all_views_; |
| 111 views::BoundsAnimator animator_; | 118 views::BoundsAnimator animator_; |
| 112 | 119 |
| 120 views::ScrollView* scroller_ = nullptr; |
| 121 |
| 113 // If true, the message loop will be quitted after the animation finishes. | 122 // If true, the message loop will be quitted after the animation finishes. |
| 114 // This is just for tests and has no setter. | 123 // This is just for tests and has no setter. |
| 115 bool quit_message_loop_after_animation_for_test_; | 124 bool quit_message_loop_after_animation_for_test_; |
| 116 | 125 |
| 117 base::WeakPtrFactory<MessageListView> weak_ptr_factory_; | 126 base::WeakPtrFactory<MessageListView> weak_ptr_factory_; |
| 118 DISALLOW_COPY_AND_ASSIGN(MessageListView); | 127 DISALLOW_COPY_AND_ASSIGN(MessageListView); |
| 119 }; | 128 }; |
| 120 | 129 |
| 121 } // namespace message_center | 130 } // namespace message_center |
| 122 | 131 |
| 123 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_LIST_VIEW_H_ | 132 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_LIST_VIEW_H_ |
| OLD | NEW |