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

Side by Side Diff: ash/shell/app_list.cc

Issue 9033007: Rename the aura_shell namespace to ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ash/app_list/app_list_item_group_model.h" 5 #include "ash/app_list/app_list_item_group_model.h"
6 #include "ash/app_list/app_list_item_model.h" 6 #include "ash/app_list/app_list_item_model.h"
7 #include "ash/app_list/app_list_item_view.h" 7 #include "ash/app_list/app_list_item_view.h"
8 #include "ash/app_list/app_list_model.h" 8 #include "ash/app_list/app_list_model.h"
9 #include "ash/app_list/app_list_view_delegate.h" 9 #include "ash/app_list/app_list_view_delegate.h"
10 #include "ash/app_list/app_list_view.h" 10 #include "ash/app_list/app_list_view.h"
11 #include "ash/shell/example_factory.h" 11 #include "ash/shell/example_factory.h"
12 #include "ash/shell/toplevel_window.h" 12 #include "ash/shell/toplevel_window.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "ui/views/examples/examples_window.h" 14 #include "ui/views/examples/examples_window.h"
15 15
16 namespace ash { 16 namespace ash {
17 namespace shell { 17 namespace shell {
18 18
19 namespace { 19 namespace {
20 20
21 class WindowTypeLauncherItem : public aura_shell::AppListItemModel { 21 class WindowTypeLauncherItem : public ash::AppListItemModel {
22 public: 22 public:
23 enum Type { 23 enum Type {
24 TOPLEVEL_WINDOW = 0, 24 TOPLEVEL_WINDOW = 0,
25 NON_RESIZABLE_WINDOW, 25 NON_RESIZABLE_WINDOW,
26 LOCK_SCREEN, 26 LOCK_SCREEN,
27 WIDGETS_WINDOW, 27 WIDGETS_WINDOW,
28 EXAMPLES_WINDOW, 28 EXAMPLES_WINDOW,
29 LAST_TYPE, 29 LAST_TYPE,
30 }; 30 };
31 31
32 WindowTypeLauncherItem(Type type) : type_(type) { 32 WindowTypeLauncherItem(Type type) : type_(type) {
33 SetIcon(GetIcon(type)); 33 SetIcon(GetIcon(type));
34 SetTitle(GetTitle(type)); 34 SetTitle(GetTitle(type));
35 } 35 }
36 36
37 static SkBitmap GetIcon(Type type) { 37 static SkBitmap GetIcon(Type type) {
38 static const SkColor kColors[] = { 38 static const SkColor kColors[] = {
39 SkColorSetA(SK_ColorRED, 0x4F), 39 SkColorSetA(SK_ColorRED, 0x4F),
40 SkColorSetA(SK_ColorGREEN, 0x4F), 40 SkColorSetA(SK_ColorGREEN, 0x4F),
41 SkColorSetA(SK_ColorBLUE, 0x4F), 41 SkColorSetA(SK_ColorBLUE, 0x4F),
42 SkColorSetA(SK_ColorYELLOW, 0x4F), 42 SkColorSetA(SK_ColorYELLOW, 0x4F),
43 SkColorSetA(SK_ColorCYAN, 0x4F), 43 SkColorSetA(SK_ColorCYAN, 0x4F),
44 }; 44 };
45 45
46 SkBitmap icon; 46 SkBitmap icon;
47 icon.setConfig(SkBitmap::kARGB_8888_Config, 47 icon.setConfig(SkBitmap::kARGB_8888_Config,
48 aura_shell::AppListItemView::kIconSize, 48 ash::AppListItemView::kIconSize,
49 aura_shell::AppListItemView::kIconSize); 49 ash::AppListItemView::kIconSize);
50 icon.allocPixels(); 50 icon.allocPixels();
51 icon.eraseColor(kColors[static_cast<int>(type) % arraysize(kColors)]); 51 icon.eraseColor(kColors[static_cast<int>(type) % arraysize(kColors)]);
52 return icon; 52 return icon;
53 } 53 }
54 54
55 static std::string GetTitle(Type type) { 55 static std::string GetTitle(Type type) {
56 switch (type) { 56 switch (type) {
57 case TOPLEVEL_WINDOW: 57 case TOPLEVEL_WINDOW:
58 return "Create Window"; 58 return "Create Window";
59 case NON_RESIZABLE_WINDOW: 59 case NON_RESIZABLE_WINDOW:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 break; 97 break;
98 } 98 }
99 } 99 }
100 100
101 private: 101 private:
102 Type type_; 102 Type type_;
103 103
104 DISALLOW_COPY_AND_ASSIGN(WindowTypeLauncherItem); 104 DISALLOW_COPY_AND_ASSIGN(WindowTypeLauncherItem);
105 }; 105 };
106 106
107 class ExampleAppListViewDelegate : public aura_shell::AppListViewDelegate { 107 class ExampleAppListViewDelegate : public ash::AppListViewDelegate {
108 public: 108 public:
109 ExampleAppListViewDelegate() {} 109 ExampleAppListViewDelegate() {}
110 110
111 private: 111 private:
112 virtual void OnAppListItemActivated(aura_shell::AppListItemModel* item, 112 virtual void OnAppListItemActivated(ash::AppListItemModel* item,
113 int event_flags) OVERRIDE { 113 int event_flags) OVERRIDE {
114 static_cast<WindowTypeLauncherItem*>(item)->Activate(event_flags); 114 static_cast<WindowTypeLauncherItem*>(item)->Activate(event_flags);
115 } 115 }
116 116
117 DISALLOW_COPY_AND_ASSIGN(ExampleAppListViewDelegate); 117 DISALLOW_COPY_AND_ASSIGN(ExampleAppListViewDelegate);
118 }; 118 };
119 119
120 aura_shell::AppListItemGroupModel* CreateGroup( 120 ash::AppListItemGroupModel* CreateGroup(
121 const std::string& title, 121 const std::string& title,
122 WindowTypeLauncherItem::Type start_type, 122 WindowTypeLauncherItem::Type start_type,
123 WindowTypeLauncherItem::Type end_type) { 123 WindowTypeLauncherItem::Type end_type) {
124 aura_shell::AppListItemGroupModel* group = 124 ash::AppListItemGroupModel* group =
125 new aura_shell::AppListItemGroupModel(title); 125 new ash::AppListItemGroupModel(title);
126 for (int i = static_cast<int>(start_type); 126 for (int i = static_cast<int>(start_type);
127 i < static_cast<int>(end_type); 127 i < static_cast<int>(end_type);
128 ++i) { 128 ++i) {
129 WindowTypeLauncherItem::Type type = 129 WindowTypeLauncherItem::Type type =
130 static_cast<WindowTypeLauncherItem::Type>(i); 130 static_cast<WindowTypeLauncherItem::Type>(i);
131 group->AddItem(new WindowTypeLauncherItem(type)); 131 group->AddItem(new WindowTypeLauncherItem(type));
132 } 132 }
133 return group; 133 return group;
134 } 134 }
135 135
136 } // namespace 136 } // namespace
137 137
138 void BuildAppListModel(aura_shell::AppListModel* model) { 138 void BuildAppListModel(ash::AppListModel* model) {
139 model->AddGroup(CreateGroup("Windows", 139 model->AddGroup(CreateGroup("Windows",
140 WindowTypeLauncherItem::TOPLEVEL_WINDOW, 140 WindowTypeLauncherItem::TOPLEVEL_WINDOW,
141 WindowTypeLauncherItem::WIDGETS_WINDOW)); 141 WindowTypeLauncherItem::WIDGETS_WINDOW));
142 model->AddGroup(CreateGroup("Samples", 142 model->AddGroup(CreateGroup("Samples",
143 WindowTypeLauncherItem::WIDGETS_WINDOW, 143 WindowTypeLauncherItem::WIDGETS_WINDOW,
144 WindowTypeLauncherItem::LAST_TYPE)); 144 WindowTypeLauncherItem::LAST_TYPE));
145 } 145 }
146 146
147 aura_shell::AppListViewDelegate* CreateAppListViewDelegate() { 147 ash::AppListViewDelegate* CreateAppListViewDelegate() {
148 return new ExampleAppListViewDelegate; 148 return new ExampleAppListViewDelegate;
149 } 149 }
150 150
151 // TODO(xiyuan): Remove this. 151 // TODO(xiyuan): Remove this.
152 void CreateAppList( 152 void CreateAppList(
153 const gfx::Rect& bounds, 153 const gfx::Rect& bounds,
154 const aura_shell::ShellDelegate::SetWidgetCallback& callback) { 154 const ash::ShellDelegate::SetWidgetCallback& callback) {
155 aura_shell::AppListModel* model = new aura_shell::AppListModel; 155 ash::AppListModel* model = new ash::AppListModel;
156 BuildAppListModel(model); 156 BuildAppListModel(model);
157 157
158 new aura_shell::AppListView( 158 new ash::AppListView(
159 model, 159 model,
160 CreateAppListViewDelegate(), 160 CreateAppListViewDelegate(),
161 bounds, 161 bounds,
162 callback); 162 callback);
163 } 163 }
164 164
165 } // namespace shell 165 } // namespace shell
166 } // namespace ash 166 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698