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

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

Issue 2558083005: Remove "top_down" flag in the message center code (Closed)
Patch Set: Created 4 years 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) 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 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/location.h" 6 #include "base/location.h"
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "ui/gfx/animation/slide_animation.h" 9 #include "ui/gfx/animation/slide_animation.h"
10 #include "ui/message_center/message_center_style.h" 10 #include "ui/message_center/message_center_style.h"
11 #include "ui/message_center/message_center_switches.h" 11 #include "ui/message_center/message_center_switches.h"
12 #include "ui/message_center/views/message_center_view.h" 12 #include "ui/message_center/views/message_center_view.h"
13 #include "ui/message_center/views/message_list_view.h" 13 #include "ui/message_center/views/message_list_view.h"
14 #include "ui/message_center/views/message_view.h" 14 #include "ui/message_center/views/message_view.h"
15 #include "ui/views/background.h" 15 #include "ui/views/background.h"
16 #include "ui/views/border.h" 16 #include "ui/views/border.h"
17 #include "ui/views/layout/box_layout.h" 17 #include "ui/views/layout/box_layout.h"
18 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
19 19
20 namespace message_center { 20 namespace message_center {
21 21
22 namespace { 22 namespace {
23 const int kAnimateClearingNextNotificationDelayMS = 40; 23 const int kAnimateClearingNextNotificationDelayMS = 40;
24 } // namespace 24 } // namespace
25 25
26 MessageListView::MessageListView(bool top_down) 26 MessageListView::MessageListView()
27 : reposition_top_(-1), 27 : reposition_top_(-1),
28 fixed_height_(0), 28 fixed_height_(0),
29 has_deferred_task_(false), 29 has_deferred_task_(false),
30 clear_all_started_(false), 30 clear_all_started_(false),
31 top_down_(top_down),
32 animator_(this), 31 animator_(this),
33 quit_message_loop_after_animation_for_test_(false), 32 quit_message_loop_after_animation_for_test_(false),
34 weak_ptr_factory_(this) { 33 weak_ptr_factory_(this) {
35 views::BoxLayout* layout = 34 views::BoxLayout* layout =
36 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1); 35 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1);
37 layout->SetDefaultFlex(1); 36 layout->SetDefaultFlex(1);
38 SetLayoutManager(layout); 37 SetLayoutManager(layout);
39 38
40 // Set the margin to 0 for the layout. BoxLayout assumes the same margin 39 // Set the margin to 0 for the layout. BoxLayout assumes the same margin
41 // for top and bottom, but the bottom margin here should be smaller 40 // for top and bottom, but the bottom margin here should be smaller
42 // because of the shadow of message view. Use an empty border instead 41 // because of the shadow of message view. Use an empty border instead
43 // to provide this margin. 42 // to provide this margin.
44 gfx::Insets shadow_insets = MessageView::GetShadowInsets(); 43 gfx::Insets shadow_insets = MessageView::GetShadowInsets();
45 set_background( 44 set_background(
46 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); 45 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor));
47 SetBorder(views::CreateEmptyBorder( 46 SetBorder(views::CreateEmptyBorder(
48 top_down ? 0 : kMarginBetweenItems - shadow_insets.top(), /* top */ 47 kMarginBetweenItems - shadow_insets.top(), /* top */
49 kMarginBetweenItems - shadow_insets.left(), /* left */ 48 kMarginBetweenItems - shadow_insets.left(), /* left */
50 top_down ? kMarginBetweenItems - shadow_insets.bottom() : 0, /* bottom */ 49 0, /* bottom */
51 kMarginBetweenItems - shadow_insets.right() /* right */)); 50 kMarginBetweenItems - shadow_insets.right() /* right */));
52 animator_.AddObserver(this); 51 animator_.AddObserver(this);
53 } 52 }
54 53
55 MessageListView::~MessageListView() { 54 MessageListView::~MessageListView() {
56 animator_.RemoveObserver(this); 55 animator_.RemoveObserver(this);
57 } 56 }
58 57
59 void MessageListView::Layout() { 58 void MessageListView::Layout() {
60 if (animator_.IsAnimating()) 59 if (animator_.IsAnimating())
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 279 }
281 280
282 if (!clearing_all_views_.empty()) { 281 if (!clearing_all_views_.empty()) {
283 AnimateClearingOneNotification(); 282 AnimateClearingOneNotification();
284 return; 283 return;
285 } 284 }
286 285
287 int new_height = GetHeightForWidth(child_area.width() + GetInsets().width()); 286 int new_height = GetHeightForWidth(child_area.width() + GetInsets().width());
288 SetSize(gfx::Size(child_area.width() + GetInsets().width(), new_height)); 287 SetSize(gfx::Size(child_area.width() + GetInsets().width(), new_height));
289 288
290 if (top_down_ || 289 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
291 base::CommandLine::ForCurrentProcess()->HasSwitch(
292 switches::kEnableMessageCenterAlwaysScrollUpUponNotificationRemoval)) 290 switches::kEnableMessageCenterAlwaysScrollUpUponNotificationRemoval))
293 AnimateNotificationsBelowTarget(); 291 AnimateNotificationsBelowTarget();
294 else 292 else
295 AnimateNotificationsAboveTarget(); 293 AnimateNotificationsAboveTarget();
296 294
297 adding_views_.clear(); 295 adding_views_.clear();
298 deleting_views_.clear(); 296 deleting_views_.clear();
299 297
300 if (!animator_.IsAnimating() && GetWidget()) 298 if (!animator_.IsAnimating() && GetWidget())
301 GetWidget()->SynthesizeMouseMoveEvent(); 299 GetWidget()->SynthesizeMouseMoveEvent();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 base::TimeDelta::FromMilliseconds( 477 base::TimeDelta::FromMilliseconds(
480 kAnimateClearingNextNotificationDelayMS)); 478 kAnimateClearingNextNotificationDelayMS));
481 } 479 }
482 } 480 }
483 481
484 void MessageListView::SetRepositionTargetForTest(const gfx::Rect& target_rect) { 482 void MessageListView::SetRepositionTargetForTest(const gfx::Rect& target_rect) {
485 SetRepositionTarget(target_rect); 483 SetRepositionTarget(target_rect);
486 } 484 }
487 485
488 } // namespace message_center 486 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/message_list_view.h ('k') | ui/message_center/views/message_list_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698