Commit 76db848d authored by Caroline Rising's avatar Caroline Rising Committed by Commit Bot

Update pinned extension dragging for the new extensions container.

Update an extension's position when it moves past the midway point between extensions.

Bug: 1008538
Change-Id: I302bc0f4b50bb37999ce5c164a171ccd2eeeee39
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1863509Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Caroline Rising <corising@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706163}
parent a37797f5
...@@ -334,14 +334,11 @@ int ExtensionsToolbarContainer::OnDragUpdated( ...@@ -334,14 +334,11 @@ int ExtensionsToolbarContainer::OnDragUpdated(
// Figure out where to display the icon during dragging transition. // Figure out where to display the icon during dragging transition.
// First, since we want to update the dragged extension's position from before // First, since we want to update the dragged extension's position from before
// an icon to after it when the event passes the midpoint of another icon, add // an icon to after it when the event passes the midpoint between two icons.
// (icon width / 2) and divide by the icon width. This will convert the // This will convert the event coordinate into the index of the icon we want
// event coordinate into the index of the icon we want to display the // to display the dragged extension before. We also mirror the event.x() so
// dragged extension before. We also mirror the event.x() so that our // that our calculations are consistent with left-to-right.
// calculations are consistent with left-to-right. const int offset_into_icon_area = GetMirroredXInView(event.x());
const auto size = GetToolbarActionSize();
const int offset_into_icon_area =
GetMirroredXInView(event.x()) + (size.width() / 2);
const int before_icon_unclamped = WidthToIconCount(offset_into_icon_area); const int before_icon_unclamped = WidthToIconCount(offset_into_icon_area);
int visible_icons = model_->pinned_action_ids().size(); int visible_icons = model_->pinned_action_ids().size();
...@@ -354,11 +351,7 @@ int ExtensionsToolbarContainer::OnDragUpdated( ...@@ -354,11 +351,7 @@ int ExtensionsToolbarContainer::OnDragUpdated(
before_icon = base::ClampToRange(before_icon_unclamped, 0, visible_icons); before_icon = base::ClampToRange(before_icon_unclamped, 0, visible_icons);
if (!drop_info_.get() || drop_info_->index != before_icon) { if (!drop_info_.get() || drop_info_->index != before_icon) {
size_t current_index = drop_info_.get() ? drop_info_->index : data.index(); drop_info_ = std::make_unique<DropInfo>(data.id(), before_icon);
// If the target drop position is past the current index we must account for
// this later being removed.
drop_info_ = std::make_unique<DropInfo>(
data.id(), before_icon > current_index ? before_icon - 1 : before_icon);
ReorderViews(); ReorderViews();
} }
......
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