OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/web_notification/web_notification_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_layout_manager_observer.h" | 10 #include "ash/shelf/shelf_layout_manager_observer.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 StopObserving(); | 117 StopObserving(); |
118 } | 118 } |
119 | 119 |
120 void WorkAreaObserver::SetSystemTrayHeight(int height) { | 120 void WorkAreaObserver::SetSystemTrayHeight(int height) { |
121 system_tray_height_ = height; | 121 system_tray_height_ = height; |
122 | 122 |
123 // If the shelf is shown during auto-hide state, the distance from the edge | 123 // If the shelf is shown during auto-hide state, the distance from the edge |
124 // should be reduced by the height of shelf's shown height. | 124 // should be reduced by the height of shelf's shown height. |
125 if (shelf_ && shelf_->visibility_state() == SHELF_AUTO_HIDE && | 125 if (shelf_ && shelf_->visibility_state() == SHELF_AUTO_HIDE && |
126 shelf_->auto_hide_state() == SHELF_AUTO_HIDE_SHOWN) { | 126 shelf_->auto_hide_state() == SHELF_AUTO_HIDE_SHOWN) { |
127 system_tray_height_ -= ShelfLayoutManager::GetPreferredShelfSize() - | 127 system_tray_height_ -= kShelfSize - ShelfLayoutManager::kAutoHideSize; |
128 ShelfLayoutManager::kAutoHideSize; | |
129 } | 128 } |
130 | 129 |
131 if (system_tray_height_ > 0 && ash::switches::UseAlternateShelfLayout()) | 130 if (system_tray_height_ > 0) |
132 system_tray_height_ += message_center::kMarginBetweenItems; | 131 system_tray_height_ += message_center::kMarginBetweenItems; |
133 | 132 |
134 if (!shelf_) | 133 if (!shelf_) |
135 return; | 134 return; |
136 | 135 |
137 OnAutoHideStateChanged(shelf_->auto_hide_state()); | 136 OnAutoHideStateChanged(shelf_->auto_hide_state()); |
138 } | 137 } |
139 | 138 |
140 void WorkAreaObserver::StartObserving( | 139 void WorkAreaObserver::StartObserving( |
141 message_center::MessagePopupCollection* collection, | 140 message_center::MessagePopupCollection* collection, |
(...skipping 25 matching lines...) Expand all Loading... |
167 | 166 |
168 void WorkAreaObserver::OnAutoHideStateChanged(ShelfAutoHideState new_state) { | 167 void WorkAreaObserver::OnAutoHideStateChanged(ShelfAutoHideState new_state) { |
169 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( | 168 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( |
170 shelf_->shelf_widget()->GetNativeView()); | 169 shelf_->shelf_widget()->GetNativeView()); |
171 gfx::Rect work_area = display.work_area(); | 170 gfx::Rect work_area = display.work_area(); |
172 int width = 0; | 171 int width = 0; |
173 if ((shelf_->visibility_state() == SHELF_AUTO_HIDE) && | 172 if ((shelf_->visibility_state() == SHELF_AUTO_HIDE) && |
174 new_state == SHELF_AUTO_HIDE_SHOWN) { | 173 new_state == SHELF_AUTO_HIDE_SHOWN) { |
175 // Since the work_area is already reduced by kAutoHideSize, the inset width | 174 // Since the work_area is already reduced by kAutoHideSize, the inset width |
176 // should be just the difference. | 175 // should be just the difference. |
177 width = ShelfLayoutManager::GetPreferredShelfSize() - | 176 width = kShelfSize - ShelfLayoutManager::kAutoHideSize; |
178 ShelfLayoutManager::kAutoHideSize; | |
179 } | 177 } |
180 work_area.Inset(shelf_->SelectValueForShelfAlignment( | 178 work_area.Inset(shelf_->SelectValueForShelfAlignment( |
181 gfx::Insets(0, 0, width, 0), | 179 gfx::Insets(0, 0, width, 0), |
182 gfx::Insets(0, width, 0, 0), | 180 gfx::Insets(0, width, 0, 0), |
183 gfx::Insets(0, 0, 0, width), | 181 gfx::Insets(0, 0, 0, width), |
184 gfx::Insets(width, 0, 0, 0))); | 182 gfx::Insets(width, 0, 0, 0))); |
185 if (system_tray_height_ > 0) { | 183 if (system_tray_height_ > 0) { |
186 work_area.set_height( | 184 work_area.set_height( |
187 std::max(0, work_area.height() - system_tray_height_)); | 185 std::max(0, work_area.height() - system_tray_height_)); |
188 if (shelf_->GetAlignment() == SHELF_ALIGNMENT_TOP) | 186 if (shelf_->GetAlignment() == SHELF_ALIGNMENT_TOP) |
(...skipping 24 matching lines...) Expand all Loading... |
213 views::TrayBubbleView::InitParams init_params = | 211 views::TrayBubbleView::InitParams init_params = |
214 bubble->GetInitParams(anchor_alignment); | 212 bubble->GetInitParams(anchor_alignment); |
215 views::View* anchor = tray->tray_container(); | 213 views::View* anchor = tray->tray_container(); |
216 if (anchor_alignment == views::TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { | 214 if (anchor_alignment == views::TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
217 gfx::Point bounds(anchor->width() / 2, 0); | 215 gfx::Point bounds(anchor->width() / 2, 0); |
218 views::View::ConvertPointToWidget(anchor, &bounds); | 216 views::View::ConvertPointToWidget(anchor, &bounds); |
219 init_params.arrow_offset = bounds.x(); | 217 init_params.arrow_offset = bounds.x(); |
220 } | 218 } |
221 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( | 219 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( |
222 tray->GetBubbleWindowContainer(), anchor, tray, &init_params); | 220 tray->GetBubbleWindowContainer(), anchor, tray, &init_params); |
223 if (ash::switches::UseAlternateShelfLayout()) | 221 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
224 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | |
225 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); | 222 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); |
226 bubble->InitializeContents(bubble_view); | 223 bubble->InitializeContents(bubble_view); |
227 } | 224 } |
228 | 225 |
229 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } | 226 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } |
230 | 227 |
231 // Convenience accessors. | 228 // Convenience accessors. |
232 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } | 229 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } |
233 | 230 |
234 private: | 231 private: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 338 |
342 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { | 339 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { |
343 if (!ShouldShowMessageCenter()) | 340 if (!ShouldShowMessageCenter()) |
344 return false; | 341 return false; |
345 | 342 |
346 should_block_shelf_auto_hide_ = true; | 343 should_block_shelf_auto_hide_ = true; |
347 message_center::MessageCenterBubble* message_center_bubble = | 344 message_center::MessageCenterBubble* message_center_bubble = |
348 new message_center::MessageCenterBubble( | 345 new message_center::MessageCenterBubble( |
349 message_center(), | 346 message_center(), |
350 message_center_tray_.get(), | 347 message_center_tray_.get(), |
351 ash::switches::UseAlternateShelfLayout()); | 348 true); |
352 | 349 |
353 int max_height = 0; | 350 int max_height = 0; |
354 aura::Window* status_area_window = status_area_widget()->GetNativeView(); | 351 aura::Window* status_area_window = status_area_widget()->GetNativeView(); |
355 switch (GetShelfLayoutManager()->GetAlignment()) { | 352 switch (GetShelfLayoutManager()->GetAlignment()) { |
356 case SHELF_ALIGNMENT_BOTTOM: { | 353 case SHELF_ALIGNMENT_BOTTOM: { |
357 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds(); | 354 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds(); |
358 max_height = shelf_bounds.y(); | 355 max_height = shelf_bounds.y(); |
359 break; | 356 break; |
360 } | 357 } |
361 case SHELF_ALIGNMENT_TOP: { | 358 case SHELF_ALIGNMENT_TOP: { |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 617 |
621 message_center::MessageCenterBubble* | 618 message_center::MessageCenterBubble* |
622 WebNotificationTray::GetMessageCenterBubbleForTest() { | 619 WebNotificationTray::GetMessageCenterBubbleForTest() { |
623 if (!message_center_bubble()) | 620 if (!message_center_bubble()) |
624 return NULL; | 621 return NULL; |
625 return static_cast<message_center::MessageCenterBubble*>( | 622 return static_cast<message_center::MessageCenterBubble*>( |
626 message_center_bubble()->bubble()); | 623 message_center_bubble()->bubble()); |
627 } | 624 } |
628 | 625 |
629 } // namespace ash | 626 } // namespace ash |
OLD | NEW |