OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_APP_LIST_VIEWS_TOP_ICON_ANIMATION_VIEW_H |
| 6 #define UI_APP_LIST_VIEWS_TOP_ICON_ANIMATION_VIEW_H |
| 7 |
| 8 #include "base/observer_list.h" |
| 9 #include "ui/compositor/layer_animation_observer.h" |
| 10 #include "ui/views/view.h" |
| 11 |
| 12 namespace views { |
| 13 class ImageView; |
| 14 } |
| 15 |
| 16 namespace app_list { |
| 17 |
| 18 // Observer for top icon animation completion. |
| 19 class TopIconAnimationObserver { |
| 20 public: |
| 21 // Called when top icon animation completes. |
| 22 virtual void OnTopIconAnimationsComplete() {} |
| 23 |
| 24 protected: |
| 25 TopIconAnimationObserver() {} |
| 26 virtual ~TopIconAnimationObserver() {} |
| 27 |
| 28 private: |
| 29 DISALLOW_COPY_AND_ASSIGN(TopIconAnimationObserver); |
| 30 }; |
| 31 |
| 32 // Transitional view used for top item icons animation when opening or closing |
| 33 // a folder. |
| 34 class TopIconAnimationView : public views::View, |
| 35 public ui::ImplicitAnimationObserver { |
| 36 public: |
| 37 // |icon|: The icon image of the item icon of full scale size. |
| 38 // |scaled_rect|: Bounds of the small icon inside folder icon. |
| 39 // |open_folder|: Specify open/close folder animation to perform. |
| 40 // The view will be self-cleaned by the end of animation. |
| 41 TopIconAnimationView(const gfx::ImageSkia& icon, |
| 42 const gfx::Rect& scaled_rect, |
| 43 bool open_folder); |
| 44 virtual ~TopIconAnimationView(); |
| 45 |
| 46 void AddObserver(TopIconAnimationObserver* observer); |
| 47 void RemoveObserver(TopIconAnimationObserver* observer); |
| 48 |
| 49 // When opening a folder, transform the top item icon from the small icon |
| 50 // inside folder icon to the full scale icon at the target location. |
| 51 // When closing a folder, transform the full scale item icon from its |
| 52 // location to the small icon inside the folder icon. |
| 53 void TransformView(); |
| 54 |
| 55 private: |
| 56 // views::View overrides: |
| 57 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 58 virtual void Layout() OVERRIDE; |
| 59 |
| 60 // ui::ImplicitAnimationObserver overrides: |
| 61 virtual void OnImplicitAnimationsCompleted() OVERRIDE; |
| 62 |
| 63 gfx::Size icon_size_; |
| 64 views::ImageView* icon_; // Owned by views hierarchy. |
| 65 // Rect of the scaled down top item icon inside folder icon's ink bubble. |
| 66 gfx::Rect scaled_rect_; |
| 67 // true: opening folder; false: closing folder. |
| 68 bool open_folder_; |
| 69 |
| 70 ObserverList<TopIconAnimationObserver> observers_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(TopIconAnimationView); |
| 73 }; |
| 74 |
| 75 } // namespace app_list |
| 76 |
| 77 #endif // UI_APP_LIST_VIEWS_TOP_ICON_ANIMATION_VIEW_H |
OLD | NEW |