OLD | NEW |
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 #include "ui/app_list/app_list_folder_item.h" | 5 #include "ui/app_list/app_list_folder_item.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "ui/app_list/app_list_constants.h" | 8 #include "ui/app_list/app_list_constants.h" |
9 #include "ui/app_list/app_list_item_list.h" | 9 #include "ui/app_list/app_list_item_list.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 new FolderImageSource(top_icons, icon_size), | 99 new FolderImageSource(top_icons, icon_size), |
100 icon_size); | 100 icon_size); |
101 SetIcon(icon, false); | 101 SetIcon(icon, false); |
102 } | 102 } |
103 | 103 |
104 const gfx::ImageSkia& AppListFolderItem::GetTopIcon(size_t item_index) { | 104 const gfx::ImageSkia& AppListFolderItem::GetTopIcon(size_t item_index) { |
105 DCHECK(item_index <= top_items_.size()); | 105 DCHECK(item_index <= top_items_.size()); |
106 return top_items_[item_index]->icon(); | 106 return top_items_[item_index]->icon(); |
107 } | 107 } |
108 | 108 |
| 109 gfx::Rect AppListFolderItem::GetTargetIconRectInFolderForItem( |
| 110 AppListItem* item, |
| 111 const gfx::Rect& folder_icon_bounds) { |
| 112 for (size_t i = 0; i < top_items_.size(); ++i) { |
| 113 if (item->id() == top_items_[i]->id()) { |
| 114 Rects rects = AppListFolderItem::GetTopIconsBounds(folder_icon_bounds); |
| 115 return rects[i]; |
| 116 } |
| 117 } |
| 118 |
| 119 gfx::Rect target_rect(folder_icon_bounds); |
| 120 target_rect.ClampToCenteredSize( |
| 121 gfx::Size(kItemIconDimension, kItemIconDimension)); |
| 122 return target_rect; |
| 123 } |
| 124 |
109 void AppListFolderItem::Activate(int event_flags) { | 125 void AppListFolderItem::Activate(int event_flags) { |
110 // Folder handling is implemented by the View, so do nothing. | 126 // Folder handling is implemented by the View, so do nothing. |
111 } | 127 } |
112 | 128 |
113 // static | 129 // static |
114 const char AppListFolderItem::kItemType[] = "FolderItem"; | 130 const char AppListFolderItem::kItemType[] = "FolderItem"; |
115 | 131 |
116 // static | 132 // static |
117 Rects AppListFolderItem::GetTopIconsBounds( | 133 Rects AppListFolderItem::GetTopIconsBounds( |
118 const gfx::Rect& folder_icon_bounds) { | 134 const gfx::Rect& folder_icon_bounds) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 for (size_t i = 0; | 240 for (size_t i = 0; |
225 i < kNumFolderTopItems && i < item_list_->item_count(); ++i) { | 241 i < kNumFolderTopItems && i < item_list_->item_count(); ++i) { |
226 AppListItem* item = item_list_->item_at(i); | 242 AppListItem* item = item_list_->item_at(i); |
227 item->AddObserver(this); | 243 item->AddObserver(this); |
228 top_items_.push_back(item); | 244 top_items_.push_back(item); |
229 } | 245 } |
230 UpdateIcon(); | 246 UpdateIcon(); |
231 } | 247 } |
232 | 248 |
233 } // namespace app_list | 249 } // namespace app_list |
OLD | NEW |