diff --git a/legacy/elementary/src/lib/elm_mapbuf.c b/legacy/elementary/src/lib/elm_mapbuf.c index f87fe11136..d9ab0dcd34 100644 --- a/legacy/elementary/src/lib/elm_mapbuf.c +++ b/legacy/elementary/src/lib/elm_mapbuf.c @@ -102,12 +102,19 @@ _configure(Evas_Object *obj) if (sd->enabled && !evas_object_visible_get(obj)) return; Evas_Coord x, y, w, h; + int i; evas_object_geometry_get(wd->resize_obj, &x, &y, &w, &h); if (sd->enabled) { if (!m) m = evas_map_new(4); evas_map_util_points_populate_from_geometry(m, x, y, w, h, 0); + for (i = 0; i < (int)(sizeof(sd->colors)/sizeof(sd->colors[0])); i++) + { + evas_map_point_color_set(m, i, sd->colors[i].r, sd->colors[i].g, + sd->colors[i].b, sd->colors[i].a); + } + evas_map_smooth_set(m, sd->smooth); evas_map_alpha_set(m, sd->alpha); evas_object_map_set(sd->content, m); @@ -273,6 +280,8 @@ _elm_mapbuf_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED) { Elm_Mapbuf_Smart_Data *priv = _pd; Evas_Object *rect = evas_object_rectangle_add(evas_object_evas_get(obj)); + int i; + elm_widget_resize_object_set(obj, rect, EINA_TRUE); eo_do_super(obj, MY_CLASS, evas_obj_smart_add()); @@ -282,6 +291,14 @@ _elm_mapbuf_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED) evas_object_pass_events_set(rect, EINA_TRUE); evas_object_color_set(rect, 0, 0, 0, 0); + for (i = 0; i < (int)(sizeof(priv->colors)/sizeof(priv->colors[0])); i++) + { + priv->colors[i].r = 255; + priv->colors[i].g = 255; + priv->colors[i].b = 255; + priv->colors[i].a = 255; + } + priv->self = obj; priv->alpha = EINA_TRUE; priv->smooth = EINA_TRUE; @@ -488,6 +505,76 @@ _auto_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list) *ret = sd->automode; } +static void +_point_color_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list) +{ + int idx = va_arg(*list, int); + int *r = va_arg(*list, int *); + int *g = va_arg(*list, int *); + int *b = va_arg(*list, int *); + int *a = va_arg(*list, int *); + + Elm_Mapbuf_Smart_Data *sd = _pd; + + *r = sd->colors[idx].r; + *g = sd->colors[idx].g; + *b = sd->colors[idx].b; + *a =sd->colors[idx].a; +} + +EAPI void +elm_mapbuf_point_color_get(Evas_Object *obj, int idx, + int *r, int *g, int *b, int *a) +{ + ELM_MAPBUF_CHECK(obj); + ELM_MAPBUF_DATA_GET(obj, sd); + + if ((idx < 0) || (idx >= (int)(sizeof(sd->colors)/sizeof(sd->colors[0])))) + { + ERR("idx value should be 0 ~ %d, mapbuf(%p)", + ((sizeof(sd->colors)/sizeof(sd->colors[0])) - 1), obj); + return; + } + + eo_do(obj, elm_obj_mapbuf_point_color_get(idx, r, g, b, a)); +} + +static void +_point_color_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list) +{ + int idx = va_arg(*list, int); + int r = va_arg(*list, int); + int g = va_arg(*list, int); + int b = va_arg(*list, int); + int a = va_arg(*list, int); + + Elm_Mapbuf_Smart_Data *sd = _pd; + + sd->colors[idx].r = r; + sd->colors[idx].g = g; + sd->colors[idx].b = b; + sd->colors[idx].a = a; + + _configure(obj); +} + +EAPI void +elm_mapbuf_point_color_set(Evas_Object *obj, int idx, + int r, int g, int b, int a) +{ + ELM_MAPBUF_CHECK(obj); + ELM_MAPBUF_DATA_GET(obj, sd); + + if ((idx < 0) || (idx >= (int)(sizeof(sd->colors)/sizeof(sd->colors[0])))) + { + ERR("idx value should be 0 ~ %d, mapbuf(%p)", + ((sizeof(sd->colors)/sizeof(sd->colors[0])) - 1), obj); + return; + } + + eo_do(obj, elm_obj_mapbuf_point_color_set(idx, r, g, b, a)); +} + static void _class_constructor(Eo_Class *klass) { @@ -516,6 +603,8 @@ _class_constructor(Eo_Class *klass) EO_OP_FUNC(ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_ALPHA_GET), _alpha_get), EO_OP_FUNC(ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_AUTO_SET), _auto_set), EO_OP_FUNC(ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_AUTO_GET), _auto_get), + EO_OP_FUNC(ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_POINT_COLOR_SET), _point_color_set), + EO_OP_FUNC(ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_POINT_COLOR_GET), _point_color_get), EO_OP_FUNC_SENTINEL }; eo_class_funcs_set(klass, func_desc); @@ -531,6 +620,8 @@ static const Eo_Op_Description op_desc[] = { EO_OP_DESCRIPTION(ELM_OBJ_MAPBUF_SUB_ID_ALPHA_GET, "Get a value whether alpha blending is enabled or not."), EO_OP_DESCRIPTION(ELM_OBJ_MAPBUF_SUB_ID_AUTO_SET, "Turn map on or off automatically based on object visibility."), EO_OP_DESCRIPTION(ELM_OBJ_MAPBUF_SUB_ID_AUTO_GET, "Get automatic mode state."), + EO_OP_DESCRIPTION(ELM_OBJ_MAPBUF_SUB_ID_POINT_COLOR_SET, "Set a vertex color of the mapbuf"), + EO_OP_DESCRIPTION(ELM_OBJ_MAPBUF_SUB_ID_POINT_COLOR_GET, "Get a vertex color of the mapbuf"), EO_OP_DESCRIPTION_SENTINEL }; static const Eo_Class_Description class_desc = { diff --git a/legacy/elementary/src/lib/elm_mapbuf_eo.h b/legacy/elementary/src/lib/elm_mapbuf_eo.h index 9602e57213..3107d6fa0b 100644 --- a/legacy/elementary/src/lib/elm_mapbuf_eo.h +++ b/legacy/elementary/src/lib/elm_mapbuf_eo.h @@ -19,6 +19,8 @@ enum ELM_OBJ_MAPBUF_SUB_ID_ALPHA_GET, ELM_OBJ_MAPBUF_SUB_ID_AUTO_SET, ELM_OBJ_MAPBUF_SUB_ID_AUTO_GET, + ELM_OBJ_MAPBUF_SUB_ID_POINT_COLOR_SET, + ELM_OBJ_MAPBUF_SUB_ID_POINT_COLOR_GET, ELM_OBJ_MAPBUF_SUB_ID_LAST }; @@ -121,6 +123,38 @@ enum */ #define elm_obj_mapbuf_auto_get(ret) ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_AUTO_GET), EO_TYPECHECK(Eina_Bool *, ret) +/** + * @def elm_obj_mapbuf_point_color_set + * @since 1.9 + * + * Set a vertex color of the mapbuf + * + * @param[in] idx + * @param[in] r + * @param[in] g + * @param[in] b + * @param[in] a + * + * @see elm_mapbuf_point_color_set + */ +#define elm_obj_mapbuf_point_color_set(idx, r, g, b, a) ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_POINT_COLOR_SET), EO_TYPECHECK(int, idx), EO_TYPECHECK(int, r), EO_TYPECHECK(int, g), EO_TYPECHECK(int, b), EO_TYPECHECK(int, a) + +/** + * @def elm_obj_mapbuf_point_color_get + * @since 1.9 + * + * get a vertex color of the mapbuf + * + * @param[in] idx + * @param[out] r + * @param[out] g + * @param[out] b + * @param[out] a + * + * @see elm_mapbuf_point_color_get + */ +#define elm_obj_mapbuf_point_color_get(idx, r, g, b, a) ELM_OBJ_MAPBUF_ID(ELM_OBJ_MAPBUF_SUB_ID_POINT_COLOR_GET), EO_TYPECHECK(int, idx), EO_TYPECHECK(int *, r), EO_TYPECHECK(int *, g), EO_TYPECHECK(int *, b), EO_TYPECHECK(int *, a) + /** * @} */ diff --git a/legacy/elementary/src/lib/elm_mapbuf_legacy.h b/legacy/elementary/src/lib/elm_mapbuf_legacy.h index e76e04dcf5..af919d0bf4 100644 --- a/legacy/elementary/src/lib/elm_mapbuf_legacy.h +++ b/legacy/elementary/src/lib/elm_mapbuf_legacy.h @@ -145,3 +145,42 @@ EAPI void elm_mapbuf_auto_set(Evas_Object *obj, Eina_Boo */ EAPI Eina_Bool elm_mapbuf_auto_get(const Evas_Object *obj); +/** + * Set the color of a vertex in the mapbuf + * + * This sets the color of the vertex in the mapbuf. Colors will be linearly + * interpolated between vertex points through the mapbuf. Color will multiply + * the "texture" pixels (like GL_MODULATE in OpenGL). The default color of + * a vertex in a mapbuf is white solid (255, 255, 255, 255) which means it will + * have no affect on modifying the texture pixels. + * + * @param obj The mapbuf object. + * @param idx index of point to change. Must be smaller than mapbuf size. + * @param r red (0 - 255) + * @param g green (0 - 255) + * @param b blue (0 - 255) + * @param a alpha (0 - 255) + * + * @see evas_object_map_set() + * @since 1.9 + */ +EAPI void elm_mapbuf_point_color_set(Evas_Object *obj, int idx, int r, int g, int b, int a); + +/** + * Get the color set on a vertex in the mapbuf + * + * This gets the color set by elm_mapbuf_point_color_set() on the given vertex + * of the mapbuf. + * + * @param obj The mapbuf object. + * @param idx index of point get. Must be smaller than map size. + * @param r pointer to red return + * @param g pointer to green return + * @param b pointer to blue return + * @param a pointer to alpha return + * + * @see elm_mapbuf_point_color_set() + * + * @since 1.9 + */ +EAPI void elm_mapbuf_point_color_get(Evas_Object *obj, int idx, int *r, int *g, int *b, int *a); diff --git a/legacy/elementary/src/lib/elm_widget_mapbuf.h b/legacy/elementary/src/lib/elm_widget_mapbuf.h index c9ca063559..0d2bb3be3b 100644 --- a/legacy/elementary/src/lib/elm_widget_mapbuf.h +++ b/legacy/elementary/src/lib/elm_widget_mapbuf.h @@ -22,8 +22,11 @@ struct _Elm_Mapbuf_Smart_Data { Evas_Object *self; Evas_Object *content; - Ecore_Idler *idler; + struct + { + int r, g, b, a; + } colors[4]; Eina_Bool enabled : 1; Eina_Bool smooth_saved : 1;