| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // Adjust the size of status tray dark background by adding additional | 277 // Adjust the size of status tray dark background by adding additional |
| 278 // empty border. | 278 // empty border. |
| 279 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || | 279 if (alignment_ == SHELF_ALIGNMENT_BOTTOM || |
| 280 alignment_ == SHELF_ALIGNMENT_TOP) { | 280 alignment_ == SHELF_ALIGNMENT_TOP) { |
| 281 int vertical_padding = kTrayContainerVerticalPaddingBottomAlignment; | 281 int vertical_padding = kTrayContainerVerticalPaddingBottomAlignment; |
| 282 int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment; | 282 int horizontal_padding = kTrayContainerHorizontalPaddingBottomAlignment; |
| 283 if (ash::switches::UseAlternateShelfLayout()) { | 283 if (ash::switches::UseAlternateShelfLayout()) { |
| 284 vertical_padding = kPaddingFromEdgeOfShelf; | 284 vertical_padding = kPaddingFromEdgeOfShelf; |
| 285 horizontal_padding = kPaddingFromEdgeOfShelf; | 285 horizontal_padding = kPaddingFromEdgeOfShelf; |
| 286 } | 286 } |
| 287 set_border(views::Border::CreateEmptyBorder( | 287 SetBorder(views::Border::CreateEmptyBorder( |
| 288 vertical_padding, | 288 vertical_padding, |
| 289 horizontal_padding, | 289 horizontal_padding, |
| 290 vertical_padding, | 290 vertical_padding, |
| 291 horizontal_padding)); | 291 horizontal_padding)); |
| 292 | 292 |
| 293 views::BoxLayout* layout = | 293 views::BoxLayout* layout = |
| 294 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 294 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
| 295 layout->set_spread_blank_space(true); | 295 layout->set_spread_blank_space(true); |
| 296 views::View::SetLayoutManager(layout); | 296 views::View::SetLayoutManager(layout); |
| 297 } else { | 297 } else { |
| 298 int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment; | 298 int vertical_padding = kTrayContainerVerticalPaddingVerticalAlignment; |
| 299 int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment; | 299 int horizontal_padding = kTrayContainerHorizontalPaddingVerticalAlignment; |
| 300 if (ash::switches::UseAlternateShelfLayout()) { | 300 if (ash::switches::UseAlternateShelfLayout()) { |
| 301 vertical_padding = kPaddingFromEdgeOfShelf; | 301 vertical_padding = kPaddingFromEdgeOfShelf; |
| 302 horizontal_padding = kPaddingFromEdgeOfShelf; | 302 horizontal_padding = kPaddingFromEdgeOfShelf; |
| 303 } | 303 } |
| 304 set_border(views::Border::CreateEmptyBorder( | 304 SetBorder(views::Border::CreateEmptyBorder( |
| 305 vertical_padding, | 305 vertical_padding, |
| 306 horizontal_padding, | 306 horizontal_padding, |
| 307 vertical_padding, | 307 vertical_padding, |
| 308 horizontal_padding)); | 308 horizontal_padding)); |
| 309 | 309 |
| 310 views::BoxLayout* layout = | 310 views::BoxLayout* layout = |
| 311 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); | 311 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); |
| 312 layout->set_spread_blank_space(true); | 312 layout->set_spread_blank_space(true); |
| 313 views::View::SetLayoutManager(layout); | 313 views::View::SetLayoutManager(layout); |
| 314 } | 314 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 343 tray_event_filter_.reset(new TrayEventFilter); | 343 tray_event_filter_.reset(new TrayEventFilter); |
| 344 } | 344 } |
| 345 | 345 |
| 346 TrayBackgroundView::~TrayBackgroundView() { | 346 TrayBackgroundView::~TrayBackgroundView() { |
| 347 if (GetWidget()) | 347 if (GetWidget()) |
| 348 GetWidget()->RemoveObserver(widget_observer_.get()); | 348 GetWidget()->RemoveObserver(widget_observer_.get()); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void TrayBackgroundView::Initialize() { | 351 void TrayBackgroundView::Initialize() { |
| 352 GetWidget()->AddObserver(widget_observer_.get()); | 352 GetWidget()->AddObserver(widget_observer_.get()); |
| 353 SetBorder(); | 353 SetTrayBorder(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 const char* TrayBackgroundView::GetClassName() const { | 356 const char* TrayBackgroundView::GetClassName() const { |
| 357 return kViewClassName; | 357 return kViewClassName; |
| 358 } | 358 } |
| 359 | 359 |
| 360 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { | 360 void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) { |
| 361 hovered_ = true; | 361 hovered_ = true; |
| 362 if (!background_ || draw_background_as_active_ || | 362 if (!background_ || draw_background_as_active_ || |
| 363 ash::switches::UseAlternateShelfLayout()) | 363 ash::switches::UseAlternateShelfLayout()) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 background_ = new internal::TrayBackground(this); | 427 background_ = new internal::TrayBackground(this); |
| 428 tray_container_->set_background(background_); | 428 tray_container_->set_background(background_); |
| 429 } | 429 } |
| 430 | 430 |
| 431 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { | 431 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { |
| 432 return ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); | 432 return ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); |
| 433 } | 433 } |
| 434 | 434 |
| 435 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 435 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
| 436 shelf_alignment_ = alignment; | 436 shelf_alignment_ = alignment; |
| 437 SetBorder(); | 437 SetTrayBorder(); |
| 438 tray_container_->SetAlignment(alignment); | 438 tray_container_->SetAlignment(alignment); |
| 439 } | 439 } |
| 440 | 440 |
| 441 void TrayBackgroundView::SetBorder() { | 441 void TrayBackgroundView::SetTrayBorder() { |
| 442 views::View* parent = status_area_widget_->status_area_widget_delegate(); | 442 views::View* parent = status_area_widget_->status_area_widget_delegate(); |
| 443 // Tray views are laid out right-to-left or bottom-to-top | 443 // Tray views are laid out right-to-left or bottom-to-top |
| 444 bool on_edge = (this == parent->child_at(0)); | 444 bool on_edge = (this == parent->child_at(0)); |
| 445 int left_edge, top_edge, right_edge, bottom_edge; | 445 int left_edge, top_edge, right_edge, bottom_edge; |
| 446 if (ash::switches::UseAlternateShelfLayout()) { | 446 if (ash::switches::UseAlternateShelfLayout()) { |
| 447 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { | 447 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { |
| 448 top_edge = ShelfLayoutManager::kShelfItemInset; | 448 top_edge = ShelfLayoutManager::kShelfItemInset; |
| 449 left_edge = 0; | 449 left_edge = 0; |
| 450 bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() - | 450 bottom_edge = ShelfLayoutManager::GetPreferredShelfSize() - |
| 451 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); | 451 ShelfLayoutManager::kShelfItemInset - GetShelfItemHeight(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 482 left_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; | 482 left_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; |
| 483 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; | 483 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; |
| 484 right_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; | 484 right_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; |
| 485 } else { | 485 } else { |
| 486 top_edge = 0; | 486 top_edge = 0; |
| 487 left_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; | 487 left_edge = kPaddingFromInnerEdgeOfLauncherVerticalAlignment; |
| 488 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; | 488 bottom_edge = on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0; |
| 489 right_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; | 489 right_edge = kPaddingFromOuterEdgeOfLauncherVerticalAlignment; |
| 490 } | 490 } |
| 491 } | 491 } |
| 492 set_border(views::Border::CreateEmptyBorder( | 492 SetBorder(views::Border::CreateEmptyBorder( |
| 493 top_edge, left_edge, bottom_edge, right_edge)); | 493 top_edge, left_edge, bottom_edge, right_edge)); |
| 494 } | 494 } |
| 495 | 495 |
| 496 void TrayBackgroundView::InitializeBubbleAnimations( | 496 void TrayBackgroundView::InitializeBubbleAnimations( |
| 497 views::Widget* bubble_widget) { | 497 views::Widget* bubble_widget) { |
| 498 views::corewm::SetWindowVisibilityAnimationType( | 498 views::corewm::SetWindowVisibilityAnimationType( |
| 499 bubble_widget->GetNativeWindow(), | 499 bubble_widget->GetNativeWindow(), |
| 500 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | 500 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |
| 501 views::corewm::SetWindowVisibilityAnimationTransition( | 501 views::corewm::SetWindowVisibilityAnimationTransition( |
| 502 bubble_widget->GetNativeWindow(), | 502 bubble_widget->GetNativeWindow(), |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 ash::internal::ShelfLayoutManager* shelf = | 625 ash::internal::ShelfLayoutManager* shelf = |
| 626 ShelfLayoutManager::ForShelf(root_window); | 626 ShelfLayoutManager::ForShelf(root_window); |
| 627 bubble_view->SetArrowPaintType( | 627 bubble_view->SetArrowPaintType( |
| 628 (shelf && shelf->IsVisible()) ? | 628 (shelf && shelf->IsVisible()) ? |
| 629 views::BubbleBorder::PAINT_NORMAL : | 629 views::BubbleBorder::PAINT_NORMAL : |
| 630 views::BubbleBorder::PAINT_TRANSPARENT); | 630 views::BubbleBorder::PAINT_TRANSPARENT); |
| 631 } | 631 } |
| 632 | 632 |
| 633 } // namespace internal | 633 } // namespace internal |
| 634 } // namespace ash | 634 } // namespace ash |
| OLD | NEW |