Chromium Code Reviews| Index: ash/wm/overview/window_selector_item.cc |
| diff --git a/ash/wm/overview/window_selector_item.cc b/ash/wm/overview/window_selector_item.cc |
| index a2c25b617e9c872b1c2849209cc383ff59a14657..eff21734a3294bfa5851546fec4352d2313e52c7 100644 |
| --- a/ash/wm/overview/window_selector_item.cc |
| +++ b/ash/wm/overview/window_selector_item.cc |
| @@ -3,11 +3,80 @@ |
| // found in the LICENSE file. |
| #include "ash/wm/overview/window_selector_item.h" |
| + |
| +#include "ash/screen_util.h" |
| +#include "ash/shell.h" |
| +#include "ash/shell_window_ids.h" |
| +#include "ash/wm/overview/scoped_transform_overview_window.h" |
|
flackr
2014/04/17 03:44:29
Don't think you need this anymore.
Nina
2014/04/17 15:02:19
Done.
Nina
2014/04/17 15:02:19
We're using it for the milliseconds constant. When
flackr
2014/04/17 15:08:33
Oops, yes of course. I was thinking of the other c
|
| #include "base/auto_reset.h" |
| +#include "base/memory/scoped_ptr.h" |
|
flackr
2014/04/17 03:44:29
Don't need this here, as you don't create any scop
Nina
2014/04/17 15:02:19
Done.
|
| +#include "third_party/skia/include/core/SkColor.h" |
| #include "ui/aura/window.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| +#include "ui/compositor/scoped_layer_animation_settings.h" |
| +#include "ui/views/controls/label.h" |
| +#include "ui/views/layout/box_layout.h" |
| +#include "ui/views/widget/widget.h" |
| namespace ash { |
| +// Foreground label color. |
| +static const SkColor kLabelColor = SK_ColorWHITE; |
| + |
| +// Background label color. |
| +static const SkColor kLabelBackground = SK_ColorTRANSPARENT; |
| + |
| +// Label shadow color. |
| +static const SkColor kLabelShadow = 0xB0000000; |
| + |
| +// Vertical padding for the label, both over and beneath it. |
| +static const int kVerticalLabelPadding = 20; |
| + |
| +// Label height, i.e. distance from the border of the window to the label |
| +// bottom. |
| +static const int kLabelHeight = 20; |
|
flackr
2014/04/17 03:44:29
To the label bottom? How is this the same as the v
Nina
2014/04/17 15:02:19
Done.
|
| + |
| +// Solid shadow length from the label |
| +static const int kVerticalShadowOffset = 1; |
| + |
| +// Amount of blur applied to the label shadow |
| +static const int kShadowBlur = 10; |
| + |
| +views::Widget* CreateWindowLabel(aura::Window* root_window, |
| + const base::string16 title) { |
| + views::Widget* widget = new views::Widget; |
| + views::Widget::InitParams params; |
| + params.type = views::Widget::InitParams::TYPE_POPUP; |
| + params.can_activate = false; |
| + params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| + params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| + params.parent = |
| + Shell::GetContainer(root_window, ash::kShellWindowId_OverlayContainer); |
| + params.accept_events = false; |
| + params.visible_on_all_workspaces = true; |
| + widget->set_focus_on_creation(false); |
| + widget->Init(params); |
| + views::Label* label = new views::Label; |
| + label->SetEnabledColor(kLabelColor); |
| + label->SetBackgroundColor(kLabelBackground); |
| + label->SetShadowColors(kLabelShadow, kLabelShadow); |
| + label->SetShadowOffset(0, kVerticalShadowOffset); |
| + label->set_shadow_blur(kShadowBlur); |
| + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| + label->SetFontList(bundle.GetFontList(ui::ResourceBundle::BoldFont)); |
| + label->SetText(title); |
| + views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical, |
| + 0, |
| + kVerticalLabelPadding, |
| + 0); |
| + label->SetLayoutManager(layout); |
| + widget->SetContentsView(label); |
| + widget->Show(); |
| + return widget; |
| +} |
| + |
| +const int WindowSelectorItem::kFadeInMilliseconds = 80; |
| + |
| WindowSelectorItem::WindowSelectorItem() |
| : root_window_(NULL), |
| in_bounds_update_(false) { |
| @@ -24,6 +93,7 @@ void WindowSelectorItem::SetBounds(aura::Window* root_window, |
| root_window_ = root_window; |
| target_bounds_ = target_bounds; |
| SetItemBounds(root_window, target_bounds, true); |
| + UpdateWindowLabels(target_bounds, root_window); |
|
flackr
2014/04/17 03:44:29
TODO(nsatragno): Handle window title updates.
Nina
2014/04/17 15:02:19
Added TODO comment
|
| } |
| void WindowSelectorItem::RecomputeWindowTransforms() { |
| @@ -34,4 +104,51 @@ void WindowSelectorItem::RecomputeWindowTransforms() { |
| SetItemBounds(root_window_, target_bounds_, false); |
| } |
| +void WindowSelectorItem::UpdateWindowLabels(const gfx::Rect& window_bounds, |
| + aura::Window* root_window) { |
| + gfx::Rect label_bounds(window_bounds.x(), |
| + window_bounds.y() + window_bounds.height(), |
|
flackr
2014/04/17 03:44:29
nit: window_bounds.bottom().
Nina
2014/04/17 15:02:19
Done.
|
| + window_bounds.width(), |
| + kLabelHeight); |
| + label_bounds = ScreenUtil::ConvertRectFromScreen(root_window, label_bounds); |
|
flackr
2014/04/17 03:44:29
nit: I'd prefer instead converting the window boun
Nina
2014/04/17 15:02:19
Done.
|
| + |
| + // If the root window has changed, force the window label to be recreated |
| + // and faded in on the new root window. |
| + if (window_label_ && |
| + window_label_->GetNativeWindow()->GetRootWindow() != root_window) { |
| + window_label_.reset(); |
| + } |
| + |
| + if (!window_label_) { |
| + window_label_.reset(CreateWindowLabel(root_window, |
| + SelectionWindow()->title())); |
| + window_label_->GetNativeWindow()->SetBounds(label_bounds); |
| + ui::Layer* layer = window_label_->GetNativeWindow()->layer(); |
| + |
| + layer->SetOpacity(0); |
| + layer->GetAnimator()->StopAnimating(); |
| + |
| + layer->GetAnimator()->SchedulePauseForProperties( |
| + base::TimeDelta::FromMilliseconds( |
| + ScopedTransformOverviewWindow::kTransitionMilliseconds), |
| + ui::LayerAnimationElement::OPACITY); |
| + |
| + ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| + settings.SetPreemptionStrategy( |
| + ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| + settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| + kFadeInMilliseconds)); |
| + layer->SetOpacity(1); |
| + } else { |
| + ui::ScopedLayerAnimationSettings settings( |
| + window_label_->GetNativeWindow()->layer()->GetAnimator()); |
| + settings.SetPreemptionStrategy( |
| + ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| + settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| + ScopedTransformOverviewWindow::kTransitionMilliseconds)); |
| + window_label_->GetNativeWindow()->SetBounds(label_bounds); |
| + } |
| + |
| +} |
| + |
| } // namespace ash |