#include "ash/wm/overview/window_selector_window.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"
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::internal::kShellWindowId_OverlayContainer);
+ params.parent =
+ Shell::GetContainer(root_window, ash::kShellWindowId_OverlayContainer);
widget->set_focus_on_creation(false);
widget->Init(params);
views::ImageButton* button = new views::ImageButton(listener);
return widget;
}
-// The time for the close button to fade in when initially shown on entering
-// overview mode.
-const int kCloseButtonFadeInMilliseconds = 80;
-
} // namespace
WindowSelectorWindow::WindowSelectorWindow(aura::Window* window)
bool animate) {
gfx::Rect src_rect = transform_window_.GetBoundsInScreen();
set_bounds(ScopedTransformOverviewWindow::
- ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds));
+ ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds));
transform_window_.SetTransform(root_window,
ScopedTransformOverviewWindow::GetTransformForRect(src_rect, bounds()),
animate);
- UpdateCloseButtonBounds();
+ // TODO move close button management to WindowSelectorItem, so that we can
+ // also handle panels.
+ // See http://crbug.com/352143
+ UpdateCloseButtonBounds(root_window, animate);
}
void WindowSelectorWindow::ButtonPressed(views::Button* sender,
transform_window_.window())->Close();
}
-void WindowSelectorWindow::UpdateCloseButtonBounds() {
- aura::Window* root_window = GetRootWindow();
- gfx::Rect align_bounds(bounds());
+void WindowSelectorWindow::UpdateCloseButtonBounds(aura::Window* root_window,
+ bool animate) {
+ gfx::Rect align_bounds(
+ ScreenUtil::ConvertRectFromScreen(root_window, bounds()));
gfx::Transform close_button_transform;
close_button_transform.Translate(align_bounds.right(), align_bounds.y());
settings.SetPreemptionStrategy(
ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
- kCloseButtonFadeInMilliseconds));
+ WindowSelectorItem::kFadeInMilliseconds));
layer->SetOpacity(1);
}
} else {
- ui::ScopedLayerAnimationSettings settings(
- close_button_->GetNativeWindow()->layer()->GetAnimator());
- settings.SetPreemptionStrategy(
- ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
- settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
- ScopedTransformOverviewWindow::kTransitionMilliseconds));
- close_button_->GetNativeWindow()->SetTransform(close_button_transform);
+ if (animate) {
+ ui::ScopedLayerAnimationSettings settings(
+ close_button_->GetNativeWindow()->layer()->GetAnimator());
+ settings.SetPreemptionStrategy(
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
+ settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
+ ScopedTransformOverviewWindow::kTransitionMilliseconds));
+ close_button_->GetNativeWindow()->SetTransform(close_button_transform);
+ } else {
+ close_button_->GetNativeWindow()->SetTransform(close_button_transform);
+ }
}
}