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

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: Fix compile on Windows (APP_LIST_EXPORT). 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_model_unittest.cc ('k') | ui/app_list/folder_image.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_export.h"
12 #include "ui/app_list/app_list_item_list_observer.h"
13 #include "ui/app_list/app_list_item_observer.h"
14 #include "ui/gfx/image/image_skia.h"
15
16 namespace gfx {
17 class Rect;
18 }
19
20 namespace app_list {
21
22 class AppListItem;
23 class AppListItemList;
24
25 class APP_LIST_EXPORT FolderImageObserver {
26 public:
27 // Called when the folder icon has changed.
28 virtual void OnFolderImageUpdated() {}
29
30 protected:
31 virtual ~FolderImageObserver() {}
32 };
33
34 // The icon for an app list folder, dynamically generated by drawing the
35 // folder's items inside a circle. Automatically keeps itself up to date, and
36 // notifies observers when it changes.
37 class APP_LIST_EXPORT FolderImage : public AppListItemListObserver,
38 public AppListItemObserver {
39 public:
40 FolderImage(AppListItemList* item_list);
41 ~FolderImage() override;
42
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.
45 void UpdateIcon();
46
47 const gfx::ImageSkia& icon() const { return icon_; }
48
49 // Returns the icon of one of the top items with |item_index|.
50 const gfx::ImageSkia& GetTopIcon(size_t item_index);
51
52 // Returns the target icon bounds for |item| to fly back to its parent folder
53 // icon in animation UI. If |item| is one of the top item icon, this will
54 // match its corresponding top item icon in the folder icon. Otherwise,
55 // the target icon bounds is centered at the |folder_icon_bounds| with
56 // the same size of the top item icon.
57 // The Rect returned is in the same coordinates of |folder_icon_bounds|.
58 gfx::Rect GetTargetIconRectInFolderForItem(
59 AppListItem* item,
60 const gfx::Rect& folder_icon_bounds);
61
62 void AddObserver(FolderImageObserver* observer);
63 void RemoveObserver(FolderImageObserver* observer);
64
65 // AppListItemObserver overrides:
66 void ItemIconChanged() override;
67
68 // AppListItemListObserver overrides:
69 void OnListItemAdded(size_t index, AppListItem* item) override;
70 void OnListItemRemoved(size_t index, AppListItem* item) override;
71 void OnListItemMoved(size_t from_index,
72 size_t to_index,
73 AppListItem* item) override;
74
75 private:
76 // Updates the folder's icon from the icons of |top_items_| and calls
77 // OnFolderImageUpdated. Does not refresh the |top_items_| list, so should
78 // only be called if the |item_list_| has not been changed (see UpdateIcon).
79 void RedrawIconAndNotify();
80
81 // The icon image.
82 gfx::ImageSkia icon_;
83
84 // List of top-level app list items (to display small in the icon).
85 AppListItemList* item_list_;
86
87 // Top items for generating folder icon.
88 std::vector<AppListItem*> top_items_;
89
90 ObserverList<FolderImageObserver> observers_;
91 };
92
93 } // namespace app_list
94
95 #endif // UI_APP_LIST_FOLDER_IMAGE_H_
OLDNEW
« no previous file with comments | « ui/app_list/app_list_model_unittest.cc ('k') | ui/app_list/folder_image.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698