libeek: add eek_element_get_absolute_position()
This commit is contained in:
@ -298,7 +298,9 @@ eek_element_get_name (EekElement *element)
|
|||||||
* @element: an #EekElement
|
* @element: an #EekElement
|
||||||
* @bounds: bounding box of @element
|
* @bounds: bounding box of @element
|
||||||
*
|
*
|
||||||
* Set the bounding box of @element to @bounds.
|
* Set the bounding box of @element to @bounds. Note that if @element
|
||||||
|
* has parent, X and Y positions of @bounds are relative to the parent
|
||||||
|
* position.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
eek_element_set_bounds (EekElement *element,
|
eek_element_set_bounds (EekElement *element,
|
||||||
@ -313,7 +315,10 @@ eek_element_set_bounds (EekElement *element,
|
|||||||
* @element: an #EekElement
|
* @element: an #EekElement
|
||||||
* @bounds: pointer where bounding box of @element will be stored
|
* @bounds: pointer where bounding box of @element will be stored
|
||||||
*
|
*
|
||||||
* Get the bounding box of @element.
|
* Get the bounding box of @element. Note that if @element has
|
||||||
|
* parent, X and Y positions of @bounds are relative to the parent
|
||||||
|
* position. To obtain the absolute position, use
|
||||||
|
* #eek_element_get_absolute_position().
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
eek_element_get_bounds (EekElement *element,
|
eek_element_get_bounds (EekElement *element,
|
||||||
@ -322,3 +327,33 @@ eek_element_get_bounds (EekElement *element,
|
|||||||
g_return_if_fail (EEK_IS_ELEMENT(element));
|
g_return_if_fail (EEK_IS_ELEMENT(element));
|
||||||
EEK_ELEMENT_GET_CLASS(element)->get_bounds (element, bounds);
|
EEK_ELEMENT_GET_CLASS(element)->get_bounds (element, bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eek_element_get_absolute_position:
|
||||||
|
* @element: an #EekElement
|
||||||
|
* @x: pointer where the X coordinate of @element will be stored
|
||||||
|
* @y: pointer where the Y coordinate of @element will be stored
|
||||||
|
*
|
||||||
|
* Compute the absolute position of @element.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
eek_element_get_absolute_position (EekElement *element,
|
||||||
|
gdouble *x,
|
||||||
|
gdouble *y)
|
||||||
|
{
|
||||||
|
EekContainer *parent;
|
||||||
|
EekBounds bounds;
|
||||||
|
gdouble ax, ay;
|
||||||
|
|
||||||
|
eek_element_get_bounds (element, &bounds);
|
||||||
|
ax = bounds.x;
|
||||||
|
ay = bounds.y;
|
||||||
|
while ((parent = eek_element_get_parent (element)) != NULL) {
|
||||||
|
eek_element_get_bounds (EEK_ELEMENT(parent), &bounds);
|
||||||
|
ax += bounds.x;
|
||||||
|
ay += bounds.y;
|
||||||
|
element = EEK_ELEMENT(parent);
|
||||||
|
}
|
||||||
|
*x = ax;
|
||||||
|
*y = ay;
|
||||||
|
}
|
||||||
|
|||||||
@ -61,21 +61,25 @@ struct _EekElementClass
|
|||||||
EekBounds *bounds);
|
EekBounds *bounds);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType eek_element_get_type (void) G_GNUC_CONST;
|
GType eek_element_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
void eek_element_set_parent (EekElement *element,
|
void eek_element_set_parent (EekElement *element,
|
||||||
EekContainer *parent);
|
EekContainer *parent);
|
||||||
EekContainer *eek_element_get_parent (EekElement *element);
|
EekContainer *eek_element_get_parent (EekElement *element);
|
||||||
void eek_element_set_name (EekElement *element,
|
void eek_element_set_name (EekElement *element,
|
||||||
const gchar *name);
|
const gchar *name);
|
||||||
|
|
||||||
G_CONST_RETURN gchar *eek_element_get_name (EekElement *element);
|
G_CONST_RETURN gchar *eek_element_get_name (EekElement *element);
|
||||||
|
|
||||||
void eek_element_set_bounds (EekElement *element,
|
void eek_element_set_bounds (EekElement *element,
|
||||||
EekBounds *bounds);
|
EekBounds *bounds);
|
||||||
|
|
||||||
void eek_element_get_bounds (EekElement *element,
|
void eek_element_get_bounds (EekElement *element,
|
||||||
EekBounds *bounds);
|
EekBounds *bounds);
|
||||||
|
|
||||||
|
void eek_element_get_absolute_position (EekElement *element,
|
||||||
|
gdouble *x,
|
||||||
|
gdouble *y);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* EEK_ELEMENT_H */
|
#endif /* EEK_ELEMENT_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user