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

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

Issue 2805143002: Don't shrink the message center height while open (Closed)
Patch Set: . Created 3 years, 8 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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/gfx/animation/multi_animation.h" 16 #include "ui/gfx/animation/multi_animation.h"
17 #include "ui/gfx/canvas.h" 17 #include "ui/gfx/canvas.h"
18 #include "ui/gfx/geometry/insets.h" 18 #include "ui/gfx/geometry/insets.h"
19 #include "ui/gfx/geometry/rect.h" 19 #include "ui/gfx/geometry/rect.h"
20 #include "ui/gfx/geometry/size.h" 20 #include "ui/gfx/geometry/size.h"
21 #include "ui/message_center/message_center.h" 21 #include "ui/message_center/message_center.h"
22 #include "ui/message_center/message_center_style.h" 22 #include "ui/message_center/message_center_style.h"
23 #include "ui/message_center/message_center_tray.h" 23 #include "ui/message_center/message_center_tray.h"
24 #include "ui/message_center/message_center_types.h" 24 #include "ui/message_center/message_center_types.h"
25 #include "ui/message_center/views/custom_notification_view.h"
25 #include "ui/message_center/views/message_center_button_bar.h" 26 #include "ui/message_center/views/message_center_button_bar.h"
26 #include "ui/message_center/views/message_list_view.h" 27 #include "ui/message_center/views/message_list_view.h"
27 #include "ui/message_center/views/message_view.h" 28 #include "ui/message_center/views/message_view.h"
28 #include "ui/message_center/views/message_view_context_menu_controller.h" 29 #include "ui/message_center/views/message_view_context_menu_controller.h"
29 #include "ui/message_center/views/message_view_factory.h" 30 #include "ui/message_center/views/message_view_factory.h"
30 #include "ui/message_center/views/notifier_settings_view.h" 31 #include "ui/message_center/views/notifier_settings_view.h"
31 #include "ui/resources/grit/ui_resources.h" 32 #include "ui/resources/grit/ui_resources.h"
32 #include "ui/strings/grit/ui_strings.h" 33 #include "ui/strings/grit/ui_strings.h"
33 #include "ui/views/background.h" 34 #include "ui/views/background.h"
34 #include "ui/views/border.h" 35 #include "ui/views/border.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); 99 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false));
99 scroller_->SetHorizontalScrollBar(new views::OverlayScrollBar(true)); 100 scroller_->SetHorizontalScrollBar(new views::OverlayScrollBar(true));
100 scroller_->set_background( 101 scroller_->set_background(
101 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); 102 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor));
102 103
103 scroller_->SetPaintToLayer(); 104 scroller_->SetPaintToLayer();
104 scroller_->layer()->SetFillsBoundsOpaquely(false); 105 scroller_->layer()->SetFillsBoundsOpaquely(false);
105 scroller_->layer()->SetMasksToBounds(true); 106 scroller_->layer()->SetMasksToBounds(true);
106 107
107 message_list_view_.reset(new MessageListView()); 108 message_list_view_.reset(new MessageListView());
109 message_list_view_->set_scroller(scroller_);
108 message_list_view_->set_owned_by_client(); 110 message_list_view_->set_owned_by_client();
109 message_list_view_->AddObserver(this); 111 message_list_view_->AddObserver(this);
110 112
111 // We want to swap the contents of the scroll view between the empty list 113 // We want to swap the contents of the scroll view between the empty list
112 // view and the message list view, without constructing them afresh each 114 // view and the message list view, without constructing them afresh each
113 // time. So, since the scroll view deletes old contents each time you 115 // time. So, since the scroll view deletes old contents each time you
114 // set the contents (regardless of the |owned_by_client_| setting) we need 116 // set the contents (regardless of the |owned_by_client_| setting) we need
115 // an intermediate view for the contents whose children we can swap in and 117 // an intermediate view for the contents whose children we can swap in and
116 // out. 118 // out.
117 views::View* scroller_contents = new views::View(); 119 views::View* scroller_contents = new views::View();
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 Update(true /* animate */); 390 Update(true /* animate */);
389 } 391 }
390 392
391 // This is a separate function so we can override it in tests. 393 // This is a separate function so we can override it in tests.
392 bool MessageCenterView::SetRepositionTarget() { 394 bool MessageCenterView::SetRepositionTarget() {
393 // Set the item on the mouse cursor as the reposition target so that it 395 // Set the item on the mouse cursor as the reposition target so that it
394 // should stick to the current position over the update. 396 // should stick to the current position over the update.
395 if (message_list_view_->IsMouseHovered()) { 397 if (message_list_view_->IsMouseHovered()) {
396 for (const auto& hover_id_view : notification_views_) { 398 for (const auto& hover_id_view : notification_views_) {
397 MessageView* hover_view = hover_id_view.second; 399 MessageView* hover_view = hover_id_view.second;
400
401 // Skip if the view is a custom view. Custom views can be expanded by
Eliot Courtney 2017/04/11 00:58:26 discussed offline: We want to keep the on-hover re
yoshiki 2017/04/11 07:46:26 I just removed this, since the reason I added this
402 // click and we don't want to stick to the target on expansion by user
403 // action.
404 // TODO(yoshiki): Distinguish if the update event comes from user action
405 // or not, and skip only in the case of user action
406 if (hover_view->GetClassName() == CustomNotificationView::kViewClassName)
407 continue;
408
398 if (hover_view->IsMouseHovered()) { 409 if (hover_view->IsMouseHovered()) {
399 message_list_view_->SetRepositionTarget(hover_view->bounds()); 410 message_list_view_->SetRepositionTarget(hover_view->bounds());
400 return true; 411 return true;
401 } 412 }
402 } 413 }
403 } 414 }
404 return false; 415 return false;
405 } 416 }
406 417
407 void MessageCenterView::OnNotificationUpdated(const std::string& id) { 418 void MessageCenterView::OnNotificationUpdated(const std::string& id) {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 // Disable the close-all button since no notification is visible. 676 // Disable the close-all button since no notification is visible.
666 button_bar_->SetCloseAllButtonEnabled(false); 677 button_bar_->SetCloseAllButtonEnabled(false);
667 } 678 }
668 } 679 }
669 680
670 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { 681 void MessageCenterView::SetNotificationViewForTest(MessageView* view) {
671 message_list_view_->AddNotificationAt(view, 0); 682 message_list_view_->AddNotificationAt(view, 0);
672 } 683 }
673 684
674 } // namespace message_center 685 } // namespace message_center
OLDNEW
« no previous file with comments | « no previous file | ui/message_center/views/message_center_view_unittest.cc » ('j') | ui/message_center/views/message_list_view.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698