libeek: make eek_container_find_by_position() as non-virtual
This commit is contained in:
@ -105,43 +105,6 @@ eek_container_real_find (EekContainer *self,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct _FbpData
|
|
||||||
{
|
|
||||||
EekKey *key;
|
|
||||||
gint x, y;
|
|
||||||
};
|
|
||||||
typedef struct _FbpData FbpData;
|
|
||||||
|
|
||||||
static gint
|
|
||||||
compare_element_by_position (EekElement *element, gpointer user_data)
|
|
||||||
{
|
|
||||||
EekBounds bounds;
|
|
||||||
FbpData *data = user_data;
|
|
||||||
|
|
||||||
eek_element_get_bounds (element, &bounds);
|
|
||||||
if (bounds.x <= data->x && bounds.y <= data->y &&
|
|
||||||
data->x <= (bounds.x + bounds.width) &&
|
|
||||||
data->y <= (bounds.y + bounds.height))
|
|
||||||
return 0;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static EekElement *
|
|
||||||
eek_container_real_find_by_position (EekContainer *self,
|
|
||||||
gdouble x,
|
|
||||||
gdouble y)
|
|
||||||
{
|
|
||||||
EekBounds bounds;
|
|
||||||
FbpData data;
|
|
||||||
|
|
||||||
eek_element_get_bounds (EEK_ELEMENT(self), &bounds);
|
|
||||||
data.x = x - bounds.x;
|
|
||||||
data.y = y - bounds.y;
|
|
||||||
return eek_container_find (self,
|
|
||||||
compare_element_by_position,
|
|
||||||
&data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eek_container_dispose (GObject *object)
|
eek_container_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
@ -178,7 +141,6 @@ eek_container_class_init (EekContainerClass *klass)
|
|||||||
klass->remove_child = eek_container_real_remove_child;
|
klass->remove_child = eek_container_real_remove_child;
|
||||||
klass->foreach_child = eek_container_real_foreach_child;
|
klass->foreach_child = eek_container_real_foreach_child;
|
||||||
klass->find = eek_container_real_find;
|
klass->find = eek_container_real_find;
|
||||||
klass->find_by_position = eek_container_real_find_by_position;
|
|
||||||
|
|
||||||
gobject_class->finalize = eek_container_finalize;
|
gobject_class->finalize = eek_container_finalize;
|
||||||
gobject_class->dispose = eek_container_dispose;
|
gobject_class->dispose = eek_container_dispose;
|
||||||
@ -269,13 +231,40 @@ eek_container_find (EekContainer *container,
|
|||||||
user_data);
|
user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct _FbpData
|
||||||
|
{
|
||||||
|
EekKey *key;
|
||||||
|
gint x, y;
|
||||||
|
};
|
||||||
|
typedef struct _FbpData FbpData;
|
||||||
|
|
||||||
|
static gint
|
||||||
|
compare_element_by_position (EekElement *element, gpointer user_data)
|
||||||
|
{
|
||||||
|
EekBounds bounds;
|
||||||
|
FbpData *data = user_data;
|
||||||
|
|
||||||
|
eek_element_get_bounds (element, &bounds);
|
||||||
|
if (bounds.x <= data->x && bounds.y <= data->y &&
|
||||||
|
data->x <= (bounds.x + bounds.width) &&
|
||||||
|
data->y <= (bounds.y + bounds.height))
|
||||||
|
return 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
EekElement *
|
EekElement *
|
||||||
eek_container_find_by_position (EekContainer *container,
|
eek_container_find_by_position (EekContainer *container,
|
||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y)
|
gdouble y)
|
||||||
{
|
{
|
||||||
|
EekBounds bounds;
|
||||||
|
FbpData data;
|
||||||
|
|
||||||
g_return_val_if_fail (EEK_IS_CONTAINER(container), NULL);
|
g_return_val_if_fail (EEK_IS_CONTAINER(container), NULL);
|
||||||
return EEK_CONTAINER_GET_CLASS(container)->find_by_position (container,
|
eek_element_get_bounds (EEK_ELEMENT(container), &bounds);
|
||||||
x,
|
data.x = x - bounds.x;
|
||||||
y);
|
data.y = y - bounds.y;
|
||||||
|
return eek_container_find (container,
|
||||||
|
compare_element_by_position,
|
||||||
|
&data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user