Add support for LdDiagramConnection to LdCanvas.

Heavy LdCanvas refactoring, some modifications to ld-types.

It just wasn't possible for me to further work with an old,
2000 lines long file without shuffling everything around
at the same time.
This commit is contained in:
Přemysl Eric Janouch 2011-02-07 01:10:17 +01:00
parent ee95916749
commit 1277b6eaaf
3 changed files with 637 additions and 241 deletions

File diff suppressed because it is too large Load Diff

View File

@ -90,7 +90,7 @@ DEFINE_BOXED_TRIVIAL_FREE (LdPoint, ld_point)
* Compute the distance between two points.
*/
gdouble
ld_point_distance (LdPoint *self, gdouble x, gdouble y)
ld_point_distance (const LdPoint *self, gdouble x, gdouble y)
{
gdouble dx, dy;
@ -291,22 +291,6 @@ DEFINE_BOXED_TRIVIAL_COPY (LdRectangle, ld_rectangle)
*/
DEFINE_BOXED_TRIVIAL_FREE (LdRectangle, ld_rectangle)
/**
* ld_rectangle_contains:
* @self: an #LdRectangle structure.
* @x: the X coordinate of the point to be checked.
* @y: the Y coordinate of the point to be checked.
*
* Return value: %TRUE if the rectangle contains the specified point.
*/
gboolean
ld_rectangle_contains (LdRectangle *self, gdouble x, gdouble y)
{
g_return_val_if_fail (self != NULL, FALSE);
return (x >= self->x && x <= self->x + self->width
&& y >= self->y && y <= self->y + self->height);
}
/**
* ld_rectangle_intersects:
* @self: an #LdRectangle structure.
@ -315,7 +299,7 @@ ld_rectangle_contains (LdRectangle *self, gdouble x, gdouble y)
* Return value: %TRUE if the two rectangles intersect.
*/
gboolean
ld_rectangle_intersects (LdRectangle *self, LdRectangle *rect)
ld_rectangle_intersects (const LdRectangle *self, const LdRectangle *rect)
{
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (rect != NULL, FALSE);
@ -326,6 +310,42 @@ ld_rectangle_intersects (LdRectangle *self, LdRectangle *rect)
|| self->y + self->height < rect->y);
}
/**
* ld_rectangle_contains:
* @self: an #LdRectangle structure.
* @rect: an #LdRectangle to be checked for containment.
*
* Return value: %TRUE if @self fully contains @rect.
*/
gboolean
ld_rectangle_contains (const LdRectangle *self, const LdRectangle *rect)
{
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (rect != NULL, FALSE);
return (self->x <= rect->x
&& self->y <= rect->y
&& self->x + self->width >= rect->x + rect->width
&& self->y + self->height >= rect->y + rect->height);
}
/**
* ld_rectangle_contains_point:
* @self: an #LdRectangle structure.
* @point: the point to be checked.
*
* Return value: %TRUE if the rectangle contains the specified point.
*/
gboolean
ld_rectangle_contains_point (const LdRectangle *self, const LdPoint *point)
{
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (point != NULL, FALSE);
return (point->x >= self->x && point->x <= self->x + self->width
&& point->y >= self->y && point->y <= self->y + self->height);
}
/**
* ld_rectangle_extend:
* @self: an #LdRectangle structure.

View File

@ -39,7 +39,7 @@ GType ld_point_get_type (void) G_GNUC_CONST;
LdPoint *ld_point_copy (const LdPoint *self);
void ld_point_free (LdPoint *self);
gdouble ld_point_distance (LdPoint *self, gdouble x, gdouble y);
gdouble ld_point_distance (const LdPoint *self, gdouble x, gdouble y);
/**
@ -88,8 +88,12 @@ GType ld_rectangle_get_type (void) G_GNUC_CONST;
LdRectangle *ld_rectangle_copy (const LdRectangle *self);
void ld_rectangle_free (LdRectangle *self);
gboolean ld_rectangle_contains (LdRectangle *self, gdouble x, gdouble y);
gboolean ld_rectangle_intersects (LdRectangle *self, LdRectangle *rect);
gboolean ld_rectangle_intersects (const LdRectangle *self,
const LdRectangle *rect);
gboolean ld_rectangle_contains (const LdRectangle *self,
const LdRectangle *rect);
gboolean ld_rectangle_contains_point (const LdRectangle *self,
const LdPoint *point);
void ld_rectangle_extend (LdRectangle *self, gdouble border);