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

Side by Side Diff: ash/system/web_notification/web_notification_tray.cc

Issue 140323010: Ash:Shelf - Cleanup of Alternate Shelf (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ButtonSize and ButtonSpacing moved to shelf_constants Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
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
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
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
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 328
332 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { 329 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) {
333 if (!ShouldShowMessageCenter()) 330 if (!ShouldShowMessageCenter())
334 return false; 331 return false;
335 332
336 should_block_shelf_auto_hide_ = true; 333 should_block_shelf_auto_hide_ = true;
337 message_center::MessageCenterBubble* message_center_bubble = 334 message_center::MessageCenterBubble* message_center_bubble =
338 new message_center::MessageCenterBubble( 335 new message_center::MessageCenterBubble(
339 message_center(), 336 message_center(),
340 message_center_tray_.get(), 337 message_center_tray_.get(),
341 ash::switches::UseAlternateShelfLayout()); 338 true);
342 339
343 int max_height = 0; 340 int max_height = 0;
344 aura::Window* status_area_window = status_area_widget()->GetNativeView(); 341 aura::Window* status_area_window = status_area_widget()->GetNativeView();
345 switch (GetShelfLayoutManager()->GetAlignment()) { 342 switch (GetShelfLayoutManager()->GetAlignment()) {
346 case SHELF_ALIGNMENT_BOTTOM: { 343 case SHELF_ALIGNMENT_BOTTOM: {
347 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds(); 344 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds();
348 max_height = shelf_bounds.y(); 345 max_height = shelf_bounds.y();
349 break; 346 break;
350 } 347 }
351 case SHELF_ALIGNMENT_TOP: { 348 case SHELF_ALIGNMENT_TOP: {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 bool WebNotificationTray::ShowPopups() { 399 bool WebNotificationTray::ShowPopups() {
403 if (message_center_bubble()) 400 if (message_center_bubble())
404 return false; 401 return false;
405 402
406 popup_collection_.reset(new message_center::MessagePopupCollection( 403 popup_collection_.reset(new message_center::MessagePopupCollection(
407 ash::Shell::GetContainer( 404 ash::Shell::GetContainer(
408 GetWidget()->GetNativeView()->GetRootWindow(), 405 GetWidget()->GetNativeView()->GetRootWindow(),
409 internal::kShellWindowId_StatusContainer), 406 internal::kShellWindowId_StatusContainer),
410 message_center(), 407 message_center(),
411 message_center_tray_.get(), 408 message_center_tray_.get(),
412 ash::switches::UseAlternateShelfLayout())); 409 true));
413 work_area_observer_->StartObserving( 410 work_area_observer_->StartObserving(
414 popup_collection_.get(), GetWidget()->GetNativeView()->GetRootWindow()); 411 popup_collection_.get(), GetWidget()->GetNativeView()->GetRootWindow());
415 return true; 412 return true;
416 } 413 }
417 414
418 void WebNotificationTray::HidePopups() { 415 void WebNotificationTray::HidePopups() {
419 DCHECK(popup_collection_.get()); 416 DCHECK(popup_collection_.get());
420 417
421 popup_collection_->MarkAllPopupsShown(); 418 popup_collection_->MarkAllPopupsShown();
422 popup_collection_.reset(); 419 popup_collection_.reset();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 618
622 message_center::MessageCenterBubble* 619 message_center::MessageCenterBubble*
623 WebNotificationTray::GetMessageCenterBubbleForTest() { 620 WebNotificationTray::GetMessageCenterBubbleForTest() {
624 if (!message_center_bubble()) 621 if (!message_center_bubble())
625 return NULL; 622 return NULL;
626 return static_cast<message_center::MessageCenterBubble*>( 623 return static_cast<message_center::MessageCenterBubble*>(
627 message_center_bubble()->bubble()); 624 message_center_bubble()->bubble());
628 } 625 }
629 626
630 } // namespace ash 627 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698