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