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

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: 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
14 namespace gfx {
15 class ImageSkia;
16 class Rect;
17 }
18
19 namespace app_list {
20
21 class AppListItem;
22 class AppListItemList;
23
24 class FolderImageObserver {
25 public:
26 // Called when the folder icon has changed.
27 virtual void OnFolderImageUpdated(const gfx::ImageSkia& icon) {}
calamity 2014/10/28 05:12:58 I think it would be less weird to have this with n
Matt Giuca 2014/10/29 07:11:23 Done.
28
29 protected:
30 virtual ~FolderImageObserver() {}
31 };
32
33 // The icon for an app list folder, dynamically generated by drawing the
34 // folder's items inside a circle. Automatically keeps itself up to date.
35 // Does not directly store the icon; just passes it for the observers to use.
calamity 2014/10/28 05:12:57 Any reason not to store the icon? It would make th
Matt Giuca 2014/10/29 07:11:23 Done.
36 class FolderImage : public AppListItemListObserver, public AppListItemObserver {
37 public:
38 FolderImage(AppListItemList* item_list);
39
calamity 2014/10/28 05:12:57 nit: no space
Matt Giuca 2014/10/29 07:11:23 Done.
40 ~FolderImage() override;
41
42 // Generates the folder's icon from the icons of the items in the item list,
43 // and calls OnFolderImageUpdated with the result.
44 void UpdateIcon();
45
46 // Returns the icon of one of the top items with |item_index|.
47 const gfx::ImageSkia& GetTopIcon(size_t item_index);
48
49 // Returns the target icon bounds for |item| to fly back to its parent folder
50 // icon in animation UI. If |item| is one of the top item icon, this will
51 // match its corresponding top item icon in the folder icon. Otherwise,
52 // the target icon bounds is centered at the |folder_icon_bounds| with
53 // the same size of the top item icon.
54 // The Rect returned is in the same coordinates of |folder_icon_bounds|.
55 gfx::Rect GetTargetIconRectInFolderForItem(
56 AppListItem* item,
57 const gfx::Rect& folder_icon_bounds);
58
59 void AddObserver(FolderImageObserver* observer);
60 void RemoveObserver(FolderImageObserver* observer);
61
62 // AppListItemObserver overrides:
calamity 2014/10/28 05:12:58 Overridden from
Matt Giuca 2014/10/29 07:11:23 Nah.
63 void ItemIconChanged() override;
64
65 // AppListItemListObserver overrides:
calamity 2014/10/28 05:12:58 Overridden from
66 void OnListItemAdded(size_t index, AppListItem* item) override;
67 void OnListItemRemoved(size_t index, AppListItem* item) override;
68 void OnListItemMoved(size_t from_index,
69 size_t to_index,
70 AppListItem* item) override;
71
72 private:
73 // Updates the folder's icon from the icons of |top_items_| and calls
74 // OnFolderImageUpdated. Does not refresh the |top_items_| list, so should
75 // only be called if the |item_list_| has not been changed (see UpdateIcon).
76 void UpdateImageOnly();
77
78 // List of top-level app list items (to display small in the icon).
79 AppListItemList* item_list_;
80
81 // Top items for generating folder icon.
82 std::vector<AppListItem*> top_items_;
83
84 ObserverList<FolderImageObserver> observers_;
85 };
86
87 } // namespace app_list
88
89 #endif // UI_APP_LIST_FOLDER_IMAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698