| 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/wm/shelf_layout_manager.h" | 5 #include "ash/wm/shelf_layout_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) { | 117 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) { |
| 118 shelf_->update_shelf_observer_ = this; | 118 shelf_->update_shelf_observer_ = this; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void Detach() { | 121 void Detach() { |
| 122 shelf_ = NULL; | 122 shelf_ = NULL; |
| 123 } | 123 } |
| 124 | 124 |
| 125 virtual void OnImplicitAnimationsCompleted() OVERRIDE { | 125 virtual void OnImplicitAnimationsCompleted() OVERRIDE { |
| 126 if (shelf_) { | 126 if (shelf_) { |
| 127 shelf_->UpdateShelfBackground( | 127 shelf_->UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); |
| 128 internal::BackgroundAnimator::CHANGE_ANIMATE); | |
| 129 } | 128 } |
| 130 delete this; | 129 delete this; |
| 131 } | 130 } |
| 132 | 131 |
| 133 private: | 132 private: |
| 134 virtual ~UpdateShelfObserver() { | 133 virtual ~UpdateShelfObserver() { |
| 135 if (shelf_) | 134 if (shelf_) |
| 136 shelf_->update_shelf_observer_ = NULL; | 135 shelf_->update_shelf_observer_ = NULL; |
| 137 } | 136 } |
| 138 | 137 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 FOR_EACH_OBSERVER(Observer, observers_, OnAutoHideStateChanged( | 301 FOR_EACH_OBSERVER(Observer, observers_, OnAutoHideStateChanged( |
| 303 CalculateAutoHideState(state_.visibility_state))); | 302 CalculateAutoHideState(state_.visibility_state))); |
| 304 } | 303 } |
| 305 } else { | 304 } else { |
| 306 auto_hide_timer_.Stop(); | 305 auto_hide_timer_.Stop(); |
| 307 } | 306 } |
| 308 } | 307 } |
| 309 | 308 |
| 310 void ShelfLayoutManager::SetWindowOverlapsShelf(bool value) { | 309 void ShelfLayoutManager::SetWindowOverlapsShelf(bool value) { |
| 311 window_overlaps_shelf_ = value; | 310 window_overlaps_shelf_ = value; |
| 312 UpdateShelfBackground(internal::BackgroundAnimator::CHANGE_ANIMATE); | 311 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); |
| 313 } | 312 } |
| 314 | 313 |
| 315 void ShelfLayoutManager::AddObserver(Observer* observer) { | 314 void ShelfLayoutManager::AddObserver(Observer* observer) { |
| 316 observers_.AddObserver(observer); | 315 observers_.AddObserver(observer); |
| 317 } | 316 } |
| 318 | 317 |
| 319 void ShelfLayoutManager::RemoveObserver(Observer* observer) { | 318 void ShelfLayoutManager::RemoveObserver(Observer* observer) { |
| 320 observers_.RemoveObserver(observer); | 319 observers_.RemoveObserver(observer); |
| 321 } | 320 } |
| 322 | 321 |
| 323 //////////////////////////////////////////////////////////////////////////////// | 322 //////////////////////////////////////////////////////////////////////////////// |
| 324 // ShelfLayoutManager, Gesture dragging: | 323 // ShelfLayoutManager, Gesture dragging: |
| 325 | 324 |
| 326 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { | 325 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { |
| 327 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; | 326 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; |
| 328 gesture_drag_amount_ = 0.f; | 327 gesture_drag_amount_ = 0.f; |
| 329 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE ? | 328 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE ? |
| 330 auto_hide_state() : SHELF_AUTO_HIDE_SHOWN; | 329 auto_hide_state() : SHELF_AUTO_HIDE_SHOWN; |
| 331 UpdateShelfBackground(internal::BackgroundAnimator::CHANGE_ANIMATE); | 330 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); |
| 332 } | 331 } |
| 333 | 332 |
| 334 ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag( | 333 ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag( |
| 335 const ui::GestureEvent& gesture) { | 334 const ui::GestureEvent& gesture) { |
| 336 bool horizontal = alignment() == SHELF_ALIGNMENT_BOTTOM; | 335 bool horizontal = alignment_ == SHELF_ALIGNMENT_BOTTOM; |
| 337 gesture_drag_amount_ += horizontal ? gesture.details().scroll_y() : | 336 gesture_drag_amount_ += horizontal ? gesture.details().scroll_y() : |
| 338 gesture.details().scroll_x(); | 337 gesture.details().scroll_x(); |
| 339 LayoutShelf(); | 338 LayoutShelf(); |
| 340 | 339 |
| 341 // Start reveling the status menu when: | 340 // Start reveling the status menu when: |
| 342 // - dragging up on an already visible shelf | 341 // - dragging up on an already visible shelf |
| 343 // - dragging up on a hidden shelf, but it is currently completely visible. | 342 // - dragging up on a hidden shelf, but it is currently completely visible. |
| 344 if (horizontal && gesture.details().scroll_y() < 0) { | 343 if (horizontal && gesture.details().scroll_y() < 0) { |
| 345 int min_height = 0; | 344 int min_height = 0; |
| 346 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN && | 345 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN && |
| 347 launcher_widget()) | 346 launcher_widget()) |
| 348 min_height = launcher_widget()->GetContentsView()-> | 347 min_height = launcher_widget()->GetContentsView()-> |
| 349 GetPreferredSize().height(); | 348 GetPreferredSize().height(); |
| 350 | 349 |
| 351 if (min_height < launcher_widget()->GetWindowBoundsInScreen().height() && | 350 if (min_height < launcher_widget()->GetWindowBoundsInScreen().height() && |
| 352 gesture.root_location().x() >= | 351 gesture.root_location().x() >= |
| 353 status_area_widget_->GetWindowBoundsInScreen().x() && | 352 status_area_widget_->GetWindowBoundsInScreen().x() && |
| 354 IsDraggingTrayEnabled()) | 353 IsDraggingTrayEnabled()) |
| 355 return DRAG_TRAY; | 354 return DRAG_TRAY; |
| 356 } | 355 } |
| 357 | 356 |
| 358 return DRAG_SHELF; | 357 return DRAG_SHELF; |
| 359 } | 358 } |
| 360 | 359 |
| 361 void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) { | 360 void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) { |
| 362 bool horizontal = alignment() == SHELF_ALIGNMENT_BOTTOM; | 361 bool horizontal = alignment_ == SHELF_ALIGNMENT_BOTTOM; |
| 363 bool should_change = false; | 362 bool should_change = false; |
| 364 if (gesture.type() == ui::ET_GESTURE_SCROLL_END) { | 363 if (gesture.type() == ui::ET_GESTURE_SCROLL_END) { |
| 365 // The visibility of the shelf changes only if the shelf was dragged X% | 364 // The visibility of the shelf changes only if the shelf was dragged X% |
| 366 // along the correct axis. If the shelf was already visible, then the | 365 // along the correct axis. If the shelf was already visible, then the |
| 367 // direction of the drag does not matter. | 366 // direction of the drag does not matter. |
| 368 const float kDragHideThreshold = 0.4f; | 367 const float kDragHideThreshold = 0.4f; |
| 369 gfx::Rect bounds = GetIdealBounds(); | 368 gfx::Rect bounds = GetIdealBounds(); |
| 370 float drag_ratio = fabs(gesture_drag_amount_) / | 369 float drag_ratio = fabs(gesture_drag_amount_) / |
| 371 (horizontal ? bounds.height() : bounds.width()); | 370 (horizontal ? bounds.height() : bounds.width()); |
| 372 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) { | 371 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) { |
| 373 should_change = drag_ratio > kDragHideThreshold; | 372 should_change = drag_ratio > kDragHideThreshold; |
| 374 } else { | 373 } else { |
| 375 bool correct_direction = false; | 374 bool correct_direction = false; |
| 376 switch (alignment()) { | 375 switch (alignment_) { |
| 377 case SHELF_ALIGNMENT_BOTTOM: | 376 case SHELF_ALIGNMENT_BOTTOM: |
| 378 case SHELF_ALIGNMENT_RIGHT: | 377 case SHELF_ALIGNMENT_RIGHT: |
| 379 correct_direction = gesture_drag_amount_ < 0; | 378 correct_direction = gesture_drag_amount_ < 0; |
| 380 break; | 379 break; |
| 381 case SHELF_ALIGNMENT_LEFT: | 380 case SHELF_ALIGNMENT_LEFT: |
| 382 correct_direction = gesture_drag_amount_ > 0; | 381 correct_direction = gesture_drag_amount_ > 0; |
| 383 break; | 382 break; |
| 384 } | 383 } |
| 385 should_change = correct_direction && drag_ratio > kDragHideThreshold; | 384 should_change = correct_direction && drag_ratio > kDragHideThreshold; |
| 386 } | 385 } |
| 387 } else if (gesture.type() == ui::ET_SCROLL_FLING_START) { | 386 } else if (gesture.type() == ui::ET_SCROLL_FLING_START) { |
| 388 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) { | 387 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) { |
| 389 should_change = horizontal ? fabs(gesture.details().velocity_y()) > 0 : | 388 should_change = horizontal ? fabs(gesture.details().velocity_y()) > 0 : |
| 390 fabs(gesture.details().velocity_x()) > 0; | 389 fabs(gesture.details().velocity_x()) > 0; |
| 391 } else { | 390 } else { |
| 392 if (horizontal) | 391 if (horizontal) |
| 393 should_change = gesture.details().velocity_y() < 0; | 392 should_change = gesture.details().velocity_y() < 0; |
| 394 else if (alignment() == SHELF_ALIGNMENT_LEFT) | 393 else if (alignment_ == SHELF_ALIGNMENT_LEFT) |
| 395 should_change = gesture.details().velocity_x() > 0; | 394 should_change = gesture.details().velocity_x() > 0; |
| 396 else | 395 else |
| 397 should_change = gesture.details().velocity_x() < 0; | 396 should_change = gesture.details().velocity_x() < 0; |
| 398 } | 397 } |
| 399 } else { | 398 } else { |
| 400 NOTREACHED(); | 399 NOTREACHED(); |
| 401 } | 400 } |
| 402 | 401 |
| 403 if (!should_change) { | 402 if (!should_change) { |
| 404 CancelGestureDrag(); | 403 CancelGestureDrag(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 426 } | 425 } |
| 427 } | 426 } |
| 428 | 427 |
| 429 void ShelfLayoutManager::CancelGestureDrag() { | 428 void ShelfLayoutManager::CancelGestureDrag() { |
| 430 gesture_drag_status_ = GESTURE_DRAG_NONE; | 429 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 431 ui::ScopedLayerAnimationSettings | 430 ui::ScopedLayerAnimationSettings |
| 432 launcher_settings(GetLayer(launcher_widget())->GetAnimator()), | 431 launcher_settings(GetLayer(launcher_widget())->GetAnimator()), |
| 433 status_settings(GetLayer(status_area_widget_)->GetAnimator()); | 432 status_settings(GetLayer(status_area_widget_)->GetAnimator()); |
| 434 LayoutShelf(); | 433 LayoutShelf(); |
| 435 UpdateVisibilityState(); | 434 UpdateVisibilityState(); |
| 436 UpdateShelfBackground(internal::BackgroundAnimator::CHANGE_ANIMATE); | 435 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); |
| 437 } | 436 } |
| 438 | 437 |
| 439 //////////////////////////////////////////////////////////////////////////////// | 438 //////////////////////////////////////////////////////////////////////////////// |
| 440 // ShelfLayoutManager, aura::LayoutManager implementation: | 439 // ShelfLayoutManager, aura::LayoutManager implementation: |
| 441 | 440 |
| 442 void ShelfLayoutManager::OnWindowResized() { | 441 void ShelfLayoutManager::OnWindowResized() { |
| 443 LayoutShelf(); | 442 LayoutShelf(); |
| 444 } | 443 } |
| 445 | 444 |
| 446 void ShelfLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 445 void ShelfLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 470 | 469 |
| 471 void ShelfLayoutManager::OnLockStateChanged(bool locked) { | 470 void ShelfLayoutManager::OnLockStateChanged(bool locked) { |
| 472 UpdateVisibilityState(); | 471 UpdateVisibilityState(); |
| 473 } | 472 } |
| 474 | 473 |
| 475 void ShelfLayoutManager::OnWindowActivated(aura::Window* active, | 474 void ShelfLayoutManager::OnWindowActivated(aura::Window* active, |
| 476 aura::Window* old_active) { | 475 aura::Window* old_active) { |
| 477 UpdateAutoHideStateNow(); | 476 UpdateAutoHideStateNow(); |
| 478 } | 477 } |
| 479 | 478 |
| 479 bool ShelfLayoutManager::IsHorizontalAlignment() const { |
| 480 return alignment_ == SHELF_ALIGNMENT_BOTTOM; |
| 481 } |
| 482 |
| 483 // static |
| 484 ShelfLayoutManager* ShelfLayoutManager::ForLauncher(aura::Window* window) { |
| 485 return RootWindowController::ForLauncher(window)->shelf(); |
| 486 } |
| 487 |
| 480 //////////////////////////////////////////////////////////////////////////////// | 488 //////////////////////////////////////////////////////////////////////////////// |
| 481 // ShelfLayoutManager, private: | 489 // ShelfLayoutManager, private: |
| 482 | 490 |
| 483 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {} | 491 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {} |
| 484 | 492 |
| 485 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { | 493 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { |
| 486 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 494 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 487 State state; | 495 State state; |
| 488 state.visibility_state = visibility_state; | 496 state.visibility_state = visibility_state; |
| 489 state.auto_hide_state = CalculateAutoHideState(visibility_state); | 497 state.auto_hide_state = CalculateAutoHideState(visibility_state); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 510 if (!event_filter_.get()) | 518 if (!event_filter_.get()) |
| 511 event_filter_.reset(new AutoHideEventFilter(this)); | 519 event_filter_.reset(new AutoHideEventFilter(this)); |
| 512 } else { | 520 } else { |
| 513 event_filter_.reset(NULL); | 521 event_filter_.reset(NULL); |
| 514 } | 522 } |
| 515 | 523 |
| 516 auto_hide_timer_.Stop(); | 524 auto_hide_timer_.Stop(); |
| 517 | 525 |
| 518 // Animating the background when transitioning from auto-hide & hidden to | 526 // Animating the background when transitioning from auto-hide & hidden to |
| 519 // visible is janky. Update the background immediately in this case. | 527 // visible is janky. Update the background immediately in this case. |
| 520 internal::BackgroundAnimator::ChangeType change_type = | 528 BackgroundAnimator::ChangeType change_type = |
| 521 (state_.visibility_state == SHELF_AUTO_HIDE && | 529 (state_.visibility_state == SHELF_AUTO_HIDE && |
| 522 state_.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN && | 530 state_.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN && |
| 523 state.visibility_state == SHELF_VISIBLE) ? | 531 state.visibility_state == SHELF_VISIBLE) ? |
| 524 internal::BackgroundAnimator::CHANGE_IMMEDIATE : | 532 BackgroundAnimator::CHANGE_IMMEDIATE : BackgroundAnimator::CHANGE_ANIMATE; |
| 525 internal::BackgroundAnimator::CHANGE_ANIMATE; | |
| 526 StopAnimating(); | 533 StopAnimating(); |
| 527 | 534 |
| 528 State old_state = state_; | 535 State old_state = state_; |
| 529 state_ = state; | 536 state_ = state; |
| 530 TargetBounds target_bounds; | 537 TargetBounds target_bounds; |
| 531 CalculateTargetBounds(state_, &target_bounds); | 538 CalculateTargetBounds(state_, &target_bounds); |
| 532 if (launcher_widget()) { | 539 if (launcher_widget()) { |
| 533 ui::ScopedLayerAnimationSettings launcher_animation_setter( | 540 ui::ScopedLayerAnimationSettings launcher_animation_setter( |
| 534 GetLayer(launcher_widget())->GetAnimator()); | 541 GetLayer(launcher_widget())->GetAnimator()); |
| 535 launcher_animation_setter.SetTransitionDuration( | 542 launcher_animation_setter.SetTransitionDuration( |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 (gesture_drag_status_ != GESTURE_DRAG_NONE || | 694 (gesture_drag_status_ != GESTURE_DRAG_NONE || |
| 688 state.visibility_state == SHELF_VISIBLE || | 695 state.visibility_state == SHELF_VISIBLE || |
| 689 state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; | 696 state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; |
| 690 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS) | 697 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS) |
| 691 UpdateTargetBoundsForGesture(target_bounds); | 698 UpdateTargetBoundsForGesture(target_bounds); |
| 692 } | 699 } |
| 693 | 700 |
| 694 void ShelfLayoutManager::UpdateTargetBoundsForGesture( | 701 void ShelfLayoutManager::UpdateTargetBoundsForGesture( |
| 695 TargetBounds* target_bounds) const { | 702 TargetBounds* target_bounds) const { |
| 696 CHECK_EQ(GESTURE_DRAG_IN_PROGRESS, gesture_drag_status_); | 703 CHECK_EQ(GESTURE_DRAG_IN_PROGRESS, gesture_drag_status_); |
| 697 bool horizontal = alignment() == SHELF_ALIGNMENT_BOTTOM; | 704 bool horizontal = alignment_ == SHELF_ALIGNMENT_BOTTOM; |
| 698 int resistance_free_region = 0; | 705 int resistance_free_region = 0; |
| 699 | 706 |
| 700 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN && | 707 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN && |
| 701 visibility_state() == SHELF_AUTO_HIDE && | 708 visibility_state() == SHELF_AUTO_HIDE && |
| 702 auto_hide_state() != SHELF_AUTO_HIDE_SHOWN) { | 709 auto_hide_state() != SHELF_AUTO_HIDE_SHOWN) { |
| 703 // If the shelf was hidden when the drag started (and the state hasn't | 710 // If the shelf was hidden when the drag started (and the state hasn't |
| 704 // changed since then, e.g. because the tray-menu was shown because of the | 711 // changed since then, e.g. because the tray-menu was shown because of the |
| 705 // drag), then allow the drag some resistance-free region at first to make | 712 // drag), then allow the drag some resistance-free region at first to make |
| 706 // sure the shelf sticks with the finger until the shelf is visible. | 713 // sure the shelf sticks with the finger until the shelf is visible. |
| 707 resistance_free_region += horizontal ? | 714 resistance_free_region += horizontal ? |
| 708 target_bounds->launcher_bounds_in_root.height() : | 715 target_bounds->launcher_bounds_in_root.height() : |
| 709 target_bounds->launcher_bounds_in_root.width(); | 716 target_bounds->launcher_bounds_in_root.width(); |
| 710 resistance_free_region -= kAutoHideSize; | 717 resistance_free_region -= kAutoHideSize; |
| 711 } | 718 } |
| 712 | 719 |
| 713 bool resist = false; | 720 bool resist = false; |
| 714 if (horizontal) | 721 if (horizontal) |
| 715 resist = gesture_drag_amount_ < -resistance_free_region; | 722 resist = gesture_drag_amount_ < -resistance_free_region; |
| 716 else if (alignment() == SHELF_ALIGNMENT_LEFT) | 723 else if (alignment_ == SHELF_ALIGNMENT_LEFT) |
| 717 resist = gesture_drag_amount_ > resistance_free_region; | 724 resist = gesture_drag_amount_ > resistance_free_region; |
| 718 else | 725 else |
| 719 resist = gesture_drag_amount_ < -resistance_free_region; | 726 resist = gesture_drag_amount_ < -resistance_free_region; |
| 720 | 727 |
| 721 float translate = 0.f; | 728 float translate = 0.f; |
| 722 if (resist) { | 729 if (resist) { |
| 723 float diff = fabsf(gesture_drag_amount_) - resistance_free_region; | 730 float diff = fabsf(gesture_drag_amount_) - resistance_free_region; |
| 724 diff = std::min(diff, sqrtf(diff)); | 731 diff = std::min(diff, sqrtf(diff)); |
| 725 if (gesture_drag_amount_ < 0) | 732 if (gesture_drag_amount_ < 0) |
| 726 translate = -resistance_free_region - diff; | 733 translate = -resistance_free_region - diff; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 745 target_bounds->launcher_bounds_in_root.height() + move - translate); | 752 target_bounds->launcher_bounds_in_root.height() + move - translate); |
| 746 | 753 |
| 747 // The statusbar should be in the center. | 754 // The statusbar should be in the center. |
| 748 gfx::Rect status_y = target_bounds->launcher_bounds_in_root; | 755 gfx::Rect status_y = target_bounds->launcher_bounds_in_root; |
| 749 status_y.ClampToCenteredSize( | 756 status_y.ClampToCenteredSize( |
| 750 target_bounds->status_bounds_in_root.size()); | 757 target_bounds->status_bounds_in_root.size()); |
| 751 target_bounds->status_bounds_in_root.set_y(status_y.y()); | 758 target_bounds->status_bounds_in_root.set_y(status_y.y()); |
| 752 } | 759 } |
| 753 } else { | 760 } else { |
| 754 // Move the launcher with the gesture. | 761 // Move the launcher with the gesture. |
| 755 if (alignment() == SHELF_ALIGNMENT_RIGHT) | 762 if (alignment_ == SHELF_ALIGNMENT_RIGHT) |
| 756 target_bounds->launcher_bounds_in_root.Offset(translate, 0); | 763 target_bounds->launcher_bounds_in_root.Offset(translate, 0); |
| 757 | 764 |
| 758 if ((translate > 0 && alignment() == SHELF_ALIGNMENT_RIGHT) || | 765 if ((translate > 0 && alignment_ == SHELF_ALIGNMENT_RIGHT) || |
| 759 (translate < 0 && alignment() == SHELF_ALIGNMENT_LEFT)) { | 766 (translate < 0 && alignment_ == SHELF_ALIGNMENT_LEFT)) { |
| 760 // When dragging towards the edge, the statusbar should move. | 767 // When dragging towards the edge, the statusbar should move. |
| 761 target_bounds->status_bounds_in_root.Offset(translate, 0); | 768 target_bounds->status_bounds_in_root.Offset(translate, 0); |
| 762 } else { | 769 } else { |
| 763 // When dragging away from the edge, the launcher width should increase. | 770 // When dragging away from the edge, the launcher width should increase. |
| 764 float move = alignment() == SHELF_ALIGNMENT_RIGHT ? | 771 float move = alignment_ == SHELF_ALIGNMENT_RIGHT ? |
| 765 std::max(translate, -static_cast<float>(resistance_free_region)) : | 772 std::max(translate, -static_cast<float>(resistance_free_region)) : |
| 766 std::min(translate, static_cast<float>(resistance_free_region)); | 773 std::min(translate, static_cast<float>(resistance_free_region)); |
| 767 | 774 |
| 768 if (alignment() == SHELF_ALIGNMENT_RIGHT) { | 775 if (alignment_ == SHELF_ALIGNMENT_RIGHT) { |
| 769 target_bounds->launcher_bounds_in_root.set_width( | 776 target_bounds->launcher_bounds_in_root.set_width( |
| 770 target_bounds->launcher_bounds_in_root.width() + move - translate); | 777 target_bounds->launcher_bounds_in_root.width() + move - translate); |
| 771 } else { | 778 } else { |
| 772 target_bounds->launcher_bounds_in_root.set_width( | 779 target_bounds->launcher_bounds_in_root.set_width( |
| 773 target_bounds->launcher_bounds_in_root.width() - move + translate); | 780 target_bounds->launcher_bounds_in_root.width() - move + translate); |
| 774 } | 781 } |
| 775 | 782 |
| 776 // The statusbar should be in the center. | 783 // The statusbar should be in the center. |
| 777 gfx::Rect status_x = target_bounds->launcher_bounds_in_root; | 784 gfx::Rect status_x = target_bounds->launcher_bounds_in_root; |
| 778 status_x.ClampToCenteredSize( | 785 status_x.ClampToCenteredSize( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 897 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
| 891 if (state.visibility_state == SHELF_VISIBLE) | 898 if (state.visibility_state == SHELF_VISIBLE) |
| 892 return size; | 899 return size; |
| 893 if (state.visibility_state == SHELF_AUTO_HIDE) | 900 if (state.visibility_state == SHELF_AUTO_HIDE) |
| 894 return kAutoHideSize; | 901 return kAutoHideSize; |
| 895 return 0; | 902 return 0; |
| 896 } | 903 } |
| 897 | 904 |
| 898 } // namespace internal | 905 } // namespace internal |
| 899 } // namespace ash | 906 } // namespace ash |
| OLD | NEW |