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

Side by Side Diff: ui/app_list/folder_image.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: Use range-based for loops where possible. 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_APP_LIST_FOLDER_IMAGE_H_
6 #define UI_APP_LIST_FOLDER_IMAGE_H_
7
8 #include <vector>
9
10 #include "base/observer_list.h"
11 #include "ui/app_list/app_list_item_list_observer.h"
12 #include "ui/app_list/app_list_item_observer.h"
13 #include "ui/gfx/image/image_skia.h"
14
15 namespace gfx {
16 class Rect;
17 }
18
19 namespace app_list {
20
21 class AppListItem;
22 class AppListItemList;
23
24 class FolderImageObserver {
25 public:
26 virtual ~FolderImageObserver() {}
calamity 2014/11/03 00:37:46 I don't think we'd ever want to have a deleter for
Matt Giuca 2014/11/03 05:23:17 Done.
27
28 // Called when the folder icon has changed.
29 virtual void OnFolderImageUpdated() {}
30 };
31
32 // The icon for an app list folder, dynamically generated by drawing the
33 // folder's items inside a circle. Automatically keeps itself up to date.
34 // Does not directly store the icon; just passes it for the observers to use.
calamity 2014/11/03 00:37:46 This description needs an update.
Matt Giuca 2014/11/03 05:23:17 Done.
35 class APP_LIST_EXPORT FolderImage : public AppListItemListObserver,
36 public AppListItemObserver {
37 public:
38 FolderImage(AppListItemList* item_list);
39 ~FolderImage() override;
40
41 // Generates the folder's icon from the icons of the items in the item list,
42 // and calls OnFolderImageUpdated with the result.
calamity 2014/11/03 00:37:45 This too.
Matt Giuca 2014/11/03 05:23:17 Done.
43 void UpdateIcon();
44
45 const gfx::ImageSkia& icon() const { return icon_; }
46
47 // Returns the icon of one of the top items with |item_index|.
48 const gfx::ImageSkia& GetTopIcon(size_t item_index);
49
50 // Returns the target icon bounds for |item| to fly back to its parent folder
51 // icon in animation UI. If |item| is one of the top item icon, this will
52 // match its corresponding top item icon in the folder icon. Otherwise,
53 // the target icon bounds is centered at the |folder_icon_bounds| with
54 // the same size of the top item icon.
55 // The Rect returned is in the same coordinates of |folder_icon_bounds|.
56 gfx::Rect GetTargetIconRectInFolderForItem(
57 AppListItem* item,
58 const gfx::Rect& folder_icon_bounds);
59
60 void AddObserver(FolderImageObserver* observer);
61 void RemoveObserver(FolderImageObserver* observer);
62
63 // AppListItemObserver overrides:
64 void ItemIconChanged() override;
65
66 // AppListItemListObserver overrides:
67 void OnListItemAdded(size_t index, AppListItem* item) override;
68 void OnListItemRemoved(size_t index, AppListItem* item) override;
69 void OnListItemMoved(size_t from_index,
70 size_t to_index,
71 AppListItem* item) override;
72
73 private:
74 // Updates the folder's icon from the icons of |top_items_| and calls
75 // OnFolderImageUpdated. Does not refresh the |top_items_| list, so should
76 // only be called if the |item_list_| has not been changed (see UpdateIcon).
77 void UpdateImageOnly();
78
79 // The icon image.
80 gfx::ImageSkia icon_;
81
82 // List of top-level app list items (to display small in the icon).
83 AppListItemList* item_list_;
84
85 // Top items for generating folder icon.
86 std::vector<AppListItem*> top_items_;
87
88 ObserverList<FolderImageObserver> observers_;
89 };
90
91 } // namespace app_list
92
93 #endif // UI_APP_LIST_FOLDER_IMAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698