| Index: ash/touch_hud/touch_hud_renderer.cc
|
| diff --git a/ash/touch/touch_hud_projection.cc b/ash/touch_hud/touch_hud_renderer.cc
|
| similarity index 75%
|
| copy from ash/touch/touch_hud_projection.cc
|
| copy to ash/touch_hud/touch_hud_renderer.cc
|
| index 02f604ef8d72543e6bb78242274de5c29a37161a..460116cd908d3d732dedadd44ce8314143affe48 100644
|
| --- a/ash/touch/touch_hud_projection.cc
|
| +++ b/ash/touch_hud/touch_hud_renderer.cc
|
| @@ -1,22 +1,22 @@
|
| -// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// 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 "ash/touch/touch_hud_projection.h"
|
| +#include "ash/touch_hud/touch_hud_renderer.h"
|
|
|
| -#include "ash/root_window_controller.h"
|
| -#include "ash/shell.h"
|
| #include "third_party/skia/include/effects/SkGradientShader.h"
|
| #include "ui/events/event.h"
|
| #include "ui/gfx/animation/animation_delegate.h"
|
| #include "ui/gfx/animation/linear_animation.h"
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/geometry/size.h"
|
| +#include "ui/views/view.h"
|
| #include "ui/views/widget/widget.h"
|
| +#include "ui/views/widget/widget_observer.h"
|
|
|
| namespace ash {
|
|
|
| -const int kPointRadius = 20;
|
| +const int kPointRadius = 40;
|
| const SkColor kProjectionFillColor = SkColorSetRGB(0xF5, 0xF5, 0xDC);
|
| const SkColor kProjectionStrokeColor = SK_ColorGRAY;
|
| const int kProjectionAlpha = 0xB0;
|
| @@ -24,7 +24,7 @@ const int kFadeoutDurationInMs = 250;
|
| const int kFadeoutFrameRate = 60;
|
|
|
| // TouchPointView draws a single touch point. This object manages its own
|
| -// lifetime and deletes itself upon fade-out completion or whenever |Remove()|
|
| +// lifetime and deletes itself upon fade-out completion or whenever |Destroy()|
|
| // is explicitly called.
|
| class TouchPointView : public views::View,
|
| public gfx::AnimationDelegate,
|
| @@ -52,9 +52,11 @@ class TouchPointView : public views::View,
|
| parent_widget->AddObserver(this);
|
| }
|
|
|
| - void UpdateTouch(const ui::TouchEvent& touch) {
|
| + void UpdateTouch(const ui::LocatedEvent& touch) {
|
| if (touch.type() == ui::ET_TOUCH_RELEASED ||
|
| - touch.type() == ui::ET_TOUCH_CANCELLED) {
|
| + touch.type() == ui::ET_TOUCH_CANCELLED ||
|
| + touch.type() == ui::ET_POINTER_UP ||
|
| + touch.type() == ui::ET_POINTER_CANCELLED) {
|
| fadeout_.reset(new gfx::LinearAnimation(kFadeoutDurationInMs,
|
| kFadeoutFrameRate, this));
|
| fadeout_->Start();
|
| @@ -65,7 +67,7 @@ class TouchPointView : public views::View,
|
| }
|
| }
|
|
|
| - void Remove() { delete this; }
|
| + void Destroy() { delete this; }
|
|
|
| private:
|
| ~TouchPointView() override {
|
| @@ -110,7 +112,7 @@ class TouchPointView : public views::View,
|
| if (fadeout_)
|
| fadeout_->Stop();
|
| else
|
| - Remove();
|
| + Destroy();
|
| }
|
|
|
| const gfx::Point circle_center_;
|
| @@ -126,50 +128,48 @@ class TouchPointView : public views::View,
|
| DISALLOW_COPY_AND_ASSIGN(TouchPointView);
|
| };
|
|
|
| -TouchHudProjection::TouchHudProjection(aura::Window* initial_root)
|
| - : TouchObserverHUD(initial_root) {}
|
| +TouchHudRenderer::TouchHudRenderer() {}
|
|
|
| -TouchHudProjection::~TouchHudProjection() {}
|
| +TouchHudRenderer::~TouchHudRenderer() {}
|
|
|
| -void TouchHudProjection::Clear() {
|
| +void TouchHudRenderer::Clear() {
|
| for (std::map<int, TouchPointView*>::iterator iter = points_.begin();
|
| iter != points_.end(); iter++)
|
| - iter->second->Remove();
|
| + iter->second->Destroy();
|
| points_.clear();
|
| }
|
|
|
| -void TouchHudProjection::OnTouchEvent(ui::TouchEvent* event) {
|
| - if (event->type() == ui::ET_TOUCH_PRESSED) {
|
| - TouchPointView* point = new TouchPointView(widget());
|
| +void TouchHudRenderer::HandleTouchEvent(const ui::LocatedEvent* event,
|
| + views::Widget* parent_widget) {
|
| + int id = 0;
|
| + if (event->IsTouchEvent()) {
|
| + id = event->AsTouchEvent()->touch_id();
|
| + } else if (event->IsPointerEvent()) {
|
| + id = event->AsPointerEvent()->pointer_id();
|
| + }
|
| + if (event->type() == ui::ET_TOUCH_PRESSED ||
|
| + event->type() == ui::ET_POINTER_DOWN) {
|
| + TouchPointView* point = new TouchPointView(parent_widget);
|
| point->UpdateTouch(*event);
|
| std::pair<std::map<int, TouchPointView*>::iterator, bool> result =
|
| - points_.insert(std::make_pair(event->touch_id(), point));
|
| - // If a |TouchPointView| is already mapped to the touch id, remove it and
|
| + points_.insert(std::make_pair(id, point));
|
| + // If a |TouchPointView| is already mapped to the touch id, destroy it and
|
| // replace it with the new one.
|
| if (!result.second) {
|
| - result.first->second->Remove();
|
| + result.first->second->Destroy();
|
| result.first->second = point;
|
| }
|
| } else {
|
| - std::map<int, TouchPointView*>::iterator iter =
|
| - points_.find(event->touch_id());
|
| + std::map<int, TouchPointView*>::iterator iter = points_.find(id);
|
| if (iter != points_.end()) {
|
| iter->second->UpdateTouch(*event);
|
| if (event->type() == ui::ET_TOUCH_RELEASED ||
|
| - event->type() == ui::ET_TOUCH_CANCELLED)
|
| + event->type() == ui::ET_TOUCH_CANCELLED ||
|
| + event->type() == ui::ET_POINTER_UP ||
|
| + event->type() == ui::ET_POINTER_CANCELLED)
|
| points_.erase(iter);
|
| }
|
| }
|
| }
|
|
|
| -void TouchHudProjection::SetHudForRootWindowController(
|
| - RootWindowController* controller) {
|
| - controller->set_touch_hud_projection(this);
|
| -}
|
| -
|
| -void TouchHudProjection::UnsetHudForRootWindowController(
|
| - RootWindowController* controller) {
|
| - controller->set_touch_hud_projection(NULL);
|
| -}
|
| -
|
| } // namespace ash
|
|
|