1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
ash / public / cpp / app_list / app_list_config.h [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_PUBLIC_CPP_APP_LIST_APP_LIST_CONFIG_H_
#define ASH_PUBLIC_CPP_APP_LIST_APP_LIST_CONFIG_H_
#include "ash/constants/ash_features.h"
#include "ash/public/cpp/app_list/app_list_types.h"
#include "ash/public/cpp/ash_public_export.h"
#include "base/no_destructor.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/size.h"
namespace gfx {
class FontList;
}
namespace ash {
// App list layout related constants that are used outside the core app list UI
// code - for example in chrome, and app list search UI.
// Unlike values is `AppListConfig`, the values in `SharedAppListConfig` do not
// depend on the current app list view state nor dimensions.
// An instance can be retrieved using `SharedAppListConfig::instance()`.
class ASH_PUBLIC_EXPORT SharedAppListConfig {
public:
static SharedAppListConfig& instance();
int default_grid_icon_dimension() const {
return default_grid_icon_dimension_;
}
int shortcut_badge_icon_dimension() const {
return shortcut_badge_icon_dimension_;
}
size_t max_search_results() const { return max_search_results_; }
size_t max_search_result_list_items() const {
return max_search_result_list_items_;
}
size_t max_assistant_search_result_list_items() const {
return max_assistant_search_result_list_items_;
}
int search_tile_icon_dimension() const { return search_tile_icon_dimension_; }
gfx::Size search_tile_icon_size() const {
return gfx::Size(search_tile_icon_dimension_, search_tile_icon_dimension_);
}
int search_tile_badge_icon_dimension() const {
return search_tile_badge_icon_dimension_;
}
gfx::Size search_tile_badge_icon_size() const {
return gfx::Size(search_tile_badge_icon_dimension_,
search_tile_badge_icon_dimension_);
}
int search_tile_badge_icon_offset() const {
return search_tile_badge_icon_offset_;
}
int search_list_icon_dimension() const { return search_list_icon_dimension_; }
gfx::Size search_list_icon_size() const {
return gfx::Size(search_list_icon_dimension_, search_list_icon_dimension_);
}
int search_list_icon_vertical_bar_dimension() const {
return search_list_icon_vertical_bar_dimension_;
}
int search_list_badge_icon_dimension() const {
return search_list_badge_icon_dimension_;
}
gfx::Size search_list_badge_icon_size() const {
return gfx::Size(search_list_badge_icon_dimension_,
search_list_badge_icon_dimension_);
}
int suggestion_chip_icon_dimension() const {
return suggestion_chip_icon_dimension_;
}
int search_tile_height() const { return search_tile_height_; }
size_t max_results_with_categorical_search() const {
return max_results_with_categorical_search_;
}
int answer_card_max_results() const { return answer_card_max_results_; }
size_t image_search_max_results() const { return image_search_max_results_; }
// Returns the maximum number of items allowed in a page in the apps grid.
int GetMaxNumOfItemsPerPage() const;
// Returns the dimension at which a result's icon should be displayed.
int GetPreferredIconDimension(SearchResultDisplayType display_type) const;
private:
friend class SharedAppListConfig;
SharedAppListConfig();
// The icon dimension of tile views in apps grid view.
const int default_grid_icon_dimension_ = 64;
// The badge icon dimension of a shortcut in apps grid view.
// TODO(crbug.com/40281395): Update the size after the effects visual done.
const int shortcut_badge_icon_dimension_ = 42;
// Maximum number of results to show in the launcher Search UI.
const size_t max_search_results_ = 6;
// Max number of search result list items in the launcher suggestion window.
const size_t max_search_result_list_items_ = 5;
// Max number of Assistant search result list items in the launcher suggestion
// window. Appears in the list after normal search results.
const size_t max_assistant_search_result_list_items_ = 1;
// The icon dimension of tile views in search result page view.
const int search_tile_icon_dimension_ = 48;
// The badge icon dimension of tile views in search result page view.
const int search_tile_badge_icon_dimension_ = 20;
// The badge icon offset of tile views in search result page view.
const int search_tile_badge_icon_offset_ = 5;
// The icon dimension of list views in search result page view.
const int search_list_icon_dimension_ = 20;
// The vertical bar icon dimension of list views in search result page view.
const int search_list_icon_vertical_bar_dimension_ = 48;
// The badge background corner radius of list views in search result page
// view.
const int search_list_badge_icon_dimension_ = 14;
// The suggestion chip icon dimension.
const int suggestion_chip_icon_dimension_ = 20;
// The height of tiles in search result.
const int search_tile_height_ = 92;
// The maximum number of filtered results within categorical search
const size_t max_results_with_categorical_search_ = 3;
// The maximum number of filtered results of type answer card within
// categorical search
const int answer_card_max_results_ = 1;
// The maximum number of results shown in the launcher image search category.
const size_t image_search_max_results_ = 3;
};
// Contains app list layout information for an app list view. `AppListConfig`
// values depend on the context in which the app list is shown (e.g. the size of
// the display on which the app list is shown). `AppListConfig` instances are
// generally owned by the app list view, which creates them using
// `AppListConfigProvider` (defined in
// ash/public/cpp/app_list/app_list_config_provider.h).
class ASH_PUBLIC_EXPORT AppListConfig {
public:
// Constructor for unscaled configurations of the provided type.
explicit AppListConfig(AppListConfigType type);
// Constructor for scaled app list configuration.
// `scale_x` - The scale at which apps grid tile should be scaled
// horizontally.
AppListConfig(const AppListConfig& base_config, float scale_x);
AppListConfig(const AppListConfig&) = delete;
AppListConfig& operator=(const AppListConfig&) = delete;
~AppListConfig();
AppListConfigType type() const { return type_; }
float scale_x() const { return scale_x_; }
int grid_tile_width() const { return grid_tile_width_; }
int grid_tile_height() const { return grid_tile_height_; }
int grid_icon_dimension() const { return grid_icon_dimension_; }
int grid_icon_bottom_padding() const { return grid_icon_bottom_padding_; }
int grid_title_top_padding() const { return grid_title_top_padding_; }
int grid_title_bottom_padding() const { return grid_title_bottom_padding_; }
int grid_title_horizontal_padding() const {
return grid_title_horizontal_padding_;
}
int grid_title_width() const { return grid_title_width_; }
int grid_focus_corner_radius() const { return grid_focus_corner_radius_; }
int app_title_max_line_height() const { return app_title_max_line_height_; }
const gfx::FontList& app_title_font() const { return app_title_font_; }
const gfx::FontList& item_counter_in_folder_icon_font() const {
return item_counter_in_folder_icon_font_;
}
int folder_bubble_radius() const { return folder_bubble_radius_; }
int icon_visible_dimension() const { return icon_visible_dimension_; }
int folder_icon_dimension() const { return folder_icon_dimension_; }
int folder_icon_radius() const { return folder_icon_radius_; }
int icon_extended_background_dimension() const {
return icon_extended_background_dimension_;
}
int icon_extended_background_radius() const {
return icon_extended_background_radius_;
}
int item_icon_in_folder_icon_dimension() const {
return item_icon_in_folder_icon_dimension_;
}
int item_icon_in_folder_icon_margin() const {
return item_icon_in_folder_icon_margin_;
}
int shortcut_host_badge_icon_dimension() const {
return shortcut_host_badge_icon_dimension_;
}
int shortcut_host_badge_icon_border_margin() const {
return shortcut_host_badge_icon_border_margin_;
}
int shortcut_background_border_margin() const {
return shortcut_background_border_margin_;
}
int promise_icon_dimension_installing() const {
return promise_icon_dimension_installing_;
}
int promise_icon_dimension_pending() const {
return promise_icon_dimension_pending_;
}
int GetShortcutHostBadgeIconContainerDimension() const;
int GetShortcutBackgroundContainerDimension() const;
int GetShortcutTeardropCornerRadius() const;
gfx::Size GetShortcutIconSize() const;
gfx::Size grid_icon_size() const {
return gfx::Size(grid_icon_dimension_, grid_icon_dimension_);
}
gfx::Size icon_visible_size() const {
return gfx::Size(icon_visible_dimension_, icon_visible_dimension_);
}
gfx::Size folder_icon_size() const {
return gfx::Size(folder_icon_dimension_, folder_icon_dimension_);
}
gfx::Size item_icon_in_folder_icon_size() const {
return gfx::Size(item_icon_in_folder_icon_dimension_,
item_icon_in_folder_icon_dimension_);
}
private:
const AppListConfigType type_;
// Current config scale values - should be different from 1 for
// AppListConfigType::kShared only. Note that `scale_x_` should be always less
// or equal to 1.
const float scale_x_;
// The tile view's width and height of the item in apps grid view.
const int grid_tile_width_;
const int grid_tile_height_;
// The icon dimension of tile views in apps grid view.
const int grid_icon_dimension_;
// The icon bottom padding in tile views in apps grid view.
const int grid_icon_bottom_padding_;
// The title top, bottom and horizontal padding in tile views in apps grid
// view.
const int grid_title_top_padding_;
const int grid_title_bottom_padding_;
const int grid_title_horizontal_padding_;
// The title width of tile views in apps grid view.
const int grid_title_width_;
// Corner radius of the focus ring for tile views in apps grid view.
const int grid_focus_corner_radius_;
// The maximum line height for app title in app list.
const int app_title_max_line_height_;
// The font for app title in app list.
const gfx::FontList app_title_font_;
// The font used to the number of apps in a folder on the fonder icon. Only
// used if app collection folder icon refresh is enabled.
const gfx::FontList item_counter_in_folder_icon_font_;
// The radius of the circle in a folder icon (i.e. the gray circle underneath
// the mini app icons).
const int folder_bubble_radius_;
// Because the nature of how an app is drawn, the visual size is slightly
// smaller than its actual icon size. `icon_visible_dimension_` is used to
// cache the visible size of an app. This is also the size of the folder icon
// in its usual state (e.g. in the apps grid, not when the user is dragging an
// item over it).
const int icon_visible_dimension_;
// The folder icon size.
const int folder_icon_dimension_;
// The corner radius of folder icon.
const int folder_icon_radius_;
// The width and height of background for item icons in extended state.
const int icon_extended_background_dimension_;
// The background corner radius of an item icon in extended state.
const int icon_extended_background_radius_;
// The dimension of the item icon in folder icon.
const int item_icon_in_folder_icon_dimension_;
// The margin between item icons inside a folder icon.
const int item_icon_in_folder_icon_margin_;
// The dimension of a host badge icon of a shortcut.
const int shortcut_host_badge_icon_dimension_;
// The dimension of a host badge icon container border of a shortcut.
const int shortcut_host_badge_icon_border_margin_;
// The bottom right corner radius of a shortcut.
const int shortcut_teardrop_corner_radius_;
// The dimension of a background container border of a shortcut.
const int shortcut_background_border_margin_;
// The preferred icon size for the promise apps on installing state.
const int promise_icon_dimension_installing_;
// The preferred icon size for the promise apps on pending state.
const int promise_icon_dimension_pending_;
};
} // namespace ash
#endif // ASH_PUBLIC_CPP_APP_LIST_APP_LIST_CONFIG_H_