Commit 168e8dce authored by Min Chen's avatar Min Chen Committed by Commit Bot

Consolidate size of the drag window from top or from overview items.

The size of dragging window used to be different depending on how dragging
started. It was bigger when you drag from the top compared to when you drag
from overview items.

This CL consolidate two into the same size, to the size used when dragged
from overview items.

see recorded video:
https://drive.google.com/file/d/0B5I0jFeLxqIiNThBNU1sbVRTRUgyZmRUNUpxdVI2WVRsSHBj/view?usp=sharing

Bug: 872528
Change-Id: I778fdb871556ec960b4d8fdffd1f608c19a01148
Reviewed-on: https://chromium-review.googlesource.com/1173158Reviewed-by: default avatarMitsuru Oshima (Slow) <oshima@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584521}
parent 1f3361c1
......@@ -23,10 +23,6 @@ namespace ash {
namespace {
// Before dragging an overview window, the window will scale up |kPreDragScale|
// to indicate its selection.
constexpr float kDragWindowScale = 0.04f;
// The amount of distance from the start of drag the item needs to be dragged
// vertically for it to be closed on release.
constexpr float kDragToCloseDistanceThresholdDp = 160.f;
......@@ -173,11 +169,7 @@ void OverviewWindowDragController::CompleteDrag(
void OverviewWindowDragController::StartSplitViewDragMode(
const gfx::Point& location_in_screen) {
// Increase the bounds of the dragged item.
gfx::Rect scaled_bounds(item_->target_bounds());
scaled_bounds.Inset(-scaled_bounds.width() * kDragWindowScale,
-scaled_bounds.height() * kDragWindowScale);
item_->SetBounds(scaled_bounds, OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS);
item_->ScaleUpSelectedItem(OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS);
did_move_ = true;
current_drag_behavior_ = DragBehavior::kDragToSnap;
......
......@@ -121,6 +121,10 @@ constexpr SkColor kBackdropColor = SkColorSetARGB(0x24, 0xFF, 0xFF, 0xFF);
// swipe to close.
constexpr int kSwipeToCloseCloseTranslationDp = 96;
// Before dragging an overview window, the window will be scaled up
// |kPreDragScale| to indicate its selection.
constexpr float kDragWindowScale = 0.04f;
std::unique_ptr<views::Widget> CreateBackdropWidget(aura::Window* parent) {
auto widget = CreateBackgroundWidget(
/*root_window=*/nullptr, ui::LAYER_TEXTURED, kBackdropColor,
......@@ -733,6 +737,19 @@ void WindowSelectorItem::UpdateBackdropBounds() {
backdrop_widget_->Show();
}
gfx::Rect WindowSelectorItem::GetBoundsOfSelectedItem() {
ScaleUpSelectedItem(OVERVIEW_ANIMATION_NONE);
return transform_window_.GetTransformedBounds();
}
void WindowSelectorItem::ScaleUpSelectedItem(
OverviewAnimationType animation_type) {
gfx::Rect scaled_bounds(target_bounds());
scaled_bounds.Inset(-scaled_bounds.width() * kDragWindowScale,
-scaled_bounds.height() * kDragWindowScale);
SetBounds(scaled_bounds, animation_type);
}
void WindowSelectorItem::SetDimmed(bool dimmed) {
dimmed_ = dimmed;
SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f);
......
......@@ -157,6 +157,13 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
void DisableBackdrop();
void UpdateBackdropBounds();
// Returns the bounds of the selected item, which will be scaled up a little
// bit and header view will be hidden after being selected.
gfx::Rect GetBoundsOfSelectedItem();
// Increases the bounds of the dragged item.
void ScaleUpSelectedItem(OverviewAnimationType animation_type);
// Sets if the item is dimmed in the overview. Changing the value will also
// change the visibility of the transform windows.
void SetDimmed(bool dimmed);
......
......@@ -39,9 +39,9 @@ WindowSelector* GetWindowSelector() {
: nullptr;
}
// Gets the new selector item's bounds in overview grid that is displaying in
// the same root window as |dragged_window|.
gfx::Rect GetNewSelectorItemBounds(aura::Window* dragged_window) {
// Gets the bounds of selected new selector item in overview grid that is
// displaying in the same root window as |dragged_window|.
gfx::Rect GetBoundsOfSelectedNewSelectorItem(aura::Window* dragged_window) {
if (!Shell::Get()->window_selector_controller()->IsSelecting())
return gfx::Rect();
......@@ -54,7 +54,7 @@ gfx::Rect GetNewSelectorItemBounds(aura::Window* dragged_window) {
if (!new_selector_item)
return gfx::Rect();
return new_selector_item->target_bounds();
return new_selector_item->GetBoundsOfSelectedItem();
}
// Set |transform| to |window| and its transient child windows. |transform| is
......@@ -119,7 +119,8 @@ void TabletModeWindowDragDelegate::StartWindowDrag(
/*animate=*/was_overview_open);
}
new_selector_item_bounds_ = GetNewSelectorItemBounds(dragged_window_);
bounds_of_selected_new_selector_item_ =
GetBoundsOfSelectedNewSelectorItem(dragged_window_);
}
void TabletModeWindowDragDelegate::ContinueWindowDrag(
......@@ -333,12 +334,14 @@ void TabletModeWindowDragDelegate::UpdateDraggedWindowTransform(
// Calculate the desired scale along the y-axis. The scale of the window
// during drag is based on the distance from |y_location_in_screen| to the y
// position of |new_selector_item_bounds_|. The dragged window will become
// smaller when it becomes nearer to the new selector item. And then keep the
// minimum scale if it has been dragged further than the new selector item.
float scale = static_cast<float>(new_selector_item_bounds_.height()) /
static_cast<float>(dragged_window_->bounds().height());
int y_full = new_selector_item_bounds_.y();
// position of |bounds_of_selected_new_selector_item_|. The dragged window
// will become smaller when it becomes nearer to the new selector item. And
// then keep the minimum scale if it has been dragged further than the new
// selector item.
float scale =
static_cast<float>(bounds_of_selected_new_selector_item_.height()) /
static_cast<float>(dragged_window_->bounds().height());
int y_full = bounds_of_selected_new_selector_item_.y();
int y_diff = y_full - location_in_screen.y();
if (y_diff >= 0)
scale = (1.0f - scale) * y_diff / y_full + scale;
......
......@@ -101,9 +101,9 @@ class TabletModeWindowDragDelegate {
// Overview mode will be triggered if a window is being dragged, and a new
// selector item will be created in the overview grid. The variable stores
// the new selector item bounds in overview and will be used to calculate
// the desired window tranform during dragging.
gfx::Rect new_selector_item_bounds_;
// the bounds of the selected new selector item in overview and will be used
// to calculate the desired window transform during dragging.
gfx::Rect bounds_of_selected_new_selector_item_;
// Flag to indicate whether a window is considered as moved. A window needs to
// be dragged vertically a small amount of distance to be considered as moved.
......
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