OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef UI_APP_LIST_FOLDER_IMAGE_H_ | 5 #ifndef UI_APP_LIST_FOLDER_IMAGE_H_ |
6 #define UI_APP_LIST_FOLDER_IMAGE_H_ | 6 #define UI_APP_LIST_FOLDER_IMAGE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 explicit FolderImage(AppListItemList* item_list); | 40 explicit FolderImage(AppListItemList* item_list); |
41 ~FolderImage() override; | 41 ~FolderImage() override; |
42 | 42 |
43 // Generates the folder's icon from the icons of the items in the item list, | 43 // Generates the folder's icon from the icons of the items in the item list, |
44 // and notifies observers that the icon has changed. | 44 // and notifies observers that the icon has changed. |
45 void UpdateIcon(); | 45 void UpdateIcon(); |
46 | 46 |
47 const gfx::ImageSkia& icon() const { return icon_; } | 47 const gfx::ImageSkia& icon() const { return icon_; } |
48 | 48 |
49 // Returns the icon of one of the top items with |item_index|. | 49 // Returns the icon of one of the top items with |item_index|. |
50 const gfx::ImageSkia& GetTopIcon(size_t item_index); | 50 const gfx::ImageSkia& GetTopIcon(size_t item_index) const; |
51 | 51 |
52 // Calculates the top item icons' bounds inside |folder_icon_bounds|. | 52 // Calculates the top item icons' bounds inside |folder_icon_bounds|. |
53 // Returns the bounds of top item icons in sequence of top left, top right, | 53 // Returns the bounds of top item icons in sequence of top left, top right, |
54 // bottom left, bottom right. | 54 // bottom left, bottom right. |
55 static std::vector<gfx::Rect> GetTopIconsBounds( | 55 static std::vector<gfx::Rect> GetTopIconsBounds( |
56 const gfx::Rect& folder_icon_bounds); | 56 const gfx::Rect& folder_icon_bounds); |
57 | 57 |
58 // Returns the target icon bounds for |item| to fly back to its parent folder | 58 // Returns the target icon bounds for |item| to fly back to its parent folder |
59 // icon in animation UI. If |item| is one of the top item icon, this will | 59 // icon in animation UI. If |item| is one of the top item icon, this will |
60 // match its corresponding top item icon in the folder icon. Otherwise, | 60 // match its corresponding top item icon in the folder icon. Otherwise, |
61 // the target icon bounds is centered at the |folder_icon_bounds| with | 61 // the target icon bounds is centered at the |folder_icon_bounds| with |
62 // the same size of the top item icon. | 62 // the same size of the top item icon. |
63 // The Rect returned is in the same coordinates of |folder_icon_bounds|. | 63 // The Rect returned is in the same coordinates of |folder_icon_bounds|. |
64 gfx::Rect GetTargetIconRectInFolderForItem( | 64 gfx::Rect GetTargetIconRectInFolderForItem( |
65 AppListItem* item, | 65 AppListItem* item, |
66 const gfx::Rect& folder_icon_bounds); | 66 const gfx::Rect& folder_icon_bounds) const; |
67 | 67 |
68 void AddObserver(FolderImageObserver* observer); | 68 void AddObserver(FolderImageObserver* observer); |
69 void RemoveObserver(FolderImageObserver* observer); | 69 void RemoveObserver(FolderImageObserver* observer); |
70 | 70 |
71 // AppListItemObserver overrides: | 71 // AppListItemObserver overrides: |
72 void ItemIconChanged() override; | 72 void ItemIconChanged() override; |
73 | 73 |
74 // AppListItemListObserver overrides: | 74 // AppListItemListObserver overrides: |
75 void OnListItemAdded(size_t index, AppListItem* item) override; | 75 void OnListItemAdded(size_t index, AppListItem* item) override; |
76 void OnListItemRemoved(size_t index, AppListItem* item) override; | 76 void OnListItemRemoved(size_t index, AppListItem* item) override; |
(...skipping 15 matching lines...) Expand all Loading... |
92 | 92 |
93 // Top items for generating folder icon. | 93 // Top items for generating folder icon. |
94 std::vector<AppListItem*> top_items_; | 94 std::vector<AppListItem*> top_items_; |
95 | 95 |
96 ObserverList<FolderImageObserver> observers_; | 96 ObserverList<FolderImageObserver> observers_; |
97 }; | 97 }; |
98 | 98 |
99 } // namespace app_list | 99 } // namespace app_list |
100 | 100 |
101 #endif // UI_APP_LIST_FOLDER_IMAGE_H_ | 101 #endif // UI_APP_LIST_FOLDER_IMAGE_H_ |
OLD | NEW |