Commit edc72771 authored by Jun Mukai's avatar Jun Mukai

Moves home card background to HomeCardView.

We'll soon remove AthenaStartPageView, so AppList independent
components like background should belong to HomeCardView.

This CL also fixes the bug of the visual effect; the spec is
saying that the gradient end should be white even in
the BOTTOM state.

BUG=425717
R=oshima@chromium.org
TEST=manually

Review URL: https://codereview.chromium.org/692643003

Cr-Commit-Position: refs/heads/master@{#302219}
parent 0991c82d
...@@ -163,9 +163,7 @@ namespace athena { ...@@ -163,9 +163,7 @@ namespace athena {
const char AthenaStartPageView::kViewClassName[] = "AthenaStartPageView"; const char AthenaStartPageView::kViewClassName[] = "AthenaStartPageView";
AthenaStartPageView::LayoutData::LayoutData() AthenaStartPageView::LayoutData::LayoutData()
: system_info_opacity(1.0f), : system_info_opacity(1.0f), logo_opacity(1.0f) {
logo_opacity(1.0f),
background_opacity(1.0f) {
} }
AthenaStartPageView::AthenaStartPageView( AthenaStartPageView::AthenaStartPageView(
...@@ -173,16 +171,6 @@ AthenaStartPageView::AthenaStartPageView( ...@@ -173,16 +171,6 @@ AthenaStartPageView::AthenaStartPageView(
: delegate_(view_delegate), : delegate_(view_delegate),
layout_state_(0.0f), layout_state_(0.0f),
weak_factory_(this) { weak_factory_(this) {
background_ = new views::View();
// Vertical gradient background for the time being.
// TODO(mukai): replace by the actual one.
background_->set_background(
views::Background::CreateVerticalGradientBackground(SK_ColorLTGRAY,
SK_ColorWHITE));
background_->SetPaintToLayer(true);
background_->SetFillsBoundsOpaquely(false);
AddChildView(background_);
system_info_view_ = system_info_view_ =
SystemUI::Get()->CreateSystemInfoView(SystemUI::COLOR_SCHEME_DARK); SystemUI::Get()->CreateSystemInfoView(SystemUI::COLOR_SCHEME_DARK);
system_info_view_->SetPaintToLayer(true); system_info_view_->SetPaintToLayer(true);
...@@ -303,7 +291,6 @@ AthenaStartPageView::LayoutData AthenaStartPageView::CreateBottomBounds( ...@@ -303,7 +291,6 @@ AthenaStartPageView::LayoutData AthenaStartPageView::CreateBottomBounds(
state.system_info_opacity = 0.0f; state.system_info_opacity = 0.0f;
state.logo_opacity = 0.0f; state.logo_opacity = 0.0f;
state.background_opacity = 0.9f;
return state; return state;
} }
...@@ -325,7 +312,6 @@ AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds( ...@@ -325,7 +312,6 @@ AthenaStartPageView::LayoutData AthenaStartPageView::CreateCenteredBounds(
state.system_info_opacity = 1.0f; state.system_info_opacity = 1.0f;
state.logo_opacity = 1.0f; state.logo_opacity = 1.0f;
state.background_opacity = 1.0f;
return state; return state;
} }
...@@ -446,12 +432,6 @@ void AthenaStartPageView::Layout() { ...@@ -446,12 +432,6 @@ void AthenaStartPageView::Layout() {
layout_state_, bottom_bounds.controls, centered_bounds.controls)); layout_state_, bottom_bounds.controls, centered_bounds.controls));
search_box_container_->SetBoundsRect(gfx::Tween::RectValueBetween( search_box_container_->SetBoundsRect(gfx::Tween::RectValueBetween(
layout_state_, bottom_bounds.search_box, centered_bounds.search_box)); layout_state_, bottom_bounds.search_box, centered_bounds.search_box));
background_->SetBoundsRect(bounds());
background_->layer()->SetOpacity(gfx::Tween::FloatValueBetween(
layout_state_,
bottom_bounds.background_opacity,
centered_bounds.background_opacity));
} }
bool AthenaStartPageView::OnKeyPressed(const ui::KeyEvent& key_event) { bool AthenaStartPageView::OnKeyPressed(const ui::KeyEvent& key_event) {
......
...@@ -63,7 +63,6 @@ class ATHENA_EXPORT AthenaStartPageView ...@@ -63,7 +63,6 @@ class ATHENA_EXPORT AthenaStartPageView
gfx::Rect controls; gfx::Rect controls;
float system_info_opacity; float system_info_opacity;
float logo_opacity; float logo_opacity;
float background_opacity;
LayoutData(); LayoutData();
}; };
...@@ -110,10 +109,6 @@ class ATHENA_EXPORT AthenaStartPageView ...@@ -110,10 +109,6 @@ class ATHENA_EXPORT AthenaStartPageView
app_list::SearchBoxView* search_box_view_; app_list::SearchBoxView* search_box_view_;
app_list::SearchResultListView* search_results_view_; app_list::SearchResultListView* search_results_view_;
// Do not use views::Background but a views::View with ui::Layer for gradient
// background opacity update and animation.
views::View* background_;
// The expected height of |search_results_view_| // The expected height of |search_results_view_|
int search_results_height_; int search_results_height_;
......
...@@ -127,10 +127,18 @@ class HomeCardView : public views::WidgetDelegateView, ...@@ -127,10 +127,18 @@ class HomeCardView : public views::WidgetDelegateView,
HomeCardView(app_list::AppListViewDelegate* view_delegate, HomeCardView(app_list::AppListViewDelegate* view_delegate,
aura::Window* container, aura::Window* container,
HomeCardGestureManager::Delegate* gesture_delegate) HomeCardGestureManager::Delegate* gesture_delegate)
: minimized_background_(new views::View()), : background_(new views::View),
drag_indicator_(new views::View()),
main_view_(new AthenaStartPageView(view_delegate)), main_view_(new AthenaStartPageView(view_delegate)),
minimized_background_(new views::View()),
drag_indicator_(new views::View()),
gesture_delegate_(gesture_delegate) { gesture_delegate_(gesture_delegate) {
background_->set_background(
views::Background::CreateVerticalGradientBackground(SK_ColorLTGRAY,
SK_ColorWHITE));
background_->SetPaintToLayer(true);
background_->SetFillsBoundsOpaquely(false);
AddChildView(background_);
// Ideally AppListMainView should be used here and have AthenaStartPageView // Ideally AppListMainView should be used here and have AthenaStartPageView
// as its child view, so that custom pages and apps grid are available in // as its child view, so that custom pages and apps grid are available in
// the home card. // the home card.
...@@ -163,12 +171,28 @@ class HomeCardView : public views::WidgetDelegateView, ...@@ -163,12 +171,28 @@ class HomeCardView : public views::WidgetDelegateView,
main_view_->SetLayoutState(1.0f - progress); main_view_->SetLayoutState(1.0f - progress);
else if (to_state == HomeCard::VISIBLE_CENTERED) else if (to_state == HomeCard::VISIBLE_CENTERED)
main_view_->SetLayoutState(progress); main_view_->SetLayoutState(progress);
float background_opacity = 1.0f;
if (from_state == HomeCard::VISIBLE_MINIMIZED || if (from_state == HomeCard::VISIBLE_MINIMIZED ||
to_state == HomeCard::VISIBLE_MINIMIZED) { to_state == HomeCard::VISIBLE_MINIMIZED) {
minimized_background_->layer()->SetOpacity( background_opacity = (from_state == HomeCard::VISIBLE_MINIMIZED)
(to_state == HomeCard::VISIBLE_MINIMIZED) ? progress ? progress
: (1.0f - progress)); : (1.0f - progress);
}
background_->layer()->SetOpacity(background_opacity);
minimized_background_->layer()->SetOpacity(1.0f - background_opacity);
int background_height = kHomeCardHeight;
if (from_state == HomeCard::VISIBLE_CENTERED ||
to_state == HomeCard::VISIBLE_CENTERED) {
gfx::Rect window_bounds = GetWidget()->GetWindowBoundsInScreen();
background_height = window_bounds.height() - window_bounds.y();
} }
gfx::Transform background_transform;
background_transform.Scale(
SK_MScalar1,
SkIntToMScalar(background_height) / SkIntToMScalar(height()));
background_->layer()->SetTransform(background_transform);
gfx::Rect from_bounds = GetDragIndicatorBounds(from_state); gfx::Rect from_bounds = GetDragIndicatorBounds(from_state);
gfx::Rect to_bounds = GetDragIndicatorBounds(to_state); gfx::Rect to_bounds = GetDragIndicatorBounds(to_state);
...@@ -181,16 +205,32 @@ class HomeCardView : public views::WidgetDelegateView, ...@@ -181,16 +205,32 @@ class HomeCardView : public views::WidgetDelegateView,
void SetStateWithAnimation(HomeCard::State state, void SetStateWithAnimation(HomeCard::State state,
gfx::Tween::Type tween_type) { gfx::Tween::Type tween_type) {
float minimized_target_opacity_for_state = float minimized_opacity =
(state == HomeCard::VISIBLE_MINIMIZED) ? 1.0f : 0.0f; (state == HomeCard::VISIBLE_MINIMIZED) ? 1.0f : 0.0f;
if (minimized_target_opacity_for_state != if (minimized_opacity !=
minimized_background_->layer()->GetTargetOpacity()) { minimized_background_->layer()->GetTargetOpacity()) {
ui::ScopedLayerAnimationSettings settings( ui::ScopedLayerAnimationSettings settings(
minimized_background_->layer()->GetAnimator()); minimized_background_->layer()->GetAnimator());
settings.SetTweenType(gfx::Tween::EASE_IN); settings.SetTweenType(gfx::Tween::EASE_IN);
minimized_background_->layer()->SetOpacity( minimized_background_->layer()->SetOpacity(minimized_opacity);
minimized_target_opacity_for_state); }
gfx::Transform background_transform;
if (state != HomeCard::VISIBLE_CENTERED) {
background_transform.Scale(
SK_MScalar1,
SkIntToMScalar(kHomeCardHeight) / SkIntToMScalar(height()));
}
float background_opacity = 1.0f - minimized_opacity;
if (background_->layer()->GetTargetTransform() != background_transform ||
background_->layer()->GetTargetOpacity() != background_opacity) {
ui::ScopedLayerAnimationSettings settings(
background_->layer()->GetAnimator());
settings.SetTweenType(tween_type);
background_->layer()->SetTransform(background_transform);
background_->layer()->SetOpacity(background_opacity);
} }
if (state == HomeCard::VISIBLE_CENTERED) if (state == HomeCard::VISIBLE_CENTERED)
main_view_->RequestFocusOnSearchBox(); main_view_->RequestFocusOnSearchBox();
else else
...@@ -245,6 +285,7 @@ class HomeCardView : public views::WidgetDelegateView, ...@@ -245,6 +285,7 @@ class HomeCardView : public views::WidgetDelegateView,
void Layout() override { void Layout() override {
gfx::Rect contents_bounds = GetContentsBounds(); gfx::Rect contents_bounds = GetContentsBounds();
background_->SetBoundsRect(contents_bounds);
main_view_->SetBoundsRect(contents_bounds); main_view_->SetBoundsRect(contents_bounds);
minimized_background_->SetBoundsRect(contents_bounds); minimized_background_->SetBoundsRect(contents_bounds);
drag_indicator_->SetBoundsRect( drag_indicator_->SetBoundsRect(
...@@ -261,9 +302,10 @@ class HomeCardView : public views::WidgetDelegateView, ...@@ -261,9 +302,10 @@ class HomeCardView : public views::WidgetDelegateView,
HomeCard::Get()->SetState(HomeCard::VISIBLE_CENTERED); HomeCard::Get()->SetState(HomeCard::VISIBLE_CENTERED);
} }
views::View* background_;
AthenaStartPageView* main_view_;
views::View* minimized_background_; views::View* minimized_background_;
views::View* drag_indicator_; views::View* drag_indicator_;
AthenaStartPageView* main_view_;
HomeCard::State state_; HomeCard::State state_;
scoped_ptr<HomeCardGestureManager> gesture_manager_; scoped_ptr<HomeCardGestureManager> gesture_manager_;
HomeCardGestureManager::Delegate* gesture_delegate_; HomeCardGestureManager::Delegate* gesture_delegate_;
......
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