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

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

Issue 2696523002: Stop notifications from being clipped on resize. (Closed)
Patch Set: Add additional comments. Created 3 years, 10 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 #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/macros.h" 10 #include "base/macros.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 next_focused_view->RequestFocus(); 359 next_focused_view->RequestFocus();
360 } 360 }
361 } 361 }
362 } 362 }
363 } 363 }
364 message_list_view_->RemoveNotification(view); 364 message_list_view_->RemoveNotification(view);
365 notification_views_.erase(view_iter); 365 notification_views_.erase(view_iter);
366 Update(true /* animate */); 366 Update(true /* animate */);
367 } 367 }
368 368
369 // This is a separate function so we can override it in tests.
370 bool MessageCenterView::SetRepositionTarget() {
371 // Set the item on the mouse cursor as the reposition target so that it
372 // should stick to the current position over the update.
373 if (message_list_view_->IsMouseHovered()) {
374 for (const auto& hover_id_view : notification_views_) {
375 MessageView* hover_view = hover_id_view.second;
376 if (hover_view->IsMouseHovered()) {
377 message_list_view_->SetRepositionTarget(hover_view->bounds());
378 return true;
379 }
380 }
381 }
382 return false;
383 }
384
369 void MessageCenterView::OnNotificationUpdated(const std::string& id) { 385 void MessageCenterView::OnNotificationUpdated(const std::string& id) {
370 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id); 386 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id);
371 if (view_iter == notification_views_.end()) 387 if (view_iter == notification_views_.end())
372 return; 388 return;
373 389
374 // Set the item on the mouse cursor as the reposition target so that it 390 // If there is no reposition target anymore, make sure to reset the reposition
375 // should stick to the current position over the update. 391 // session.
376 bool set = false; 392 if (!SetRepositionTarget())
377 if (message_list_view_->IsMouseHovered()) {
378 for (const auto& hover_id_view : notification_views_) {
379 MessageView* hover_view = hover_id_view.second;
380 if (hover_view->IsMouseHovered()) {
381 message_list_view_->SetRepositionTarget(hover_view->bounds());
382 set = true;
383 break;
384 }
385 }
386 }
387 if (!set)
388 message_list_view_->ResetRepositionSession(); 393 message_list_view_->ResetRepositionSession();
389 394
390 // TODO(dimich): add MessageCenter::GetVisibleNotificationById(id) 395 // TODO(dimich): add MessageCenter::GetVisibleNotificationById(id)
391 MessageView* view = view_iter->second; 396 MessageView* view = view_iter->second;
392 const NotificationList::Notifications& notifications = 397 const NotificationList::Notifications& notifications =
393 message_center_->GetVisibleNotifications(); 398 message_center_->GetVisibleNotifications();
394 for (NotificationList::Notifications::const_iterator iter = 399 for (NotificationList::Notifications::const_iterator iter =
395 notifications.begin(); iter != notifications.end(); ++iter) { 400 notifications.begin(); iter != notifications.end(); ++iter) {
396 if ((*iter)->id() == id) { 401 if ((*iter)->id() == id) {
397 int old_width = view->width(); 402 int old_width = view->width();
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 // Disable the close-all button since no notification is visible. 652 // Disable the close-all button since no notification is visible.
648 button_bar_->SetCloseAllButtonEnabled(false); 653 button_bar_->SetCloseAllButtonEnabled(false);
649 } 654 }
650 } 655 }
651 656
652 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { 657 void MessageCenterView::SetNotificationViewForTest(MessageView* view) {
653 message_list_view_->AddNotificationAt(view, 0); 658 message_list_view_->AddNotificationAt(view, 0);
654 } 659 }
655 660
656 } // namespace message_center 661 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/message_center_view.h ('k') | ui/message_center/views/message_center_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698