2008-07-29 Alejandro G. Castro <alex@igalia.com>
+ Modified the procedure to get the widget at a point inside the
+ pannable area when using the movement type signals. Now the user
+ has to call a function to get the child, that way we just
+ calculate the child in case the user really want to use it and not
+ all the time.
+
+ * src/hildon-marshalers.list: Modified the marshallers, now we do
+ not have the widget as a parameter.
+
+ * src/hildon-pannable-area.c
+ (hildon_pannable_area_motion_notify_cb),
+ (hildon_pannable_area_class_init),
+ (hildon_pannable_get_child_widget_at): Removed the widget
+ parameter from the signal callback. We have also refactored the
+ emission of the signals.
+
+ * src/hildon-pannable-area.h: Added a new method to the API to
+ calculate a widget at a point inside the pannable area,
+ hildon_pannable_get_child_widget_at.
+
+ * examples/hildon-pannable-area-example-4.c
+ (horizontal_movement): Modified the example to use the new API,
+ added condition to control which widget is under the event. This
+ way we can avoid scrolling laterally over other widgets.
+
+2008-07-29 Alejandro G. Castro <alex@igalia.com>
+
* src/hildon-pannable-area.c
(hildon_pannable_area_motion_notify_cb): Fixed bug handling the
modes, we stop getting the pointer events due to returning the
static void
horizontal_movement (HildonPannableArea *area,
HildonPannableAreaMovDirection direction,
- GtkWidget *widget, gdouble x, gdouble y,
- gpointer user_data)
+ gdouble x, gdouble y, gpointer user_data)
{
GtkTreePath *path;
GdkRectangle rect;
gint col_x;
GtkTreeViewColumn *col = GTK_TREE_VIEW_COLUMN (user_data);
+ GtkWidget *child = hildon_pannable_get_child_widget_at (area, x, y);
- g_print ("widget %p treeview %p\n", widget, ctx->treeview);
+ g_print ("widget %p treeview %p\n", child, ctx->treeview);
- if (direction == HILDON_PANNABLE_AREA_MOV_LEFT) {
+ if (child == ctx->treeview) {
+ if (direction == HILDON_PANNABLE_AREA_MOV_LEFT){
- path = gtk_tree_path_new_first ();
+ path = gtk_tree_path_new_first ();
- gtk_tree_view_get_background_area (GTK_TREE_VIEW (ctx->treeview),
- path, col, &rect);
+ gtk_tree_view_get_background_area (GTK_TREE_VIEW (ctx->treeview),
+ path, col, &rect);
- gtk_tree_view_convert_bin_window_to_tree_coords (GTK_TREE_VIEW (ctx->treeview),
- rect.x, 0, &col_x, NULL);
+ gtk_tree_view_convert_bin_window_to_tree_coords (GTK_TREE_VIEW (ctx->treeview),
+ rect.x, 0, &col_x, NULL);
- gtk_tree_path_free (path);
+ gtk_tree_path_free (path);
- hildon_pannable_area_scroll_to (area, col_x, -1);
- }
- else {
- hildon_pannable_area_scroll_to (area, 0, -1);
+ hildon_pannable_area_scroll_to (area, col_x, -1);
+ }
+ else {
+ hildon_pannable_area_scroll_to (area, 0, -1);
+ }
}
g_print ("horizontal_movement %lf, %lf\n", x, y);
priv->moved = TRUE;
if (priv->first_drag) {
- GdkWindow *window = NULL;
- GtkWidget *child_widget = NULL;
-
- window = hildon_pannable_area_get_topmost
- (gtk_bin_get_child (GTK_BIN (widget))->window,
- priv->click_x, priv->click_y, NULL, NULL);
-
- gdk_window_get_user_data (window, (void**) &child_widget);
if (ABS (priv->click_y - event->y) >=
ABS (priv->click_x - event->x)) {
gboolean vscroll;
- if (priv->click_y > event->y)
- g_signal_emit (area,
- pannable_area_signals[VERTICAL_MOVEMENT],
- 0, HILDON_PANNABLE_AREA_MOV_UP, child_widget,
- priv->click_x, priv->click_y);
- else
- g_signal_emit (area,
- pannable_area_signals[VERTICAL_MOVEMENT],
- 0, HILDON_PANNABLE_AREA_MOV_DOWN, child_widget,
- priv->click_x, priv->click_y);
+ g_signal_emit (area,
+ pannable_area_signals[VERTICAL_MOVEMENT],
+ 0, (priv->click_y > event->y) ?
+ HILDON_PANNABLE_AREA_MOV_UP :
+ HILDON_PANNABLE_AREA_MOV_DOWN,
+ priv->click_x, priv->click_y);
vscroll = (priv->vadjust->upper - priv->vadjust->lower >
priv->vadjust->page_size) ? TRUE : FALSE;
} else {
gboolean hscroll;
- if (priv->click_x > event->x)
- g_signal_emit (area,
- pannable_area_signals[HORIZONTAL_MOVEMENT],
- 0, HILDON_PANNABLE_AREA_MOV_LEFT, child_widget,
- priv->click_x, priv->click_y);
- else
- g_signal_emit (area,
- pannable_area_signals[HORIZONTAL_MOVEMENT],
- 0, HILDON_PANNABLE_AREA_MOV_RIGHT, child_widget,
- priv->click_x, priv->click_y);
+ g_signal_emit (area,
+ pannable_area_signals[HORIZONTAL_MOVEMENT],
+ 0, (priv->click_x > event->x) ?
+ HILDON_PANNABLE_AREA_MOV_LEFT :
+ HILDON_PANNABLE_AREA_MOV_RIGHT,
+ priv->click_x, priv->click_y);
hscroll = (priv->hadjust->upper - priv->hadjust->lower >
priv->hadjust->page_size) ? TRUE : FALSE;
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (HildonPannableAreaClass, horizontal_movement),
NULL, NULL,
- _hildon_marshal_VOID__INT_OBJECT_DOUBLE_DOUBLE,
- G_TYPE_NONE, 4,
+ _hildon_marshal_VOID__INT_DOUBLE_DOUBLE,
+ G_TYPE_NONE, 3,
G_TYPE_INT,
- GTK_TYPE_WIDGET,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE);
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (HildonPannableAreaClass, vertical_movement),
NULL, NULL,
- _hildon_marshal_VOID__INT_OBJECT_DOUBLE_DOUBLE,
- G_TYPE_NONE, 4,
+ _hildon_marshal_VOID__INT_DOUBLE_DOUBLE,
+ G_TYPE_NONE, 3,
G_TYPE_INT,
- GTK_TYPE_WIDGET,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE);
if (gtk_widget_translate_coordinates (child, bin_child, 0, 0, &x, &y))
hildon_pannable_area_jump_to (area, x, y);
}
+
+/**
+ * hildon_pannable_get_child_widget_at:
+ * @area: A #HildonPannableArea.
+ * @x: horizontal coordinate of the point
+ * @y: vertical coordinate of the point
+ *
+ * Get the widget at the point (x, y) inside the pannable area. In
+ * case no widget found it returns NULL.
+ *
+ * returns: the #GtkWidget if we find a widget, NULL in any other case
+ **/
+GtkWidget*
+hildon_pannable_get_child_widget_at (HildonPannableArea *area,
+ gdouble x, gdouble y)
+{
+ GdkWindow *window = NULL;
+ GtkWidget *child_widget = NULL;
+
+ window = hildon_pannable_area_get_topmost
+ (gtk_bin_get_child (GTK_BIN (area))->window,
+ x, y, NULL, NULL);
+
+ gdk_window_get_user_data (window, (void**) &child_widget);
+
+ return child_widget;
+}