1 // Copyright 2015 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 #include "ui/app_list/views/custom_launcher_page_view.h"
7 #include "ui/app_list/app_list_constants.h"
8 #include "ui/views/layout/fill_layout.h"
12 CustomLauncherPageView::CustomLauncherPageView(
13 View
* custom_launcher_page_contents
)
14 : custom_launcher_page_contents_(custom_launcher_page_contents
) {
15 SetLayoutManager(new views::FillLayout());
16 AddChildView(custom_launcher_page_contents_
);
19 CustomLauncherPageView::~CustomLauncherPageView() {
22 gfx::Rect
CustomLauncherPageView::GetCollapsedLauncherPageBounds() const {
23 gfx::Rect rect
= GetFullContentsBounds();
24 int page_height
= rect
.height();
25 rect
.set_y(page_height
- kCustomPageCollapsedHeight
);
29 gfx::Rect
CustomLauncherPageView::GetPageBoundsForState(
30 AppListModel::State state
) const {
31 gfx::Rect onscreen_bounds
= GetFullContentsBounds();
33 case AppListModel::STATE_CUSTOM_LAUNCHER_PAGE
:
34 return onscreen_bounds
;
35 case AppListModel::STATE_START
:
36 return GetCollapsedLauncherPageBounds();
38 return GetBelowContentsOffscreenBounds(onscreen_bounds
.size());
42 void CustomLauncherPageView::OnShown() {
43 custom_launcher_page_contents_
->SetFocusable(true);
46 void CustomLauncherPageView::OnWillBeHidden() {
47 custom_launcher_page_contents_
->SetFocusable(false);
50 } // namespace app_list