Chromium Code Reviews| Index: ppapi/cpp/input_event.h |
| =================================================================== |
| --- ppapi/cpp/input_event.h (revision 96394) |
| +++ ppapi/cpp/input_event.h (working copy) |
| @@ -10,6 +10,9 @@ |
| #include "ppapi/c/ppb_input_event.h" |
| #include "ppapi/cpp/resource.h" |
| +/// @file |
| +/// This file defines the API used to handle mouse and keyboard input events. |
| + |
| namespace pp { |
| class FloatPoint; |
| @@ -17,12 +20,16 @@ |
| class Point; |
| class Var; |
| -/// Represents an input event resource. Normally you will get passed this |
| -/// object through the HandleInputEvent on the Instance object. |
| +/// This class represents an input event resource. Normally you will get passed |
| +/// this object through the <code>HandleInputEvent</code> on the |
|
dmichael (off chromium)
2011/08/12 20:17:59
HandleInputEvent()?
Probably should either remove
jond
2011/08/12 20:50:59
Done.
|
| +/// <code>Instance</code> object. |
| /// |
| /// Typically you would check the type of the event and then create the |
| /// appropriate event-specific object to query the properties. |
| /// |
| +/// <strong>Example:</strong> |
| +/// @code |
|
dmichael (off chromium)
2011/08/12 20:17:59
This still looks super weird to me. Can we resolve
jond
2011/08/12 20:50:59
Sure. Josie is back on Monday.
On 2011/08/12 20:1
|
| +/// |
| /// bool MyInstance::HandleInputEvent(const pp::InputEvent& event) { |
| /// switch (event.GetType()) { |
| /// case PP_INPUTEVENT_TYPE_MOUSE_DOWN { |
| @@ -32,55 +39,89 @@ |
| /// default: |
| /// return false; |
| /// } |
| +/// |
| +/// @endcode |
| class InputEvent : public Resource { |
| public: |
| /// Default constructor that creates an is_null() InputEvent object. |
| InputEvent(); |
| - /// Constructs an input event from the given input event resource ID. The |
| - /// InputEvent object will be is_null() if the given resource is not a valid |
| - /// input event. |
| + /// This constructor constructs an input event from the provided input event |
|
dmichael (off chromium)
2011/08/12 20:17:59
What's wrong with 'given'? I don't care particular
jond
2011/08/12 20:50:59
I believe the word "given" is improperly used in t
dmichael (off chromium)
2011/08/12 21:32:37
Yeah, makes sense. There is a sense of the word Gi
|
| + /// resource ID. The InputEvent object will be is_null() if the given |
| + /// resource is not a valid input event. |
| + /// |
| + /// @param[in] input_event_resource A input event resource ID. |
| explicit InputEvent(PP_Resource input_event_resource); |
| ~InputEvent(); |
| - /// Returns the type of input event for the given input event resource. |
| - /// This is valid for all input events. Returns PP_INPUTEVENT_TYPE_UNDEFINED |
| - /// if the resource is invalid. |
| + /// GetType() returns the type of input event for this input event |
| + /// object. This function is valid for all input events. |
|
dmichael (off chromium)
2011/08/12 20:17:59
You can delete the last sentence; it's a holdover
jond
2011/08/12 20:50:59
Done.
|
| + /// |
| + /// @return A <code>PP_InputEvent_Type</code> if successful, |
| + /// PP_INPUTEVENT_TYPE_UNDEFINED if the resource is invalid. |
| PP_InputEvent_Type GetType() const; |
| - /// Returns the time that the event was generated. This will be before the |
| - /// current time since processing and dispatching the event has some overhead. |
| - /// Use this value to compare the times the user generated two events without |
| - /// being sensitive to variable processing time. |
| + /// GetTimeStamp() returns the time that the event was generated. The time |
| + /// will be before the current time since processing and dispatching the |
| + /// event has some overhead. Use this value to compare the times the user |
| + /// generated two events without being sensitive to variable processing time. |
| /// |
| /// The return value is in time ticks, which is a monotonically increasing |
| /// clock not related to the wall clock time. It will not change if the user |
| /// changes their clock or daylight savings time starts, so can be reliably |
| /// used to compare events. This means, however, that you can't correlate |
| /// event times to a particular time of day on the system clock. |
| + /// |
| + /// @return A <code>PP_TimeTicks</code> containing the time the event was |
| + /// generated. |
| PP_TimeTicks GetTimeStamp() const; |
| - /// Returns a bitfield indicating which modifiers were down at the time of |
| - /// the event. This is a combination of the flags in the |
| - /// PP_InputEvent_Modifier enum. |
| + /// GetModifiers() returns a bitfield indicating which modifiers were down |
| + /// at the time of the event. This is a combination of the flags in the |
| + /// <code>PP_InputEvent_Modifier</code> enum. |
| /// |
| /// @return The modifiers associated with the event, or 0 if the given |
| /// resource is not a valid event resource. |
| uint32_t GetModifiers() const; |
| }; |
| +/// This class handles mouse events. |
| class MouseInputEvent : public InputEvent { |
| public: |
| /// Constructs an is_null() mouse input event object. |
| MouseInputEvent(); |
| - /// Constructs a mouse input event object from the given generic input |
| - /// event. If the given event is itself is_null() or is not a mouse input |
| - /// event, the mouse object will be is_null(). |
| + /// This constructor constructs a mouse input event object from the provided |
| + /// generic input event. If the given event is itself is_null() or is not |
| + /// a mouse input event, the mouse object will be is_null(). |
| + /// |
| + /// @param event An <code>InputEvent</code>. |
| explicit MouseInputEvent(const InputEvent& event); |
| - /// Manually constructs a mouse event from the given parameters. |
| + /// This constructor manually constructs a mouse event from the provided |
| + /// parameters. |
| + /// |
| + /// @param[in] instance |
| + /// |
| + /// @param[in] type A <code>PP_InputEvent_Type</code> identifying the type of |
| + /// input event. |
| + /// |
| + /// @param[in] time_stamp |
| + /// |
| + /// @param modifiers A bit field combination of the |
| + /// <code>PP_InputEvent_Modifier</code> flags. |
| + /// |
| + /// @param mouse_button The button that changed for mouse down or up events. |
| + /// This value will be <code>PP_EVENT_MOUSEBUTTON_NONE</code> for mouse move, |
| + /// enter, and leave events. |
| + /// |
| + /// @param[in] mouse_position A <code>Point</code> containing the x and y |
| + /// position of the mouse when the eent occurred. |
| + /// |
| + /// @param[in] click_count |
| + /// TODO(brettw) figure out exactly what this means. |
| + /// |
| MouseInputEvent(Instance* instance, |
| PP_InputEvent_Type type, |
| PP_TimeTicks time_stamp, |
| @@ -89,15 +130,15 @@ |
| const Point& mouse_position, |
| int32_t click_count); |
| - /// Returns the mouse position for a mouse input event. |
| + /// GetButton() returns the mouse position for a mouse input event. |
| /// |
| /// @return The mouse button associated with mouse down and up events. This |
| /// value will be PP_EVENT_MOUSEBUTTON_NONE for mouse move, enter, and leave |
| /// events, and for all non-mouse events. |
| PP_InputEvent_MouseButton GetButton() const; |
| - /// Returns the pixel location of a mouse input event. This value is in |
| - /// floating-point units to support high-resolution input events. |
| + /// GetPostion() returns the pixel location of a mouse input event. This |
| + /// value is in floating-point units to support high-resolution input events. |
| /// |
| /// @return The point associated with the mouse event, relative to the upper- |
| /// left of the instance receiving the event. These values can be negative for |
| @@ -113,9 +154,10 @@ |
| /// Constructs an is_null() wheel input event object. |
| WheelInputEvent(); |
| - /// Constructs a wheel input event object from the given generic input |
| - /// event. If the given event is itself is_null() or is not a wheel input |
| - /// event, the wheel object will be is_null(). |
| + /// This constructor constructs a wheel input event object from the |
| + /// provided generic input event. If the given event is itself |
| + /// is_null() or is not a wheel input event, the wheel object will be |
| + /// is_null(). |
|
dmichael (off chromium)
2011/08/12 20:17:59
missing param? I think it's okay either way, but y
jond
2011/08/12 20:50:59
Done.
|
| explicit WheelInputEvent(const InputEvent& event); |
| /// Constructs a wheel input even from the given parameters. |
|
dmichael (off chromium)
2011/08/12 20:17:59
you added params for the analogous Mouse construct
jond
2011/08/12 20:50:59
Done.
jond
2011/08/12 20:50:59
Done.
|
| @@ -126,17 +168,12 @@ |
| const FloatPoint& wheel_ticks, |
| bool scroll_by_page); |
| - /// Indicates the amount vertically and horizontally the user has requested |
| - /// to scroll by with their mouse wheel. A scroll down or to the right (where |
| - /// the content moves up or left) is represented as positive values, and |
| - /// a scroll up or to the left (where the content moves down or right) is |
| - /// represented as negative values. |
| + /// GetDelta() returns the amount vertically and horizontally the user has |
| + /// requested to scroll by with their mouse wheel. A scroll down or to the |
| + /// right (where the content moves up or left) is represented as positive |
| + /// values, and a scroll up or to the left (where the content moves down or |
| + /// right) is represented as negative values. |
| /// |
| - /// The units are either in pixels (when scroll_by_page is false) or pages |
| - /// (when scroll_by_page is true). For example, y = -3 means scroll up 3 |
| - /// pixels when scroll_by_page is false, and scroll up 3 pages when |
| - /// scroll_by_page is true. |
| - /// |
| /// This amount is system dependent and will take into account the user's |
| /// preferred scroll sensitivity and potentially also nonlinear acceleration |
| /// based on the speed of the scrolling. |
| @@ -145,21 +182,27 @@ |
| /// only generate integer scroll amounts. But fractional values are also |
| /// possible, for example, on some trackpads and newer mice that don't have |
| /// "clicks". |
| + /// |
| + /// @return The vertial and horizontal scroll values. The units are either in |
| + /// pixels (when scroll_by_page is false) or pages (when scroll_by_page is |
| + /// true). For example, y = -3 means scroll up 3 pixels when scroll_by_page |
| + /// is false, and scroll up 3 pages when scroll_by_page is true. |
| FloatPoint GetDelta() const; |
| - /// The number of "clicks" of the scroll wheel that have produced the |
| - /// event. The value may have system-specific acceleration applied to it, |
| - /// depending on the device. The positive and negative meanings are the same |
| - /// as for GetDelta(). |
| + /// GetScrollByPage() returns the number of "clicks" of the scroll wheel |
|
dmichael (off chromium)
2011/08/12 20:17:59
GetScrollByPage->GetTicks
|
| + /// that have produced the event. The value may have system-specific |
| + /// acceleration applied to it, depending on the device. The positive and |
| + /// negative meanings are the same as for GetDelta(). |
| /// |
| /// If you are scrolling, you probably want to use the delta values. These |
| /// tick events can be useful if you aren't doing actual scrolling and don't |
| /// want or pixel values. An example may be cycling between different items in |
| /// a game. |
| /// |
| - /// You may receive fractional values for the wheel ticks if the mouse wheel |
| - /// is high resolution or doesn't have "clicks". If your program wants |
| - /// discrete events (as in the "picking items" example) you should accumulate |
| + /// @return The number of "clicks" of the scroll wheel. You may receive |
| + /// fractional values for the wheel ticks if the mouse wheel is high |
| + /// resolution or doesn't have "clicks". If your program wants discrete |
| + /// events (as in the "picking items" example) you should accumulate |
| /// fractional click values from multiple messages until the total value |
| /// reaches positive or negative one. This should represent a similar amount |
| /// of scrolling as for a mouse that has a discrete mouse wheel. |
| @@ -168,8 +211,8 @@ |
| // Indicates if the scroll delta x/y indicates pages or lines to |
| // scroll by. |
| // |
| - // @return PP_TRUE if the event is a wheel event and the user is scrolling |
| - // by pages. PP_FALSE if not or if the resource is not a wheel event. |
| + // @return True if the event is a wheel event and the user is scrolling |
| + // by pages, false if not or if the resource is not a wheel event. |
| bool GetScrollByPage() const; |
| }; |
| @@ -178,9 +221,11 @@ |
| /// Constructs an is_null() keyboard input event object. |
| KeyboardInputEvent(); |
| - /// Constructs a keyboard input event object from the given generic input |
| + /// Constructs a keyboard input event object from the provided generic input |
| /// event. If the given event is itself is_null() or is not a keyboard input |
| /// event, the keybaord object will be is_null(). |
| + /// |
| + /// @param[in] event A generic input event. |
| explicit KeyboardInputEvent(const InputEvent& event); |
| /// Constructs a keyboard input even from the given parameters. |
|
dmichael (off chromium)
2011/08/12 20:17:59
Ditto about params fields; we should probably be c
jond
2011/08/12 20:50:59
Done.
|