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

Side by Side Diff: ui/app_list/app_list_folder_item.h

Issue 682843004: Experimental app list: "All apps" button has a folder-like icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ares-allapps-button
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_APP_LIST_FOLDER_ITEM_H_ 5 #ifndef UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_
6 #define UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_ 6 #define UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ui/app_list/app_list_export.h" 11 #include "ui/app_list/app_list_export.h"
12 #include "ui/app_list/app_list_item.h" 12 #include "ui/app_list/app_list_item.h"
13 #include "ui/app_list/app_list_item_list_observer.h" 13 #include "ui/app_list/app_list_item_list_observer.h"
14 #include "ui/app_list/app_list_item_observer.h" 14 #include "ui/app_list/app_list_item_observer.h"
15 #include "ui/app_list/folder_image.h"
15 16
16 namespace gfx { 17 namespace gfx {
18 class ImageSkia;
17 class Rect; 19 class Rect;
18 } 20 }
19 21
20 namespace app_list { 22 namespace app_list {
21 23
22 class AppListItemList; 24 class AppListItemList;
23 25
24 // AppListFolderItem implements the model/controller for folders. 26 // AppListFolderItem implements the model/controller for folders.
25 class APP_LIST_EXPORT AppListFolderItem : public AppListItem, 27 class APP_LIST_EXPORT AppListFolderItem : public AppListItem,
26 public AppListItemListObserver, 28 public FolderImageObserver {
27 public AppListItemObserver {
28 public: 29 public:
29 // The folder type affects folder behavior. 30 // The folder type affects folder behavior.
30 enum FolderType { 31 enum FolderType {
31 // Default folder type. 32 // Default folder type.
32 FOLDER_TYPE_NORMAL, 33 FOLDER_TYPE_NORMAL,
33 // Items can not be moved to/from OEM folders in the UI. 34 // Items can not be moved to/from OEM folders in the UI.
34 FOLDER_TYPE_OEM 35 FOLDER_TYPE_OEM
35 }; 36 };
36 37
37 static const char kItemType[]; 38 static const char kItemType[];
38 39
39 AppListFolderItem(const std::string& id, FolderType folder_type); 40 AppListFolderItem(const std::string& id, FolderType folder_type);
40 ~AppListFolderItem() override; 41 ~AppListFolderItem() override;
41 42
42 // Updates the folder's icon.
43 void UpdateIcon();
44
45 // Returns the icon of one of the top items with |item_index|. 43 // Returns the icon of one of the top items with |item_index|.
46 const gfx::ImageSkia& GetTopIcon(size_t item_index); 44 const gfx::ImageSkia& GetTopIcon(size_t item_index);
47 45
48 // Returns the target icon bounds for |item| to fly back to its parent folder 46 // Returns the target icon bounds for |item| to fly back to its parent folder
49 // icon in animation UI. If |item| is one of the top item icon, this will 47 // icon in animation UI. If |item| is one of the top item icon, this will
50 // match its corresponding top item icon in the folder icon. Otherwise, 48 // match its corresponding top item icon in the folder icon. Otherwise,
51 // the target icon bounds is centered at the |folder_icon_bounds| with 49 // the target icon bounds is centered at the |folder_icon_bounds| with
52 // the same size of the top item icon. 50 // the same size of the top item icon.
53 // The Rect returned is in the same coordinates of |folder_icon_bounds|. 51 // The Rect returned is in the same coordinates of |folder_icon_bounds|.
54 gfx::Rect GetTargetIconRectInFolderForItem( 52 gfx::Rect GetTargetIconRectInFolderForItem(
55 AppListItem* item, const gfx::Rect& folder_icon_bounds); 53 AppListItem* item, const gfx::Rect& folder_icon_bounds);
calamity 2014/10/28 05:12:57 You could expose folder_image_ and then just have
Matt Giuca 2014/10/29 07:11:23 Done.
56 54
57 AppListItemList* item_list() { return item_list_.get(); } 55 AppListItemList* item_list() { return item_list_.get(); }
58 const AppListItemList* item_list() const { return item_list_.get(); } 56 const AppListItemList* item_list() const { return item_list_.get(); }
59 57
60 FolderType folder_type() const { return folder_type_; } 58 FolderType folder_type() const { return folder_type_; }
61 59
62 // AppListItem 60 // AppListItem
63 void Activate(int event_flags) override; 61 void Activate(int event_flags) override;
64 const char* GetItemType() const override; 62 const char* GetItemType() const override;
65 ui::MenuModel* GetContextMenuModel() override; 63 ui::MenuModel* GetContextMenuModel() override;
66 AppListItem* FindChildItem(const std::string& id) override; 64 AppListItem* FindChildItem(const std::string& id) override;
67 size_t ChildItemCount() const override; 65 size_t ChildItemCount() const override;
68 void OnExtensionPreferenceChanged() override; 66 void OnExtensionPreferenceChanged() override;
69 bool CompareForTest(const AppListItem* other) const override; 67 bool CompareForTest(const AppListItem* other) const override;
70 68
71 // Returns an id for a new folder. 69 // Returns an id for a new folder.
72 static std::string GenerateId(); 70 static std::string GenerateId();
73 71
72 protected:
73 // FolderImageObserver overrides:
calamity 2014/10/28 05:12:57 Overridden from FolderImageObserver:
Matt Giuca 2014/10/29 07:11:23 Doesn't matter (as long as its per-file consistent
74 void OnFolderImageUpdated(const gfx::ImageSkia& icon) override;
calamity 2014/10/28 05:12:57 Why protected?
Matt Giuca 2014/10/29 07:11:23 Done.
75
74 private: 76 private:
75 // AppListItemObserver
76 void ItemIconChanged() override;
77
78 // AppListItemListObserver
79 void OnListItemAdded(size_t index, AppListItem* item) override;
80 void OnListItemRemoved(size_t index, AppListItem* item) override;
81 ;
82 void OnListItemMoved(size_t from_index,
83 size_t to_index,
84 AppListItem* item) override;
85
86 void UpdateTopItems();
87
88 // The type of folder; may affect behavior of folder views. 77 // The type of folder; may affect behavior of folder views.
89 const FolderType folder_type_; 78 const FolderType folder_type_;
90 79
91 // List of items in the folder. 80 // List of items in the folder.
92 scoped_ptr<AppListItemList> item_list_; 81 scoped_ptr<AppListItemList> item_list_;
93 82
94 // Top items for generating folder icon. 83 FolderImage folder_image_;
95 std::vector<AppListItem*> top_items_;
96 84
97 DISALLOW_COPY_AND_ASSIGN(AppListFolderItem); 85 DISALLOW_COPY_AND_ASSIGN(AppListFolderItem);
98 }; 86 };
99 87
100 } // namespace app_list 88 } // namespace app_list
101 89
102 #endif // UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_ 90 #endif // UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698