Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: ash/common/shelf/shelf_layout_manager.cc

Issue 2676673005: ash: Clean up shelf GetAlignment() and IsHorizontalAlignment() calls (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/shelf/shelf_layout_manager.h ('k') | ash/common/shelf/shelf_widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/shelf/shelf_layout_manager.h" 5 #include "ash/common/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/common/material_design/material_design_controller.h" 11 #include "ash/common/material_design/material_design_controller.h"
12 #include "ash/common/session/session_controller.h" 12 #include "ash/common/session/session_controller.h"
13 #include "ash/common/session/session_state_delegate.h" 13 #include "ash/common/session/session_state_delegate.h"
14 #include "ash/common/shelf/shelf_constants.h" 14 #include "ash/common/shelf/shelf_constants.h"
15 #include "ash/common/shelf/shelf_layout_manager_observer.h" 15 #include "ash/common/shelf/shelf_layout_manager_observer.h"
16 #include "ash/common/shelf/shelf_widget.h"
16 #include "ash/common/shelf/wm_shelf.h" 17 #include "ash/common/shelf/wm_shelf.h"
17 #include "ash/common/shelf/wm_shelf_util.h"
18 #include "ash/common/system/status_area_widget.h" 18 #include "ash/common/system/status_area_widget.h"
19 #include "ash/common/wm/fullscreen_window_finder.h" 19 #include "ash/common/wm/fullscreen_window_finder.h"
20 #include "ash/common/wm/mru_window_tracker.h" 20 #include "ash/common/wm/mru_window_tracker.h"
21 #include "ash/common/wm/window_state.h" 21 #include "ash/common/wm/window_state.h"
22 #include "ash/common/wm/wm_screen_util.h" 22 #include "ash/common/wm/wm_screen_util.h"
23 #include "ash/common/wm_lookup.h" 23 #include "ash/common/wm_lookup.h"
24 #include "ash/common/wm_shell.h" 24 #include "ash/common/wm_shell.h"
25 #include "ash/common/wm_window.h" 25 #include "ash/common/wm_window.h"
26 #include "ash/public/cpp/shell_window_ids.h" 26 #include "ash/public/cpp/shell_window_ids.h"
27 #include "ash/root_window_controller.h" 27 #include "ash/root_window_controller.h"
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // window. 428 // window.
429 if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked() && 429 if (WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked() &&
430 keyboard_is_about_to_hide) { 430 keyboard_is_about_to_hide) {
431 WmWindow* window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 431 WmWindow* window = WmLookup::Get()->GetWindowForWidget(shelf_widget_);
432 WmShell::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets()); 432 WmShell::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets());
433 } 433 }
434 } 434 }
435 435
436 void ShelfLayoutManager::OnKeyboardClosed() {} 436 void ShelfLayoutManager::OnKeyboardClosed() {}
437 437
438 bool ShelfLayoutManager::IsHorizontalAlignment() const {
439 return ::ash::IsHorizontalAlignment(GetAlignment());
440 }
441
442 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { 438 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
443 if (state_.pre_lock_screen_animation_active) 439 if (state_.pre_lock_screen_animation_active)
444 return SHELF_BACKGROUND_DEFAULT; 440 return SHELF_BACKGROUND_DEFAULT;
445 441
446 // Handle all non active screen states, including OOBE and pre-login. 442 // Handle all non active screen states, including OOBE and pre-login.
447 if (state_.session_state != session_manager::SessionState::ACTIVE) 443 if (state_.session_state != session_manager::SessionState::ACTIVE)
448 return SHELF_BACKGROUND_OVERLAP; 444 return SHELF_BACKGROUND_OVERLAP;
449 445
450 if (state_.visibility_state != SHELF_AUTO_HIDE && 446 if (state_.visibility_state != SHELF_AUTO_HIDE &&
451 state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) { 447 state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; 601 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf;
606 status_bounds.Offset(target_bounds.shelf_bounds_in_root.OffsetFromOrigin()); 602 status_bounds.Offset(target_bounds.shelf_bounds_in_root.OffsetFromOrigin());
607 WmWindow* status_window = WmLookup::Get()->GetWindowForWidget( 603 WmWindow* status_window = WmLookup::Get()->GetWindowForWidget(
608 shelf_widget_->status_area_widget()); 604 shelf_widget_->status_area_widget());
609 shelf_widget_->status_area_widget()->SetBounds( 605 shelf_widget_->status_area_widget()->SetBounds(
610 status_window->GetParent()->ConvertRectToScreen(status_bounds)); 606 status_window->GetParent()->ConvertRectToScreen(status_bounds));
611 607
612 // For crbug.com/622431, when the shelf alignment is BOTTOM_LOCKED, we 608 // For crbug.com/622431, when the shelf alignment is BOTTOM_LOCKED, we
613 // don't set display work area, as it is not real user-set alignment. 609 // don't set display work area, as it is not real user-set alignment.
614 if (!state_.IsScreenLocked() && 610 if (!state_.IsScreenLocked() &&
615 shelf_widget_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM_LOCKED && 611 wm_shelf_->GetAlignment() != SHELF_ALIGNMENT_BOTTOM_LOCKED &&
616 change_work_area) { 612 change_work_area) {
617 gfx::Insets insets; 613 gfx::Insets insets;
618 // If user session is blocked (login to new user session or add user to 614 // If user session is blocked (login to new user session or add user to
619 // the existing session - multi-profile) then give 100% of work area only 615 // the existing session - multi-profile) then give 100% of work area only
620 // if keyboard is not shown. 616 // if keyboard is not shown.
621 if (!state_.IsAddingSecondaryUser() || !keyboard_bounds_.IsEmpty()) 617 if (!state_.IsAddingSecondaryUser() || !keyboard_bounds_.IsEmpty())
622 insets = target_bounds.work_area_insets; 618 insets = target_bounds.work_area_insets;
623 WmShell::Get()->SetDisplayWorkAreaInsets(shelf_window, insets); 619 WmShell::Get()->SetDisplayWorkAreaInsets(shelf_window, insets);
624 } 620 }
625 } 621 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 666
671 gfx::Point shelf_origin = SelectValueForShelfAlignment( 667 gfx::Point shelf_origin = SelectValueForShelfAlignment(
672 gfx::Point(available_bounds.x(), bottom_shelf_vertical_offset), 668 gfx::Point(available_bounds.x(), bottom_shelf_vertical_offset),
673 gfx::Point(available_bounds.x(), available_bounds.y()), 669 gfx::Point(available_bounds.x(), available_bounds.y()),
674 gfx::Point(available_bounds.right() - shelf_width, available_bounds.y())); 670 gfx::Point(available_bounds.right() - shelf_width, available_bounds.y()));
675 target_bounds->shelf_bounds_in_root = 671 target_bounds->shelf_bounds_in_root =
676 gfx::Rect(shelf_origin.x(), shelf_origin.y(), shelf_width, shelf_height); 672 gfx::Rect(shelf_origin.x(), shelf_origin.y(), shelf_width, shelf_height);
677 673
678 gfx::Size status_size( 674 gfx::Size status_size(
679 shelf_widget_->status_area_widget()->GetWindowBoundsInScreen().size()); 675 shelf_widget_->status_area_widget()->GetWindowBoundsInScreen().size());
680 if (IsHorizontalAlignment()) 676 if (wm_shelf_->IsHorizontalAlignment())
681 status_size.set_height(GetShelfConstant(SHELF_SIZE)); 677 status_size.set_height(GetShelfConstant(SHELF_SIZE));
682 else 678 else
683 status_size.set_width(GetShelfConstant(SHELF_SIZE)); 679 status_size.set_width(GetShelfConstant(SHELF_SIZE));
684 680
685 gfx::Point status_origin = SelectValueForShelfAlignment( 681 gfx::Point status_origin = SelectValueForShelfAlignment(
686 gfx::Point(0, 0), gfx::Point(shelf_width - status_size.width(), 682 gfx::Point(0, 0), gfx::Point(shelf_width - status_size.width(),
687 shelf_height - status_size.height()), 683 shelf_height - status_size.height()),
688 gfx::Point(0, shelf_height - status_size.height())); 684 gfx::Point(0, shelf_height - status_size.height()));
689 if (IsHorizontalAlignment() && !base::i18n::IsRTL()) 685 if (wm_shelf_->IsHorizontalAlignment() && !base::i18n::IsRTL())
690 status_origin.set_x(shelf_width - status_size.width()); 686 status_origin.set_x(shelf_width - status_size.width());
691 target_bounds->status_bounds_in_shelf = gfx::Rect(status_origin, status_size); 687 target_bounds->status_bounds_in_shelf = gfx::Rect(status_origin, status_size);
692 688
693 target_bounds->work_area_insets = SelectValueForShelfAlignment( 689 target_bounds->work_area_insets = SelectValueForShelfAlignment(
694 gfx::Insets(0, 0, GetWorkAreaInsets(state, shelf_height), 0), 690 gfx::Insets(0, 0, GetWorkAreaInsets(state, shelf_height), 0),
695 gfx::Insets(0, GetWorkAreaInsets(state, shelf_width), 0, 0), 691 gfx::Insets(0, GetWorkAreaInsets(state, shelf_width), 0, 0),
696 gfx::Insets(0, 0, 0, GetWorkAreaInsets(state, shelf_width))); 692 gfx::Insets(0, 0, 0, GetWorkAreaInsets(state, shelf_width)));
697 693
698 // TODO(varkha): The functionality of managing insets for display areas 694 // TODO(varkha): The functionality of managing insets for display areas
699 // should probably be pushed to a separate component. This would simplify or 695 // should probably be pushed to a separate component. This would simplify or
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 available_bounds.Subtract(target_bounds->shelf_bounds_in_root); 739 available_bounds.Subtract(target_bounds->shelf_bounds_in_root);
744 available_bounds.Subtract(keyboard_bounds_); 740 available_bounds.Subtract(keyboard_bounds_);
745 741
746 WmWindow* root = shelf_window->GetRootWindow(); 742 WmWindow* root = shelf_window->GetRootWindow();
747 user_work_area_bounds_ = root->ConvertRectToScreen(available_bounds); 743 user_work_area_bounds_ = root->ConvertRectToScreen(available_bounds);
748 } 744 }
749 745
750 void ShelfLayoutManager::UpdateTargetBoundsForGesture( 746 void ShelfLayoutManager::UpdateTargetBoundsForGesture(
751 TargetBounds* target_bounds) const { 747 TargetBounds* target_bounds) const {
752 CHECK_EQ(GESTURE_DRAG_IN_PROGRESS, gesture_drag_status_); 748 CHECK_EQ(GESTURE_DRAG_IN_PROGRESS, gesture_drag_status_);
753 bool horizontal = IsHorizontalAlignment(); 749 bool horizontal = wm_shelf_->IsHorizontalAlignment();
754 WmWindow* window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 750 WmWindow* window = WmLookup::Get()->GetWindowForWidget(shelf_widget_);
755 gfx::Rect available_bounds = wm::GetDisplayBoundsWithShelf(window); 751 gfx::Rect available_bounds = wm::GetDisplayBoundsWithShelf(window);
756 int resistance_free_region = 0; 752 int resistance_free_region = 0;
757 753
758 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN && 754 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN &&
759 visibility_state() == SHELF_AUTO_HIDE && 755 visibility_state() == SHELF_AUTO_HIDE &&
760 auto_hide_state() != SHELF_AUTO_HIDE_SHOWN) { 756 auto_hide_state() != SHELF_AUTO_HIDE_SHOWN) {
761 // If the shelf was hidden when the drag started (and the state hasn't 757 // If the shelf was hidden when the drag started (and the state hasn't
762 // changed since then, e.g. because the tray-menu was shown because of the 758 // changed since then, e.g. because the tray-menu was shown because of the
763 // drag), then allow the drag some resistance-free region at first to make 759 // drag), then allow the drag some resistance-free region at first to make
(...skipping 16 matching lines...) Expand all
780 translate = resistance_free_region + diff; 776 translate = resistance_free_region + diff;
781 } else { 777 } else {
782 translate = gesture_drag_amount_; 778 translate = gesture_drag_amount_;
783 } 779 }
784 int shelf_insets = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); 780 int shelf_insets = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE);
785 if (horizontal) { 781 if (horizontal) {
786 // Move and size the shelf with the gesture. 782 // Move and size the shelf with the gesture.
787 int shelf_height = target_bounds->shelf_bounds_in_root.height() - translate; 783 int shelf_height = target_bounds->shelf_bounds_in_root.height() - translate;
788 shelf_height = std::max(shelf_height, shelf_insets); 784 shelf_height = std::max(shelf_height, shelf_insets);
789 target_bounds->shelf_bounds_in_root.set_height(shelf_height); 785 target_bounds->shelf_bounds_in_root.set_height(shelf_height);
790 if (IsHorizontalAlignment()) { 786 if (wm_shelf_->IsHorizontalAlignment()) {
791 target_bounds->shelf_bounds_in_root.set_y(available_bounds.bottom() - 787 target_bounds->shelf_bounds_in_root.set_y(available_bounds.bottom() -
792 shelf_height); 788 shelf_height);
793 } 789 }
794 790
795 target_bounds->status_bounds_in_shelf.set_y(0); 791 target_bounds->status_bounds_in_shelf.set_y(0);
796 } else { 792 } else {
797 // Move and size the shelf with the gesture. 793 // Move and size the shelf with the gesture.
798 int shelf_width = target_bounds->shelf_bounds_in_root.width(); 794 int shelf_width = target_bounds->shelf_bounds_in_root.width();
799 bool right_aligned = GetAlignment() == SHELF_ALIGNMENT_RIGHT; 795 bool right_aligned = wm_shelf_->GetAlignment() == SHELF_ALIGNMENT_RIGHT;
800 if (right_aligned) 796 if (right_aligned)
801 shelf_width -= translate; 797 shelf_width -= translate;
802 else 798 else
803 shelf_width += translate; 799 shelf_width += translate;
804 shelf_width = std::max(shelf_width, shelf_insets); 800 shelf_width = std::max(shelf_width, shelf_insets);
805 target_bounds->shelf_bounds_in_root.set_width(shelf_width); 801 target_bounds->shelf_bounds_in_root.set_width(shelf_width);
806 if (right_aligned) { 802 if (right_aligned) {
807 target_bounds->shelf_bounds_in_root.set_x(available_bounds.right() - 803 target_bounds->shelf_bounds_in_root.set_x(available_bounds.right() -
808 shelf_width); 804 shelf_width);
809 } 805 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 840
845 gfx::Rect ShelfLayoutManager::GetAutoHideShowShelfRegionInScreen() const { 841 gfx::Rect ShelfLayoutManager::GetAutoHideShowShelfRegionInScreen() const {
846 gfx::Rect shelf_bounds_in_screen = shelf_widget_->GetWindowBoundsInScreen(); 842 gfx::Rect shelf_bounds_in_screen = shelf_widget_->GetWindowBoundsInScreen();
847 gfx::Vector2d offset = SelectValueForShelfAlignment( 843 gfx::Vector2d offset = SelectValueForShelfAlignment(
848 gfx::Vector2d(0, shelf_bounds_in_screen.height()), 844 gfx::Vector2d(0, shelf_bounds_in_screen.height()),
849 gfx::Vector2d(-kMaxAutoHideShowShelfRegionSize, 0), 845 gfx::Vector2d(-kMaxAutoHideShowShelfRegionSize, 0),
850 gfx::Vector2d(shelf_bounds_in_screen.width(), 0)); 846 gfx::Vector2d(shelf_bounds_in_screen.width(), 0));
851 847
852 gfx::Rect show_shelf_region_in_screen = shelf_bounds_in_screen; 848 gfx::Rect show_shelf_region_in_screen = shelf_bounds_in_screen;
853 show_shelf_region_in_screen += offset; 849 show_shelf_region_in_screen += offset;
854 if (IsHorizontalAlignment()) 850 if (wm_shelf_->IsHorizontalAlignment())
855 show_shelf_region_in_screen.set_height(kMaxAutoHideShowShelfRegionSize); 851 show_shelf_region_in_screen.set_height(kMaxAutoHideShowShelfRegionSize);
856 else 852 else
857 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); 853 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize);
858 854
859 // TODO: Figure out if we need any special handling when the keyboard is 855 // TODO: Figure out if we need any special handling when the keyboard is
860 // visible. 856 // visible.
861 return show_shelf_region_in_screen; 857 return show_shelf_region_in_screen;
862 } 858 }
863 859
864 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( 860 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 // Ignore the mouse position if mouse events are disabled. 911 // Ignore the mouse position if mouse events are disabled.
916 if (!shelf_widget_->IsMouseEventsEnabled()) 912 if (!shelf_widget_->IsMouseEventsEnabled())
917 return SHELF_AUTO_HIDE_HIDDEN; 913 return SHELF_AUTO_HIDE_HIDDEN;
918 914
919 gfx::Rect shelf_region = shelf_widget_->GetWindowBoundsInScreen(); 915 gfx::Rect shelf_region = shelf_widget_->GetWindowBoundsInScreen();
920 if (shelf_widget_->status_area_widget() && 916 if (shelf_widget_->status_area_widget() &&
921 shelf_widget_->status_area_widget()->IsMessageBubbleShown() && 917 shelf_widget_->status_area_widget()->IsMessageBubbleShown() &&
922 IsVisible()) { 918 IsVisible()) {
923 // Increase the the hit test area to prevent the shelf from disappearing 919 // Increase the the hit test area to prevent the shelf from disappearing
924 // when the mouse is over the bubble gap. 920 // when the mouse is over the bubble gap.
925 ShelfAlignment alignment = GetAlignment(); 921 ShelfAlignment alignment = wm_shelf_->GetAlignment();
926 shelf_region.Inset( 922 shelf_region.Inset(
927 alignment == SHELF_ALIGNMENT_RIGHT ? -kNotificationBubbleGapHeight : 0, 923 alignment == SHELF_ALIGNMENT_RIGHT ? -kNotificationBubbleGapHeight : 0,
928 IsHorizontalAlignment() ? -kNotificationBubbleGapHeight : 0, 924 wm_shelf_->IsHorizontalAlignment() ? -kNotificationBubbleGapHeight : 0,
929 alignment == SHELF_ALIGNMENT_LEFT ? -kNotificationBubbleGapHeight : 0, 925 alignment == SHELF_ALIGNMENT_LEFT ? -kNotificationBubbleGapHeight : 0,
930 0); 926 0);
931 } 927 }
932 928
933 gfx::Point cursor_position_in_screen = 929 gfx::Point cursor_position_in_screen =
934 display::Screen::GetScreen()->GetCursorScreenPoint(); 930 display::Screen::GetScreen()->GetCursorScreenPoint();
935 if (shelf_region.Contains(cursor_position_in_screen)) 931 if (shelf_region.Contains(cursor_position_in_screen))
936 return SHELF_AUTO_HIDE_SHOWN; 932 return SHELF_AUTO_HIDE_SHOWN;
937 933
938 // When the shelf is auto hidden and the shelf is on the boundary between two 934 // When the shelf is auto hidden and the shelf is on the boundary between two
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 MaybeUpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE); 1063 MaybeUpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE);
1068 } 1064 }
1069 1065
1070 void ShelfLayoutManager::UpdateGestureDrag(const ui::GestureEvent& gesture) { 1066 void ShelfLayoutManager::UpdateGestureDrag(const ui::GestureEvent& gesture) {
1071 gesture_drag_amount_ += PrimaryAxisValue(gesture.details().scroll_y(), 1067 gesture_drag_amount_ += PrimaryAxisValue(gesture.details().scroll_y(),
1072 gesture.details().scroll_x()); 1068 gesture.details().scroll_x());
1073 LayoutShelf(); 1069 LayoutShelf();
1074 } 1070 }
1075 1071
1076 void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) { 1072 void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) {
1077 bool horizontal = IsHorizontalAlignment(); 1073 bool horizontal = wm_shelf_->IsHorizontalAlignment();
1078 bool should_change = false; 1074 bool should_change = false;
1079 if (gesture.type() == ui::ET_GESTURE_SCROLL_END) { 1075 if (gesture.type() == ui::ET_GESTURE_SCROLL_END) {
1080 // The visibility of the shelf changes only if the shelf was dragged X% 1076 // The visibility of the shelf changes only if the shelf was dragged X%
1081 // along the correct axis. If the shelf was already visible, then the 1077 // along the correct axis. If the shelf was already visible, then the
1082 // direction of the drag does not matter. 1078 // direction of the drag does not matter.
1083 const float kDragHideThreshold = 0.4f; 1079 const float kDragHideThreshold = 0.4f;
1084 gfx::Rect bounds = GetIdealBounds(); 1080 gfx::Rect bounds = GetIdealBounds();
1085 float drag_ratio = fabs(gesture_drag_amount_) / 1081 float drag_ratio = fabs(gesture_drag_amount_) /
1086 (horizontal ? bounds.height() : bounds.width()); 1082 (horizontal ? bounds.height() : bounds.width());
1087 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) { 1083 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) {
1088 should_change = drag_ratio > kDragHideThreshold; 1084 should_change = drag_ratio > kDragHideThreshold;
1089 } else { 1085 } else {
1090 bool correct_direction = false; 1086 bool correct_direction = false;
1091 switch (GetAlignment()) { 1087 switch (wm_shelf_->GetAlignment()) {
1092 case SHELF_ALIGNMENT_BOTTOM: 1088 case SHELF_ALIGNMENT_BOTTOM:
1093 case SHELF_ALIGNMENT_BOTTOM_LOCKED: 1089 case SHELF_ALIGNMENT_BOTTOM_LOCKED:
1094 case SHELF_ALIGNMENT_RIGHT: 1090 case SHELF_ALIGNMENT_RIGHT:
1095 correct_direction = gesture_drag_amount_ < 0; 1091 correct_direction = gesture_drag_amount_ < 0;
1096 break; 1092 break;
1097 case SHELF_ALIGNMENT_LEFT: 1093 case SHELF_ALIGNMENT_LEFT:
1098 correct_direction = gesture_drag_amount_ > 0; 1094 correct_direction = gesture_drag_amount_ > 0;
1099 break; 1095 break;
1100 } 1096 }
1101 should_change = correct_direction && drag_ratio > kDragHideThreshold; 1097 should_change = correct_direction && drag_ratio > kDragHideThreshold;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 gesture_drag_status_ = GESTURE_DRAG_NONE; 1139 gesture_drag_status_ = GESTURE_DRAG_NONE;
1144 } 1140 }
1145 1141
1146 void ShelfLayoutManager::CancelGestureDrag() { 1142 void ShelfLayoutManager::CancelGestureDrag() {
1147 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; 1143 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS;
1148 UpdateVisibilityState(); 1144 UpdateVisibilityState();
1149 gesture_drag_status_ = GESTURE_DRAG_NONE; 1145 gesture_drag_status_ = GESTURE_DRAG_NONE;
1150 } 1146 }
1151 1147
1152 } // namespace ash 1148 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_layout_manager.h ('k') | ash/common/shelf/shelf_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698