[Clean up] Expose ConnectToServiceInsecurely as a BluetoothDevice API on all platforms.
[chromium-blink-merge.git] / ui / app_list / app_list_folder_item.h
blobbfcb86ec30f02aab922112190515ab1947b0515c
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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_
6 #define UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_
8 #include <string>
9 #include <vector>
11 #include "ui/app_list/app_list_export.h"
12 #include "ui/app_list/app_list_item.h"
13 #include "ui/app_list/app_list_item_list_observer.h"
14 #include "ui/app_list/app_list_item_observer.h"
15 #include "ui/gfx/geometry/rect.h"
17 namespace app_list {
19 class AppListItemList;
21 typedef std::vector<gfx::Rect> Rects;
23 // AppListFolderItem implements the model/controller for folders.
24 class APP_LIST_EXPORT AppListFolderItem : public AppListItem,
25 public AppListItemListObserver,
26 public AppListItemObserver {
27 public:
28 // The folder type affects folder behavior.
29 enum FolderType {
30 // Default folder type.
31 FOLDER_TYPE_NORMAL,
32 // Items can not be moved to/from OEM folders in the UI.
33 FOLDER_TYPE_OEM
36 static const char kItemType[];
38 AppListFolderItem(const std::string& id, FolderType folder_type);
39 virtual ~AppListFolderItem();
41 // Updates the folder's icon.
42 void UpdateIcon();
44 // Returns the icon of one of the top items with |item_index|.
45 const gfx::ImageSkia& GetTopIcon(size_t item_index);
47 // Returns the target icon bounds for |item| to fly back to its parent folder
48 // icon in animation UI. If |item| is one of the top item icon, this will
49 // match its corresponding top item icon in the folder icon. Otherwise,
50 // the target icon bounds is centered at the |folder_icon_bounds| with
51 // the same size of the top item icon.
52 // The Rect returned is in the same coordinates of |folder_icon_bounds|.
53 gfx::Rect GetTargetIconRectInFolderForItem(
54 AppListItem* item, const gfx::Rect& folder_icon_bounds);
56 AppListItemList* item_list() { return item_list_.get(); }
57 const AppListItemList* item_list() const { return item_list_.get(); }
59 FolderType folder_type() const { return folder_type_; }
61 // AppListItem
62 virtual void Activate(int event_flags) override;
63 virtual const char* GetItemType() const override;
64 virtual ui::MenuModel* GetContextMenuModel() override;
65 virtual AppListItem* FindChildItem(const std::string& id) override;
66 virtual size_t ChildItemCount() const override;
67 virtual void OnExtensionPreferenceChanged() override;
68 virtual bool CompareForTest(const AppListItem* other) const override;
70 // Calculates the top item icons' bounds inside |folder_icon_bounds|.
71 // Returns the bounds of top item icons in sequence of top left, top right,
72 // bottom left, bottom right.
73 static Rects GetTopIconsBounds(const gfx::Rect& folder_icon_bounds);
75 // Returns an id for a new folder.
76 static std::string GenerateId();
78 private:
79 // AppListItemObserver
80 virtual void ItemIconChanged() override;
82 // AppListItemListObserver
83 virtual void OnListItemAdded(size_t index, AppListItem* item) override;
84 virtual void OnListItemRemoved(size_t index,
85 AppListItem* item) override;;
86 virtual void OnListItemMoved(size_t from_index,
87 size_t to_index,
88 AppListItem* item) override;
90 void UpdateTopItems();
92 // The type of folder; may affect behavior of folder views.
93 const FolderType folder_type_;
95 // List of items in the folder.
96 scoped_ptr<AppListItemList> item_list_;
98 // Top items for generating folder icon.
99 std::vector<AppListItem*> top_items_;
101 DISALLOW_COPY_AND_ASSIGN(AppListFolderItem);
104 } // namespace app_list
106 #endif // UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_