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

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: Review response (including writing a full test). 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
« no previous file with comments | « ui/app_list/app_list.gyp ('k') | ui/app_list/app_list_folder_item.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
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
58 // For tests.
59 // TODO(mgiuca): return a const FolderImage& (requires that
60 // base::ObserverList::HasObserver takes a const*).
Matt Giuca 2014/10/29 07:14:51 Note: I have a separate CL to do this. (Unless you
calamity 2014/11/03 00:37:45 Ack.
61 FolderImage* folder_image() { return &folder_image_; }
62
60 FolderType folder_type() const { return folder_type_; } 63 FolderType folder_type() const { return folder_type_; }
61 64
62 // AppListItem 65 // AppListItem
63 void Activate(int event_flags) override; 66 void Activate(int event_flags) override;
64 const char* GetItemType() const override; 67 const char* GetItemType() const override;
65 ui::MenuModel* GetContextMenuModel() override; 68 ui::MenuModel* GetContextMenuModel() override;
66 AppListItem* FindChildItem(const std::string& id) override; 69 AppListItem* FindChildItem(const std::string& id) override;
67 size_t ChildItemCount() const override; 70 size_t ChildItemCount() const override;
68 void OnExtensionPreferenceChanged() override; 71 void OnExtensionPreferenceChanged() override;
69 bool CompareForTest(const AppListItem* other) const override; 72 bool CompareForTest(const AppListItem* other) const override;
70 73
71 // Returns an id for a new folder. 74 // Returns an id for a new folder.
72 static std::string GenerateId(); 75 static std::string GenerateId();
73 76
77 // FolderImageObserver overrides:
78 void OnFolderImageUpdated() override;
79
74 private: 80 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. 81 // The type of folder; may affect behavior of folder views.
89 const FolderType folder_type_; 82 const FolderType folder_type_;
90 83
91 // List of items in the folder. 84 // List of items in the folder.
92 scoped_ptr<AppListItemList> item_list_; 85 scoped_ptr<AppListItemList> item_list_;
93 86
94 // Top items for generating folder icon. 87 FolderImage folder_image_;
95 std::vector<AppListItem*> top_items_;
96 88
97 DISALLOW_COPY_AND_ASSIGN(AppListFolderItem); 89 DISALLOW_COPY_AND_ASSIGN(AppListFolderItem);
98 }; 90 };
99 91
100 } // namespace app_list 92 } // namespace app_list
101 93
102 #endif // UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_ 94 #endif // UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_
OLDNEW
« no previous file with comments | « ui/app_list/app_list.gyp ('k') | ui/app_list/app_list_folder_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698