summaryrefslogtreecommitdiffstats
path: root/ui/app_list
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-01 05:02:42 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-01 05:02:42 +0000
commitcd1d651b3470728e5b7a3c8dae528060c81d12a5 (patch)
tree4fb48dd08aaa70d07d622abfcc942df43979feca /ui/app_list
parente6c7ca19599a02bd21f06824018623c173c97ff8 (diff)
downloadchromium_src-cd1d651b3470728e5b7a3c8dae528060c81d12a5.zip
chromium_src-cd1d651b3470728e5b7a3c8dae528060c81d12a5.tar.gz
chromium_src-cd1d651b3470728e5b7a3c8dae528060c81d12a5.tar.bz2
Fixed problem with clicking on app launcher item
Had to also adjust the new drag and drop host proxy image to be at the same place where the "legacy" icon was to make the animation smoother. BUG=245511 TEST=unittest Review URL: https://chromiumcodereview.appspot.com/15774015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/app_list')
-rw-r--r--ui/app_list/views/app_list_drag_and_drop_host.h4
-rw-r--r--ui/app_list/views/app_list_item_view.h4
-rw-r--r--ui/app_list/views/apps_grid_view.cc31
-rw-r--r--ui/app_list/views/apps_grid_view.h4
4 files changed, 31 insertions, 12 deletions
diff --git a/ui/app_list/views/app_list_drag_and_drop_host.h b/ui/app_list/views/app_list_drag_and_drop_host.h
index ace8804..7774f94 100644
--- a/ui/app_list/views/app_list_drag_and_drop_host.h
+++ b/ui/app_list/views/app_list_drag_and_drop_host.h
@@ -9,6 +9,7 @@
namespace gfx {
class Point;
+class Vector2d;
} // namespace gfx
namespace app_list {
@@ -21,10 +22,13 @@ class ApplicationDragAndDropHost {
// The proxy should get created using the |icon| with a magnification of
// |scale_factor| at a center location of |location_in_screen_coordinates.
// Use |replaced_view| to find the screen which is used.
+ // The |cursor_offset_from_center| is the offset from the mouse cursor to
+ // the center of the item.
virtual void CreateDragIconProxy(
const gfx::Point& location_in_screen_coordinates,
const gfx::ImageSkia& icon,
views::View* replaced_view,
+ const gfx::Vector2d& cursor_offset_from_center,
float scale_factor) = 0;
// Update the screen location of the Drag icon proxy.
diff --git a/ui/app_list/views/app_list_item_view.h b/ui/app_list/views/app_list_item_view.h
index 1e11bdeb..713e36e 100644
--- a/ui/app_list/views/app_list_item_view.h
+++ b/ui/app_list/views/app_list_item_view.h
@@ -12,6 +12,7 @@
#include "base/timer.h"
#include "ui/app_list/app_list_export.h"
#include "ui/app_list/app_list_item_model_observer.h"
+#include "ui/app_list/views/cached_label.h"
#include "ui/gfx/shadow_value.h"
#include "ui/views/context_menu_controller.h"
#include "ui/views/controls/button/custom_button.h"
@@ -28,7 +29,6 @@ namespace app_list {
class AppListItemModel;
class AppsGridView;
-class CachedLabel;
class APP_LIST_EXPORT AppListItemView : public views::CustomButton,
public views::ContextMenuController,
@@ -46,6 +46,8 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton,
AppListItemModel* model() const { return model_; }
+ const views::Label* title() const { return title_; }
+
private:
enum UIState {
UI_STATE_NORMAL, // Normal UI (icon + label)
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc
index dd145ca..f825000 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -15,6 +15,7 @@
#include "ui/app_list/views/pulsing_block_view.h"
#include "ui/base/animation/animation.h"
#include "ui/base/events/event.h"
+#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/views/border.h"
#include "ui/views/view_model_utils.h"
#include "ui/views/widget/widget.h"
@@ -201,14 +202,19 @@ void AppsGridView::InitiateDrag(AppListItemView* view,
// Note: This code has very likely to be changed for Windows (non metro mode)
// when a |drag_and_drop_host_| gets implemented.
if (drag_and_drop_host_) {
+ // Determine the mouse offset to the center of the icon so that the drag and
+ // drop host follows this layer.
+ gfx::Vector2d delta = event.root_location() -
+ drag_view_->GetBoundsInScreen().CenterPoint();
+ delta.set_y(delta.y() + drag_view_->title()->size().height() / 2);
// We have to hide the original item since the drag and drop host will do
// the OS dependent code to "lift off the dragged item".
- // Note that we cannot use SetVisible since it would remove the mouse input.
- drag_view_->SetSize(gfx::Size());
drag_and_drop_host_->CreateDragIconProxy(event.root_location(),
view->model()->icon(),
drag_view_,
+ delta,
kDragAndDropProxyScale);
+ HideView(drag_view_, true);
}
drag_start_ = event.location();
}
@@ -244,10 +250,8 @@ void AppsGridView::UpdateDrag(AppListItemView* view,
if (last_drop_target != drop_target_)
AnimateToIdealBounds();
- if (drag_and_drop_host_) {
+ if (drag_and_drop_host_)
drag_and_drop_host_->UpdateDragIconProxy(event.root_location());
- return;
- }
drag_view_->SetPosition(
gfx::PointAtOffsetFromOrigin(last_drag_point_ - drag_start_));
@@ -263,14 +267,11 @@ void AppsGridView::EndDrag(bool cancel) {
MoveItemInModel(drag_view_, drop_target_);
}
- // In case we had a drag and drop proxy icon, we delete it and make the real
- // item visible again.
if (drag_and_drop_host_) {
+ // If we had a drag and drop proxy icon, we delete it and make the real
+ // item visible again.
drag_and_drop_host_->DestroyDragIconProxy();
- // To avoid an incorrect animation on re-group, |drag_view_| gets positioned
- // at its last known drag location.
- drag_view_->SetPosition(
- gfx::PointAtOffsetFromOrigin(last_drag_point_ - drag_start_));
+ HideView(drag_view_, false);
}
drag_pointer_ = NONE;
@@ -919,4 +920,12 @@ void AppsGridView::OnAppListModelStatusChanged() {
SchedulePaint();
}
+void AppsGridView::HideView(views::View* view, bool hide) {
+#if defined(USE_AURA)
+ ui::ScopedLayerAnimationSettings animator(view->layer()->GetAnimator());
+ animator.SetPreemptionStrategy(ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET);
+ view->layer()->SetOpacity(hide ? 0 : 1);
+#endif
+}
+
} // namespace app_list
diff --git a/ui/app_list/views/apps_grid_view.h b/ui/app_list/views/apps_grid_view.h
index 8a3f090..483f737 100644
--- a/ui/app_list/views/apps_grid_view.h
+++ b/ui/app_list/views/apps_grid_view.h
@@ -207,6 +207,10 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// Overridden from AppListModelObserver:
virtual void OnAppListModelStatusChanged() OVERRIDE;
+ // Hide a given view temporarily without losing (mouse) events and / or
+ // changing the size of it.
+ void HideView(views::View* view, bool hide);
+
AppListModel* model_; // Owned by AppListView.
AppsGridViewDelegate* delegate_;
PaginationModel* pagination_model_; // Owned by AppListController.