| Index: ash/surfaces/test_shell_surface_overlay_view.cc
|
| diff --git a/ash/surfaces/test_shell_surface_overlay_view.cc b/ash/surfaces/test_shell_surface_overlay_view.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e1700350e377e0c34632bc8aea725d345df371e6
|
| --- /dev/null
|
| +++ b/ash/surfaces/test_shell_surface_overlay_view.cc
|
| @@ -0,0 +1,116 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ash/surfaces/test_shell_surface_overlay_view.h"
|
| +
|
| +#include "ash/shell.h"
|
| +#include "ash/shell_window_ids.h"
|
| +#include "ash/surfaces/surface_controller.h"
|
| +#include "ui/events/event.h"
|
| +#include "ui/gfx/canvas.h"
|
| +#include "ui/gfx/transform_util.h"
|
| +
|
| +namespace ash {
|
| +
|
| +TestShellSurfaceOverlayView::TestShellSurfaceOverlayView() {}
|
| +
|
| +TestShellSurfaceOverlayView::~TestShellSurfaceOverlayView() {}
|
| +
|
| +void TestShellSurfaceOverlayView::OnPaint(gfx::Canvas* canvas) {
|
| + canvas->FillRect(GetLocalBounds(), SK_ColorBLACK);
|
| +}
|
| +
|
| +void TestShellSurfaceOverlayView::WindowClosing() {
|
| + Cancel();
|
| +}
|
| +
|
| +void TestShellSurfaceOverlayView::Cancel() {
|
| + Shell::GetInstance()->overlay_filter()->Deactivate(this);
|
| + views::Widget* widget = GetWidget();
|
| + if (widget)
|
| + widget->Close();
|
| +}
|
| +
|
| +bool TestShellSurfaceOverlayView::IsCancelingKeyEvent(ui::KeyEvent* event) {
|
| + if (event->type() != ui::ET_KEY_PRESSED)
|
| + return false;
|
| +
|
| + // Ignore the caps lock and shift state.
|
| + const int flags =
|
| + event->flags() & ~(ui::EF_CAPS_LOCK_DOWN | ui::EF_SHIFT_DOWN);
|
| +
|
| + // Keys to invoke hide (Ctrl+Alt+A).
|
| + return event->key_code() == ui::VKEY_A &&
|
| + flags == (ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN);
|
| +}
|
| +
|
| +aura::Window* TestShellSurfaceOverlayView::GetWindow() {
|
| + return GetWidget()->GetNativeWindow();
|
| +}
|
| +
|
| +// static
|
| +void TestShellSurfaceOverlayView::Show() {
|
| + if (Shell::GetInstance()->overlay_filter()->IsActive())
|
| + return;
|
| +
|
| + const gfx::Point kOrigin(64, 40);
|
| + const float kScale = 0.3f;
|
| +
|
| + ui::Layer* test_shell_surface_layer =
|
| + Shell::GetInstance()->surface_controller()->test_shell_surface_layer();
|
| +
|
| + test_shell_surface_layer->SetTransform(
|
| + gfx::GetScaleTransform(gfx::Point(), kScale));
|
| +
|
| + TestShellSurfaceOverlayView* view = new TestShellSurfaceOverlayView;
|
| + views::Widget::InitParams params(
|
| + views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
|
| + params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_DROP;
|
| + params.bounds = gfx::Rect(
|
| + kOrigin,
|
| + gfx::ScaleToRoundedSize(
|
| + Shell::GetScreen()->GetPrimaryDisplay().bounds().size(), kScale));
|
| + params.show_state = ui::SHOW_STATE_NORMAL;
|
| + params.parent = Shell::GetContainer(Shell::GetPrimaryRootWindow(),
|
| + kShellWindowId_OverlayContainer);
|
| + views::Widget* widget = new views::Widget;
|
| + widget->Init(params);
|
| + widget->SetContentsView(view);
|
| + widget->GetNativeWindow()->layer()->Add(test_shell_surface_layer);
|
| + widget->Show();
|
| + widget->GetNativeView()->SetName("TestShellSurfaceOverlayView");
|
| + widget->GetNativeView()->Focus();
|
| +
|
| + Shell::GetInstance()->overlay_filter()->Activate(view);
|
| +}
|
| +
|
| +// static
|
| +void TestShellSurfaceOverlayView::ShowFullscreen() {
|
| + if (Shell::GetInstance()->overlay_filter()->IsActive())
|
| + return;
|
| +
|
| + ui::Layer* test_shell_surface_layer =
|
| + Shell::GetInstance()->surface_controller()->test_shell_surface_layer();
|
| +
|
| + test_shell_surface_layer->SetTransform(gfx::Transform());
|
| +
|
| + TestShellSurfaceOverlayView* view = new TestShellSurfaceOverlayView;
|
| + views::Widget::InitParams params(
|
| + views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
|
| + params.bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds();
|
| + params.show_state = ui::SHOW_STATE_FULLSCREEN;
|
| + params.parent = Shell::GetContainer(Shell::GetPrimaryRootWindow(),
|
| + kShellWindowId_OverlayContainer);
|
| + views::Widget* widget = new views::Widget;
|
| + widget->Init(params);
|
| + widget->SetContentsView(view);
|
| + widget->GetNativeWindow()->layer()->Add(test_shell_surface_layer);
|
| + widget->Show();
|
| + widget->GetNativeView()->SetName("TestShellSurfaceOverlayView");
|
| + widget->GetNativeView()->Focus();
|
| +
|
| + Shell::GetInstance()->overlay_filter()->Activate(view);
|
| +}
|
| +
|
| +} // namespace ash
|
|
|