OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/touch_observer_hud.h" | 5 #include "ash/touch/touch_observer_hud.h" |
6 | 6 |
7 #include "ash/shell_window_ids.h" | 7 #include "ash/shell_window_ids.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "third_party/skia/include/core/SkPath.h" | 10 #include "third_party/skia/include/core/SkPath.h" |
11 #include "third_party/skia/include/core/SkXfermode.h" | 11 #include "third_party/skia/include/core/SkXfermode.h" |
12 #include "ui/aura/event.h" | 12 #include "ui/base/event.h" |
13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
14 #include "ui/gfx/display.h" | 14 #include "ui/gfx/display.h" |
15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
16 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
18 #include "ui/views/background.h" | 18 #include "ui/views/background.h" |
19 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
20 #include "ui/views/layout/box_layout.h" | 20 #include "ui/views/layout/box_layout.h" |
21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
22 | 22 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 default: | 176 default: |
177 status = "?"; | 177 status = "?"; |
178 break; | 178 break; |
179 } | 179 } |
180 std::string string = base::StringPrintf("%2d: %s %s", | 180 std::string string = base::StringPrintf("%2d: %s %s", |
181 index, status, touch_positions_[index].ToString().c_str()); | 181 index, status, touch_positions_[index].ToString().c_str()); |
182 touch_labels_[index]->SetText(UTF8ToUTF16(string)); | 182 touch_labels_[index]->SetText(UTF8ToUTF16(string)); |
183 } | 183 } |
184 | 184 |
185 bool TouchObserverHUD::PreHandleKeyEvent(aura::Window* target, | 185 bool TouchObserverHUD::PreHandleKeyEvent(aura::Window* target, |
186 aura::KeyEvent* event) { | 186 ui::KeyEvent* event) { |
187 return false; | 187 return false; |
188 } | 188 } |
189 | 189 |
190 bool TouchObserverHUD::PreHandleMouseEvent(aura::Window* target, | 190 bool TouchObserverHUD::PreHandleMouseEvent(aura::Window* target, |
191 aura::MouseEvent* event) { | 191 ui::MouseEvent* event) { |
192 return false; | 192 return false; |
193 } | 193 } |
194 | 194 |
195 ui::TouchStatus TouchObserverHUD::PreHandleTouchEvent( | 195 ui::TouchStatus TouchObserverHUD::PreHandleTouchEvent( |
196 aura::Window* target, | 196 aura::Window* target, |
197 aura::TouchEvent* event) { | 197 ui::TouchEventImpl* event) { |
198 if (event->touch_id() >= kMaxTouchPoints) | 198 if (event->touch_id() >= kMaxTouchPoints) |
199 return ui::TOUCH_STATUS_UNKNOWN; | 199 return ui::TOUCH_STATUS_UNKNOWN; |
200 | 200 |
201 if (event->type() != ui::ET_TOUCH_CANCELLED) | 201 if (event->type() != ui::ET_TOUCH_CANCELLED) |
202 touch_positions_[event->touch_id()] = event->root_location(); | 202 touch_positions_[event->touch_id()] = event->root_location(); |
203 if (event->type() == ui::ET_TOUCH_PRESSED) | 203 if (event->type() == ui::ET_TOUCH_PRESSED) |
204 canvas_->Start(event->touch_id(), touch_positions_[event->touch_id()]); | 204 canvas_->Start(event->touch_id(), touch_positions_[event->touch_id()]); |
205 else | 205 else |
206 canvas_->Update(event->touch_id(), touch_positions_[event->touch_id()]); | 206 canvas_->Update(event->touch_id(), touch_positions_[event->touch_id()]); |
207 touch_status_[event->touch_id()] = event->type(); | 207 touch_status_[event->touch_id()] = event->type(); |
208 touch_labels_[event->touch_id()]->SetVisible(true); | 208 touch_labels_[event->touch_id()]->SetVisible(true); |
209 UpdateTouchPointLabel(event->touch_id()); | 209 UpdateTouchPointLabel(event->touch_id()); |
210 | 210 |
211 widget_->SetSize(widget_->GetContentsView()->GetPreferredSize()); | 211 widget_->SetSize(widget_->GetContentsView()->GetPreferredSize()); |
212 | 212 |
213 return ui::TOUCH_STATUS_UNKNOWN; | 213 return ui::TOUCH_STATUS_UNKNOWN; |
214 } | 214 } |
215 | 215 |
216 ui::GestureStatus TouchObserverHUD::PreHandleGestureEvent( | 216 ui::GestureStatus TouchObserverHUD::PreHandleGestureEvent( |
217 aura::Window* target, | 217 aura::Window* target, |
218 aura::GestureEvent* event) { | 218 ui::GestureEventImpl* event) { |
219 return ui::GESTURE_STATUS_UNKNOWN; | 219 return ui::GESTURE_STATUS_UNKNOWN; |
220 } | 220 } |
221 | 221 |
222 void TouchObserverHUD::OnWidgetClosing(views::Widget* widget) { | 222 void TouchObserverHUD::OnWidgetClosing(views::Widget* widget) { |
223 DCHECK_EQ(widget, widget_); | 223 DCHECK_EQ(widget, widget_); |
224 widget_ = NULL; | 224 widget_ = NULL; |
225 } | 225 } |
226 | 226 |
227 } // namespace internal | 227 } // namespace internal |
228 } // namespace ash | 228 } // namespace ash |
OLD | NEW |