aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/evas/src/lib/canvas/evas_object_line.c
diff options
context:
space:
mode:
Diffstat (limited to 'legacy/evas/src/lib/canvas/evas_object_line.c')
-rw-r--r--legacy/evas/src/lib/canvas/evas_object_line.c283
1 files changed, 152 insertions, 131 deletions
diff --git a/legacy/evas/src/lib/canvas/evas_object_line.c b/legacy/evas/src/lib/canvas/evas_object_line.c
index 177421dc2f..8f7ed6eef7 100644
--- a/legacy/evas/src/lib/canvas/evas_object_line.c
+++ b/legacy/evas/src/lib/canvas/evas_object_line.c
@@ -1,6 +1,12 @@
#include "evas_common.h"
#include "evas_private.h"
+#include "Eo.h"
+
+EAPI Eo_Op EVAS_OBJ_LINE_BASE_ID = EO_NOOP;
+
+#define MY_CLASS EVAS_OBJ_LINE_CLASS
+
/* private magic number for line objects */
static const char o_type[] = "line";
@@ -9,7 +15,6 @@ typedef struct _Evas_Object_Line Evas_Object_Line;
struct _Evas_Object_Line
{
- DATA32 magic;
struct {
struct {
Evas_Coord x1, y1, x2, y2;
@@ -25,27 +30,25 @@ struct _Evas_Object_Line
};
/* private methods for line objects */
-static void evas_object_line_init(Evas_Object *obj);
-static void *evas_object_line_new(void);
-static void evas_object_line_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y);
-static void evas_object_line_free(Evas_Object *obj);
-static void evas_object_line_render_pre(Evas_Object *obj);
-static void evas_object_line_render_post(Evas_Object *obj);
-
-static unsigned int evas_object_line_id_get(Evas_Object *obj);
-static unsigned int evas_object_line_visual_id_get(Evas_Object *obj);
-static void *evas_object_line_engine_data_get(Evas_Object *obj);
-
-static int evas_object_line_is_opaque(Evas_Object *obj);
-static int evas_object_line_was_opaque(Evas_Object *obj);
-static int evas_object_line_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
-static int evas_object_line_was_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
-static void evas_object_line_coords_recalc(Evas_Object *obj);
+static void evas_object_line_init(Evas_Object *eo_obj);
+static void evas_object_line_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, void *output, void *context, void *surface, int x, int y);
+static void evas_object_line_render_pre(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj);
+static void evas_object_line_render_post(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj);
+
+static unsigned int evas_object_line_id_get(Evas_Object *eo_obj);
+static unsigned int evas_object_line_visual_id_get(Evas_Object *eo_obj);
+static void *evas_object_line_engine_data_get(Evas_Object *eo_obj);
+
+static int evas_object_line_is_opaque(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj);
+static int evas_object_line_was_opaque(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj);
+static int evas_object_line_is_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coord x, Evas_Coord y);
+static int evas_object_line_was_inside(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coord x, Evas_Coord y);
+static void evas_object_line_coords_recalc(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj);
static const Evas_Object_Func object_func =
{
/* methods (compulsory) */
- evas_object_line_free,
+ NULL,
evas_object_line_render,
evas_object_line_render_pre,
evas_object_line_render_post,
@@ -71,43 +74,47 @@ static const Evas_Object_Func object_func =
/* the actual api call to add a rect */
/* it has no other api calls as all properties are standard */
-EVAS_MEMPOOL(_mp_obj);
-
EAPI Evas_Object *
evas_object_line_add(Evas *e)
{
- Evas_Object *obj;
-
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
- obj = evas_object_new(e);
- evas_object_line_init(obj);
- evas_object_inject(obj, e);
- return obj;
+ Evas_Object *eo_obj = eo_add(EVAS_OBJ_LINE_CLASS, e);
+ eo_unref(eo_obj);
+ return eo_obj;
}
EAPI void
-evas_object_line_xy_set(Evas_Object *obj, Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
+evas_object_line_xy_set(Evas_Object *eo_obj, Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
{
- Evas_Object_Line *o;
+ eo_do(eo_obj, evas_obj_line_xy_set(x1, y1, x2, y2));
+}
+
+static void
+_line_xy_set(Eo *eo_obj, void *_pd, va_list *list)
+{
+ Evas_Coord x1 = va_arg(*list, Evas_Coord);
+ Evas_Coord y1 = va_arg(*list, Evas_Coord);
+ Evas_Coord x2 = va_arg(*list, Evas_Coord);
+ Evas_Coord y2 = va_arg(*list, Evas_Coord);
+
+ Evas_Object_Line *o = _pd;
Evas_Coord min_x, max_x, min_y, max_y;
int is, was = 0;
- MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
- return;
- MAGIC_CHECK_END();
- o = (Evas_Object_Line *)(obj->object_data);
- MAGIC_CHECK(o, Evas_Object_Line, MAGIC_OBJ_LINE);
+ MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
if ((x1 == o->cur.x1) && (y1 == o->cur.y1) &&
(x2 == o->cur.x2) && (y2 == o->cur.y2)) return;
- if (obj->layer->evas->events_frozen <= 0)
+
+ Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS);
+ if (!(obj->layer->evas->is_frozen))
{
- if (!evas_event_passes_through(obj) &&
- !evas_event_freezes_through(obj))
- was = evas_object_is_in_output_rect(obj,
+ if (!evas_event_passes_through(eo_obj, obj) &&
+ !evas_event_freezes_through(eo_obj, obj))
+ was = evas_object_is_in_output_rect(eo_obj, obj,
obj->layer->evas->pointer.x,
obj->layer->evas->pointer.y,
1, 1);
@@ -142,49 +149,53 @@ evas_object_line_xy_set(Evas_Object *obj, Evas_Coord x1, Evas_Coord y1, Evas_Coo
o->cur.x2 = x2 - min_x;
o->cur.y2 = y2 - min_y;
o->changed = EINA_TRUE;
- evas_object_change(obj);
- evas_object_coords_recalc(obj);
- evas_object_clip_dirty(obj);
- if (obj->layer->evas->events_frozen <= 0)
+ evas_object_change(eo_obj, obj);
+ evas_object_coords_recalc(eo_obj, obj);
+ evas_object_clip_dirty(eo_obj, obj);
+ if (!(obj->layer->evas->is_frozen))
{
- is = evas_object_is_in_output_rect(obj,
+ is = evas_object_is_in_output_rect(eo_obj, obj,
obj->layer->evas->pointer.x,
obj->layer->evas->pointer.y, 1, 1);
- if (!evas_event_passes_through(obj) &&
- !evas_event_freezes_through(obj))
+ if (!evas_event_passes_through(eo_obj, obj) &&
+ !evas_event_freezes_through(eo_obj, obj))
{
if ((is ^ was) && obj->cur.visible)
- evas_event_feed_mouse_move(obj->layer->evas,
+ evas_event_feed_mouse_move(obj->layer->evas->evas,
obj->layer->evas->pointer.x,
obj->layer->evas->pointer.y,
obj->layer->evas->last_timestamp,
NULL);
}
}
- evas_object_inform_call_move(obj);
- evas_object_inform_call_resize(obj);
+ evas_object_inform_call_move(eo_obj, obj);
+ evas_object_inform_call_resize(eo_obj);
}
EAPI void
-evas_object_line_xy_get(const Evas_Object *obj, Evas_Coord *x1, Evas_Coord *y1, Evas_Coord *x2, Evas_Coord *y2)
+evas_object_line_xy_get(const Evas_Object *eo_obj, Evas_Coord *x1, Evas_Coord *y1, Evas_Coord *x2, Evas_Coord *y2)
{
- Evas_Object_Line *o;
-
- MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
- if (x1) *x1 = 0;
- if (y1) *y1 = 0;
- if (x2) *x2 = 0;
- if (y2) *y2 = 0;
- return;
- MAGIC_CHECK_END();
- o = (Evas_Object_Line *)(obj->object_data);
- MAGIC_CHECK(o, Evas_Object_Line, MAGIC_OBJ_LINE);
+ MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
if (x1) *x1 = 0;
if (y1) *y1 = 0;
if (x2) *x2 = 0;
if (y2) *y2 = 0;
return;
MAGIC_CHECK_END();
+ eo_do((Eo *)eo_obj, evas_obj_line_xy_get(x1, y1, x2, y2));
+}
+
+static void
+_line_xy_get(Eo *eo_obj, void *_pd, va_list *list)
+{
+ const Evas_Object_Line *o = _pd;
+
+ Evas_Coord *x1 = va_arg(*list, Evas_Coord *);
+ Evas_Coord *y1 = va_arg(*list, Evas_Coord *);
+ Evas_Coord *x2 = va_arg(*list, Evas_Coord *);
+ Evas_Coord *y2 = va_arg(*list, Evas_Coord *);
+
+ Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS);
if (x1) *x1 = obj->cur.geometry.x + o->cur.x1;
if (y1) *y1 = obj->cur.geometry.y + o->cur.y1;
if (x2) *x2 = obj->cur.geometry.x + o->cur.x2;
@@ -193,10 +204,9 @@ evas_object_line_xy_get(const Evas_Object *obj, Evas_Coord *x1, Evas_Coord *y1,
/* all nice and private */
static void
-evas_object_line_init(Evas_Object *obj)
+evas_object_line_init(Evas_Object *eo_obj)
{
- /* alloc image ob, setup methods and default values */
- obj->object_data = evas_object_line_new();
+ Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS);
/* set up default settings for this kind of object */
obj->cur.color.r = 255;
obj->cur.color.g = 255;
@@ -216,47 +226,37 @@ evas_object_line_init(Evas_Object *obj)
obj->type = o_type;
}
-static void *
-evas_object_line_new(void)
+static void
+_constructor(Eo *eo_obj, void *class_data, va_list *list EINA_UNUSED)
{
- Evas_Object_Line *o;
+ eo_do_super(eo_obj, eo_constructor());
+ Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS);
+ evas_object_line_init(eo_obj);
+ evas_object_inject(eo_obj, obj, evas_object_evas_get(eo_parent_get(eo_obj)));
+
+ Evas_Object_Line *o = class_data;
/* alloc obj private data */
- EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_line", Evas_Object_Line, 4, NULL);
- o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Line);
- if (!o) return NULL;
- EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Line);
- o->magic = MAGIC_OBJ_LINE;
o->cur.x1 = 0;
o->cur.y1 = 0;
o->cur.x2 = 31;
o->cur.y2 = 31;
o->prev = o->cur;
- return o;
}
static void
-evas_object_line_free(Evas_Object *obj)
+_destructor(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
{
- Evas_Object_Line *o;
-
- /* frees private object data. very simple here */
- o = (Evas_Object_Line *)(obj->object_data);
- MAGIC_CHECK(o, Evas_Object_Line, MAGIC_OBJ_LINE);
- return;
- MAGIC_CHECK_END();
- /* free obj */
- o->magic = 0;
- EVAS_MEMPOOL_FREE(_mp_obj, o);
+ eo_do_super(eo_obj, eo_destructor());
}
static void
-evas_object_line_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y)
+evas_object_line_render(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, void *output, void *context, void *surface, int x, int y)
{
- Evas_Object_Line *o;
+ Evas_Object_Line *o = eo_data_get(eo_obj, MY_CLASS);
/* render object to surface with context, and offxet by x,y */
- o = (Evas_Object_Line *)(obj->object_data);
+
obj->layer->evas->engine.func->context_color_set(output,
context,
obj->cur.cache.clip.r,
@@ -279,9 +279,9 @@ evas_object_line_render(Evas_Object *obj, void *output, void *context, void *sur
}
static void
-evas_object_line_render_pre(Evas_Object *obj)
+evas_object_line_render_pre(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
{
- Evas_Object_Line *o;
+ Evas_Object_Line *o = eo_data_get(eo_obj, MY_CLASS);
int is_v, was_v;
Eina_Bool changed_color = EINA_FALSE;
@@ -293,34 +293,33 @@ evas_object_line_render_pre(Evas_Object *obj)
/* elsewhere, decoding video etc. */
/* then when this is done the object needs to figure if it changed and */
/* if so what and where and add the appropriate redraw lines */
- o = (Evas_Object_Line *)(obj->object_data);
/* if someone is clipping this obj - go calculate the clipper */
if (obj->cur.clipper)
{
- if (obj->cur.cache.clip.dirty)
- evas_object_clip_recalc(obj->cur.clipper);
- obj->cur.clipper->func->render_pre(obj->cur.clipper);
+ Evas_Object_Protected_Data *cur_clipper = eo_data_get(obj->cur.clipper, EVAS_OBJ_CLASS);
+ if (obj->cur.cache.clip.dirty)
+ evas_object_clip_recalc(obj->cur.clipper, cur_clipper);
+ cur_clipper->func->render_pre(obj->cur.clipper, cur_clipper);
}
/* now figure what changed and add draw rects */
/* if it just became visible or invisible */
- is_v = evas_object_is_visible(obj);
- was_v = evas_object_was_visible(obj);
+ is_v = evas_object_is_visible(eo_obj, obj);
+ was_v = evas_object_was_visible(eo_obj, obj);
if (is_v != was_v)
{
- evas_object_render_pre_visible_change(&obj->layer->evas->clip_changes,
- obj, is_v, was_v);
- goto done;
+ evas_object_render_pre_visible_change(&obj->layer->evas->clip_changes, eo_obj, is_v, was_v);
+ goto done;
}
if (obj->changed_map)
{
- evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes,
+ evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes, eo_obj,
obj);
goto done;
}
/* it's not visible - we accounted for it appearing or not so just abort */
if (!is_v) goto done;
/* clipper changed this is in addition to anything else for obj */
- evas_object_render_pre_clipper_change(&obj->layer->evas->clip_changes, obj);
+ evas_object_render_pre_clipper_change(&obj->layer->evas->clip_changes, eo_obj);
if ((obj->cur.color.r != obj->prev.color.r) ||
(obj->cur.color.g != obj->prev.color.g) ||
@@ -339,7 +338,7 @@ evas_object_line_render_pre(Evas_Object *obj)
)
{
evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes,
- obj);
+ eo_obj, obj);
goto done;
}
@@ -357,62 +356,51 @@ evas_object_line_render_pre(Evas_Object *obj)
(o->cur.y2 != o->prev.y2)))
)
{
- evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes,
- obj);
- goto done;
+ evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes, eo_obj, obj);
+ goto done;
}
-
-done:
- evas_object_render_pre_effect_updates(&obj->layer->evas->clip_changes, obj,
- is_v, was_v);
+ done:
+ evas_object_render_pre_effect_updates(&obj->layer->evas->clip_changes, eo_obj, is_v, was_v);
}
static void
-evas_object_line_render_post(Evas_Object *obj)
+evas_object_line_render_post(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj EINA_UNUSED)
{
- Evas_Object_Line *o;
+ Evas_Object_Line *o = eo_data_get(eo_obj, MY_CLASS);
/* this moves the current data to the previous state parts of the object */
/* in whatever way is safest for the object. also if we don't need object */
/* data anymore we can free it if the object deems this is a good idea */
- o = (Evas_Object_Line *)(obj->object_data);
/* remove those pesky changes */
- evas_object_clip_changes_clean(obj);
+ evas_object_clip_changes_clean(eo_obj);
/* move cur to prev safely for object data */
- evas_object_cur_prev(obj);
+ evas_object_cur_prev(eo_obj);
o->prev = o->cur;
o->changed = EINA_FALSE;
}
-static unsigned int evas_object_line_id_get(Evas_Object *obj)
+static unsigned int evas_object_line_id_get(Evas_Object *eo_obj)
{
- Evas_Object_Line *o;
-
- o = (Evas_Object_Line *)(obj->object_data);
+ Evas_Object_Line *o = eo_data_get(eo_obj, MY_CLASS);
if (!o) return 0;
return MAGIC_OBJ_LINE;
}
-static unsigned int evas_object_line_visual_id_get(Evas_Object *obj)
+static unsigned int evas_object_line_visual_id_get(Evas_Object *eo_obj)
{
- Evas_Object_Line *o;
-
- o = (Evas_Object_Line *)(obj->object_data);
+ Evas_Object_Line *o = eo_data_get(eo_obj, MY_CLASS);
if (!o) return 0;
return MAGIC_OBJ_SHAPE;
}
-static void *evas_object_line_engine_data_get(Evas_Object *obj)
+static void *evas_object_line_engine_data_get(Evas_Object *eo_obj)
{
- Evas_Object_Line *o;
-
- o = (Evas_Object_Line *)(obj->object_data);
- if (!o) return NULL;
+ Evas_Object_Line *o = eo_data_get(eo_obj, MY_CLASS);
return o->engine_data;
}
static int
-evas_object_line_is_opaque(Evas_Object *obj __UNUSED__)
+evas_object_line_is_opaque(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj EINA_UNUSED)
{
/* this returns 1 if the internal object data implies that the object is */
/* currently fully opaque over the entire line it occupies */
@@ -420,7 +408,7 @@ evas_object_line_is_opaque(Evas_Object *obj __UNUSED__)
}
static int
-evas_object_line_was_opaque(Evas_Object *obj __UNUSED__)
+evas_object_line_was_opaque(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj EINA_UNUSED)
{
/* this returns 1 if the internal object data implies that the object was */
/* previously fully opaque over the entire line it occupies */
@@ -428,7 +416,7 @@ evas_object_line_was_opaque(Evas_Object *obj __UNUSED__)
}
static int
-evas_object_line_is_inside(Evas_Object *obj __UNUSED__, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
+evas_object_line_is_inside(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj EINA_UNUSED, Evas_Coord x EINA_UNUSED, Evas_Coord y EINA_UNUSED)
{
/* this returns 1 if the canvas co-ordinates are inside the object based */
/* on object private data. not much use for rects, but for polys, images */
@@ -437,7 +425,7 @@ evas_object_line_is_inside(Evas_Object *obj __UNUSED__, Evas_Coord x __UNUSED__,
}
static int
-evas_object_line_was_inside(Evas_Object *obj __UNUSED__, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
+evas_object_line_was_inside(Evas_Object *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj EINA_UNUSED, Evas_Coord x EINA_UNUSED, Evas_Coord y EINA_UNUSED)
{
/* this returns 1 if the canvas co-ordinates were inside the object based */
/* on object private data. not much use for rects, but for polys, images */
@@ -446,11 +434,10 @@ evas_object_line_was_inside(Evas_Object *obj __UNUSED__, Evas_Coord x __UNUSED__
}
static void
-evas_object_line_coords_recalc(Evas_Object *obj)
+evas_object_line_coords_recalc(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
{
- Evas_Object_Line *o;
+ Evas_Object_Line *o = eo_data_get(eo_obj, MY_CLASS);
- o = (Evas_Object_Line *)(obj->object_data);
o->cur.cache.x1 = obj->cur.geometry.x + o->cur.x1;
o->cur.cache.y1 = obj->cur.geometry.y + o->cur.y1;
o->cur.cache.x2 = obj->cur.geometry.x + o->cur.x2;
@@ -458,3 +445,37 @@ evas_object_line_coords_recalc(Evas_Object *obj)
o->cur.cache.object.w = obj->cur.geometry.w;
o->cur.cache.object.h = obj->cur.geometry.h;
}
+
+static void
+_class_constructor(Eo_Class *klass)
+{
+ const Eo_Op_Func_Description func_desc[] = {
+ EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
+ EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
+ EO_OP_FUNC(EVAS_OBJ_LINE_ID(EVAS_OBJ_LINE_SUB_ID_XY_SET), _line_xy_set),
+ EO_OP_FUNC(EVAS_OBJ_LINE_ID(EVAS_OBJ_LINE_SUB_ID_XY_GET), _line_xy_get),
+ EO_OP_FUNC_SENTINEL
+ };
+
+ eo_class_funcs_set(klass, func_desc);
+}
+
+static const Eo_Op_Description op_desc[] = {
+ EO_OP_DESCRIPTION(EVAS_OBJ_LINE_SUB_ID_XY_SET, "Sets the coordinates of the end points of the given evas line object."),
+ EO_OP_DESCRIPTION(EVAS_OBJ_LINE_SUB_ID_XY_GET, "Retrieves the coordinates of the end points of the given evas line object."),
+ EO_OP_DESCRIPTION_SENTINEL
+};
+
+static const Eo_Class_Description class_desc = {
+ EO_VERSION,
+ "Evas_Object_Line",
+ EO_CLASS_TYPE_REGULAR,
+ EO_CLASS_DESCRIPTION_OPS(&EVAS_OBJ_LINE_BASE_ID, op_desc, EVAS_OBJ_LINE_SUB_ID_LAST),
+ NULL,
+ sizeof(Evas_Object_Line),
+ _class_constructor,
+ NULL
+};
+
+EO_DEFINE_CLASS(evas_object_line_class_get, &class_desc, EVAS_OBJ_CLASS, NULL);
+