Commit 401ee65b authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Per pixel launcher dragging

Use PointF/float to calculate Y position, then use
SubpixelPositionOffset to move the window to pixel position.

Reset to DP position when moving to the specific state.

   requires a fix to event generator.

Bug: 1042754, 1038998
Test: Maually tested. unit tests will be added in a separate CL as it
Change-Id: I6157f46bc00929e03379a4b3e80e9b5b75ed72ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2002863
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732997}
parent 15b7ba37
...@@ -1309,7 +1309,9 @@ bool AppListControllerImpl::ShouldDismissImmediately() { ...@@ -1309,7 +1309,9 @@ bool AppListControllerImpl::ShouldDismissImmediately() {
Shelf::ForWindow(presenter_.GetView()->GetWidget()->GetNativeView()) Shelf::ForWindow(presenter_.GetView()->GetWidget()->GetNativeView())
->GetIdealBounds() ->GetIdealBounds()
.y(); .y();
const int current_y = presenter_.GetView()->GetBoundsInScreen().y();
const int current_y =
presenter_.GetView()->GetWidget()->GetNativeWindow()->bounds().y();
return current_y > ideal_shelf_y; return current_y > ideal_shelf_y;
} }
......
...@@ -243,7 +243,7 @@ bool AppListPresenterImpl::GetTargetVisibility() const { ...@@ -243,7 +243,7 @@ bool AppListPresenterImpl::GetTargetVisibility() const {
return is_target_visibility_show_; return is_target_visibility_show_;
} }
void AppListPresenterImpl::UpdateYPositionAndOpacity(int y_position_in_screen, void AppListPresenterImpl::UpdateYPositionAndOpacity(float y_position_in_screen,
float background_opacity) { float background_opacity) {
if (!is_target_visibility_show_) if (!is_target_visibility_show_)
return; return;
...@@ -264,7 +264,7 @@ void AppListPresenterImpl::ProcessMouseWheelOffset( ...@@ -264,7 +264,7 @@ void AppListPresenterImpl::ProcessMouseWheelOffset(
} }
void AppListPresenterImpl::UpdateYPositionAndOpacityForHomeLauncher( void AppListPresenterImpl::UpdateYPositionAndOpacityForHomeLauncher(
int y_position_in_screen, float y_position_in_screen,
float opacity, float opacity,
base::Optional<TabletModeAnimationTransition> transition, base::Optional<TabletModeAnimationTransition> transition,
UpdateHomeLauncherAnimationSettingsCallback callback) { UpdateHomeLauncherAnimationSettingsCallback callback) {
...@@ -283,7 +283,7 @@ void AppListPresenterImpl::UpdateYPositionAndOpacityForHomeLauncher( ...@@ -283,7 +283,7 @@ void AppListPresenterImpl::UpdateYPositionAndOpacityForHomeLauncher(
} }
const gfx::Transform translation(1.f, 0.f, 0.f, 1.f, 0.f, const gfx::Transform translation(1.f, 0.f, 0.f, 1.f, 0.f,
static_cast<float>(y_position_in_screen)); y_position_in_screen);
if (layer->GetAnimator()->is_animating()) { if (layer->GetAnimator()->is_animating()) {
layer->GetAnimator()->StopAnimating(); layer->GetAnimator()->StopAnimating();
......
...@@ -93,7 +93,7 @@ class APP_LIST_EXPORT AppListPresenterImpl ...@@ -93,7 +93,7 @@ class APP_LIST_EXPORT AppListPresenterImpl
bool GetTargetVisibility() const; bool GetTargetVisibility() const;
// Updates y position and opacity of app list. // Updates y position and opacity of app list.
void UpdateYPositionAndOpacity(int y_position_in_screen, void UpdateYPositionAndOpacity(float y_position_in_screen,
float background_opacity); float background_opacity);
// Ends the drag of app list from shelf. // Ends the drag of app list from shelf.
...@@ -110,7 +110,7 @@ class APP_LIST_EXPORT AppListPresenterImpl ...@@ -110,7 +110,7 @@ class APP_LIST_EXPORT AppListPresenterImpl
// |callback| is non-null. If not set, the animation smoothness metrics will // |callback| is non-null. If not set, the animation smoothness metrics will
// not be reported. // not be reported.
void UpdateYPositionAndOpacityForHomeLauncher( void UpdateYPositionAndOpacityForHomeLauncher(
int y_position_in_screen, float y_position_in_screen,
float opacity, float opacity,
base::Optional<TabletModeAnimationTransition> transition, base::Optional<TabletModeAnimationTransition> transition,
UpdateHomeLauncherAnimationSettingsCallback callback); UpdateHomeLauncherAnimationSettingsCallback callback);
......
This diff is collapsed.
...@@ -212,7 +212,7 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -212,7 +212,7 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
bool triggered_by_contents_change); bool triggered_by_contents_change);
// Updates y position and opacity of app list during dragging. // Updates y position and opacity of app list during dragging.
void UpdateYPositionAndOpacity(int y_position_in_screen, void UpdateYPositionAndOpacity(float y_position_in_screen,
float background_opacity); float background_opacity);
// Offsets the y position of the app list (above the screen) // Offsets the y position of the app list (above the screen)
...@@ -398,15 +398,15 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -398,15 +398,15 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
void HandleClickOrTap(ui::LocatedEvent* event); void HandleClickOrTap(ui::LocatedEvent* event);
// Initializes |initial_drag_point_|. // Initializes |initial_drag_point_|.
void StartDrag(const gfx::Point& location); void StartDrag(const gfx::PointF& location_in_root);
// Updates the bounds of the widget while maintaining the relative position // Updates the bounds of the widget while maintaining the relative position
// of the top of the widget and the gesture. // of the top of the widget and the gesture.
void UpdateDrag(const gfx::Point& location); void UpdateDrag(const gfx::PointF& location_in_root);
// Handles app list state transfers. If the drag was fast enough, ignore the // Handles app list state transfers. If the drag was fast enough, ignore the
// release position and snap to the next state. // release position and snap to the next state.
void EndDrag(const gfx::Point& location); void EndDrag(const gfx::PointF& location_in_root);
// Set child views for |target_state|. // Set child views for |target_state|.
void SetChildViewsForStateTransition(AppListViewState target_state); void SetChildViewsForStateTransition(AppListViewState target_state);
...@@ -492,6 +492,10 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -492,6 +492,10 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// |state| and |is_in_drag_|. // |state| and |is_in_drag_|.
void UpdateAppListBackgroundYPosition(AppListViewState state); void UpdateAppListBackgroundYPosition(AppListViewState state);
// Reset the subpixel position offset of the |layer| so that it's DP origin
// is snapped.
void ResetSubpixelPositionOffset(ui::Layer* layer);
AppListViewDelegate* delegate_; // Weak. Owned by AppListService. AppListViewDelegate* delegate_; // Weak. Owned by AppListService.
AppListModel* const model_; // Not Owned. AppListModel* const model_; // Not Owned.
SearchModel* const search_model_; // Not Owned. SearchModel* const search_model_; // Not Owned.
...@@ -524,22 +528,19 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -524,22 +528,19 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// Whether the view is being built. // Whether the view is being built.
bool is_building_ = false; bool is_building_ = false;
// Y position of the app list in screen space coordinate during dragging.
int app_list_y_position_in_screen_ = 0;
// The opacity of app list background during dragging. This ensures a gradual // The opacity of app list background during dragging. This ensures a gradual
// opacity shift from the shelf opacity while dragging to show the AppListView // opacity shift from the shelf opacity while dragging to show the AppListView
// from the shelf. // from the shelf.
float background_opacity_in_drag_ = 0.f; float background_opacity_in_drag_ = 0.f;
// The location of initial gesture event in screen coordinates. // The location of initial gesture event in root window coordinates.
gfx::Point initial_drag_point_; gfx::PointF initial_drag_point_;
// The rectangle of initial widget's window in screen coordinates. // The offset to the widget from dragging location.
gfx::Rect initial_window_bounds_; float drag_offset_;
// The location of the initial mouse event in view coordinates. // The location of the initial mouse event in root window coordinates.
gfx::Point initial_mouse_drag_point_; gfx::PointF initial_mouse_drag_point_;
// The velocity of the gesture event. // The velocity of the gesture event.
float last_fling_velocity_ = 0; float last_fling_velocity_ = 0;
......
...@@ -2382,11 +2382,12 @@ void ShelfLayoutManager::UpdateDrag(const ui::LocatedEvent& event_in_screen, ...@@ -2382,11 +2382,12 @@ void ShelfLayoutManager::UpdateDrag(const ui::LocatedEvent& event_in_screen,
return; return;
} }
const gfx::Rect shelf_bounds = GetIdealBounds(); const gfx::Rect shelf_bounds = GetIdealBounds();
float y_position_in_root = std::min(event_in_screen.root_location_f().y(),
static_cast<float>(shelf_bounds.y()));
Shell::Get()->app_list_controller()->UpdateYPositionAndOpacity( Shell::Get()->app_list_controller()->UpdateYPositionAndOpacity(
std::min(event_in_screen.location().y(), shelf_bounds.y()), y_position_in_root, GetAppListBackgroundOpacityOnShelfOpacity());
GetAppListBackgroundOpacityOnShelfOpacity());
launcher_above_shelf_bottom_amount_ = launcher_above_shelf_bottom_amount_ =
shelf_bounds.bottom() - event_in_screen.location().y(); shelf_bounds.bottom() - event_in_screen.root_location().y();
} else { } else {
if (drag_start_point_in_screen_ == gfx::Point()) if (drag_start_point_in_screen_ == gfx::Point())
drag_start_point_in_screen_ = event_in_screen.location(); drag_start_point_in_screen_ = event_in_screen.location();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment