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() {
Shelf::ForWindow(presenter_.GetView()->GetWidget()->GetNativeView())
->GetIdealBounds()
.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;
}
......
......@@ -243,7 +243,7 @@ bool AppListPresenterImpl::GetTargetVisibility() const {
return is_target_visibility_show_;
}
void AppListPresenterImpl::UpdateYPositionAndOpacity(int y_position_in_screen,
void AppListPresenterImpl::UpdateYPositionAndOpacity(float y_position_in_screen,
float background_opacity) {
if (!is_target_visibility_show_)
return;
......@@ -264,7 +264,7 @@ void AppListPresenterImpl::ProcessMouseWheelOffset(
}
void AppListPresenterImpl::UpdateYPositionAndOpacityForHomeLauncher(
int y_position_in_screen,
float y_position_in_screen,
float opacity,
base::Optional<TabletModeAnimationTransition> transition,
UpdateHomeLauncherAnimationSettingsCallback callback) {
......@@ -283,7 +283,7 @@ void AppListPresenterImpl::UpdateYPositionAndOpacityForHomeLauncher(
}
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()) {
layer->GetAnimator()->StopAnimating();
......
......@@ -93,7 +93,7 @@ class APP_LIST_EXPORT AppListPresenterImpl
bool GetTargetVisibility() const;
// 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);
// Ends the drag of app list from shelf.
......@@ -110,7 +110,7 @@ class APP_LIST_EXPORT AppListPresenterImpl
// |callback| is non-null. If not set, the animation smoothness metrics will
// not be reported.
void UpdateYPositionAndOpacityForHomeLauncher(
int y_position_in_screen,
float y_position_in_screen,
float opacity,
base::Optional<TabletModeAnimationTransition> transition,
UpdateHomeLauncherAnimationSettingsCallback callback);
......
This diff is collapsed.
......@@ -212,7 +212,7 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
bool triggered_by_contents_change);
// 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);
// Offsets the y position of the app list (above the screen)
......@@ -398,15 +398,15 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
void HandleClickOrTap(ui::LocatedEvent* event);
// 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
// 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
// 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|.
void SetChildViewsForStateTransition(AppListViewState target_state);
......@@ -492,6 +492,10 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// |state| and |is_in_drag_|.
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.
AppListModel* const model_; // Not Owned.
SearchModel* const search_model_; // Not Owned.
......@@ -524,22 +528,19 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// Whether the view is being built.
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
// opacity shift from the shelf opacity while dragging to show the AppListView
// from the shelf.
float background_opacity_in_drag_ = 0.f;
// The location of initial gesture event in screen coordinates.
gfx::Point initial_drag_point_;
// The location of initial gesture event in root window coordinates.
gfx::PointF initial_drag_point_;
// The rectangle of initial widget's window in screen coordinates.
gfx::Rect initial_window_bounds_;
// The offset to the widget from dragging location.
float drag_offset_;
// The location of the initial mouse event in view coordinates.
gfx::Point initial_mouse_drag_point_;
// The location of the initial mouse event in root window coordinates.
gfx::PointF initial_mouse_drag_point_;
// The velocity of the gesture event.
float last_fling_velocity_ = 0;
......
......@@ -2382,11 +2382,12 @@ void ShelfLayoutManager::UpdateDrag(const ui::LocatedEvent& event_in_screen,
return;
}
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(
std::min(event_in_screen.location().y(), shelf_bounds.y()),
GetAppListBackgroundOpacityOnShelfOpacity());
y_position_in_root, GetAppListBackgroundOpacityOnShelfOpacity());
launcher_above_shelf_bottom_amount_ =
shelf_bounds.bottom() - event_in_screen.location().y();
shelf_bounds.bottom() - event_in_screen.root_location().y();
} else {
if (drag_start_point_in_screen_ == gfx::Point())
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