OLD | NEW |
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 view->SetEnabled(enabled); | 55 view->SetEnabled(enabled); |
56 } | 56 } |
57 | 57 |
58 } // namespace | 58 } // namespace |
59 | 59 |
60 // MessageCenterView /////////////////////////////////////////////////////////// | 60 // MessageCenterView /////////////////////////////////////////////////////////// |
61 | 61 |
62 MessageCenterView::MessageCenterView(MessageCenter* message_center, | 62 MessageCenterView::MessageCenterView(MessageCenter* message_center, |
63 MessageCenterTray* tray, | 63 MessageCenterTray* tray, |
64 int max_height, | 64 int max_height, |
65 bool initially_settings_visible, | 65 bool initially_settings_visible) |
66 bool top_down) | |
67 : message_center_(message_center), | 66 : message_center_(message_center), |
68 tray_(tray), | 67 tray_(tray), |
69 scroller_(NULL), | 68 scroller_(NULL), |
70 settings_view_(NULL), | 69 settings_view_(NULL), |
71 button_bar_(NULL), | 70 button_bar_(NULL), |
72 top_down_(top_down), | |
73 settings_visible_(initially_settings_visible), | 71 settings_visible_(initially_settings_visible), |
74 source_view_(NULL), | 72 source_view_(NULL), |
75 source_height_(0), | 73 source_height_(0), |
76 target_view_(NULL), | 74 target_view_(NULL), |
77 target_height_(0), | 75 target_height_(0), |
78 is_closing_(false), | 76 is_closing_(false), |
79 is_locked_(message_center_->IsLockedState()), | 77 is_locked_(message_center_->IsLockedState()), |
80 mode_((!initially_settings_visible || is_locked_) ? Mode::BUTTONS_ONLY | 78 mode_((!initially_settings_visible || is_locked_) ? Mode::BUTTONS_ONLY |
81 : Mode::SETTINGS), | 79 : Mode::SETTINGS), |
82 context_menu_controller_(new MessageViewContextMenuController(this)) { | 80 context_menu_controller_(new MessageViewContextMenuController(this)) { |
(...skipping 14 matching lines...) Expand all Loading... |
97 scroller_ = new views::ScrollView(); | 95 scroller_ = new views::ScrollView(); |
98 scroller_->ClipHeightTo(kMinScrollViewHeight, max_height - button_height); | 96 scroller_->ClipHeightTo(kMinScrollViewHeight, max_height - button_height); |
99 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); | 97 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); |
100 scroller_->set_background( | 98 scroller_->set_background( |
101 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); | 99 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); |
102 | 100 |
103 scroller_->SetPaintToLayer(true); | 101 scroller_->SetPaintToLayer(true); |
104 scroller_->layer()->SetFillsBoundsOpaquely(false); | 102 scroller_->layer()->SetFillsBoundsOpaquely(false); |
105 scroller_->layer()->SetMasksToBounds(true); | 103 scroller_->layer()->SetMasksToBounds(true); |
106 | 104 |
107 message_list_view_.reset(new MessageListView(top_down)); | 105 message_list_view_.reset(new MessageListView()); |
108 message_list_view_->set_owned_by_client(); | 106 message_list_view_->set_owned_by_client(); |
109 message_list_view_->AddObserver(this); | 107 message_list_view_->AddObserver(this); |
110 | 108 |
111 // We want to swap the contents of the scroll view between the empty list | 109 // 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 | 110 // view and the message list view, without constructing them afresh each |
113 // time. So, since the scroll view deletes old contents each time you | 111 // 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 | 112 // 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 | 113 // an intermediate view for the contents whose children we can swap in and |
116 // out. | 114 // out. |
117 views::View* scroller_contents = new views::View(); | 115 views::View* scroller_contents = new views::View(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 void MessageCenterView::Layout() { | 206 void MessageCenterView::Layout() { |
209 if (is_closing_) | 207 if (is_closing_) |
210 return; | 208 return; |
211 | 209 |
212 int button_height = button_bar_->GetHeightForWidth(width()) + | 210 int button_height = button_bar_->GetHeightForWidth(width()) + |
213 button_bar_->GetInsets().height(); | 211 button_bar_->GetInsets().height(); |
214 // Skip unnecessary re-layout of contents during the resize animation. | 212 // Skip unnecessary re-layout of contents during the resize animation. |
215 bool animating = settings_transition_animation_ && | 213 bool animating = settings_transition_animation_ && |
216 settings_transition_animation_->is_animating(); | 214 settings_transition_animation_->is_animating(); |
217 if (animating && settings_transition_animation_->current_part_index() == 0) { | 215 if (animating && settings_transition_animation_->current_part_index() == 0) { |
218 if (!top_down_) { | 216 button_bar_->SetBounds(0, height() - button_height, width(), button_height); |
219 button_bar_->SetBounds( | |
220 0, height() - button_height, width(), button_height); | |
221 } | |
222 return; | 217 return; |
223 } | 218 } |
224 | 219 |
225 scroller_->SetBounds(0, | 220 scroller_->SetBounds(0, |
226 top_down_ ? button_height : 0, | 221 0, |
227 width(), | 222 width(), |
228 height() - button_height); | 223 height() - button_height); |
229 settings_view_->SetBounds(0, | 224 settings_view_->SetBounds(0, |
230 top_down_ ? button_height : 0, | 225 0, |
231 width(), | 226 width(), |
232 height() - button_height); | 227 height() - button_height); |
233 | 228 |
234 bool is_scrollable = false; | 229 bool is_scrollable = false; |
235 if (scroller_->visible()) | 230 if (scroller_->visible()) |
236 is_scrollable = scroller_->height() < message_list_view_->height(); | 231 is_scrollable = scroller_->height() < message_list_view_->height(); |
237 else if (settings_view_->visible()) | 232 else if (settings_view_->visible()) |
238 is_scrollable = settings_view_->IsScrollable(); | 233 is_scrollable = settings_view_->IsScrollable(); |
239 | 234 |
240 if (!animating) { | 235 if (!animating) { |
241 if (is_scrollable) { | 236 if (is_scrollable) { |
242 // Draw separator line on the top of the button bar if it is on the bottom | 237 // Draw separator line on the top of the button bar if it is on the bottom |
243 // or draw it at the bottom if the bar is on the top. | 238 // or draw it at the bottom if the bar is on the top. |
244 button_bar_->SetBorder(views::CreateSolidSidedBorder( | 239 button_bar_->SetBorder(views::CreateSolidSidedBorder( |
245 top_down_ ? 0 : 1, 0, top_down_ ? 1 : 0, 0, kFooterDelimiterColor)); | 240 1, 0, 0, 0, kFooterDelimiterColor)); |
246 } else { | 241 } else { |
247 button_bar_->SetBorder( | 242 button_bar_->SetBorder( |
248 views::CreateEmptyBorder(top_down_ ? 0 : 1, 0, top_down_ ? 1 : 0, 0)); | 243 views::CreateEmptyBorder(1, 0, 0, 0)); |
249 } | 244 } |
250 button_bar_->SchedulePaint(); | 245 button_bar_->SchedulePaint(); |
251 } | 246 } |
252 button_bar_->SetBounds(0, | 247 button_bar_->SetBounds(0, |
253 top_down_ ? 0 : height() - button_height, | 248 height() - button_height, |
254 width(), | 249 width(), |
255 button_height); | 250 button_height); |
256 if (GetWidget()) | 251 if (GetWidget()) |
257 GetWidget()->GetRootView()->SchedulePaint(); | 252 GetWidget()->GetRootView()->SchedulePaint(); |
258 } | 253 } |
259 | 254 |
260 gfx::Size MessageCenterView::GetPreferredSize() const { | 255 gfx::Size MessageCenterView::GetPreferredSize() const { |
261 if (settings_transition_animation_ && | 256 if (settings_transition_animation_ && |
262 settings_transition_animation_->is_animating()) { | 257 settings_transition_animation_->is_animating()) { |
263 int content_width = | 258 int content_width = |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 // Disable the close-all button since no notification is visible. | 637 // Disable the close-all button since no notification is visible. |
643 button_bar_->SetCloseAllButtonEnabled(false); | 638 button_bar_->SetCloseAllButtonEnabled(false); |
644 } | 639 } |
645 } | 640 } |
646 | 641 |
647 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { | 642 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { |
648 message_list_view_->AddNotificationAt(view, 0); | 643 message_list_view_->AddNotificationAt(view, 0); |
649 } | 644 } |
650 | 645 |
651 } // namespace message_center | 646 } // namespace message_center |
OLD | NEW |