Commit 52d14038 authored by varkha's avatar varkha Committed by Commit bot

[ash-md] Implements a shadow over overview items and selector

This is non-MD 9-patch shadow just to test drive the looks.
Effectively this patch preserves the regular ash window shadows
and applies them in overview.

BUG=608852

Review-Url: https://codereview.chromium.org/2150823002
Cr-Commit-Position: refs/heads/master@{#405932}
parent 906c4dd5
......@@ -40,6 +40,7 @@
#include "ui/views/painter.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/shadow.h"
#include "ui/wm/core/window_animations.h"
namespace ash {
......@@ -723,6 +724,7 @@ void WindowGrid::FilterItems(const base::string16& pattern) {
if (selection_widget_ && SelectedWindow() == *iter) {
SelectedWindow()->SetSelected(false);
selection_widget_.reset();
selector_shadow_.reset();
}
}
}
......@@ -823,7 +825,6 @@ void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) {
selection_widget_.reset(CreateBackgroundWidget(root_window_, selection_color,
border_thickness,
border_radius, border_color));
WmWindow* widget_window =
WmLookup::Get()->GetWindowForWidget(selection_widget_.get());
const gfx::Rect target_bounds =
......@@ -831,6 +832,15 @@ void WindowGrid::InitSelectionWidget(WindowSelector::Direction direction) {
gfx::Vector2d fade_out_direction =
GetSlideVectorForFadeIn(direction, target_bounds);
widget_window->SetBounds(target_bounds - fade_out_direction);
if (material) {
selector_shadow_.reset(new ::wm::Shadow());
selector_shadow_->Init(::wm::Shadow::STYLE_ACTIVE);
selector_shadow_->layer()->SetVisible(true);
selection_widget_->GetLayer()->SetMasksToBounds(false);
selection_widget_->GetLayer()->Add(selector_shadow_->layer());
selector_shadow_->SetContentBounds(gfx::Rect(target_bounds.size()));
}
}
void WindowGrid::MoveSelectionWidget(WindowSelector::Direction direction,
......@@ -894,10 +904,32 @@ void WindowGrid::MoveSelectionWidgetToTarget(bool animate) {
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
selection_widget_->SetBounds(bounds);
selection_widget_->SetOpacity(1.f);
if (selector_shadow_) {
ui::ScopedLayerAnimationSettings animation_settings_shadow(
selector_shadow_->shadow_layer()->GetAnimator());
animation_settings_shadow.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(
kOverviewSelectorTransitionMilliseconds));
animation_settings_shadow.SetTweenType(
ash::MaterialDesignController::IsOverviewMaterial()
? gfx::Tween::EASE_IN_OUT
: gfx::Tween::LINEAR_OUT_SLOW_IN);
animation_settings_shadow.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
bounds.Inset(1, 1);
selector_shadow_->SetContentBounds(
gfx::Rect(gfx::Point(1, 1), bounds.size()));
}
return;
}
selection_widget_->SetBounds(bounds);
selection_widget_->SetOpacity(1.f);
if (selector_shadow_) {
bounds.Inset(1, 1);
selector_shadow_->SetContentBounds(
gfx::Rect(gfx::Point(1, 1), bounds.size()));
}
}
bool WindowGrid::FitWindowRectsInBounds(const gfx::Rect& bounds,
......
......@@ -20,6 +20,10 @@ namespace views {
class Widget;
}
namespace wm {
class Shadow;
}
namespace ash {
class WindowSelectorItem;
......@@ -174,6 +178,9 @@ class ASH_EXPORT WindowGrid : public WmWindowObserver {
// Widget that indicates to the user which is the selected window.
std::unique_ptr<views::Widget> selection_widget_;
// Shadow around the selector.
std::unique_ptr<::wm::Shadow> selector_shadow_;
// Current selected window position.
size_t selected_index_;
......
......@@ -42,6 +42,7 @@
#include "ui/views/controls/button/image_button.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/window/non_client_view.h"
#include "ui/wm/core/shadow.h"
#include "ui/wm/core/window_util.h"
namespace ash {
......@@ -372,6 +373,17 @@ void WindowSelectorItem::SetSelected(bool selected) {
animation_settings.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
window->SetOpacity(selected ? 0.0f : 1.0f);
ui::ScopedLayerAnimationSettings animation_settings_shadow(
shadow_->shadow_layer()->GetAnimator());
animation_settings_shadow.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds));
animation_settings_shadow.SetTweenType(selected
? gfx::Tween::FAST_OUT_LINEAR_IN
: gfx::Tween::LINEAR_OUT_SLOW_IN);
animation_settings_shadow.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
shadow_->shadow_layer()->SetOpacity(selected ? 0.0f : 1.0f);
}
void WindowSelectorItem::RecomputeWindowTransforms() {
......@@ -546,6 +558,12 @@ void WindowSelectorItem::CreateWindowLabel(const base::string16& title) {
window_label_button_view_->SetVisible(false);
window_label_->Show();
shadow_.reset(new ::wm::Shadow());
shadow_->Init(::wm::Shadow::STYLE_INACTIVE);
shadow_->layer()->SetVisible(true);
window_label_->GetLayer()->Add(shadow_->layer());
window_label_->GetLayer()->SetMasksToBounds(false);
views::View* background_view =
new RoundedContainerView(kLabelBackgroundRadius, kLabelBackgroundColor);
window_label_selector_.reset(new views::Widget);
......@@ -594,6 +612,7 @@ void WindowSelectorItem::UpdateHeaderLayout(
// the window including its sizing borders.
label_rect.set_height(label_rect.height() +
transformed_window_bounds.height());
gfx::Rect shadow_bounds(label_rect.size());
label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin);
window_label_window->SetBounds(label_rect);
gfx::Transform label_transform;
......@@ -601,6 +620,9 @@ void WindowSelectorItem::UpdateHeaderLayout(
transformed_window_bounds.y());
window_label_window->SetTransform(label_transform);
window_label_selector_window->SetTransform(label_transform);
shadow_bounds.Offset(kWindowSelectorMargin, kWindowSelectorMargin);
shadow_->SetContentBounds(shadow_bounds);
} else {
if (!close_button_->visible()) {
close_button_->SetVisible(true);
......
......@@ -21,6 +21,10 @@ namespace views {
class ImageButton;
}
namespace wm {
class Shadow;
}
namespace ash {
class WindowSelector;
......@@ -174,6 +178,9 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
// Otherwise it is shown under the window.
std::unique_ptr<views::Widget> window_label_;
// Shadow around the item in overview.
std::unique_ptr<::wm::Shadow> shadow_;
// Label background widget used to fade in opacity when moving selection.
std::unique_ptr<views::Widget> window_label_selector_;
......
......@@ -45,6 +45,10 @@ class WM_EXPORT Shadow : public ui::ImplicitAnimationObserver {
// transformations to this layer).
ui::Layer* layer() const { return layer_.get(); }
// Exposed to allow setting animation parameters for bounds and opacity
// animations.
ui::Layer* shadow_layer() const { return shadow_layer_.get(); }
const gfx::Rect& content_bounds() const { return content_bounds_; }
Style style() const { return style_; }
......
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