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

Side by Side Diff: ash/wm/shelf_layout_manager.cc

Issue 10384217: Add left/right layout support for uber tray. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to resolve patching issue. Created 8 years, 7 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
« no previous file with comments | « ash/system/tray/tray_constants.cc ('k') | ash/wm/status_area_layout_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/wm/shelf_layout_manager.h" 5 #include "ash/wm/shelf_layout_manager.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 LayoutShelf(); 186 LayoutShelf();
187 } 187 }
188 188
189 void ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { 189 void ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) {
190 if (alignment_ == alignment) 190 if (alignment_ == alignment)
191 return; 191 return;
192 192
193 alignment_ = alignment; 193 alignment_ = alignment;
194 if (launcher_) 194 if (launcher_)
195 launcher_->SetAlignment(alignment); 195 launcher_->SetAlignment(alignment);
196 if (Shell::GetInstance()->tray())
197 Shell::GetInstance()->tray()->SetShelfAlignment(alignment);
196 LayoutShelf(); 198 LayoutShelf();
197 } 199 }
198 200
199 gfx::Rect ShelfLayoutManager::GetIdealBounds() { 201 gfx::Rect ShelfLayoutManager::GetIdealBounds() {
200 // TODO: this is wrong. Figure out what monitor shelf is on and everything 202 // TODO: this is wrong. Figure out what monitor shelf is on and everything
201 // should be based on it. 203 // should be based on it.
202 gfx::Rect bounds( 204 gfx::Rect bounds(
203 gfx::Screen::GetMonitorNearestWindow(status_->GetNativeView()).bounds()); 205 gfx::Screen::GetMonitorNearestWindow(status_->GetNativeView()).bounds());
204 int width = 0, height = 0; 206 int width = 0, height = 0;
205 GetShelfSize(&width, &height); 207 GetShelfSize(&width, &height);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 387 }
386 388
387 void ShelfLayoutManager::StopAnimating() { 389 void ShelfLayoutManager::StopAnimating() {
388 if (launcher_widget()) 390 if (launcher_widget())
389 GetLayer(launcher_widget())->GetAnimator()->StopAnimating(); 391 GetLayer(launcher_widget())->GetAnimator()->StopAnimating();
390 GetLayer(status_)->GetAnimator()->StopAnimating(); 392 GetLayer(status_)->GetAnimator()->StopAnimating();
391 } 393 }
392 394
393 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { 395 void ShelfLayoutManager::GetShelfSize(int* width, int* height) {
394 *width = *height = 0; 396 *width = *height = 0;
395 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); 397 gfx::Size status_size = Shell::GetInstance()->tray() ?
398 status_->GetContentsView()->GetPreferredSize() : gfx::Size();
396 gfx::Size launcher_size = launcher_ ? 399 gfx::Size launcher_size = launcher_ ?
397 launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size(); 400 launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size();
398 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { 401 if (alignment_ == SHELF_ALIGNMENT_BOTTOM)
399 *height = std::max(launcher_size.height(), status_bounds.height()); 402 *height = std::max(launcher_size.height(), status_size.height());
400 } else { 403 else
401 // TODO: include status when supports alignment. 404 *width = std::max(launcher_size.width(), status_size.width());
sky 2012/05/18 15:01:48 Does the tray now support left/right alignment tha
402 *width = launcher_size.width();
403 }
404 } 405 }
405 406
406 void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset, 407 void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset,
407 gfx::Rect* bounds) const { 408 gfx::Rect* bounds) const {
408 switch (alignment_) { 409 switch (alignment_) {
409 case SHELF_ALIGNMENT_BOTTOM: 410 case SHELF_ALIGNMENT_BOTTOM:
410 bounds->Inset(gfx::Insets(0, 0, inset, 0)); 411 bounds->Inset(gfx::Insets(0, 0, inset, 0));
411 break; 412 break;
412 case SHELF_ALIGNMENT_LEFT: 413 case SHELF_ALIGNMENT_LEFT:
413 bounds->Inset(gfx::Insets(0, inset, 0, 0)); 414 bounds->Inset(gfx::Insets(0, inset, 0, 0));
414 break; 415 break;
415 case SHELF_ALIGNMENT_RIGHT: 416 case SHELF_ALIGNMENT_RIGHT:
416 bounds->Inset(gfx::Insets(0, 0, 0, inset)); 417 bounds->Inset(gfx::Insets(0, 0, 0, inset));
417 break; 418 break;
418 } 419 }
419 } 420 }
420 421
421 void ShelfLayoutManager::CalculateTargetBounds( 422 void ShelfLayoutManager::CalculateTargetBounds(
422 const State& state, 423 const State& state,
423 TargetBounds* target_bounds) { 424 TargetBounds* target_bounds) {
424 const gfx::Rect& available_bounds( 425 const gfx::Rect& available_bounds(
425 status_->GetNativeView()->GetRootWindow()->bounds()); 426 status_->GetNativeView()->GetRootWindow()->bounds());
426 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); 427 gfx::Size status_size = Shell::GetInstance()->tray() ?
sky 2012/05/18 15:01:48 Why does this and GetShelfSize need to query for t
jennyz 2012/05/18 22:05:10 Done. I updated the widget size when changing layo
428 status_->GetContentsView()->GetPreferredSize() : gfx::Size();
429
427 gfx::Size launcher_size = launcher_ ? 430 gfx::Size launcher_size = launcher_ ?
428 launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size(); 431 launcher_widget()->GetContentsView()->GetPreferredSize() : gfx::Size();
429 int shelf_size = 0; 432 int shelf_size = 0;
430 int shelf_width = 0, shelf_height = 0; 433 int shelf_width = 0, shelf_height = 0;
431 GetShelfSize(&shelf_width, &shelf_height); 434 GetShelfSize(&shelf_width, &shelf_height);
432 if (state.visibility_state == VISIBLE || 435 if (state.visibility_state == VISIBLE ||
433 (state.visibility_state == AUTO_HIDE && 436 (state.visibility_state == AUTO_HIDE &&
434 state.auto_hide_state == AUTO_HIDE_SHOWN)) { 437 state.auto_hide_state == AUTO_HIDE_SHOWN)) {
435 shelf_size = std::max(shelf_width, shelf_height); 438 shelf_size = std::max(shelf_width, shelf_height);
436 } else if (state.visibility_state == AUTO_HIDE && 439 } else if (state.visibility_state == AUTO_HIDE &&
437 state.auto_hide_state == AUTO_HIDE_HIDDEN) { 440 state.auto_hide_state == AUTO_HIDE_HIDDEN) {
438 shelf_size = kAutoHideSize; 441 shelf_size = kAutoHideSize;
439 } 442 }
440 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { 443 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) {
441 int y = available_bounds.bottom(); 444 int y = available_bounds.bottom();
442 y -= shelf_size; 445 y -= shelf_size;
443 // The status widget should extend to the bottom and right edges. 446 // The status widget should extend to the bottom and right edges.
444 target_bounds->status_bounds = gfx::Rect( 447 target_bounds->status_bounds = gfx::Rect(
445 base::i18n::IsRTL() ? available_bounds.x() : 448 base::i18n::IsRTL() ? available_bounds.x() :
446 available_bounds.right() - status_bounds.width(), 449 available_bounds.right() - status_size.width(),
447 y + shelf_height - status_bounds.height(), 450 y + shelf_height - status_size.height(),
448 status_bounds.width(), status_bounds.height()); 451 status_size.width(), status_size.height());
452
449 if (launcher_widget()) { 453 if (launcher_widget()) {
450 target_bounds->launcher_bounds = gfx::Rect( 454 target_bounds->launcher_bounds = gfx::Rect(
451 available_bounds.x(), 455 available_bounds.x(),
452 y + (shelf_height - launcher_size.height()) / 2, 456 y + (shelf_height - launcher_size.height()) / 2,
453 available_bounds.width(), 457 available_bounds.width(),
454 launcher_size.height()); 458 launcher_size.height());
455 } 459 }
456 target_bounds->work_area_insets.Set( 460 target_bounds->work_area_insets.Set(
457 0, 0, GetWorkAreaSize(state, shelf_height), 0); 461 0, 0, GetWorkAreaSize(state, shelf_height), 0);
458 } else { 462 } else {
459 int x = (alignment_ == SHELF_ALIGNMENT_LEFT) ? 463 int x = (alignment_ == SHELF_ALIGNMENT_LEFT) ?
460 available_bounds.x() + shelf_size - shelf_width : 464 available_bounds.x() + shelf_size - shelf_width :
461 available_bounds.right() - shelf_size; 465 available_bounds.right() - shelf_size;
462 target_bounds->status_bounds = gfx::Rect( 466 target_bounds->status_bounds = gfx::Rect(
463 x, available_bounds.bottom() - status_bounds.height(), 467 x, available_bounds.bottom() - status_size.height(),
464 shelf_width, status_bounds.height()); 468 shelf_width, status_size.height());
465 if (launcher_widget()) { 469 if (launcher_widget()) {
466 target_bounds->launcher_bounds = gfx::Rect( 470 target_bounds->launcher_bounds = gfx::Rect(
467 x, 471 x,
468 available_bounds.y(), 472 available_bounds.y(),
469 launcher_size.width(), 473 launcher_size.width(),
470 available_bounds.height()); 474 available_bounds.height());
471 } 475 }
472 if (alignment_ == SHELF_ALIGNMENT_LEFT) { 476 if (alignment_ == SHELF_ALIGNMENT_LEFT) {
473 target_bounds->work_area_insets.Set( 477 target_bounds->work_area_insets.Set(
474 0, GetWorkAreaSize(state, shelf_width), 0, 0); 478 0, GetWorkAreaSize(state, shelf_width), 0, 0);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { 571 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const {
568 if (state.visibility_state == VISIBLE) 572 if (state.visibility_state == VISIBLE)
569 return size; 573 return size;
570 if (state.visibility_state == AUTO_HIDE) 574 if (state.visibility_state == AUTO_HIDE)
571 return kAutoHideSize; 575 return kAutoHideSize;
572 return 0; 576 return 0;
573 } 577 }
574 578
575 } // namespace internal 579 } // namespace internal
576 } // namespace ash 580 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_constants.cc ('k') | ash/wm/status_area_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698