Commit 0b7308c3 authored by David Black's avatar David Black Committed by Commit Bot

Adds new horizontal page.

Bug: b:75033730

Change-Id: I164d8798d4587a816cb11ccecb6027a2b8eec695
Reviewed-on: https://chromium-review.googlesource.com/964615
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarWeidong Guo <weidongg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543753}
parent 6aa9cebe
...@@ -44,6 +44,8 @@ component("app_list") { ...@@ -44,6 +44,8 @@ component("app_list") {
"views/apps_grid_view.cc", "views/apps_grid_view.cc",
"views/apps_grid_view.h", "views/apps_grid_view.h",
"views/apps_grid_view_folder_delegate.h", "views/apps_grid_view_folder_delegate.h",
"views/assistant_container_view.cc",
"views/assistant_container_view.h",
"views/contents_view.cc", "views/contents_view.cc",
"views/contents_view.h", "views/contents_view.h",
"views/expand_arrow_view.cc", "views/expand_arrow_view.cc",
...@@ -99,6 +101,7 @@ component("app_list") { ...@@ -99,6 +101,7 @@ component("app_list") {
"//base:i18n", "//base:i18n",
"//base/third_party/dynamic_annotations", "//base/third_party/dynamic_annotations",
"//cc/paint", "//cc/paint",
"//chromeos:chromeos",
"//components/keyed_service/core", "//components/keyed_service/core",
"//components/sync", "//components/sync",
"//components/wallpaper", "//components/wallpaper",
......
include_rules = [ include_rules = [
"+chromeos/chromeos_switches.h",
"+components/keyed_service/core", "+components/keyed_service/core",
"+components/sync", "+components/sync",
"+components/wallpaper", "+components/wallpaper",
......
...@@ -47,6 +47,11 @@ const int kGridTitleHorizontalPadding = 8; ...@@ -47,6 +47,11 @@ const int kGridTitleHorizontalPadding = 8;
const int kGridSelectedSize = 64; const int kGridSelectedSize = 64;
const int kGridSelectedCornerRadius = 8; const int kGridSelectedCornerRadius = 8;
// The preferred height for horizontal pages. For page #01 in the apps grid, it
// includes the top/bottom 24px padding. For page #02 and all the followings,
// it includes top 24px padding and bottom 56px padding.
const int kHorizontalPagePreferredHeight = 623;
const SkColor kFolderTitleColor = SkColorSetRGB(0x33, 0x33, 0x33); const SkColor kFolderTitleColor = SkColorSetRGB(0x33, 0x33, 0x33);
const SkColor kFolderTitleHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); const SkColor kFolderTitleHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0);
// Color of the folder bubble shadow. // Color of the folder bubble shadow.
......
...@@ -46,6 +46,8 @@ APP_LIST_EXPORT extern const int kGridTitleHorizontalPadding; ...@@ -46,6 +46,8 @@ APP_LIST_EXPORT extern const int kGridTitleHorizontalPadding;
APP_LIST_EXPORT extern const int kGridSelectedSize; APP_LIST_EXPORT extern const int kGridSelectedSize;
APP_LIST_EXPORT extern const int kGridSelectedCornerRadius; APP_LIST_EXPORT extern const int kGridSelectedCornerRadius;
APP_LIST_EXPORT extern const int kHorizontalPagePreferredHeight;
APP_LIST_EXPORT extern const SkColor kFolderTitleColor; APP_LIST_EXPORT extern const SkColor kFolderTitleColor;
APP_LIST_EXPORT extern const SkColor kFolderTitleHintTextColor; APP_LIST_EXPORT extern const SkColor kFolderTitleHintTextColor;
APP_LIST_EXPORT extern const SkColor kFolderShadowColor; APP_LIST_EXPORT extern const SkColor kFolderShadowColor;
......
...@@ -61,11 +61,8 @@ namespace app_list { ...@@ -61,11 +61,8 @@ namespace app_list {
namespace { namespace {
// The preferred width/height for apps grid. For page #01, it includes the // The preferred width for apps grid.
// top/bottom 24px padding. For page #02 and all the followings, it includes top
// 24px padding and bottom 56px padding.
constexpr int kAppsGridPreferredWidth = 576; constexpr int kAppsGridPreferredWidth = 576;
constexpr int kAppsGridPreferredHeight = 623;
// 32px page break space adjustment needed to keep 48px page break space due to // 32px page break space adjustment needed to keep 48px page break space due to
// the fact that page #02 and all the followings have bottom 56px padding. // the fact that page #02 and all the followings have bottom 56px padding.
...@@ -765,7 +762,8 @@ gfx::Size AppsGridView::CalculatePreferredSize() const { ...@@ -765,7 +762,8 @@ gfx::Size AppsGridView::CalculatePreferredSize() const {
if (folder_delegate_) if (folder_delegate_)
return GetTileGridSize(); return GetTileGridSize();
gfx::Size size = gfx::Size(kAppsGridPreferredWidth, kAppsGridPreferredHeight); gfx::Size size =
gfx::Size(kAppsGridPreferredWidth, kHorizontalPagePreferredHeight);
return size; return size;
} }
...@@ -2338,7 +2336,7 @@ AppsGridView::Index AppsGridView::GetNearestTileIndexForPoint( ...@@ -2338,7 +2336,7 @@ AppsGridView::Index AppsGridView::GetNearestTileIndexForPoint(
gfx::Size AppsGridView::GetTileGridSize() const { gfx::Size AppsGridView::GetTileGridSize() const {
if (!folder_delegate_) if (!folder_delegate_)
return gfx::Size(kAppsGridPreferredWidth, kAppsGridPreferredHeight); return gfx::Size(kAppsGridPreferredWidth, kHorizontalPagePreferredHeight);
gfx::Rect rect(GetTotalTileSize()); gfx::Rect rect(GetTotalTileSize());
rect.set_size( rect.set_size(
......
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/app_list/views/assistant_container_view.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/views/contents_view.h"
namespace app_list {
AssistantContainerView::AssistantContainerView(ContentsView* contents_view)
: contents_view_(contents_view) {}
gfx::Size AssistantContainerView::CalculatePreferredSize() const {
if (!GetWidget()) {
return gfx::Size();
}
return gfx::Size(contents_view_->GetDisplayWidth(),
kHorizontalPagePreferredHeight);
}
} // namespace app_list
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_APP_LIST_VIEWS_ASSISTANT_CONTAINER_VIEW_H_
#define UI_APP_LIST_VIEWS_ASSISTANT_CONTAINER_VIEW_H_
#include "base/macros.h"
#include "ui/app_list/views/horizontal_page.h"
namespace app_list {
class ContentsView;
class APP_LIST_EXPORT AssistantContainerView : public HorizontalPage {
public:
explicit AssistantContainerView(ContentsView* contents_view);
~AssistantContainerView() override = default;
// Overridden from views::View.
gfx::Size CalculatePreferredSize() const override;
private:
ContentsView* const contents_view_; // Not owned.
DISALLOW_COPY_AND_ASSIGN(AssistantContainerView);
};
} // namespace app_list
#endif // UI_APP_LIST_VIEWS_ASSISTANT_CONTAINER_VIEW_H_
...@@ -458,6 +458,14 @@ int ContentsView::GetDisplayHeight() const { ...@@ -458,6 +458,14 @@ int ContentsView::GetDisplayHeight() const {
.height(); .height();
} }
int ContentsView::GetDisplayWidth() const {
return display::Screen::GetScreen()
->GetDisplayNearestView(GetWidget()->GetNativeView())
.work_area()
.size()
.width();
}
void ContentsView::FadeOutOnClose(base::TimeDelta animation_duration) { void ContentsView::FadeOutOnClose(base::TimeDelta animation_duration) {
DoAnimation(animation_duration, layer(), 0.0f); DoAnimation(animation_duration, layer(), 0.0f);
DoAnimation(animation_duration, GetSearchBoxView()->layer(), 0.0f); DoAnimation(animation_duration, GetSearchBoxView()->layer(), 0.0f);
......
...@@ -154,6 +154,9 @@ class APP_LIST_EXPORT ContentsView : public views::View, ...@@ -154,6 +154,9 @@ class APP_LIST_EXPORT ContentsView : public views::View,
// Returns the height of current display. // Returns the height of current display.
int GetDisplayHeight() const; int GetDisplayHeight() const;
// Returns the width of the current display.
int GetDisplayWidth() const;
// Starts the fade out animation when the app list is closed. // Starts the fade out animation when the app list is closed.
void FadeOutOnClose(base::TimeDelta animation_duration); void FadeOutOnClose(base::TimeDelta animation_duration);
......
...@@ -5,10 +5,12 @@ ...@@ -5,10 +5,12 @@
#include "ui/app_list/views/horizontal_page_container.h" #include "ui/app_list/views/horizontal_page_container.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chromeos/chromeos_switches.h"
#include "ui/app_list/app_list_constants.h" #include "ui/app_list/app_list_constants.h"
#include "ui/app_list/pagination_controller.h" #include "ui/app_list/pagination_controller.h"
#include "ui/app_list/views/app_list_view.h" #include "ui/app_list/views/app_list_view.h"
#include "ui/app_list/views/apps_container_view.h" #include "ui/app_list/views/apps_container_view.h"
#include "ui/app_list/views/assistant_container_view.h"
#include "ui/app_list/views/contents_view.h" #include "ui/app_list/views/contents_view.h"
#include "ui/chromeos/search_box/search_box_constants.h" #include "ui/chromeos/search_box/search_box_constants.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
...@@ -33,9 +35,13 @@ HorizontalPageContainer::HorizontalPageContainer(ContentsView* contents_view, ...@@ -33,9 +35,13 @@ HorizontalPageContainer::HorizontalPageContainer(ContentsView* contents_view,
pagination_controller_.reset(new PaginationController( pagination_controller_.reset(new PaginationController(
&pagination_model_, PaginationController::SCROLL_AXIS_HORIZONTAL)); &pagination_model_, PaginationController::SCROLL_AXIS_HORIZONTAL));
apps_container_view_ = new AppsContainerView(contents_view_, model);
// Add horizontal pages. // Add horizontal pages.
if (chromeos::switches::IsAssistantEnabled()) {
assistant_container_view_ = new AssistantContainerView(contents_view_);
AddHorizontalPage(assistant_container_view_);
}
apps_container_view_ = new AppsContainerView(contents_view_, model);
AddHorizontalPage(apps_container_view_); AddHorizontalPage(apps_container_view_);
pagination_model_.SetTotalPages(horizontal_pages_.size()); pagination_model_.SetTotalPages(horizontal_pages_.size());
...@@ -48,7 +54,11 @@ HorizontalPageContainer::~HorizontalPageContainer() { ...@@ -48,7 +54,11 @@ HorizontalPageContainer::~HorizontalPageContainer() {
} }
gfx::Size HorizontalPageContainer::CalculatePreferredSize() const { gfx::Size HorizontalPageContainer::CalculatePreferredSize() const {
return apps_container_view_->GetPreferredSize(); gfx::Size size;
for (auto* page : horizontal_pages_) {
size.SetToMax(page->GetPreferredSize());
}
return size;
} }
void HorizontalPageContainer::Layout() { void HorizontalPageContainer::Layout() {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
namespace app_list { namespace app_list {
class AppsContainerView; class AppsContainerView;
class AssistantContainerView;
class PaginationController; class PaginationController;
class HorizontalPage; class HorizontalPage;
...@@ -79,6 +80,9 @@ class APP_LIST_EXPORT HorizontalPageContainer : public AppListPage, ...@@ -79,6 +80,9 @@ class APP_LIST_EXPORT HorizontalPageContainer : public AppListPage,
// Owned by view hierarchy: // Owned by view hierarchy:
AppsContainerView* apps_container_view_ = nullptr; AppsContainerView* apps_container_view_ = nullptr;
// Owned by view hierarchy:
AssistantContainerView* assistant_container_view_ = nullptr;
// The child page views. Owned by the views hierarchy. // The child page views. Owned by the views hierarchy.
std::vector<HorizontalPage*> horizontal_pages_; std::vector<HorizontalPage*> horizontal_pages_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment