| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/app_list/views/apps_grid_view.h" | 5 #include "ui/app_list/views/apps_grid_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 ui::Layer* layer, | 130 ui::Layer* layer, |
| 131 const gfx::Rect& layer_target) | 131 const gfx::Rect& layer_target) |
| 132 : view_(view), | 132 : view_(view), |
| 133 layer_(layer), | 133 layer_(layer), |
| 134 layer_start_(layer ? layer->bounds() : gfx::Rect()), | 134 layer_start_(layer ? layer->bounds() : gfx::Rect()), |
| 135 layer_target_(layer_target) { | 135 layer_target_(layer_target) { |
| 136 } | 136 } |
| 137 virtual ~RowMoveAnimationDelegate() {} | 137 virtual ~RowMoveAnimationDelegate() {} |
| 138 | 138 |
| 139 // gfx::AnimationDelegate overrides: | 139 // gfx::AnimationDelegate overrides: |
| 140 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE { | 140 virtual void AnimationProgressed(const gfx::Animation* animation) override { |
| 141 view_->layer()->SetOpacity(animation->GetCurrentValue()); | 141 view_->layer()->SetOpacity(animation->GetCurrentValue()); |
| 142 view_->layer()->ScheduleDraw(); | 142 view_->layer()->ScheduleDraw(); |
| 143 | 143 |
| 144 if (layer_) { | 144 if (layer_) { |
| 145 layer_->SetOpacity(1 - animation->GetCurrentValue()); | 145 layer_->SetOpacity(1 - animation->GetCurrentValue()); |
| 146 layer_->SetBounds(animation->CurrentValueBetween(layer_start_, | 146 layer_->SetBounds(animation->CurrentValueBetween(layer_start_, |
| 147 layer_target_)); | 147 layer_target_)); |
| 148 layer_->ScheduleDraw(); | 148 layer_->ScheduleDraw(); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE { | 151 virtual void AnimationEnded(const gfx::Animation* animation) override { |
| 152 view_->layer()->SetOpacity(1.0f); | 152 view_->layer()->SetOpacity(1.0f); |
| 153 view_->SchedulePaint(); | 153 view_->SchedulePaint(); |
| 154 } | 154 } |
| 155 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE { | 155 virtual void AnimationCanceled(const gfx::Animation* animation) override { |
| 156 view_->layer()->SetOpacity(1.0f); | 156 view_->layer()->SetOpacity(1.0f); |
| 157 view_->SchedulePaint(); | 157 view_->SchedulePaint(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 private: | 160 private: |
| 161 // The view that needs to be wrapped. Owned by views hierarchy. | 161 // The view that needs to be wrapped. Owned by views hierarchy. |
| 162 views::View* view_; | 162 views::View* view_; |
| 163 | 163 |
| 164 scoped_ptr<ui::Layer> layer_; | 164 scoped_ptr<ui::Layer> layer_; |
| 165 const gfx::Rect layer_start_; | 165 const gfx::Rect layer_start_; |
| 166 const gfx::Rect layer_target_; | 166 const gfx::Rect layer_target_; |
| 167 | 167 |
| 168 DISALLOW_COPY_AND_ASSIGN(RowMoveAnimationDelegate); | 168 DISALLOW_COPY_AND_ASSIGN(RowMoveAnimationDelegate); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 // ItemRemoveAnimationDelegate is used to show animation for removing an item. | 171 // ItemRemoveAnimationDelegate is used to show animation for removing an item. |
| 172 // This happens when user drags an item into a folder. The dragged item will | 172 // This happens when user drags an item into a folder. The dragged item will |
| 173 // be removed from the original list after it is dropped into the folder. | 173 // be removed from the original list after it is dropped into the folder. |
| 174 class ItemRemoveAnimationDelegate : public gfx::AnimationDelegate { | 174 class ItemRemoveAnimationDelegate : public gfx::AnimationDelegate { |
| 175 public: | 175 public: |
| 176 explicit ItemRemoveAnimationDelegate(views::View* view) | 176 explicit ItemRemoveAnimationDelegate(views::View* view) |
| 177 : view_(view) { | 177 : view_(view) { |
| 178 } | 178 } |
| 179 | 179 |
| 180 virtual ~ItemRemoveAnimationDelegate() { | 180 virtual ~ItemRemoveAnimationDelegate() { |
| 181 } | 181 } |
| 182 | 182 |
| 183 // gfx::AnimationDelegate overrides: | 183 // gfx::AnimationDelegate overrides: |
| 184 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE { | 184 virtual void AnimationProgressed(const gfx::Animation* animation) override { |
| 185 view_->layer()->SetOpacity(1 - animation->GetCurrentValue()); | 185 view_->layer()->SetOpacity(1 - animation->GetCurrentValue()); |
| 186 view_->layer()->ScheduleDraw(); | 186 view_->layer()->ScheduleDraw(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 private: | 189 private: |
| 190 scoped_ptr<views::View> view_; | 190 scoped_ptr<views::View> view_; |
| 191 | 191 |
| 192 DISALLOW_COPY_AND_ASSIGN(ItemRemoveAnimationDelegate); | 192 DISALLOW_COPY_AND_ASSIGN(ItemRemoveAnimationDelegate); |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 // ItemMoveAnimationDelegate observes when an item finishes animating when it is | 195 // ItemMoveAnimationDelegate observes when an item finishes animating when it is |
| 196 // not moving between rows. This is to ensure an item is repainted for the | 196 // not moving between rows. This is to ensure an item is repainted for the |
| 197 // "zoom out" case when releasing an item being dragged. | 197 // "zoom out" case when releasing an item being dragged. |
| 198 class ItemMoveAnimationDelegate : public gfx::AnimationDelegate { | 198 class ItemMoveAnimationDelegate : public gfx::AnimationDelegate { |
| 199 public: | 199 public: |
| 200 ItemMoveAnimationDelegate(views::View* view) : view_(view) {} | 200 ItemMoveAnimationDelegate(views::View* view) : view_(view) {} |
| 201 | 201 |
| 202 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE { | 202 virtual void AnimationEnded(const gfx::Animation* animation) override { |
| 203 view_->SchedulePaint(); | 203 view_->SchedulePaint(); |
| 204 } | 204 } |
| 205 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE { | 205 virtual void AnimationCanceled(const gfx::Animation* animation) override { |
| 206 view_->SchedulePaint(); | 206 view_->SchedulePaint(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 private: | 209 private: |
| 210 views::View* view_; | 210 views::View* view_; |
| 211 | 211 |
| 212 DISALLOW_COPY_AND_ASSIGN(ItemMoveAnimationDelegate); | 212 DISALLOW_COPY_AND_ASSIGN(ItemMoveAnimationDelegate); |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 // Returns true if the |item| is an folder item. | 215 // Returns true if the |item| is an folder item. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 294 |
| 295 void EndDragExternally() { | 295 void EndDragExternally() { |
| 296 CancelDrag(); | 296 CancelDrag(); |
| 297 DCHECK(drag_view_); | 297 DCHECK(drag_view_); |
| 298 drag_view_->SetVisible(true); | 298 drag_view_->SetVisible(true); |
| 299 drag_view_ = NULL; | 299 drag_view_ = NULL; |
| 300 } | 300 } |
| 301 | 301 |
| 302 private: | 302 private: |
| 303 // Overridden from ui::DragSourceWin. | 303 // Overridden from ui::DragSourceWin. |
| 304 virtual void OnDragSourceCancel() OVERRIDE { | 304 virtual void OnDragSourceCancel() override { |
| 305 canceled_ = true; | 305 canceled_ = true; |
| 306 } | 306 } |
| 307 | 307 |
| 308 virtual void OnDragSourceDrop() OVERRIDE { | 308 virtual void OnDragSourceDrop() override { |
| 309 } | 309 } |
| 310 | 310 |
| 311 virtual void OnDragSourceMove() OVERRIDE { | 311 virtual void OnDragSourceMove() override { |
| 312 grid_view_->UpdateDrag(AppsGridView::MOUSE, GetCursorInGridViewCoords()); | 312 grid_view_->UpdateDrag(AppsGridView::MOUSE, GetCursorInGridViewCoords()); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void SetupExchangeData(ui::OSExchangeData* data) { | 315 void SetupExchangeData(ui::OSExchangeData* data) { |
| 316 data->SetFilename(shortcut_path_); | 316 data->SetFilename(shortcut_path_); |
| 317 gfx::ImageSkia image(drag_view_->GetDragImage()); | 317 gfx::ImageSkia image(drag_view_->GetDragImage()); |
| 318 gfx::Size image_size(image.size()); | 318 gfx::Size image_size(image.size()); |
| 319 drag_utils::SetDragImageOnDataObject( | 319 drag_utils::SetDragImageOnDataObject( |
| 320 image, | 320 image, |
| 321 drag_view_offset_ - drag_view_->GetDragImageOffset(), | 321 drag_view_offset_ - drag_view_->GetDragImageOffset(), |
| (...skipping 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2155 | 2155 |
| 2156 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 2156 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
| 2157 bool is_target_folder) { | 2157 bool is_target_folder) { |
| 2158 AppListItemView* target_view = | 2158 AppListItemView* target_view = |
| 2159 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); | 2159 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); |
| 2160 if (target_view) | 2160 if (target_view) |
| 2161 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 2161 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
| 2162 } | 2162 } |
| 2163 | 2163 |
| 2164 } // namespace app_list | 2164 } // namespace app_list |
| OLD | NEW |