Chromium Code Reviews| Index: chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.cc |
| diff --git a/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.cc b/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..da4d4c93b6db6d89fc481b1991b4877f6355c4b5 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.cc |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2016 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 "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.h" |
| + |
| +#include "ash/display/window_tree_host_manager.h" |
| +#include "ash/public/cpp/shell_window_ids.h" |
| +#include "ash/shell.h" |
| +#include "ui/aura/window.h" |
| +#include "ui/gfx/canvas.h" |
| +#include "ui/views/widget/widget.h" |
| + |
| +namespace chromeos { |
|
stevenjb
2016/12/22 01:14:21
blank line
malaykeshav
2016/12/22 11:50:07
Done
|
| +namespace { |
| + |
| +const char kWidgetName[] = "TouchCalibratorOverlay"; |
|
stevenjb
2016/12/22 01:14:21
constexpr
malaykeshav
2016/12/22 11:50:07
Done
|
| + |
| +// Returns the initialization params for the widget that contains the touch |
| +// calibrator view. |
| +views::Widget::InitParams GetWidgetParams(aura::Window* root_window) { |
| + views::Widget::InitParams params; |
| + params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; |
| + params.name = kWidgetName; |
| + params.keep_on_top = true; |
| + params.accept_events = true; |
| + params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; |
| + params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| + params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| + params.parent = ash::Shell::GetContainer( |
| + root_window, ash::kShellWindowId_OverlayContainer); |
| + return params; |
| +} |
| + |
| +} // namespace |
| + |
| +TouchCalibratorView::TouchCalibratorView(const display::Display& target_display, |
| + bool is_primary_view) |
| + : display_(target_display), is_primary_view_(is_primary_view) { |
| + aura::Window* root = ash::Shell::GetInstance() |
| + ->window_tree_host_manager() |
| + ->GetRootWindowForDisplayId(display_.id()); |
| + widget_.reset(new views::Widget); |
| + widget_->Init(GetWidgetParams(root)); |
| + widget_->Show(); |
| + widget_->SetContentsView(this); |
| + widget_->SetBounds(display_.bounds()); |
| + set_owned_by_client(); |
| +} |
| + |
| +TouchCalibratorView::~TouchCalibratorView() { |
| + state_ = UNKNOWN; |
| + widget_->Hide(); |
| +} |
|
stevenjb
2016/12/22 01:14:21
blank line
malaykeshav
2016/12/22 11:50:07
Done
|
| +// views::View override: |
|
stevenjb
2016/12/22 01:14:21
Elim. unnecessary comments, these should just be i
malaykeshav
2016/12/22 11:50:07
Done
|
| +void TouchCalibratorView::OnPaint(gfx::Canvas* canvas) { |
| + OnPaintBackground(canvas); |
| +} |
| + |
| +// views::View override: |
| +void TouchCalibratorView::OnPaintBackground(gfx::Canvas* canvas) {} |
| + |
| +// gfx::AnimationDelegate override: |
| +void TouchCalibratorView::AnimationProgressed(const gfx::Animation* animation) { |
| +} |
| + |
| +// gfx::AnimationDelegate override: |
| +void TouchCalibratorView::AnimationCanceled(const gfx::Animation* animation) { |
| + AnimationEnded(animation); |
| +} |
| + |
| +// gfx::AnimationDelegate override: |
| +void TouchCalibratorView::AnimationEnded(const gfx::Animation* animation) {} |
| + |
| +void TouchCalibratorView::NextState() {} |
| + |
| +bool TouchCalibratorView::GetTouchPointLocation(gfx::Point* location) { |
| + if (!is_primary_view_) |
| + return false; |
| + return false; |
| +} |
| + |
| +void TouchCalibratorView::SkipToFinalState() {} |
| + |
| +} // namespace chromeos |