}
/**
+ * gst_navigation_send_mouse_scroll_event:
+ * @navigation: The navigation interface instance
+ * @x: The x coordinate of the mouse event.
+ * @y: The y coordinate of the mouse event.
+ * @delta_x: The delta_x coordinate of the mouse event.
+ * @delta_y: The delta_y coordinate of the mouse event.
+ *
+ * Sends a mouse scroll event to the navigation interface. Mouse event coordinates
+ * are sent relative to the display space of the related output area. This is
+ * usually the size in pixels of the window associated with the element
+ * implementing the #GstNavigation interface.
+ *
+ * Since: 1.18
+ */
+void
+gst_navigation_send_mouse_scroll_event (GstNavigation * navigation,
+ double x, double y, double delta_x, double delta_y)
+{
+ gst_navigation_send_event (navigation,
+ gst_structure_new (GST_NAVIGATION_EVENT_NAME,
+ "event", G_TYPE_STRING, "mouse-scroll",
+ "pointer_x", G_TYPE_DOUBLE, x,
+ "pointer_y", G_TYPE_DOUBLE, y,
+ "delta_pointer_x", G_TYPE_DOUBLE, delta_x,
+ "delta_pointer_y", G_TYPE_DOUBLE, delta_y, NULL));
+}
+
+/**
* gst_navigation_send_command:
* @navigation: The navigation interface instance
* @command: The command to issue
return GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE;
else if (g_str_equal (e_type, "mouse-move"))
return GST_NAVIGATION_EVENT_MOUSE_MOVE;
+ else if (g_str_equal (e_type, "mouse-scroll"))
+ return GST_NAVIGATION_EVENT_MOUSE_SCROLL;
else if (g_str_equal (e_type, "key-press"))
return GST_NAVIGATION_EVENT_KEY_PRESS;
else if (g_str_equal (e_type, "key-release"))
}
/**
+ * gst_navigation_event_parse_mouse_scroll_event:
+ * @event: A #GstEvent to inspect.
+ * @x: (out) (optional): Pointer to a gdouble to receive the x coordinate of the
+ * mouse movement.
+ * @y: (out) (optional): Pointer to a gdouble to receive the y coordinate of the
+ * mouse movement.
+ * @delta_x: (out) (optional): Pointer to a gdouble to receive the delta_x coordinate of the
+ * mouse movement.
+ * @delta_y: (out) (optional): Pointer to a gdouble to receive the delta_y coordinate of the
+ * mouse movement.
+ *
+ * Inspect a #GstNavigation mouse scroll event and extract the coordinates
+ * of the event.
+ *
+ * Returns: TRUE if all coordinates could be extracted, otherwise FALSE.
+ *
+ * Since: 1.18
+ */
+gboolean
+gst_navigation_event_parse_mouse_scroll_event (GstEvent * event,
+ gdouble * x, gdouble * y, gdouble * delta_x, gdouble * delta_y)
+{
+ const GstStructure *s;
+ gboolean ret = TRUE;
+
+ g_return_val_if_fail (GST_NAVIGATION_EVENT_HAS_TYPE (event, MOUSE_SCROLL),
+ FALSE);
+
+ s = gst_event_get_structure (event);
+ if (x)
+ ret &= gst_structure_get_double (s, "pointer_x", x);
+ if (y)
+ ret &= gst_structure_get_double (s, "pointer_y", y);
+ if (delta_x)
+ ret &= gst_structure_get_double (s, "delta_pointer_x", delta_x);
+ if (delta_y)
+ ret &= gst_structure_get_double (s, "delta_pointer_y", delta_y);
+
+ WARN_IF_FAIL (ret, "Couldn't extract positions from mouse scroll event");
+
+ return ret;
+}
+
+/**
* gst_navigation_event_parse_command:
* @event: A #GstEvent to inspect.
* @command: (out) (optional): Pointer to GstNavigationCommand to receive the
* @GST_NAVIGATION_QUERY_COMMANDS: command query
* @GST_NAVIGATION_QUERY_ANGLES: viewing angle query
*
- * Tyoes of navigation interface queries.
+ * Types of navigation interface queries.
*/
typedef enum
{
* event.
* @GST_NAVIGATION_EVENT_COMMAND: A navigation command event. Use
* gst_navigation_event_parse_command() to extract the details from the event.
+ * @GST_NAVIGATION_EVENT_MOUSE_SCROLL: A mouse scroll event. Use
+ * gst_navigation_event_parse_mouse_scroll_event() to extract the details from
+ * the event.
*
* Enum values for the various events that an element implementing the
* GstNavigation interface might send up the pipeline.
GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS = 3,
GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE = 4,
GST_NAVIGATION_EVENT_MOUSE_MOVE = 5,
- GST_NAVIGATION_EVENT_COMMAND = 6
+ GST_NAVIGATION_EVENT_COMMAND = 6,
+ GST_NAVIGATION_EVENT_MOUSE_SCROLL = 7
} GstNavigationEventType;
GST_VIDEO_API
gdouble *x, gdouble *y);
GST_VIDEO_API
+gboolean gst_navigation_event_parse_mouse_scroll_event (GstEvent *event,
+ gdouble *x, gdouble *y,
+ gdouble *delta_x, gdouble *delta_y);
+
+GST_VIDEO_API
gboolean gst_navigation_event_parse_command (GstEvent *event,
GstNavigationCommand *command);
const char *event, int button, double x, double y);
GST_VIDEO_API
+void gst_navigation_send_mouse_scroll_event (GstNavigation *navigation,
+ double x, double y, double delta_x, double delta_y);
+
+GST_VIDEO_API
void gst_navigation_send_command (GstNavigation *navigation,
GstNavigationCommand command);
GstNavigationEventType sent_type;
const gchar *sent_key;
gdouble sent_x, sent_y;
+ gdouble sent_delta_x, sent_delta_y;
gint sent_button;
GstNavigationCommand sent_command;
};
fail_unless (y == self->sent_y);
break;
}
+ case GST_NAVIGATION_EVENT_MOUSE_SCROLL:{
+ gdouble x, y, delta_x, delta_y;
+ fail_unless (gst_navigation_event_parse_mouse_scroll_event (event, &x, &y,
+ &delta_x, &delta_y));
+ fail_unless (x == self->sent_x);
+ fail_unless (y == self->sent_y);
+ fail_unless (delta_x == self->sent_delta_x);
+ fail_unless (delta_y == self->sent_delta_y);
+ break;
+ }
case GST_NAVIGATION_EVENT_COMMAND:{
GstNavigationCommand cmd;
fail_unless (gst_navigation_event_parse_command (event, &cmd));
gst_navigation_send_mouse_event (GST_NAVIGATION (test_element), "mouse-move",
0, 50, 100);
+ test_element->sent_type = GST_NAVIGATION_EVENT_MOUSE_SCROLL;
+ test_element->sent_x = 60;
+ test_element->sent_y = 120;
+ test_element->sent_delta_x = 2;
+ test_element->sent_delta_y = 3;
+ gst_navigation_send_mouse_scroll_event (GST_NAVIGATION (test_element),
+ 60, 120, 2, 3);
+
test_element->sent_type = GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS;
test_element->sent_x = 10;
test_element->sent_y = 20;