From f7399786a3e469393ff16a23d7ffc4e561f0ff79 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Fri, 18 Jun 2010 14:58:48 +0900 Subject: [PATCH] libeek: make eek_container_find_by_position() as non-virtual --- eek/eek-container.c | 71 +++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/eek/eek-container.c b/eek/eek-container.c index d5c15c07..f1b71da4 100644 --- a/eek/eek-container.c +++ b/eek/eek-container.c @@ -105,43 +105,6 @@ eek_container_real_find (EekContainer *self, 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 eek_container_dispose (GObject *object) { @@ -178,7 +141,6 @@ eek_container_class_init (EekContainerClass *klass) klass->remove_child = eek_container_real_remove_child; klass->foreach_child = eek_container_real_foreach_child; klass->find = eek_container_real_find; - klass->find_by_position = eek_container_real_find_by_position; gobject_class->finalize = eek_container_finalize; gobject_class->dispose = eek_container_dispose; @@ -269,13 +231,40 @@ eek_container_find (EekContainer *container, 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 * eek_container_find_by_position (EekContainer *container, gdouble x, gdouble y) { + EekBounds bounds; + FbpData data; + g_return_val_if_fail (EEK_IS_CONTAINER(container), NULL); - return EEK_CONTAINER_GET_CLASS(container)->find_by_position (container, - x, - y); + eek_element_get_bounds (EEK_ELEMENT(container), &bounds); + data.x = x - bounds.x; + data.y = y - bounds.y; + return eek_container_find (container, + compare_element_by_position, + &data); }