OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/touch_hud/touch_hud_renderer.h" | 5 #include "ash/touch_hud/touch_hud_renderer.h" |
6 | 6 |
7 #include "third_party/skia/include/effects/SkGradientShader.h" | 7 #include "third_party/skia/include/effects/SkGradientShader.h" |
8 #include "ui/compositor/layer.h" | 8 #include "ui/compositor/layer.h" |
9 #include "ui/compositor/layer_owner.h" | 9 #include "ui/compositor/layer_owner.h" |
10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 void TouchHudRenderer::Clear() { | 138 void TouchHudRenderer::Clear() { |
139 for (std::map<int, TouchPointView*>::iterator iter = points_.begin(); | 139 for (std::map<int, TouchPointView*>::iterator iter = points_.begin(); |
140 iter != points_.end(); iter++) | 140 iter != points_.end(); iter++) |
141 iter->second->Destroy(); | 141 iter->second->Destroy(); |
142 points_.clear(); | 142 points_.clear(); |
143 } | 143 } |
144 | 144 |
145 void TouchHudRenderer::HandleTouchEvent(const ui::LocatedEvent& event) { | 145 void TouchHudRenderer::HandleTouchEvent(const ui::LocatedEvent& event) { |
146 int id = 0; | 146 int id = 0; |
147 if (event.IsTouchEvent()) { | 147 if (event.IsTouchEvent()) { |
148 id = event.AsTouchEvent()->touch_id(); | 148 id = event.AsTouchEvent()->pointer_details().id; |
149 } else { | 149 } else { |
150 DCHECK(event.IsPointerEvent()); | 150 DCHECK(event.IsPointerEvent()); |
151 DCHECK(event.AsPointerEvent()->pointer_details().pointer_type == | 151 DCHECK(event.AsPointerEvent()->pointer_details().pointer_type == |
152 ui::EventPointerType::POINTER_TYPE_TOUCH); | 152 ui::EventPointerType::POINTER_TYPE_TOUCH); |
153 id = event.AsPointerEvent()->pointer_id(); | 153 id = event.AsPointerEvent()->pointer_details().id; |
154 } | 154 } |
155 if (event.type() == ui::ET_TOUCH_PRESSED || | 155 if (event.type() == ui::ET_TOUCH_PRESSED || |
156 event.type() == ui::ET_POINTER_DOWN) { | 156 event.type() == ui::ET_POINTER_DOWN) { |
157 TouchPointView* point = new TouchPointView(parent_widget_); | 157 TouchPointView* point = new TouchPointView(parent_widget_); |
158 point->UpdateTouch(event); | 158 point->UpdateTouch(event); |
159 std::pair<std::map<int, TouchPointView*>::iterator, bool> result = | 159 std::pair<std::map<int, TouchPointView*>::iterator, bool> result = |
160 points_.insert(std::make_pair(id, point)); | 160 points_.insert(std::make_pair(id, point)); |
161 // If a |TouchPointView| is already mapped to the touch id, destroy it and | 161 // If a |TouchPointView| is already mapped to the touch id, destroy it and |
162 // replace it with the new one. | 162 // replace it with the new one. |
163 if (!result.second) { | 163 if (!result.second) { |
164 result.first->second->Destroy(); | 164 result.first->second->Destroy(); |
165 result.first->second = point; | 165 result.first->second = point; |
166 } | 166 } |
167 } else { | 167 } else { |
168 std::map<int, TouchPointView*>::iterator iter = points_.find(id); | 168 std::map<int, TouchPointView*>::iterator iter = points_.find(id); |
169 if (iter != points_.end()) { | 169 if (iter != points_.end()) { |
170 iter->second->UpdateTouch(event); | 170 iter->second->UpdateTouch(event); |
171 if (event.type() == ui::ET_TOUCH_RELEASED || | 171 if (event.type() == ui::ET_TOUCH_RELEASED || |
172 event.type() == ui::ET_TOUCH_CANCELLED || | 172 event.type() == ui::ET_TOUCH_CANCELLED || |
173 event.type() == ui::ET_POINTER_UP || | 173 event.type() == ui::ET_POINTER_UP || |
174 event.type() == ui::ET_POINTER_CANCELLED) | 174 event.type() == ui::ET_POINTER_CANCELLED) |
175 points_.erase(iter); | 175 points_.erase(iter); |
176 } | 176 } |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 } // namespace ash | 180 } // namespace ash |
OLD | NEW |