focus: Refactor mouse tracking code for focus.

- Reduced the if statement depth.
- Introduced new macro ELM_RECTS_POINT_OUT that checks if the point(xx,
yy) stays out of the rectangle(x, y, w, h) area.
This commit is contained in:
Daniel Juyung Seo 2014-03-01 15:50:07 +09:00
parent ff2aa6e679
commit 5f3fedeff5
2 changed files with 11 additions and 10 deletions

View File

@ -1,3 +1,6 @@
/* handy macros */
#define ELM_RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy)))
#define ELM_PI 3.14159265358979323846
// checks if the point(xx, yy) stays out of the rectangle(x, y, w, h) area.
#define ELM_RECTS_POINT_OUT(x, y, w, h, xx, yy) (((xx) < (x)) || ((yy) < (y)) || ((xx) > ((x) + (w))) || ((yy) > ((y) + (h))))

View File

@ -237,18 +237,16 @@ _obj_mouse_move(void *data,
{
ELM_WIDGET_DATA_GET(data, sd);
Evas_Event_Mouse_Move *ev = event_info;
if (sd->still_in)
if (!sd->still_in) return;
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
sd->still_in = EINA_FALSE;
else
{
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
Evas_Coord x, y, w, h;
evas_object_geometry_get(obj, &x, &y, &w, &h);
if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, ev->cur.canvas.y))
sd->still_in = EINA_FALSE;
else
{
Evas_Coord x, y, w, h;
evas_object_geometry_get(obj, &x, &y, &w, &h);
if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
(ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
sd->still_in = EINA_FALSE;
}
}
}