Commit 0a938cca authored by Timm Bäder's avatar Timm Bäder 👎

widget: Use translate_coordinates in pick()

In case converting the coordinate into the child coordinate space
consists of more than just a translation.
parent 07e48d39
......@@ -816,11 +816,12 @@ gtk_widget_real_pick (GtkWidget *widget,
child = _gtk_widget_get_prev_sibling (child))
{
GtkWidget *picked;
int dx, dy;
double dx, dy;
gtk_widget_get_origin_relative_to_parent (child, &dx, &dy);
gtk_widget_translate_coordinatesf (widget, child, x, y, &dx, &dy);
  • I think at this point it's worth to introduce a bunch of the "new" getter APIs that we intend to use once transforms have landed:

    • gboolean gtk_widget_compute_transform (GtkWidget *widget, GtkWidget *target, graphene_matrix_t *out_matrix)
      This would basically mirror gtk_widget_compute_bounds() but compute the matrix to go from widget's coords to target's coords (or return FALSE if they're not related).

    • gboolean gtk_widget_compute_coordinates (GtkWidget *widget, GtkWidget *target, graphene_point_t *point, graphene_point_t *out_target_point)
      This one would use the same method to transform the input x/y into target's coord system or return FALSE if that is impossible (because the matrix does a 90deg rotation between the two).

    • const graphene_matrix_t *gtk_widget_get_transform (GtkWidget *widget)
      Not 100% sold on the name, in particular because it's in use already, but I think it's the right name. This would return the matrix from parent's coords to widget's coords and would essentially return widget->priv->transform.

    With those functions we could get rid of gtk_widget_translate_coordinates(), gtk_widget_get_origin_relative_to_parent() and a bunch of other functions and replace them with the relevant case of the above 3 functions before going any further here.

    This particular case I would have use gtk_widget_get_transform() and graphene_matrix_transform_point() directly as it's (meant to be) a fast path.

Please register or sign in to reply
picked = gtk_widget_pick (child, dx, dy);
picked = gtk_widget_pick (child, x - dx, y - dy);
if (picked)
return picked;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment