Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view .h" | |
| 6 | |
| 7 #include "ash/display/window_tree_host_manager.h" | |
| 8 #include "ash/public/cpp/shell_window_ids.h" | |
| 9 #include "ash/shell.h" | |
| 10 #include "ui/aura/window.h" | |
| 11 #include "ui/gfx/canvas.h" | |
| 12 #include "ui/views/widget/widget.h" | |
| 13 | |
| 14 namespace chromeos { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 constexpr char kWidgetName[] = "TouchCalibratorOverlay"; | |
| 19 | |
| 20 // Returns the initialization params for the widget that contains the touch | |
| 21 // calibrator view. | |
| 22 views::Widget::InitParams GetWidgetParams(aura::Window* root_window) { | |
| 23 views::Widget::InitParams params; | |
| 24 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; | |
| 25 params.name = kWidgetName; | |
| 26 params.keep_on_top = true; | |
| 27 params.accept_events = true; | |
| 28 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; | |
| 29 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
| 30 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | |
| 31 params.parent = ash::Shell::GetContainer( | |
| 32 root_window, ash::kShellWindowId_OverlayContainer); | |
| 33 return params; | |
| 34 } | |
| 35 | |
| 36 } // namespace | |
| 37 | |
| 38 TouchCalibratorView::TouchCalibratorView(const display::Display& target_display, | |
| 39 bool is_primary_view) | |
| 40 : display_(target_display), is_primary_view_(is_primary_view) { | |
| 41 aura::Window* root = ash::Shell::GetInstance() | |
| 42 ->window_tree_host_manager() | |
| 43 ->GetRootWindowForDisplayId(display_.id()); | |
| 44 widget_.reset(new views::Widget); | |
| 45 widget_->Init(GetWidgetParams(root)); | |
| 46 widget_->Show(); | |
|
xiyuan
2016/12/22 19:23:30
nit: move Show() after SetcontentsView and SetBoun
malaykeshav
2016/12/22 20:17:01
done
| |
| 47 widget_->SetContentsView(this); | |
| 48 widget_->SetBounds(display_.bounds()); | |
| 49 set_owned_by_client(); | |
| 50 } | |
| 51 | |
| 52 TouchCalibratorView::~TouchCalibratorView() { | |
| 53 state_ = UNKNOWN; | |
| 54 widget_->Hide(); | |
| 55 } | |
| 56 | |
| 57 void TouchCalibratorView::OnPaint(gfx::Canvas* canvas) { | |
| 58 OnPaintBackground(canvas); | |
| 59 } | |
| 60 | |
| 61 void TouchCalibratorView::OnPaintBackground(gfx::Canvas* canvas) {} | |
| 62 | |
| 63 void TouchCalibratorView::AnimationProgressed(const gfx::Animation* animation) { | |
| 64 } | |
| 65 | |
| 66 void TouchCalibratorView::AnimationCanceled(const gfx::Animation* animation) { | |
| 67 AnimationEnded(animation); | |
| 68 } | |
| 69 | |
| 70 void TouchCalibratorView::AnimationEnded(const gfx::Animation* animation) {} | |
| 71 | |
| 72 void TouchCalibratorView::AdvanceToNextState() {} | |
| 73 | |
| 74 bool TouchCalibratorView::GetDisplayPointLocation(gfx::Point* location) { | |
| 75 if (!is_primary_view_) | |
| 76 return false; | |
| 77 return false; | |
| 78 } | |
| 79 | |
| 80 void TouchCalibratorView::SkipToFinalState() {} | |
| 81 | |
| 82 } // namespace chromeos | |
| OLD | NEW |