Index: ui/base/touch/multi_touch_device.h |
=================================================================== |
--- ui/base/touch/multi_touch_device.h (revision 0) |
+++ ui/base/touch/multi_touch_device.h (revision 0) |
@@ -0,0 +1,114 @@ |
+// Copyright (c) 2012 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. |
+ |
+#ifndef UI_BASE_TOUCH_MULTI_TOUCH_DEVICE_H_ |
+#define UI_BASE_TOUCH_MULTI_TOUCH_DEVICE_H_ |
+#pragma once |
+ |
+#include <map> |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+#include "ui/base/touch/axis.h" |
+ |
+namespace ui { |
+// Models a multi-touch capable device and its properties. |
+class MultiTouchDevice { |
+ public: |
+ typedef std::map<Axis::Type, Axis> Axes; |
+ |
+ // Models different touch device types. |
+ enum Type { |
+ // A device with 1:1 mapping to screen coords, e.g., a touchscreen. |
+ // In contrast, an indirect touch device would require a coordinate |
+ // transformation to map touch coordinates to screen coordinates. |
+ DIRECT_TOUCH_DEVICE_TYPE, |
+ // Marks an indirect device with cursor movement dependent on touches. |
+ // Example: A trackpad. |
+ DEPENDENT_TOUCH_DEVICE_TYPE, |
+ // Marks an indirect device with cursor movement independent of touches. |
+ // Example: A mouse with an additional touch area. |
+ INDEPENDENT_TOUCH_DEVICE_TYPE, |
+ // Marks a device that provides a bounding-box of some touches. |
+ // In contrast, a full-multitouch device provides accurate locations |
+ // of individual touches. |
+ SEMI_MULTI_TOUCH_DEVICE_TYPE, |
+ // Marks the initial and unknown type of a device. |
+ UNKNOWN_TOUCH_DEVICE_TYPE |
+ }; |
+ |
+ // Initializes the object to a default, undefined state. |
+ MultiTouchDevice(); |
+ |
+ ~MultiTouchDevice(); |
+ |
+ // Compiler generated copy-c'tor and assignment operator are fine. |
+ |
+ // Returns the unique id of the device. |
+ int id() const { return id_; } |
+ // Adjusts the id of the device to id. |
+ void set_id(int id) { id_ = id; } |
+ |
+ // Returns the human-readable name of the device. |
+ const std::string & name() const { return name_; } |
+ // Adjusts the human-readable name of the device. |
+ void set_name(const std::string& name) { name_ = name; } |
+ |
+ // Returns the type of the device. |
+ Type type() const { return type_; } |
+ // Adjusts the type of the device. |
+ void set_type(Type type) { type_ = type; } |
+ |
+ // Returns the maximum number of touches that this device can |
+ // report simultaneously. |
+ uint32_t max_num_touches() const { return max_num_touches_; } |
+ // Adjusts the maximum number of touches that this device can |
+ // report simultaneously. |
+ void set_max_num_touches(uint32_t num) { max_num_touches_ = num; } |
+ |
+ // Returns the number of axes that this device supports. |
+ // Here, an axis models a property/measurement that is associated |
+ // with individual touches. |
+ uint32_t num_axes() const { return axes_.size(); } |
+ |
+ // Returns the map of axis objects supported by this device. |
+ const Axes & axes() const { return axes_; } |
+ // Adjusts the map of axis. |
+ void set_axes(const Axes & axes) { axes_ = axes; } |
+ |
+ // Returns the resolution of the window coordinates |
+ // of the device in the X axis |
+ float window_resolution_x() const { return window_resolution_x_; } |
+ // Adjusts the resolution of the window coordintaes |
+ // of the device in the X axis. |
+ void set_window_resolution_x(float res) { window_resolution_x_ = res; } |
+ |
+ // Returns the resolution of the window coordinates |
+ // of the device in the Y axis |
+ float window_resolution_y() const { return window_resolution_y_; } |
+ // Returns the resolution of the window coordinates |
+ // of the device in the Y axis |
+ void set_window_resolution_y(float res) { window_resolution_y_ = res; } |
+ |
+ private: |
+ int id_; |
+ std::string name_; |
+ Type type_; |
+ uint32_t max_num_touches_; |
+ Axes axes_; |
+ float window_resolution_x_; |
+ float window_resolution_y_; |
+ |
+ // REMARK(tvoss): Consider handling of devices to rely on shared ptr's. |
+ // A device might be considered unique and non-copyable and non-assignable |
+ // in the future. However, at the present moment, it is perfectly fine to |
+ // model the device as copyable and assignable as it only wraps up various |
+ // device properties. |
+ // DISALLOW_COPY_AND_ASSIGN(MultiTouchDevice); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_BASE_TOUCH_MULTI_TOUCH_DEVICE_H_ |
+ |
Property changes on: ui/base/touch/multi_touch_device.h |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |