| 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() == AUTO_HIDE ? | 328 gesture_drag_auto_hide_state_ = visibility_state() == AUTO_HIDE ? |
| 330 auto_hide_state() : AUTO_HIDE_SHOWN; | 329 auto_hide_state() : 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_ == AUTO_HIDE_HIDDEN && launcher_widget()) | 345 if (gesture_drag_auto_hide_state_ == AUTO_HIDE_HIDDEN && launcher_widget()) |
| 347 min_height = launcher_widget()->GetContentsView()-> | 346 min_height = launcher_widget()->GetContentsView()-> |
| 348 GetPreferredSize().height(); | 347 GetPreferredSize().height(); |
| 349 | 348 |
| 350 if (min_height < launcher_widget()->GetWindowBoundsInScreen().height() && | 349 if (min_height < launcher_widget()->GetWindowBoundsInScreen().height() && |
| 351 gesture.root_location().x() >= | 350 gesture.root_location().x() >= |
| 352 status_area_widget_->GetWindowBoundsInScreen().x() && | 351 status_area_widget_->GetWindowBoundsInScreen().x() && |
| 353 IsDraggingTrayEnabled()) | 352 IsDraggingTrayEnabled()) |
| 354 return DRAG_TRAY; | 353 return DRAG_TRAY; |
| 355 } | 354 } |
| 356 | 355 |
| 357 return DRAG_SHELF; | 356 return DRAG_SHELF; |
| 358 } | 357 } |
| 359 | 358 |
| 360 void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) { | 359 void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) { |
| 361 bool horizontal = alignment() == SHELF_ALIGNMENT_BOTTOM; | 360 bool horizontal = alignment_ == SHELF_ALIGNMENT_BOTTOM; |
| 362 bool should_change = false; | 361 bool should_change = false; |
| 363 if (gesture.type() == ui::ET_GESTURE_SCROLL_END) { | 362 if (gesture.type() == ui::ET_GESTURE_SCROLL_END) { |
| 364 // The visibility of the shelf changes only if the shelf was dragged X% | 363 // The visibility of the shelf changes only if the shelf was dragged X% |
| 365 // along the correct axis. If the shelf was already visible, then the | 364 // along the correct axis. If the shelf was already visible, then the |
| 366 // direction of the drag does not matter. | 365 // direction of the drag does not matter. |
| 367 const float kDragHideThreshold = 0.4f; | 366 const float kDragHideThreshold = 0.4f; |
| 368 gfx::Rect bounds = GetIdealBounds(); | 367 gfx::Rect bounds = GetIdealBounds(); |
| 369 float drag_ratio = fabs(gesture_drag_amount_) / | 368 float drag_ratio = fabs(gesture_drag_amount_) / |
| 370 (horizontal ? bounds.height() : bounds.width()); | 369 (horizontal ? bounds.height() : bounds.width()); |
| 371 if (gesture_drag_auto_hide_state_ == AUTO_HIDE_SHOWN) { | 370 if (gesture_drag_auto_hide_state_ == AUTO_HIDE_SHOWN) { |
| 372 should_change = drag_ratio > kDragHideThreshold; | 371 should_change = drag_ratio > kDragHideThreshold; |
| 373 } else { | 372 } else { |
| 374 bool correct_direction = false; | 373 bool correct_direction = false; |
| 375 switch (alignment()) { | 374 switch (alignment_) { |
| 376 case SHELF_ALIGNMENT_BOTTOM: | 375 case SHELF_ALIGNMENT_BOTTOM: |
| 377 case SHELF_ALIGNMENT_RIGHT: | 376 case SHELF_ALIGNMENT_RIGHT: |
| 378 correct_direction = gesture_drag_amount_ < 0; | 377 correct_direction = gesture_drag_amount_ < 0; |
| 379 break; | 378 break; |
| 380 case SHELF_ALIGNMENT_LEFT: | 379 case SHELF_ALIGNMENT_LEFT: |
| 381 correct_direction = gesture_drag_amount_ > 0; | 380 correct_direction = gesture_drag_amount_ > 0; |
| 382 break; | 381 break; |
| 383 } | 382 } |
| 384 should_change = correct_direction && drag_ratio > kDragHideThreshold; | 383 should_change = correct_direction && drag_ratio > kDragHideThreshold; |
| 385 } | 384 } |
| 386 } else if (gesture.type() == ui::ET_SCROLL_FLING_START) { | 385 } else if (gesture.type() == ui::ET_SCROLL_FLING_START) { |
| 387 if (gesture_drag_auto_hide_state_ == AUTO_HIDE_SHOWN) { | 386 if (gesture_drag_auto_hide_state_ == AUTO_HIDE_SHOWN) { |
| 388 should_change = horizontal ? fabs(gesture.details().velocity_y()) > 0 : | 387 should_change = horizontal ? fabs(gesture.details().velocity_y()) > 0 : |
| 389 fabs(gesture.details().velocity_x()) > 0; | 388 fabs(gesture.details().velocity_x()) > 0; |
| 390 } else { | 389 } else { |
| 391 if (horizontal) | 390 if (horizontal) |
| 392 should_change = gesture.details().velocity_y() < 0; | 391 should_change = gesture.details().velocity_y() < 0; |
| 393 else if (alignment() == SHELF_ALIGNMENT_LEFT) | 392 else if (alignment_ == SHELF_ALIGNMENT_LEFT) |
| 394 should_change = gesture.details().velocity_x() > 0; | 393 should_change = gesture.details().velocity_x() > 0; |
| 395 else | 394 else |
| 396 should_change = gesture.details().velocity_x() < 0; | 395 should_change = gesture.details().velocity_x() < 0; |
| 397 } | 396 } |
| 398 } else { | 397 } else { |
| 399 NOTREACHED(); | 398 NOTREACHED(); |
| 400 } | 399 } |
| 401 | 400 |
| 402 if (!should_change) { | 401 if (!should_change) { |
| 403 CancelGestureDrag(); | 402 CancelGestureDrag(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 425 } | 424 } |
| 426 } | 425 } |
| 427 | 426 |
| 428 void ShelfLayoutManager::CancelGestureDrag() { | 427 void ShelfLayoutManager::CancelGestureDrag() { |
| 429 gesture_drag_status_ = GESTURE_DRAG_NONE; | 428 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 430 ui::ScopedLayerAnimationSettings | 429 ui::ScopedLayerAnimationSettings |
| 431 launcher_settings(GetLayer(launcher_widget())->GetAnimator()), | 430 launcher_settings(GetLayer(launcher_widget())->GetAnimator()), |
| 432 status_settings(GetLayer(status_area_widget_)->GetAnimator()); | 431 status_settings(GetLayer(status_area_widget_)->GetAnimator()); |
| 433 LayoutShelf(); | 432 LayoutShelf(); |
| 434 UpdateVisibilityState(); | 433 UpdateVisibilityState(); |
| 435 UpdateShelfBackground(internal::BackgroundAnimator::CHANGE_ANIMATE); | 434 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); |
| 436 } | 435 } |
| 437 | 436 |
| 438 //////////////////////////////////////////////////////////////////////////////// | 437 //////////////////////////////////////////////////////////////////////////////// |
| 439 // ShelfLayoutManager, aura::LayoutManager implementation: | 438 // ShelfLayoutManager, aura::LayoutManager implementation: |
| 440 | 439 |
| 441 void ShelfLayoutManager::OnWindowResized() { | 440 void ShelfLayoutManager::OnWindowResized() { |
| 442 LayoutShelf(); | 441 LayoutShelf(); |
| 443 } | 442 } |
| 444 | 443 |
| 445 void ShelfLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 444 void ShelfLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 469 | 468 |
| 470 void ShelfLayoutManager::OnLockStateChanged(bool locked) { | 469 void ShelfLayoutManager::OnLockStateChanged(bool locked) { |
| 471 UpdateVisibilityState(); | 470 UpdateVisibilityState(); |
| 472 } | 471 } |
| 473 | 472 |
| 474 void ShelfLayoutManager::OnWindowActivated(aura::Window* active, | 473 void ShelfLayoutManager::OnWindowActivated(aura::Window* active, |
| 475 aura::Window* old_active) { | 474 aura::Window* old_active) { |
| 476 UpdateAutoHideStateNow(); | 475 UpdateAutoHideStateNow(); |
| 477 } | 476 } |
| 478 | 477 |
| 478 bool ShelfLayoutManager::IsHorizontalAlignment() const { |
| 479 return alignment_ == SHELF_ALIGNMENT_BOTTOM; |
| 480 } |
| 481 |
| 482 // static |
| 483 ShelfLayoutManager* ShelfLayoutManager::ForLauncher(aura::Window* window) { |
| 484 return RootWindowController::ForLauncher(window)->shelf(); |
| 485 } |
| 486 |
| 479 //////////////////////////////////////////////////////////////////////////////// | 487 //////////////////////////////////////////////////////////////////////////////// |
| 480 // ShelfLayoutManager, private: | 488 // ShelfLayoutManager, private: |
| 481 | 489 |
| 482 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {} | 490 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {} |
| 483 | 491 |
| 484 void ShelfLayoutManager::SetState(VisibilityState visibility_state) { | 492 void ShelfLayoutManager::SetState(VisibilityState visibility_state) { |
| 485 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 493 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 486 State state; | 494 State state; |
| 487 state.visibility_state = visibility_state; | 495 state.visibility_state = visibility_state; |
| 488 state.auto_hide_state = CalculateAutoHideState(visibility_state); | 496 state.auto_hide_state = CalculateAutoHideState(visibility_state); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 509 if (!event_filter_.get()) | 517 if (!event_filter_.get()) |
| 510 event_filter_.reset(new AutoHideEventFilter(this)); | 518 event_filter_.reset(new AutoHideEventFilter(this)); |
| 511 } else { | 519 } else { |
| 512 event_filter_.reset(NULL); | 520 event_filter_.reset(NULL); |
| 513 } | 521 } |
| 514 | 522 |
| 515 auto_hide_timer_.Stop(); | 523 auto_hide_timer_.Stop(); |
| 516 | 524 |
| 517 // Animating the background when transitioning from auto-hide & hidden to | 525 // Animating the background when transitioning from auto-hide & hidden to |
| 518 // visible is janky. Update the background immediately in this case. | 526 // visible is janky. Update the background immediately in this case. |
| 519 internal::BackgroundAnimator::ChangeType change_type = | 527 BackgroundAnimator::ChangeType change_type = |
| 520 (state_.visibility_state == AUTO_HIDE && | 528 (state_.visibility_state == AUTO_HIDE && |
| 521 state_.auto_hide_state == AUTO_HIDE_HIDDEN && | 529 state_.auto_hide_state == AUTO_HIDE_HIDDEN && |
| 522 state.visibility_state == VISIBLE) ? | 530 state.visibility_state == VISIBLE) ? |
| 523 internal::BackgroundAnimator::CHANGE_IMMEDIATE : | 531 BackgroundAnimator::CHANGE_IMMEDIATE : BackgroundAnimator::CHANGE_ANIMATE; |
| 524 internal::BackgroundAnimator::CHANGE_ANIMATE; | |
| 525 StopAnimating(); | 532 StopAnimating(); |
| 526 | 533 |
| 527 State old_state = state_; | 534 State old_state = state_; |
| 528 state_ = state; | 535 state_ = state; |
| 529 TargetBounds target_bounds; | 536 TargetBounds target_bounds; |
| 530 CalculateTargetBounds(state_, &target_bounds); | 537 CalculateTargetBounds(state_, &target_bounds); |
| 531 if (launcher_widget()) { | 538 if (launcher_widget()) { |
| 532 ui::ScopedLayerAnimationSettings launcher_animation_setter( | 539 ui::ScopedLayerAnimationSettings launcher_animation_setter( |
| 533 GetLayer(launcher_widget())->GetAnimator()); | 540 GetLayer(launcher_widget())->GetAnimator()); |
| 534 launcher_animation_setter.SetTransitionDuration( | 541 launcher_animation_setter.SetTransitionDuration( |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 (gesture_drag_status_ != GESTURE_DRAG_NONE || | 693 (gesture_drag_status_ != GESTURE_DRAG_NONE || |
| 687 state.visibility_state == VISIBLE || | 694 state.visibility_state == VISIBLE || |
| 688 state.visibility_state == AUTO_HIDE) ? 1.0f : 0.0f; | 695 state.visibility_state == AUTO_HIDE) ? 1.0f : 0.0f; |
| 689 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS) | 696 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS) |
| 690 UpdateTargetBoundsForGesture(target_bounds); | 697 UpdateTargetBoundsForGesture(target_bounds); |
| 691 } | 698 } |
| 692 | 699 |
| 693 void ShelfLayoutManager::UpdateTargetBoundsForGesture( | 700 void ShelfLayoutManager::UpdateTargetBoundsForGesture( |
| 694 TargetBounds* target_bounds) const { | 701 TargetBounds* target_bounds) const { |
| 695 CHECK_EQ(GESTURE_DRAG_IN_PROGRESS, gesture_drag_status_); | 702 CHECK_EQ(GESTURE_DRAG_IN_PROGRESS, gesture_drag_status_); |
| 696 bool horizontal = alignment() == SHELF_ALIGNMENT_BOTTOM; | 703 bool horizontal = alignment_ == SHELF_ALIGNMENT_BOTTOM; |
| 697 int resistance_free_region = 0; | 704 int resistance_free_region = 0; |
| 698 | 705 |
| 699 if (gesture_drag_auto_hide_state_ == AUTO_HIDE_HIDDEN && | 706 if (gesture_drag_auto_hide_state_ == AUTO_HIDE_HIDDEN && |
| 700 visibility_state() == AUTO_HIDE && auto_hide_state() != AUTO_HIDE_SHOWN) { | 707 visibility_state() == AUTO_HIDE && auto_hide_state() != AUTO_HIDE_SHOWN) { |
| 701 // If the shelf was hidden when the drag started (and the state hasn't | 708 // If the shelf was hidden when the drag started (and the state hasn't |
| 702 // changed since then, e.g. because the tray-menu was shown because of the | 709 // changed since then, e.g. because the tray-menu was shown because of the |
| 703 // drag), then allow the drag some resistance-free region at first to make | 710 // drag), then allow the drag some resistance-free region at first to make |
| 704 // sure the shelf sticks with the finger until the shelf is visible. | 711 // sure the shelf sticks with the finger until the shelf is visible. |
| 705 resistance_free_region += horizontal ? | 712 resistance_free_region += horizontal ? |
| 706 target_bounds->launcher_bounds_in_root.height() : | 713 target_bounds->launcher_bounds_in_root.height() : |
| 707 target_bounds->launcher_bounds_in_root.width(); | 714 target_bounds->launcher_bounds_in_root.width(); |
| 708 resistance_free_region -= kAutoHideSize; | 715 resistance_free_region -= kAutoHideSize; |
| 709 } | 716 } |
| 710 | 717 |
| 711 bool resist = false; | 718 bool resist = false; |
| 712 if (horizontal) | 719 if (horizontal) |
| 713 resist = gesture_drag_amount_ < -resistance_free_region; | 720 resist = gesture_drag_amount_ < -resistance_free_region; |
| 714 else if (alignment() == SHELF_ALIGNMENT_LEFT) | 721 else if (alignment_ == SHELF_ALIGNMENT_LEFT) |
| 715 resist = gesture_drag_amount_ > resistance_free_region; | 722 resist = gesture_drag_amount_ > resistance_free_region; |
| 716 else | 723 else |
| 717 resist = gesture_drag_amount_ < -resistance_free_region; | 724 resist = gesture_drag_amount_ < -resistance_free_region; |
| 718 | 725 |
| 719 float translate = 0.f; | 726 float translate = 0.f; |
| 720 if (resist) { | 727 if (resist) { |
| 721 float diff = fabsf(gesture_drag_amount_) - resistance_free_region; | 728 float diff = fabsf(gesture_drag_amount_) - resistance_free_region; |
| 722 diff = std::min(diff, sqrtf(diff)); | 729 diff = std::min(diff, sqrtf(diff)); |
| 723 if (gesture_drag_amount_ < 0) | 730 if (gesture_drag_amount_ < 0) |
| 724 translate = -resistance_free_region - diff; | 731 translate = -resistance_free_region - diff; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 743 target_bounds->launcher_bounds_in_root.height() + move - translate); | 750 target_bounds->launcher_bounds_in_root.height() + move - translate); |
| 744 | 751 |
| 745 // The statusbar should be in the center. | 752 // The statusbar should be in the center. |
| 746 gfx::Rect status_y = target_bounds->launcher_bounds_in_root; | 753 gfx::Rect status_y = target_bounds->launcher_bounds_in_root; |
| 747 status_y.ClampToCenteredSize( | 754 status_y.ClampToCenteredSize( |
| 748 target_bounds->status_bounds_in_root.size()); | 755 target_bounds->status_bounds_in_root.size()); |
| 749 target_bounds->status_bounds_in_root.set_y(status_y.y()); | 756 target_bounds->status_bounds_in_root.set_y(status_y.y()); |
| 750 } | 757 } |
| 751 } else { | 758 } else { |
| 752 // Move the launcher with the gesture. | 759 // Move the launcher with the gesture. |
| 753 if (alignment() == SHELF_ALIGNMENT_RIGHT) | 760 if (alignment_ == SHELF_ALIGNMENT_RIGHT) |
| 754 target_bounds->launcher_bounds_in_root.Offset(translate, 0); | 761 target_bounds->launcher_bounds_in_root.Offset(translate, 0); |
| 755 | 762 |
| 756 if ((translate > 0 && alignment() == SHELF_ALIGNMENT_RIGHT) || | 763 if ((translate > 0 && alignment_ == SHELF_ALIGNMENT_RIGHT) || |
| 757 (translate < 0 && alignment() == SHELF_ALIGNMENT_LEFT)) { | 764 (translate < 0 && alignment_ == SHELF_ALIGNMENT_LEFT)) { |
| 758 // When dragging towards the edge, the statusbar should move. | 765 // When dragging towards the edge, the statusbar should move. |
| 759 target_bounds->status_bounds_in_root.Offset(translate, 0); | 766 target_bounds->status_bounds_in_root.Offset(translate, 0); |
| 760 } else { | 767 } else { |
| 761 // When dragging away from the edge, the launcher width should increase. | 768 // When dragging away from the edge, the launcher width should increase. |
| 762 float move = alignment() == SHELF_ALIGNMENT_RIGHT ? | 769 float move = alignment_ == SHELF_ALIGNMENT_RIGHT ? |
| 763 std::max(translate, -static_cast<float>(resistance_free_region)) : | 770 std::max(translate, -static_cast<float>(resistance_free_region)) : |
| 764 std::min(translate, static_cast<float>(resistance_free_region)); | 771 std::min(translate, static_cast<float>(resistance_free_region)); |
| 765 | 772 |
| 766 if (alignment() == SHELF_ALIGNMENT_RIGHT) { | 773 if (alignment_ == SHELF_ALIGNMENT_RIGHT) { |
| 767 target_bounds->launcher_bounds_in_root.set_width( | 774 target_bounds->launcher_bounds_in_root.set_width( |
| 768 target_bounds->launcher_bounds_in_root.width() + move - translate); | 775 target_bounds->launcher_bounds_in_root.width() + move - translate); |
| 769 } else { | 776 } else { |
| 770 target_bounds->launcher_bounds_in_root.set_width( | 777 target_bounds->launcher_bounds_in_root.set_width( |
| 771 target_bounds->launcher_bounds_in_root.width() - move + translate); | 778 target_bounds->launcher_bounds_in_root.width() - move + translate); |
| 772 } | 779 } |
| 773 | 780 |
| 774 // The statusbar should be in the center. | 781 // The statusbar should be in the center. |
| 775 gfx::Rect status_x = target_bounds->launcher_bounds_in_root; | 782 gfx::Rect status_x = target_bounds->launcher_bounds_in_root; |
| 776 status_x.ClampToCenteredSize( | 783 status_x.ClampToCenteredSize( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 895 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
| 889 if (state.visibility_state == VISIBLE) | 896 if (state.visibility_state == VISIBLE) |
| 890 return size; | 897 return size; |
| 891 if (state.visibility_state == AUTO_HIDE) | 898 if (state.visibility_state == AUTO_HIDE) |
| 892 return kAutoHideSize; | 899 return kAutoHideSize; |
| 893 return 0; | 900 return 0; |
| 894 } | 901 } |
| 895 | 902 |
| 896 } // namespace internal | 903 } // namespace internal |
| 897 } // namespace ash | 904 } // namespace ash |
| OLD | NEW |