Chromium Code Reviews| 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/tray/tray_background_view.h" | 5 #include "ash/system/tray/tray_background_view.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/screen_util.h" | 9 #include "ash/screen_util.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 | 205 |
| 206 canvas->TileImageInt(*middle, | 206 canvas->TileImageInt(*middle, |
| 207 middle_bounds.x(), | 207 middle_bounds.x(), |
| 208 middle_bounds.y(), | 208 middle_bounds.y(), |
| 209 middle_bounds.width(), | 209 middle_bounds.width(), |
| 210 middle_bounds.height()); | 210 middle_bounds.height()); |
| 211 } | 211 } |
| 212 | 212 |
| 213 // Overridden from views::Background. | 213 // Overridden from views::Background. |
| 214 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { | 214 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { |
| 215 if (ash::switches::UseAlternateShelfLayout()) { | 215 PaintForAlternateShelf(canvas, view); |
| 216 PaintForAlternateShelf(canvas, view); | |
| 217 } else { | |
| 218 SkPaint paint; | |
| 219 paint.setAntiAlias(true); | |
| 220 paint.setStyle(SkPaint::kFill_Style); | |
| 221 paint.setColor(color_); | |
| 222 SkPath path; | |
| 223 gfx::Rect bounds(view->GetLocalBounds()); | |
| 224 SkScalar radius = SkIntToScalar(kTrayRoundedBorderRadius); | |
| 225 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); | |
| 226 canvas->DrawPath(path, paint); | |
| 227 } | |
| 228 } | 216 } |
| 229 | 217 |
| 230 SkColor color_; | 218 SkColor color_; |
| 231 // Reference to the TrayBackgroundView for which this is a background. | 219 // Reference to the TrayBackgroundView for which this is a background. |
| 232 TrayBackgroundView* tray_background_view_; | 220 TrayBackgroundView* tray_background_view_; |
| 233 | 221 |
| 234 // References to the images used as backgrounds, they are owned by the | 222 // References to the images used as backgrounds, they are owned by the |
| 235 // resource bundle class. | 223 // resource bundle class. |
| 236 const gfx::ImageSkia* leading_images_[kNumOrientations][kNumStates]; | 224 const gfx::ImageSkia* leading_images_[kNumOrientations][kNumStates]; |
| 237 const gfx::ImageSkia* middle_images_[kNumOrientations][kNumStates]; | 225 const gfx::ImageSkia* middle_images_[kNumOrientations][kNumStates]; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 const ViewHierarchyChangedDetails& details) { | 259 const ViewHierarchyChangedDetails& details) { |
| 272 if (details.parent == this) | 260 if (details.parent == this) |
| 273 PreferredSizeChanged(); | 261 PreferredSizeChanged(); |
| 274 } | 262 } |
| 275 | 263 |
| 276 void TrayBackgroundView::TrayContainer::UpdateLayout() { | 264 void TrayBackgroundView::TrayContainer::UpdateLayout() { |
| 277 // Adjust the size of status tray dark background by adding additional | 265 // Adjust the size of status tray dark background by adding additional |
| 278 // empty border. | 266 // empty border. |
| 279 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || | 267 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || |
| 280 alignment_ == SHELF_ALIGNMENT_TOP) { | 268 alignment_ == SHELF_ALIGNMENT_TOP) { |
| 281 int vertical_padding = kTrayContainerVerticalPaddingBottomAlignment; | 269 int vertical_padding = kPaddingFromEdgeOfShelf; |
| 282 int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment; | 270 int horizontal_padding = kPaddingFromEdgeOfShelf; |
| 283 if (ash::switches::UseAlternateShelfLayout()) { | |
| 284 vertical_padding = kPaddingFromEdgeOfShelf; | |
| 285 horizontal_padding = kPaddingFromEdgeOfShelf; | |
| 286 } | |
| 287 set_border(views::Border::CreateEmptyBorder( | 271 set_border(views::Border::CreateEmptyBorder( |
| 288 vertical_padding, | 272 vertical_padding, |
| 289 horizontal_padding, | 273 horizontal_padding, |
| 290 vertical_padding, | 274 vertical_padding, |
| 291 horizontal_padding)); | 275 horizontal_padding)); |
| 292 | 276 |
| 293 views::BoxLayout* layout = | 277 views::BoxLayout* layout = |
| 294 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 278 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
| 295 layout->set_spread_blank_space(true); | 279 layout->set_spread_blank_space(true); |
| 296 views::View::SetLayoutManager(layout); | 280 views::View::SetLayoutManager(layout); |
| 297 } else { | 281 } else { |
| 298 int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment; | 282 int vertical_padding = kPaddingFromEdgeOfShelf; |
| 299 int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment; | 283 int horizontal_padding = kPaddingFromEdgeOfShelf; |
| 300 if (ash::switches::UseAlternateShelfLayout()) { | |
| 301 vertical_padding = kPaddingFromEdgeOfShelf; | |
| 302 horizontal_padding = kPaddingFromEdgeOfShelf; | |
| 303 } | |
| 304 set_border(views::Border::CreateEmptyBorder( | 284 set_border(views::Border::CreateEmptyBorder( |
| 305 vertical_padding, | 285 vertical_padding, |
| 306 horizontal_padding, | 286 horizontal_padding, |
| 307 vertical_padding, | 287 vertical_padding, |
| 308 horizontal_padding)); | 288 horizontal_padding)); |
| 309 | 289 |
| 310 views::BoxLayout* layout = | 290 views::BoxLayout* layout = |
| 311 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); | 291 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); |
| 312 layout->set_spread_blank_space(true); | 292 layout->set_spread_blank_space(true); |
| 313 views::View::SetLayoutManager(layout); | 293 views::View::SetLayoutManager(layout); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 GetWidget()->AddObserver(widget_observer_.get()); | 332 GetWidget()->AddObserver(widget_observer_.get()); |
| 353 SetBorder(); | 333 SetBorder(); |
| 354 } | 334 } |
| 355 | 335 |
| 356 const char* TrayBackgroundView::GetClassName() const { | 336 const char* TrayBackgroundView::GetClassName() const { |
| 357 return kViewClassName; | 337 return kViewClassName; |
| 358 } | 338 } |
| 359 | 339 |
| 360 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { | 340 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { |
| 361 hovered_ = true; | 341 hovered_ = true; |
| 362 if (!background_ || draw_background_as_active_ || | |
| 363 ash::switches::UseAlternateShelfLayout()) | |
| 364 return; | |
| 365 hover_background_animator_.SetPaintsBackground( | |
| 366 true, BACKGROUND_CHANGE_ANIMATE); | |
| 367 } | 342 } |
| 368 | 343 |
| 369 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { | 344 void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) { |
| 370 hovered_ = false; | 345 hovered_ = false; |
| 371 if (!background_ || draw_background_as_active_ || | |
| 372 ash::switches::UseAlternateShelfLayout()) | |
| 373 return; | |
| 374 hover_background_animator_.SetPaintsBackground( | |
| 375 false, BACKGROUND_CHANGE_ANIMATE); | |
| 376 } | 346 } |
| 377 | 347 |
| 378 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { | 348 void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { |
| 379 PreferredSizeChanged(); | 349 PreferredSizeChanged(); |
| 380 } | 350 } |
| 381 | 351 |
| 382 void TrayBackgroundView::GetAccessibleState(ui::AccessibleViewState* state) { | 352 void TrayBackgroundView::GetAccessibleState(ui::AccessibleViewState* state) { |
| 383 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 353 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
| 384 state->name = GetAccessibleNameForTray(); | 354 state->name = GetAccessibleNameForTray(); |
| 385 } | 355 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 399 // The tray itself expands to the right and bottom edge of the screen to make | 369 // The tray itself expands to the right and bottom edge of the screen to make |
| 400 // sure clicking on the edges brings up the popup. However, the focus border | 370 // sure clicking on the edges brings up the popup. However, the focus border |
| 401 // should be only around the container. | 371 // should be only around the container. |
| 402 return GetContentsBounds(); | 372 return GetContentsBounds(); |
| 403 } | 373 } |
| 404 | 374 |
| 405 void TrayBackgroundView::UpdateBackground(int alpha) { | 375 void TrayBackgroundView::UpdateBackground(int alpha) { |
| 406 // The animator should never fire when the alternate shelf layout is used. | 376 // The animator should never fire when the alternate shelf layout is used. |
| 407 if (!background_ || draw_background_as_active_) | 377 if (!background_ || draw_background_as_active_) |
| 408 return; | 378 return; |
| 409 DCHECK(!ash::switches::UseAlternateShelfLayout()); | |
| 410 background_->set_alpha(hide_background_animator_.alpha() + | 379 background_->set_alpha(hide_background_animator_.alpha() + |
|
Harry McCleave
2014/01/23 02:06:16
Should I remove this code now or in the later patc
| |
| 411 hover_background_animator_.alpha()); | 380 hover_background_animator_.alpha()); |
| 412 SchedulePaint(); | 381 SchedulePaint(); |
| 413 } | 382 } |
| 414 | 383 |
| 415 void TrayBackgroundView::SetContents(views::View* contents) { | 384 void TrayBackgroundView::SetContents(views::View* contents) { |
| 416 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 385 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 417 AddChildView(contents); | 386 AddChildView(contents); |
| 418 } | 387 } |
| 419 | 388 |
| 420 void TrayBackgroundView::SetPaintsBackground( | 389 void TrayBackgroundView::SetPaintsBackground( |
| 421 bool value, BackgroundAnimatorChangeType change_type) { | 390 bool value, BackgroundAnimatorChangeType change_type) { |
| 422 DCHECK(!ash::switches::UseAlternateShelfLayout()); | |
| 423 hide_background_animator_.SetPaintsBackground(value, change_type); | 391 hide_background_animator_.SetPaintsBackground(value, change_type); |
| 424 } | 392 } |
| 425 | 393 |
| 426 void TrayBackgroundView::SetContentsBackground() { | 394 void TrayBackgroundView::SetContentsBackground() { |
| 427 background_ = new internal::TrayBackground(this); | 395 background_ = new internal::TrayBackground(this); |
| 428 tray_container_->set_background(background_); | 396 tray_container_->set_background(background_); |
| 429 } | 397 } |
| 430 | 398 |
| 431 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { | 399 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { |
| 432 return ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); | 400 return ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); |
| 433 } | 401 } |
| 434 | 402 |
| 435 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 403 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
| 436 shelf_alignment_ = alignment; | 404 shelf_alignment_ = alignment; |
| 437 SetBorder(); | 405 SetBorder(); |
| 438 tray_container_->SetAlignment(alignment); | 406 tray_container_->SetAlignment(alignment); |
| 439 } | 407 } |
| 440 | 408 |
| 441 void TrayBackgroundView::SetBorder() { | 409 void TrayBackgroundView::SetBorder() { |
| 442 views::View* parent = status_area_widget_->status_area_widget_delegate(); | 410 views::View* parent = status_area_widget_->status_area_widget_delegate(); |
| 443 // Tray views are laid out right-to-left or bottom-to-top | 411 // Tray views are laid out right-to-left or bottom-to-top |
| 444 bool on_edge = (this == parent->child_at(0)); | 412 bool on_edge = (this == parent->child_at(0)); |
| 445 int left_edge, top_edge, right_edge, bottom_edge; | 413 int left_edge, top_edge, right_edge, bottom_edge; |
| 446 if (ash::switches::UseAlternateShelfLayout()) { | 414 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
| 447 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | 415 top_edge = ShelfLayoutManager::kShelfItemInset; |
| 448 top_edge = ShelfLayoutManager::kShelfItemInset; | 416 left_edge = 0; |
| 449 left_edge = 0; | 417 bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() - |
| 450 bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() - | 418 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); |
| 451 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); | 419 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
| 452 right_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 420 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { |
| 453 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { | 421 top_edge = 0; |
| 454 top_edge = 0; | 422 left_edge = ShelfLayoutManager::GetPreferredShelfSize() - |
| 455 left_edge = ShelfLayoutManager::GetPreferredShelfSize() - | 423 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); |
| 456 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); | 424 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
| 457 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 425 right_edge = ShelfLayoutManager::kShelfItemInset; |
| 458 right_edge = ShelfLayoutManager::kShelfItemInset; | 426 } else { // SHELF_ALIGNMENT_RIGHT |
| 459 } else { // SHELF_ALIGNMENT_RIGHT | 427 top_edge = 0; |
| 460 top_edge = 0; | 428 left_edge = ShelfLayoutManager::kShelfItemInset; |
| 461 left_edge = ShelfLayoutManager::kShelfItemInset; | 429 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; |
| 462 bottom_edge = on_edge ? kPaddingFromEdgeOfShelf : 0; | 430 right_edge = ShelfLayoutManager::GetPreferredShelfSize() - |
| 463 right_edge = ShelfLayoutManager::GetPreferredShelfSize() - | 431 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); |
| 464 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); | |
| 465 } | |
| 466 } else { | |
| 467 // Change the border padding for different shelf alignment. | |
| 468 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | |
| 469 top_edge = 0; | |
| 470 left_edge = 0; | |
| 471 bottom_edge = on_edge ? kPaddingFromBottomOfScreenBottomAlignment : | |
| 472 kPaddingFromBottomOfScreenBottomAlignment - 1; | |
| 473 right_edge = on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0; | |
| 474 } else if (shelf_alignment() == SHELF_ALIGNMENT_TOP) { | |
| 475 top_edge = on_edge ? kPaddingFromBottomOfScreenBottomAlignment : | |
| 476 kPaddingFromBottomOfScreenBottomAlignment - 1; | |
| 477 left_edge = 0; | |
| 478 bottom_edge = 0; | |
| 479 right_edge = on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0; | |
| 480 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { | |
| 481 top_edge = 0; | |
| 482 left_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; | |
| 483 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; | |
| 484 right_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; | |
| 485 } else { | |
| 486 top_edge = 0; | |
| 487 left_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; | |
| 488 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; | |
| 489 right_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; | |
| 490 } | |
| 491 } | 432 } |
| 492 set_border(views::Border::CreateEmptyBorder( | 433 set_border(views::Border::CreateEmptyBorder( |
| 493 top_edge, left_edge, bottom_edge, right_edge)); | 434 top_edge, left_edge, bottom_edge, right_edge)); |
| 494 } | 435 } |
| 495 | 436 |
| 496 void TrayBackgroundView::InitializeBubbleAnimations( | 437 void TrayBackgroundView::InitializeBubbleAnimations( |
| 497 views::Widget* bubble_widget) { | 438 views::Widget* bubble_widget) { |
| 498 views::corewm::SetWindowVisibilityAnimationType( | 439 views::corewm::SetWindowVisibilityAnimationType( |
| 499 bubble_widget->GetNativeWindow(), | 440 bubble_widget->GetNativeWindow(), |
| 500 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | 441 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 515 gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( | 456 gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( |
| 516 views::Widget* anchor_widget, | 457 views::Widget* anchor_widget, |
| 517 TrayBubbleView::AnchorType anchor_type, | 458 TrayBubbleView::AnchorType anchor_type, |
| 518 TrayBubbleView::AnchorAlignment anchor_alignment) const { | 459 TrayBubbleView::AnchorAlignment anchor_alignment) const { |
| 519 gfx::Rect rect; | 460 gfx::Rect rect; |
| 520 if (anchor_widget && anchor_widget->IsVisible()) { | 461 if (anchor_widget && anchor_widget->IsVisible()) { |
| 521 rect = anchor_widget->GetWindowBoundsInScreen(); | 462 rect = anchor_widget->GetWindowBoundsInScreen(); |
| 522 if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) { | 463 if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) { |
| 523 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { | 464 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
| 524 bool rtl = base::i18n::IsRTL(); | 465 bool rtl = base::i18n::IsRTL(); |
| 525 if (!ash::switches::UseAlternateShelfLayout()) { | 466 rect.Inset( |
| 526 rect.Inset( | 467 rtl ? kAlternateLayoutBubblePaddingHorizontalSide : 0, |
| 527 rtl ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0, | 468 kAlternateLayoutBubblePaddingHorizontalBottom, |
| 528 kTrayBubbleAnchorTopInsetBottomAnchor, | 469 rtl ? 0 : kAlternateLayoutBubblePaddingHorizontalSide, |
| 529 rtl ? 0 : kPaddingFromRightEdgeOfScreenBottomAlignment, | 470 0); |
| 530 kPaddingFromBottomOfScreenBottomAlignment); | |
| 531 } else { | |
| 532 rect.Inset( | |
| 533 rtl ? kAlternateLayoutBubblePaddingHorizontalSide : 0, | |
| 534 kAlternateLayoutBubblePaddingHorizontalBottom, | |
| 535 rtl ? 0 : kAlternateLayoutBubblePaddingHorizontalSide, | |
| 536 0); | |
| 537 } | |
| 538 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { | 471 } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) { |
| 539 if (!ash::switches::UseAlternateShelfLayout()) { | 472 rect.Inset(0, 0, kAlternateLayoutBubblePaddingVerticalSide + 4, |
| 540 rect.Inset(0, 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 5, | 473 kAlternateLayoutBubblePaddingVerticalBottom); |
| 541 kPaddingFromBottomOfScreenVerticalAlignment); | |
| 542 } else { | |
| 543 rect.Inset(0, 0, kAlternateLayoutBubblePaddingVerticalSide + 4, | |
| 544 kAlternateLayoutBubblePaddingVerticalBottom); | |
| 545 } | |
| 546 } else { | 474 } else { |
| 547 if (!ash::switches::UseAlternateShelfLayout()) { | 475 rect.Inset(kAlternateLayoutBubblePaddingVerticalSide, 0, 0, |
| 548 rect.Inset(kPaddingFromInnerEdgeOfLauncherVerticalAlignment + 1, | 476 kAlternateLayoutBubblePaddingVerticalBottom); |
| 549 0, 0, kPaddingFromBottomOfScreenVerticalAlignment); | |
| 550 } else { | |
| 551 rect.Inset(kAlternateLayoutBubblePaddingVerticalSide, 0, 0, | |
| 552 kAlternateLayoutBubblePaddingVerticalBottom); | |
| 553 } | |
| 554 } | 477 } |
| 555 } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { | 478 } else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) { |
| 556 // Invert the offsets to align with the bubble below. | 479 // Invert the offsets to align with the bubble below. |
| 557 // Note that with the alternate shelf layout the tips are not shown and | 480 int vertical_alignment = 0; |
| 558 // the offsets for left and right alignment do not need to be applied. | 481 int horizontal_alignment = |
| 559 int vertical_alignment = ash::switches::UseAlternateShelfLayout() ? | 482 kAlternateLayoutBubblePaddingVerticalBottom; |
| 560 0 : | |
| 561 kPaddingFromInnerEdgeOfLauncherVerticalAlignment; | |
| 562 int horizontal_alignment = ash::switches::UseAlternateShelfLayout() ? | |
| 563 kAlternateLayoutBubblePaddingVerticalBottom : | |
| 564 kPaddingFromBottomOfScreenVerticalAlignment; | |
| 565 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) | 483 if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) |
| 566 rect.Inset(vertical_alignment, 0, 0, horizontal_alignment); | 484 rect.Inset(vertical_alignment, 0, 0, horizontal_alignment); |
| 567 else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) | 485 else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) |
| 568 rect.Inset(0, 0, vertical_alignment, horizontal_alignment); | 486 rect.Inset(0, 0, vertical_alignment, horizontal_alignment); |
| 569 } | 487 } |
| 570 } | 488 } |
| 571 | 489 |
| 572 // TODO(jennyz): May need to add left/right alignment in the following code. | 490 // TODO(jennyz): May need to add left/right alignment in the following code. |
| 573 if (rect.IsEmpty()) { | 491 if (rect.IsEmpty()) { |
| 574 aura::Window* target_root = anchor_widget ? | 492 aura::Window* target_root = anchor_widget ? |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 595 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; | 513 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; |
| 596 case SHELF_ALIGNMENT_TOP: | 514 case SHELF_ALIGNMENT_TOP: |
| 597 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; | 515 return TrayBubbleView::ANCHOR_ALIGNMENT_TOP; |
| 598 } | 516 } |
| 599 NOTREACHED(); | 517 NOTREACHED(); |
| 600 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 518 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
| 601 } | 519 } |
| 602 | 520 |
| 603 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { | 521 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { |
| 604 draw_background_as_active_ = visible; | 522 draw_background_as_active_ = visible; |
| 605 if (!background_ || !switches::UseAlternateShelfLayout()) | 523 if (!background_) |
| 606 return; | 524 return; |
| 607 | 525 |
| 608 // Do not change gradually, changing color between grey and blue is weird. | 526 // Do not change gradually, changing color between grey and blue is weird. |
| 609 if (draw_background_as_active_) | 527 if (draw_background_as_active_) |
| 610 background_->set_color(kTrayBackgroundPressedColor); | 528 background_->set_color(kTrayBackgroundPressedColor); |
| 611 else if (hovered_) | 529 else if (hovered_) |
| 612 background_->set_alpha(kTrayBackgroundHoverAlpha); | 530 background_->set_alpha(kTrayBackgroundHoverAlpha); |
| 613 else | 531 else |
| 614 background_->set_alpha(kTrayBackgroundAlpha); | 532 background_->set_alpha(kTrayBackgroundAlpha); |
| 615 SchedulePaint(); | 533 SchedulePaint(); |
| 616 } | 534 } |
| 617 | 535 |
| 618 void TrayBackgroundView::UpdateBubbleViewArrow( | 536 void TrayBackgroundView::UpdateBubbleViewArrow( |
| 619 views::TrayBubbleView* bubble_view) { | 537 views::TrayBubbleView* bubble_view) { |
| 620 if (switches::UseAlternateShelfLayout()) | |
| 621 return; | |
| 622 | |
| 623 aura::Window* root_window = | |
| 624 bubble_view->GetWidget()->GetNativeView()->GetRootWindow(); | |
| 625 ash::internal::ShelfLayoutManager* shelf = | |
| 626 ShelfLayoutManager::ForShelf(root_window); | |
| 627 bubble_view->SetArrowPaintType( | |
| 628 (shelf && shelf->IsVisible()) ? | |
| 629 views::BubbleBorder::PAINT_NORMAL : | |
| 630 views::BubbleBorder::PAINT_TRANSPARENT); | |
| 631 } | 538 } |
| 632 | 539 |
| 633 } // namespace internal | 540 } // namespace internal |
| 634 } // namespace ash | 541 } // namespace ash |
| OLD | NEW |