path: Add gsk_path_get_start/end_point
These are useful to have, now that we are relying more on GskPathPoint in our api.
This commit is contained in:
@@ -66,6 +66,10 @@ struct _GskContourClass
|
||||
float threshold,
|
||||
GskRealPathPoint *result,
|
||||
float *out_dist);
|
||||
gboolean (* get_start_point) (const GskContour *contour,
|
||||
GskRealPathPoint *result);
|
||||
gboolean (* get_end_point) (const GskContour *contour,
|
||||
GskRealPathPoint *result);
|
||||
void (* get_position) (const GskContour *contour,
|
||||
GskRealPathPoint *point,
|
||||
graphene_point_t *position);
|
||||
@@ -682,6 +686,28 @@ gsk_standard_contour_get_closest_point (const GskContour *contour,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_standard_contour_get_start_point (const GskContour *contour,
|
||||
GskRealPathPoint *result)
|
||||
{
|
||||
result->data.std.idx = 1;
|
||||
result->data.std.t = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_standard_contour_get_end_point (const GskContour *contour,
|
||||
GskRealPathPoint *result)
|
||||
{
|
||||
GskStandardContour *self = (GskStandardContour *) contour;
|
||||
|
||||
result->data.std.idx = self->n_ops - 1;
|
||||
result->data.std.t = 1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_standard_contour_get_point (const GskContour *contour,
|
||||
gpointer measure_data,
|
||||
@@ -847,6 +873,8 @@ static const GskContourClass GSK_STANDARD_CONTOUR_CLASS =
|
||||
gsk_standard_contour_reverse,
|
||||
gsk_standard_contour_get_winding,
|
||||
gsk_standard_contour_get_closest_point,
|
||||
gsk_standard_contour_get_start_point,
|
||||
gsk_standard_contour_get_end_point,
|
||||
gsk_standard_contour_get_position,
|
||||
gsk_standard_contour_get_tangent,
|
||||
gsk_standard_contour_get_curvature,
|
||||
@@ -1035,6 +1063,20 @@ gsk_contour_get_closest_point (const GskContour *self,
|
||||
return self->klass->get_closest_point (self, point, threshold, result, out_dist);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_contour_get_start_point (const GskContour *self,
|
||||
GskRealPathPoint *result)
|
||||
{
|
||||
self->klass->get_start_point (self, result);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_contour_get_end_point (const GskContour *self,
|
||||
GskRealPathPoint *result)
|
||||
{
|
||||
self->klass->get_end_point (self, result);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_contour_get_point (const GskContour *self,
|
||||
gpointer measure_data,
|
||||
|
||||
@@ -94,6 +94,10 @@ void gsk_contour_get_point (const GskContou
|
||||
gpointer measure_data,
|
||||
float offset,
|
||||
GskRealPathPoint *result);
|
||||
void gsk_contour_get_start_point (const GskContour *self,
|
||||
GskRealPathPoint *result);
|
||||
void gsk_contour_get_end_point (const GskContour *self,
|
||||
GskRealPathPoint *result);
|
||||
float gsk_contour_get_distance (const GskContour *self,
|
||||
GskRealPathPoint *point,
|
||||
gpointer measure_data);
|
||||
|
||||
@@ -540,6 +540,74 @@ gsk_path_get_closest_point (GskPath *self,
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_path_get_start_point:
|
||||
* @self: a `GskPath`
|
||||
* @result: (out caller-allocates): return location for point
|
||||
*
|
||||
* Gets the start point of the path.
|
||||
*
|
||||
* An empty path has no points, so `FALSE`
|
||||
* is returned in this case.
|
||||
*
|
||||
* Returns: `TRUE` if @result was filled
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
gboolean
|
||||
gsk_path_get_start_point (GskPath *self,
|
||||
GskPathPoint *result)
|
||||
{
|
||||
GskRealPathPoint *res = (GskRealPathPoint *) result;
|
||||
|
||||
g_return_val_if_fail (self != NULL, FALSE);
|
||||
g_return_val_if_fail (result != NULL, FALSE);
|
||||
|
||||
if (self->n_contours == 0)
|
||||
return FALSE;
|
||||
|
||||
gsk_contour_get_start_point (self->contours[0], res);
|
||||
|
||||
res->path = self;
|
||||
res->contour = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_path_get_end_point:
|
||||
* @self: a `GskPath`
|
||||
* @result: (out caller-allocates): return location for point
|
||||
*
|
||||
* Gets the end point of the path.
|
||||
*
|
||||
* An empty path has no points, so `FALSE`
|
||||
* is returned in this case.
|
||||
*
|
||||
* Returns: `TRUE` if @result was filled
|
||||
*
|
||||
* Since: 4.14
|
||||
*/
|
||||
gboolean
|
||||
gsk_path_get_end_point (GskPath *self,
|
||||
GskPathPoint *result)
|
||||
{
|
||||
GskRealPathPoint *res = (GskRealPathPoint *) result;
|
||||
|
||||
g_return_val_if_fail (self != NULL, FALSE);
|
||||
g_return_val_if_fail (result!= NULL, FALSE);
|
||||
|
||||
if (self->n_contours == 0)
|
||||
return FALSE;
|
||||
|
||||
gsk_contour_get_end_point (self->contours[self->n_contours - 1], res);
|
||||
|
||||
res->path = self;
|
||||
res->contour = self->n_contours - 1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_path_foreach:
|
||||
* @self: a `GskPath`
|
||||
|
||||
@@ -116,6 +116,13 @@ gboolean gsk_path_get_closest_point (GskPath
|
||||
float threshold,
|
||||
GskPathPoint *result);
|
||||
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
gboolean gsk_path_get_start_point (GskPath *self,
|
||||
GskPathPoint *result);
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
gboolean gsk_path_get_end_point (GskPath *self,
|
||||
GskPathPoint *result);
|
||||
|
||||
GDK_AVAILABLE_IN_4_14
|
||||
gboolean gsk_path_foreach (GskPath *self,
|
||||
GskPathForeachFlags flags,
|
||||
|
||||
Reference in New Issue
Block a user