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

Side by Side Diff: ui/message_center/views/message_center_view.cc

Issue 271773002: Retain popup bubble mouse status even through updates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 #include "ui/message_center/views/message_center_view.h" 5 #include "ui/message_center/views/message_center_view.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // repositioning. 106 // repositioning.
107 class MessageListView : public views::View, 107 class MessageListView : public views::View,
108 public views::BoundsAnimatorObserver { 108 public views::BoundsAnimatorObserver {
109 public: 109 public:
110 explicit MessageListView(MessageCenterView* message_center_view, 110 explicit MessageListView(MessageCenterView* message_center_view,
111 bool top_down); 111 bool top_down);
112 virtual ~MessageListView(); 112 virtual ~MessageListView();
113 113
114 void AddNotificationAt(MessageView* view, int i); 114 void AddNotificationAt(MessageView* view, int i);
115 void RemoveNotification(MessageView* view); 115 void RemoveNotification(MessageView* view);
116 void UpdateNotification(MessageView* view, MessageView* new_view); 116 void UpdateNotification(MessageView* view, const Notification& notification);
117 void SetRepositionTarget(const gfx::Rect& target_rect); 117 void SetRepositionTarget(const gfx::Rect& target_rect);
118 void ResetRepositionSession(); 118 void ResetRepositionSession();
119 void ClearAllNotifications(const gfx::Rect& visible_scroll_rect); 119 void ClearAllNotifications(const gfx::Rect& visible_scroll_rect);
120 120
121 protected: 121 protected:
122 // Overridden from views::View. 122 // Overridden from views::View.
123 virtual void Layout() OVERRIDE; 123 virtual void Layout() OVERRIDE;
124 virtual gfx::Size GetPreferredSize() OVERRIDE; 124 virtual gfx::Size GetPreferredSize() OVERRIDE;
125 virtual int GetHeightForWidth(int width) OVERRIDE; 125 virtual int GetHeightForWidth(int width) OVERRIDE;
126 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; 126 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } else { 254 } else {
255 if (animator_.get()) 255 if (animator_.get())
256 animator_->StopAnimatingView(view); 256 animator_->StopAnimatingView(view);
257 delete view; 257 delete view;
258 } 258 }
259 DoUpdateIfPossible(); 259 DoUpdateIfPossible();
260 } 260 }
261 } 261 }
262 262
263 void MessageListView::UpdateNotification(MessageView* view, 263 void MessageListView::UpdateNotification(MessageView* view,
264 MessageView* new_view) { 264 const Notification& notification) {
265 int index = GetIndexOf(view); 265 int index = GetIndexOf(view);
266 DCHECK_LE(0, index); // GetIndexOf is negative if not a child. 266 DCHECK_LE(0, index); // GetIndexOf is negative if not a child.
267 267
268 if (animator_.get()) 268 if (animator_.get())
269 animator_->StopAnimatingView(view); 269 animator_->StopAnimatingView(view);
270 gfx::Rect old_bounds = view->bounds();
271 if (deleting_views_.find(view) != deleting_views_.end()) 270 if (deleting_views_.find(view) != deleting_views_.end())
272 deleting_views_.erase(view); 271 deleting_views_.erase(view);
273 if (deleted_when_done_.find(view) != deleted_when_done_.end()) 272 if (deleted_when_done_.find(view) != deleted_when_done_.end())
274 deleted_when_done_.erase(view); 273 deleted_when_done_.erase(view);
275 delete view; 274 view->UpdateWithNotification(notification);
276 AddChildViewAt(new_view, index);
277 new_view->SetBounds(old_bounds.x(),
278 old_bounds.y(),
279 old_bounds.width(),
280 new_view->GetHeightForWidth(old_bounds.width()));
281 DoUpdateIfPossible(); 275 DoUpdateIfPossible();
282 } 276 }
283 277
284 gfx::Size MessageListView::GetPreferredSize() { 278 gfx::Size MessageListView::GetPreferredSize() {
285 int width = 0; 279 int width = 0;
286 for (int i = 0; i < child_count(); i++) { 280 for (int i = 0; i < child_count(); i++) {
287 views::View* child = child_at(i); 281 views::View* child = child_at(i);
288 if (IsValidChild(child)) 282 if (IsValidChild(child))
289 width = std::max(width, child->GetPreferredSize().width()); 283 width = std::max(width, child->GetPreferredSize().width());
290 } 284 }
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id); 872 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id);
879 if (view_iter == notification_views_.end()) 873 if (view_iter == notification_views_.end())
880 return; 874 return;
881 NotificationView* view = view_iter->second; 875 NotificationView* view = view_iter->second;
882 // TODO(dimich): add MessageCenter::GetVisibleNotificationById(id) 876 // TODO(dimich): add MessageCenter::GetVisibleNotificationById(id)
883 const NotificationList::Notifications& notifications = 877 const NotificationList::Notifications& notifications =
884 message_center_->GetVisibleNotifications(); 878 message_center_->GetVisibleNotifications();
885 for (NotificationList::Notifications::const_iterator iter = 879 for (NotificationList::Notifications::const_iterator iter =
886 notifications.begin(); iter != notifications.end(); ++iter) { 880 notifications.begin(); iter != notifications.end(); ++iter) {
887 if ((*iter)->id() == id) { 881 if ((*iter)->id() == id) {
888 NotificationView* new_view = 882 int old_width = view->width();
889 NotificationView::Create(this, 883 int old_height = view->GetHeightForWidth(old_width);
890 *(*iter), 884 message_list_view_->UpdateNotification(view, **iter);
891 false); // Not creating a top-level 885 if (view->GetHeightForWidth(old_width) != old_height)
892 // notification. 886 NotificationsChanged();
893 new_view->set_context_menu_controller(context_menu_controller_.get());
894 new_view->set_scroller(scroller_);
895 message_list_view_->UpdateNotification(view, new_view);
896 notification_views_[id] = new_view;
897 NotificationsChanged();
898 break; 887 break;
899 } 888 }
900 } 889 }
901 } 890 }
902 891
903 void MessageCenterView::ClickOnNotification( 892 void MessageCenterView::ClickOnNotification(
904 const std::string& notification_id) { 893 const std::string& notification_id) {
905 message_center_->ClickOnNotification(notification_id); 894 message_center_->ClickOnNotification(notification_id);
906 } 895 }
907 896
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 scroller_->InvalidateLayout(); 991 scroller_->InvalidateLayout();
1003 PreferredSizeChanged(); 992 PreferredSizeChanged();
1004 Layout(); 993 Layout();
1005 } 994 }
1006 995
1007 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { 996 void MessageCenterView::SetNotificationViewForTest(MessageView* view) {
1008 message_list_view_->AddNotificationAt(view, 0); 997 message_list_view_->AddNotificationAt(view, 0);
1009 } 998 }
1010 999
1011 } // namespace message_center 1000 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698