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