| 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" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 break; | 175 break; |
| 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 ui::EventResult TouchObserverHUD::OnTouchEvent(ui::TouchEvent* event) { | 185 void TouchObserverHUD::OnTouchEvent(ui::TouchEvent* event) { |
| 186 if (event->touch_id() >= kMaxTouchPoints) | 186 if (event->touch_id() >= kMaxTouchPoints) |
| 187 return ui::ER_UNHANDLED; | 187 return; |
| 188 | 188 |
| 189 if (event->type() != ui::ET_TOUCH_CANCELLED) | 189 if (event->type() != ui::ET_TOUCH_CANCELLED) |
| 190 touch_positions_[event->touch_id()] = event->root_location(); | 190 touch_positions_[event->touch_id()] = event->root_location(); |
| 191 if (event->type() == ui::ET_TOUCH_PRESSED) | 191 if (event->type() == ui::ET_TOUCH_PRESSED) |
| 192 canvas_->Start(event->touch_id(), touch_positions_[event->touch_id()]); | 192 canvas_->Start(event->touch_id(), touch_positions_[event->touch_id()]); |
| 193 else | 193 else |
| 194 canvas_->Update(event->touch_id(), touch_positions_[event->touch_id()]); | 194 canvas_->Update(event->touch_id(), touch_positions_[event->touch_id()]); |
| 195 touch_status_[event->touch_id()] = event->type(); | 195 touch_status_[event->touch_id()] = event->type(); |
| 196 touch_labels_[event->touch_id()]->SetVisible(true); | 196 touch_labels_[event->touch_id()]->SetVisible(true); |
| 197 UpdateTouchPointLabel(event->touch_id()); | 197 UpdateTouchPointLabel(event->touch_id()); |
| 198 | 198 |
| 199 widget_->SetSize(widget_->GetContentsView()->GetPreferredSize()); | 199 widget_->SetSize(widget_->GetContentsView()->GetPreferredSize()); |
| 200 | |
| 201 return ui::ER_UNHANDLED; | |
| 202 } | 200 } |
| 203 | 201 |
| 204 void TouchObserverHUD::OnWidgetClosing(views::Widget* widget) { | 202 void TouchObserverHUD::OnWidgetClosing(views::Widget* widget) { |
| 205 DCHECK_EQ(widget, widget_); | 203 DCHECK_EQ(widget, widget_); |
| 206 widget_ = NULL; | 204 widget_ = NULL; |
| 207 } | 205 } |
| 208 | 206 |
| 209 } // namespace internal | 207 } // namespace internal |
| 210 } // namespace ash | 208 } // namespace ash |
| OLD | NEW |