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

Unified Diff: ash/shelf/shelf_view.cc

Issue 2820693004: shelf: Allow dragging items from main shelf to overflow shelf. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ash/shelf/shelf_view.cc
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc
index 434c5bfc76f6b15fee7922e1cf3c0695322809db..71b120abbce3ece9957a78859cd50bb7b8ef1ae3 100644
--- a/ash/shelf/shelf_view.cc
+++ b/ash/shelf/shelf_view.cc
@@ -266,7 +266,7 @@ ShelfView::ShelfView(ShelfModel* model,
snap_back_from_rip_off_view_(nullptr),
overflow_mode_(false),
main_shelf_(nullptr),
- dragged_off_from_overflow_to_shelf_(false),
+ dragged_off_from_shelf_to_other_shelf_(false),
is_repost_event_on_same_item_(false),
last_pressed_index_(-1),
weak_factory_(this) {
@@ -754,7 +754,7 @@ void ShelfView::UpdateAllButtonsVisibilityInOverflowMode() {
bool visible = i >= first_visible_index_ && i <= last_visible_index_;
// To track the dragging of |drag_view_| continuously, its visibility
// should be always true regardless of its position.
- if (dragged_off_from_overflow_to_shelf_ &&
+ if (dragged_off_from_shelf_to_other_shelf_ &&
view_model_->view_at(i) == drag_view_)
view_model_->view_at(i)->SetVisible(true);
else
@@ -1077,17 +1077,21 @@ bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) {
// If the shelf/overflow bubble bounds contains |screen_location| we insert
// the item back into the shelf.
if (GetBoundsForDragInsertInScreen().Contains(screen_location)) {
- if (dragged_off_from_overflow_to_shelf_) {
+ if (dragged_off_from_shelf_to_other_shelf_) {
// During the dragging an item from Shelf to Overflow, it can enter here
- // directly because both are located very closly.
- main_shelf_->EndDrag(true);
+ // directly because both are located very closely.
+ if (is_overflow_mode())
+ main_shelf_->EndDrag(true);
+ else if (overflow_bubble_ && overflow_bubble_->IsShowing())
msw 2017/04/17 19:29:09 q: shouldn't this definitely be true if we are dra
sammiequon 2017/04/17 23:42:28 Done.
+ overflow_bubble_->shelf_view()->EndDrag(true);
+
// Stops the animation of |drag_view_| and sets its bounds explicitly
- // becase ContinueDrag() stops its animation. Without this, unexpected
+ // because ContinueDrag() stops its animation. Without this, unexpected
// bounds will be set.
bounds_animator_->StopAnimatingView(drag_view_);
int drag_view_index = view_model_->GetIndexOfView(drag_view_);
drag_view_->SetBoundsRect(view_model_->ideal_bounds(drag_view_index));
- dragged_off_from_overflow_to_shelf_ = false;
+ dragged_off_from_shelf_to_other_shelf_ = false;
}
// Destroy our proxy view item.
DestroyDragIconProxy();
@@ -1103,18 +1107,44 @@ bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) {
} else if (is_overflow_mode() &&
main_shelf_->GetBoundsForDragInsertInScreen().Contains(
screen_location)) {
- if (!dragged_off_from_overflow_to_shelf_) {
- dragged_off_from_overflow_to_shelf_ = true;
+ // Item is dragged from overflow shelf to shelf.
msw 2017/04/17 19:29:09 nit: "The item was dragged from the overflow shelf
sammiequon 2017/04/17 23:42:29 Done.
+ if (!dragged_off_from_shelf_to_other_shelf_) {
+ dragged_off_from_shelf_to_other_shelf_ = true;
drag_image_->SetOpacity(1.0f);
main_shelf_->StartDrag(dragged_app_id, screen_location);
} else {
main_shelf_->Drag(screen_location);
}
- } else if (dragged_off_from_overflow_to_shelf_) {
+ } else if (!is_overflow_mode() && overflow_bubble_ &&
+ overflow_bubble_->IsShowing() &&
+ overflow_bubble_->shelf_view()
+ ->GetBoundsForDragInsertInScreen()
+ .Contains(screen_location)) {
+ // Item is dragged from shelf to overflow shelf.
msw 2017/04/17 19:29:09 The item was dragged from the main shelf to the ov
sammiequon 2017/04/17 23:42:28 Done.
+ if (!dragged_off_from_shelf_to_other_shelf_) {
+ dragged_off_from_shelf_to_other_shelf_ = true;
+ drag_image_->SetOpacity(1.0f);
+ overflow_bubble_->shelf_view()->StartDrag(dragged_app_id,
+ screen_location);
+ } else {
+ overflow_bubble_->shelf_view()->Drag(screen_location);
+ }
+ } else if (dragged_off_from_shelf_to_other_shelf_) {
// Makes the |drag_image_| partially disappear again.
- dragged_off_from_overflow_to_shelf_ = false;
+ dragged_off_from_shelf_to_other_shelf_ = false;
drag_image_->SetOpacity(kDraggedImageOpacity);
- main_shelf_->EndDrag(true);
+
+ if (is_overflow_mode()) {
+ main_shelf_->EndDrag(true);
+ } else if (overflow_bubble_ && overflow_bubble_->IsShowing()) {
msw 2017/04/17 19:29:09 ditto q: shouldn't this definitely be true if we a
+ overflow_bubble_->shelf_view()->EndDrag(true);
+ // After entering the overflow shelf the last item becomes visible
msw 2017/04/17 19:29:09 I don't understand what is happening here (I also
sammiequon 2017/04/17 23:42:29 If we do not hide the last item, when an item is r
msw 2017/04/18 00:11:03 Ah, I didn't realize that when we started dragging
+ // again. Hide the last item when we exit the overflow shelf, otherwise
+ // a copy of the item we are dragging will appear on the overflow shelf.
+ overflow_bubble_->shelf_view()->last_visible_index_ =
msw 2017/04/17 19:29:09 nit: overflow_bubble_->shelf_view()->last_visible_
sammiequon 2017/04/17 23:42:28 Done.
+ overflow_bubble_->shelf_view()->last_visible_index_ - 1;
+ }
+
bounds_animator_->StopAnimatingView(drag_view_);
int drag_view_index = view_model_->GetIndexOfView(drag_view_);
drag_view_->SetBoundsRect(view_model_->ideal_bounds(drag_view_index));
@@ -1140,6 +1170,14 @@ bool ShelfView::HandleRipOffDrag(const ui::LocatedEvent& event) {
if (current_index != model_->FirstPanelIndex() - 1) {
model_->Move(current_index, model_->FirstPanelIndex() - 1);
StartFadeInLastVisibleItem();
+
+ // If the overflow bubble is showing, the current item will swap to the
msw 2017/04/17 19:29:09 Ditto, I'm a bit confused by this... current/last/
+ // back of the overflow shelf as well, so we tell the overflow shelf to
+ // not show their last item, which would be the current item.
+ if (overflow_bubble_ && overflow_bubble_->IsShowing()) {
+ overflow_bubble_->shelf_view()->last_visible_index_ =
msw 2017/04/17 19:29:09 nit: overflow_bubble_->shelf_view()->last_visible_
sammiequon 2017/04/17 23:42:28 Done.
+ overflow_bubble_->shelf_view()->last_visible_index_ - 1;
+ }
} else if (is_overflow_mode()) {
// Overflow bubble should be shrunk when an item is ripped off.
PreferredSizeChanged();
@@ -1174,9 +1212,12 @@ void ShelfView::FinalizeRipOffDrag(bool cancel) {
bool snap_back = false;
// Items which cannot be dragged off will be handled as a cancel.
if (!cancel) {
- if (dragged_off_from_overflow_to_shelf_) {
- dragged_off_from_overflow_to_shelf_ = false;
- main_shelf_->EndDrag(false);
+ if (dragged_off_from_shelf_to_other_shelf_) {
+ dragged_off_from_shelf_to_other_shelf_ = false;
+ if (is_overflow_mode())
+ main_shelf_->EndDrag(false);
+ else if (overflow_bubble_ && overflow_bubble_->IsShowing())
msw 2017/04/17 19:29:09 ditto q: shouldn't this definitely be true if we a
sammiequon 2017/04/17 23:42:28 Done.
+ overflow_bubble_->shelf_view()->EndDrag(false);
drag_view_->layer()->SetOpacity(1.0f);
} else if (RemovableByRipOff(current_index) != REMOVABLE) {
// Make sure we do not try to remove un-removable items like items which
@@ -1192,10 +1233,13 @@ void ShelfView::FinalizeRipOffDrag(bool cancel) {
}
}
if (cancel || snap_back) {
- if (dragged_off_from_overflow_to_shelf_) {
- dragged_off_from_overflow_to_shelf_ = false;
- // Main shelf handles revert of dragged item.
- main_shelf_->EndDrag(true);
+ if (dragged_off_from_shelf_to_other_shelf_) {
+ dragged_off_from_shelf_to_other_shelf_ = false;
+ // Other shelf handles revert of dragged item.
+ if (is_overflow_mode())
+ main_shelf_->EndDrag(true);
+ else if (overflow_bubble_ && overflow_bubble_->IsShowing())
msw 2017/04/17 19:29:09 ditto q: shouldn't this definitely be true if we a
sammiequon 2017/04/17 23:42:29 Done.
+ overflow_bubble_->shelf_view()->EndDrag(true);
drag_view_->layer()->SetOpacity(1.0f);
} else if (!cancelling_drag_model_changed_) {
// Only do something if the change did not come through a model change.
@@ -1409,10 +1453,10 @@ gfx::Size ShelfView::GetPreferredSize() const {
// When an item is dragged off from the overflow bubble, it is moved to last
// position and and changed to invisible. Overflow bubble size should be
// shrunk to fit only for visible items.
- // If |dragged_off_from_overflow_to_shelf_| is set, there will be no invisible
- // items in the shelf.
+ // If |dragged_off_from_shelf_to_other_shelf_| is set, there will be no
+ // invisible items in the shelf.
if (is_overflow_mode() && dragged_off_shelf_ &&
- !dragged_off_from_overflow_to_shelf_ &&
+ !dragged_off_from_shelf_to_other_shelf_ &&
RemovableByRipOff(view_model_->GetIndexOfView(drag_view_)) == REMOVABLE)
last_button_index--;

Powered by Google App Engine
This is Rietveld 408576698