2013-06-20 03:53:29 -07:00
|
|
|
#include "evas_common_private.h" /* Includes evas_bidi_utils stuff. */
|
2002-11-08 00:02:15 -08:00
|
|
|
#include "evas_private.h"
|
2013-12-09 03:55:38 -08:00
|
|
|
#include "evas_filter.h"
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2014-06-02 06:47:59 -07:00
|
|
|
#define MY_CLASS EVAS_TEXT_CLASS
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2013-11-07 03:16:01 -08:00
|
|
|
#define MY_CLASS_NAME "Evas_Text"
|
2013-01-28 22:36:23 -08:00
|
|
|
|
2014-01-16 18:19:02 -08:00
|
|
|
#ifdef EVAS_CSERVE2
|
|
|
|
# include "evas_cs2_private.h"
|
|
|
|
#endif
|
|
|
|
|
2005-11-26 00:04:20 -08:00
|
|
|
/* save typing */
|
|
|
|
#define ENFN obj->layer->evas->engine.func
|
|
|
|
#define ENDT obj->layer->evas->engine.data.output
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* private magic number for text objects */
|
|
|
|
static const char o_type[] = "text";
|
|
|
|
|
|
|
|
/* private struct for text object internal data */
|
2014-03-09 00:31:28 -08:00
|
|
|
typedef struct _Evas_Text_Data Evas_Text_Data;
|
2011-01-30 02:36:02 -08:00
|
|
|
typedef struct _Evas_Object_Text_Item Evas_Object_Text_Item;
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
struct _Evas_Text_Data
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2005-11-26 00:04:20 -08:00
|
|
|
DATA32 magic;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
struct {
|
2013-03-12 03:01:32 -07:00
|
|
|
struct {
|
|
|
|
unsigned char r, g, b, a;
|
|
|
|
} outline, shadow, glow, glow2;
|
|
|
|
|
2010-07-28 05:00:41 -07:00
|
|
|
const char *utf8_text; /* The text exposed to the API */
|
|
|
|
const char *font;
|
2011-08-01 01:20:52 -07:00
|
|
|
Evas_Font_Description *fdesc;
|
2010-07-28 05:00:41 -07:00
|
|
|
const char *source;
|
2013-03-12 03:01:32 -07:00
|
|
|
Eina_Unicode *text;
|
2005-11-26 00:04:20 -08:00
|
|
|
|
2012-12-12 06:05:29 -08:00
|
|
|
double ellipsis;
|
2013-03-12 03:01:32 -07:00
|
|
|
|
|
|
|
Evas_Font_Size size;
|
2013-12-09 03:55:38 -08:00
|
|
|
Evas_Text_Style_Type style;
|
|
|
|
|
|
|
|
// special effects. VERY EXPERIMENTAL for now.
|
2014-01-02 18:11:40 -08:00
|
|
|
struct {
|
2014-02-04 22:34:28 -08:00
|
|
|
Eina_Stringshare *code;
|
2014-01-02 18:11:40 -08:00
|
|
|
Evas_Filter_Program *chain;
|
2014-02-05 03:09:05 -08:00
|
|
|
Eina_Hash *sources; // Evas_Filter_Proxy_Binding
|
|
|
|
int sources_count;
|
2014-01-02 18:11:40 -08:00
|
|
|
void *output;
|
|
|
|
Eina_Bool changed : 1;
|
2014-02-06 21:23:29 -08:00
|
|
|
Eina_Bool invalid : 1; // Code parse failed
|
2014-01-02 18:11:40 -08:00
|
|
|
} filter;
|
2002-11-08 00:02:15 -08:00
|
|
|
} cur, prev;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2013-03-12 03:01:32 -07:00
|
|
|
struct {
|
|
|
|
Evas_Object_Text_Item *ellipsis_start;
|
|
|
|
Evas_Object_Text_Item *ellipsis_end;
|
|
|
|
Evas_Coord w, h;
|
2013-09-30 23:29:38 -07:00
|
|
|
int advance;
|
2014-03-17 03:29:16 -07:00
|
|
|
int advance_without_ellipsis;
|
2013-10-01 04:34:03 -07:00
|
|
|
Eina_Bool ellipsis;
|
2013-03-12 03:01:32 -07:00
|
|
|
} last_computed;
|
|
|
|
|
2011-01-30 02:36:02 -08:00
|
|
|
Evas_BiDi_Paragraph_Props *bidi_par_props;
|
2011-04-14 08:34:01 -07:00
|
|
|
const char *bidi_delimiters;
|
2011-01-30 02:36:02 -08:00
|
|
|
Evas_Object_Text_Item *items;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2011-05-29 06:00:54 -07:00
|
|
|
Evas_Font_Set *font;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2013-03-12 03:01:32 -07:00
|
|
|
float ascent, descent;
|
|
|
|
float max_ascent, max_descent;
|
2012-12-12 21:12:14 -08:00
|
|
|
|
2013-02-21 05:39:37 -08:00
|
|
|
Evas_BiDi_Direction bidi_dir : 2;
|
2011-01-30 02:36:02 -08:00
|
|
|
char changed : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Evas_Object_Text_Item
|
|
|
|
{
|
|
|
|
EINA_INLIST;
|
|
|
|
|
|
|
|
size_t text_pos;
|
|
|
|
size_t visual_pos;
|
2011-01-30 02:36:39 -08:00
|
|
|
Evas_Text_Props text_props;
|
2011-01-30 02:36:02 -08:00
|
|
|
Evas_Coord x, w, h, adv;
|
2002-11-08 00:02:15 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* private methods for text objects */
|
2012-10-08 18:58:41 -07:00
|
|
|
static void evas_object_text_init(Evas_Object *eo_obj);
|
2013-07-08 17:46:15 -07:00
|
|
|
static void evas_object_text_render(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *obj,
|
|
|
|
void *type_private_data,
|
|
|
|
void *output, void *context, void *surface, int x, int y, Eina_Bool do_async);
|
|
|
|
static void evas_object_text_free(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *obj);
|
|
|
|
static void evas_object_text_render_pre(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *obj,
|
|
|
|
void *type_private_data);
|
|
|
|
static void evas_object_text_render_post(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *obj,
|
|
|
|
void *type_private_data);
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
static unsigned int evas_object_text_id_get(Evas_Object *eo_obj);
|
|
|
|
static unsigned int evas_object_text_visual_id_get(Evas_Object *eo_obj);
|
|
|
|
static void *evas_object_text_engine_data_get(Evas_Object *eo_obj);
|
2008-08-25 22:45:04 -07:00
|
|
|
|
2013-07-08 17:46:15 -07:00
|
|
|
static int evas_object_text_is_opaque(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *obj,
|
|
|
|
void *type_private_data);
|
|
|
|
static int evas_object_text_was_opaque(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *obj,
|
|
|
|
void *type_private_data);
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2013-07-08 17:46:15 -07:00
|
|
|
static void evas_object_text_scale_update(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *obj,
|
|
|
|
void *type_private_data);
|
2012-12-30 17:49:36 -08:00
|
|
|
static void _evas_object_text_recalc(Evas_Object *eo_obj, Eina_Unicode *text);
|
2008-11-15 02:39:46 -08:00
|
|
|
|
2007-05-06 04:29:37 -07:00
|
|
|
static const Evas_Object_Func object_func =
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
/* methods (compulsory) */
|
2012-10-08 18:58:41 -07:00
|
|
|
NULL,
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_text_render,
|
|
|
|
evas_object_text_render_pre,
|
|
|
|
evas_object_text_render_post,
|
2008-08-30 19:04:31 -07:00
|
|
|
evas_object_text_id_get,
|
|
|
|
evas_object_text_visual_id_get,
|
2008-08-25 22:45:04 -07:00
|
|
|
evas_object_text_engine_data_get,
|
2002-11-08 00:02:15 -08:00
|
|
|
/* these are optional. NULL = nothing */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
evas_object_text_is_opaque,
|
|
|
|
evas_object_text_was_opaque,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2008-11-15 02:39:46 -08:00
|
|
|
NULL,
|
2009-02-16 20:53:03 -08:00
|
|
|
evas_object_text_scale_update,
|
|
|
|
NULL,
|
2010-08-18 08:11:07 -07:00
|
|
|
NULL,
|
2009-02-16 20:53:03 -08:00
|
|
|
NULL
|
2002-11-08 00:02:15 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* the actual api call to add a rect */
|
|
|
|
/* it has no other api calls as all properties are standard */
|
2003-03-04 18:30:20 -08:00
|
|
|
|
2011-01-30 02:36:02 -08:00
|
|
|
static int
|
2012-10-08 18:58:41 -07:00
|
|
|
_evas_object_text_char_coords_get(const Evas_Object *eo_obj,
|
2014-03-09 00:31:28 -08:00
|
|
|
const Evas_Text_Data *o,
|
2011-01-30 02:36:02 -08:00
|
|
|
size_t pos, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
|
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2011-01-30 02:36:02 -08:00
|
|
|
Evas_Object_Text_Item *it;
|
|
|
|
|
|
|
|
EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it)
|
|
|
|
{
|
|
|
|
if ((it->text_pos <= pos) &&
|
2011-05-03 23:57:35 -07:00
|
|
|
(pos < (it->text_pos + it->text_props.text_len)))
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-07-12 08:04:07 -07:00
|
|
|
int ret;
|
|
|
|
ret = ENFN->font_char_coords_get(ENDT, o->font,
|
2011-01-30 02:36:39 -08:00
|
|
|
&it->text_props, pos - it->text_pos, x, y, w, h);
|
2011-07-12 08:04:07 -07:00
|
|
|
if (x) *x += it->x;
|
|
|
|
return ret;
|
2011-01-30 02:36:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_text_item_clean(Evas_Object_Text_Item *it)
|
|
|
|
{
|
2011-01-30 02:36:39 -08:00
|
|
|
evas_common_text_props_content_unref(&it->text_props);
|
2011-01-30 02:36:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-03-09 00:31:28 -08:00
|
|
|
_evas_object_text_item_del(Evas_Text_Data *o, Evas_Object_Text_Item *it)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2013-01-11 00:31:09 -08:00
|
|
|
if (o->last_computed.ellipsis_start == it)
|
|
|
|
o->last_computed.ellipsis_start = NULL;
|
|
|
|
else if (o->last_computed.ellipsis_end == it)
|
|
|
|
o->last_computed.ellipsis_end = NULL;
|
|
|
|
|
2013-11-03 03:33:05 -08:00
|
|
|
if ((EINA_INLIST_GET(it)->next) ||
|
|
|
|
(EINA_INLIST_GET(it)->prev) ||
|
2013-11-03 18:27:59 -08:00
|
|
|
(EINA_INLIST_GET(o->items) == (EINA_INLIST_GET(it))))
|
2013-11-02 03:35:45 -07:00
|
|
|
o->items = (Evas_Object_Text_Item *)eina_inlist_remove
|
|
|
|
(EINA_INLIST_GET(o->items), EINA_INLIST_GET(it));
|
2012-12-12 06:05:29 -08:00
|
|
|
_evas_object_text_item_clean(it);
|
|
|
|
free(it);
|
|
|
|
}
|
2011-01-30 02:36:02 -08:00
|
|
|
|
2012-12-12 22:50:08 -08:00
|
|
|
static void
|
2014-03-09 00:31:28 -08:00
|
|
|
_evas_object_text_items_clean(Evas_Object_Protected_Data *obj, Evas_Text_Data *o)
|
2012-12-12 22:50:08 -08:00
|
|
|
{
|
|
|
|
/* FIXME: also preserve item */
|
2013-01-01 00:22:46 -08:00
|
|
|
if ((o->cur.font == o->prev.font) &&
|
|
|
|
(o->cur.fdesc == o->prev.fdesc) &&
|
|
|
|
(o->cur.size == o->prev.size) &&
|
|
|
|
(!memcmp(&o->cur.outline, &o->prev.outline, sizeof (o->cur.outline))) &&
|
|
|
|
(!memcmp(&o->cur.shadow, &o->prev.shadow, sizeof (o->cur.shadow))) &&
|
|
|
|
(!memcmp(&o->cur.glow, &o->prev.glow, sizeof (o->cur.glow))) &&
|
|
|
|
(!memcmp(&o->cur.glow2, &o->prev.glow2, sizeof (o->cur.glow2))) &&
|
|
|
|
(o->cur.style == o->prev.style) &&
|
2013-03-12 05:58:19 -07:00
|
|
|
(obj->cur->scale == obj->prev->scale))
|
2012-12-12 22:50:08 -08:00
|
|
|
{
|
2013-01-01 00:22:46 -08:00
|
|
|
if ((o->last_computed.ellipsis_start) &&
|
|
|
|
(o->last_computed.ellipsis_start == o->items))
|
2012-12-12 22:50:08 -08:00
|
|
|
o->items = (Evas_Object_Text_Item *) eina_inlist_remove(EINA_INLIST_GET(o->items),
|
2012-12-27 16:58:10 -08:00
|
|
|
EINA_INLIST_GET(o->last_computed.ellipsis_start));
|
2013-01-01 00:22:46 -08:00
|
|
|
if ((o->last_computed.ellipsis_end) &&
|
|
|
|
(EINA_INLIST_GET(o->last_computed.ellipsis_end) == EINA_INLIST_GET(o->items)->last))
|
2012-12-12 22:50:08 -08:00
|
|
|
o->items = (Evas_Object_Text_Item *) eina_inlist_remove(EINA_INLIST_GET(o->items),
|
2012-12-27 16:58:10 -08:00
|
|
|
EINA_INLIST_GET(o->last_computed.ellipsis_end));
|
2012-12-12 22:50:08 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-28 02:44:26 -07:00
|
|
|
/* It is not guaranteed that the ellipsis are still inside the items, so remove them by force */
|
|
|
|
if (o->last_computed.ellipsis_start)
|
|
|
|
_evas_object_text_item_del(o, o->last_computed.ellipsis_start);
|
2012-12-12 22:50:08 -08:00
|
|
|
o->last_computed.ellipsis_start = NULL;
|
2013-10-28 02:44:26 -07:00
|
|
|
|
|
|
|
if (o->last_computed.ellipsis_end)
|
|
|
|
_evas_object_text_item_del(o, o->last_computed.ellipsis_end);
|
2012-12-12 22:50:08 -08:00
|
|
|
o->last_computed.ellipsis_end = NULL;
|
|
|
|
}
|
|
|
|
while (o->items)
|
|
|
|
{
|
|
|
|
_evas_object_text_item_del(o, o->items);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-12 06:05:29 -08:00
|
|
|
static void
|
2014-03-09 00:31:28 -08:00
|
|
|
_evas_object_text_items_clear(Evas_Text_Data *o)
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
2013-01-01 00:22:46 -08:00
|
|
|
if ((o->last_computed.ellipsis_start) &&
|
|
|
|
(o->last_computed.ellipsis_start != o->items))
|
2012-12-12 22:50:08 -08:00
|
|
|
{
|
2013-10-28 03:45:46 -07:00
|
|
|
_evas_object_text_item_del(o, o->last_computed.ellipsis_start);
|
2012-12-12 22:50:08 -08:00
|
|
|
}
|
|
|
|
o->last_computed.ellipsis_start = NULL;
|
2013-01-01 00:22:46 -08:00
|
|
|
if ((o->last_computed.ellipsis_end) &&
|
|
|
|
(EINA_INLIST_GET(o->last_computed.ellipsis_end) != EINA_INLIST_GET(o->items)->last))
|
2012-12-12 22:50:08 -08:00
|
|
|
{
|
2013-10-28 03:45:46 -07:00
|
|
|
_evas_object_text_item_del(o, o->last_computed.ellipsis_end);
|
2012-12-12 22:50:08 -08:00
|
|
|
}
|
|
|
|
o->last_computed.ellipsis_end = NULL;
|
2011-01-30 02:36:02 -08:00
|
|
|
while (o->items)
|
|
|
|
{
|
2012-12-12 06:05:29 -08:00
|
|
|
_evas_object_text_item_del(o, o->items);
|
2011-01-30 02:36:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 02:40:14 -08:00
|
|
|
#ifdef BIDI_SUPPORT
|
2011-01-30 02:38:55 -08:00
|
|
|
static int
|
|
|
|
_evas_object_text_it_compare_logical(const void *_it1, const void *_it2)
|
|
|
|
{
|
|
|
|
const Evas_Object_Text_Item *it1 = _it1, *it2 = _it2;
|
|
|
|
if (it1->text_pos < it2->text_pos)
|
|
|
|
return -1;
|
|
|
|
else if (it1->text_pos == it2->text_pos)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
2011-01-30 02:40:14 -08:00
|
|
|
#endif
|
2011-04-08 00:26:20 -07:00
|
|
|
|
2011-01-30 02:36:02 -08:00
|
|
|
static int
|
2012-10-08 18:58:41 -07:00
|
|
|
_evas_object_text_last_up_to_pos(const Evas_Object *eo_obj,
|
2014-03-09 00:31:28 -08:00
|
|
|
const Evas_Text_Data *o, Evas_Coord cx, Evas_Coord cy)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2011-01-30 02:36:02 -08:00
|
|
|
Evas_Object_Text_Item *it;
|
|
|
|
|
2011-01-30 02:38:55 -08:00
|
|
|
#ifdef BIDI_SUPPORT
|
|
|
|
/*FIXME: not very efficient, sort the items arrays. */
|
|
|
|
/* Reorder if it's a bidi text */
|
|
|
|
if (o->bidi_par_props)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-01-30 02:38:55 -08:00
|
|
|
Eina_List *logical_it = NULL;
|
|
|
|
Evas_Object_Text_Item *i;
|
|
|
|
Eina_List *itr;
|
|
|
|
Evas_Coord x = 0;
|
|
|
|
/* Insert all to the logical list */
|
|
|
|
EINA_INLIST_FOREACH(o->items, i)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-01-30 02:38:55 -08:00
|
|
|
logical_it = eina_list_sorted_insert(logical_it,
|
|
|
|
_evas_object_text_it_compare_logical, i);
|
|
|
|
}
|
|
|
|
EINA_LIST_FOREACH(logical_it, itr, it)
|
|
|
|
{
|
|
|
|
if ((x <= cx) && (cx < x + it->adv))
|
|
|
|
{
|
|
|
|
return it->text_pos + ENFN->font_last_up_to_pos(ENDT,
|
2011-05-29 06:00:54 -07:00
|
|
|
o->font,
|
2011-04-07 09:25:56 -07:00
|
|
|
&it->text_props,
|
2011-01-30 02:38:55 -08:00
|
|
|
cx - x,
|
|
|
|
cy);
|
|
|
|
}
|
|
|
|
x += it->adv;
|
|
|
|
}
|
|
|
|
eina_list_free(logical_it);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it)
|
|
|
|
{
|
|
|
|
if ((it->x <= cx) && (cx < it->x + it->adv))
|
|
|
|
{
|
|
|
|
return it->text_pos + ENFN->font_last_up_to_pos(ENDT,
|
2011-05-29 06:00:54 -07:00
|
|
|
o->font,
|
2011-04-07 09:25:56 -07:00
|
|
|
&it->text_props,
|
2011-01-30 02:38:55 -08:00
|
|
|
cx - it->x,
|
|
|
|
cy);
|
|
|
|
}
|
2011-01-30 02:36:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-08 18:58:41 -07:00
|
|
|
_evas_object_text_char_at_coords(const Evas_Object *eo_obj,
|
2014-03-09 00:31:28 -08:00
|
|
|
const Evas_Text_Data *o, Evas_Coord cx, Evas_Coord cy,
|
2011-01-30 02:36:02 -08:00
|
|
|
Evas_Coord *rx, Evas_Coord *ry, Evas_Coord *rw, Evas_Coord *rh)
|
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2011-01-30 02:36:02 -08:00
|
|
|
Evas_Object_Text_Item *it;
|
|
|
|
|
|
|
|
EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it)
|
|
|
|
{
|
2011-01-30 02:38:55 -08:00
|
|
|
if ((it->x <= cx) && (cx < it->x + it->adv))
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-01-30 02:38:44 -08:00
|
|
|
return it->text_pos + ENFN->font_char_at_coords_get(ENDT,
|
2011-05-29 06:00:54 -07:00
|
|
|
o->font,
|
2011-04-07 09:25:56 -07:00
|
|
|
&it->text_props,
|
2011-07-12 08:04:10 -07:00
|
|
|
cx - it->x,
|
2011-01-30 02:36:02 -08:00
|
|
|
cy,
|
|
|
|
rx, ry,
|
|
|
|
rw, rh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-17 03:29:16 -07:00
|
|
|
static Evas_Coord
|
|
|
|
_evas_object_text_horiz_advance_without_ellipsis_get(const Evas_Text_Data *o)
|
|
|
|
{
|
|
|
|
return o->last_computed.advance_without_ellipsis;
|
|
|
|
}
|
|
|
|
|
2011-01-30 02:36:02 -08:00
|
|
|
static Evas_Coord
|
2014-03-09 00:31:28 -08:00
|
|
|
_evas_object_text_horiz_advance_get(const Evas_Text_Data *o)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2013-10-02 03:07:48 -07:00
|
|
|
return o->last_computed.advance;
|
2011-01-30 02:36:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Coord
|
2012-11-04 03:51:42 -08:00
|
|
|
_evas_object_text_vert_advance_get(const Evas_Object *obj EINA_UNUSED,
|
2014-03-09 00:31:28 -08:00
|
|
|
const Evas_Text_Data *o)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-01-30 02:44:17 -08:00
|
|
|
return o->max_ascent + o->max_descent;
|
2011-01-30 02:36:02 -08:00
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI Evas_Object *
|
2002-11-08 00:02:15 -08:00
|
|
|
evas_object_text_add(Evas *e)
|
|
|
|
{
|
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object *eo_obj = eo_add(EVAS_TEXT_CLASS, e);
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_unref(eo_obj);
|
|
|
|
return eo_obj;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
2014-03-18 07:01:24 -07:00
|
|
|
_evas_text_eo_base_constructor(Eo *eo_obj, Evas_Text_Data *class_data EINA_UNUSED)
|
2004-01-22 18:14:45 -08:00
|
|
|
{
|
2013-03-18 08:33:54 -07:00
|
|
|
eo_do_super(eo_obj, MY_CLASS, eo_constructor());
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_text_init(eo_obj);
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2014-04-02 03:16:09 -07:00
|
|
|
Eo *parent = NULL;
|
2013-09-24 21:32:56 -07:00
|
|
|
|
2014-04-02 03:16:09 -07:00
|
|
|
eo_do(eo_obj, parent = eo_parent_get());
|
2013-09-24 21:32:56 -07:00
|
|
|
evas_object_inject(eo_obj, obj, evas_object_evas_get(parent));
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_font_source_set(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o, const char *font_source)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2005-05-21 19:49:50 -07:00
|
|
|
if ((o->cur.source) && (font_source) &&
|
|
|
|
(!strcmp(o->cur.source, font_source)))
|
2004-01-22 18:14:45 -08:00
|
|
|
return;
|
2010-07-17 12:49:16 -07:00
|
|
|
/*
|
2008-10-15 07:38:34 -07:00
|
|
|
if (o->cur.source) eina_stringshare_del(o->cur.source);
|
|
|
|
if (font_source) o->cur.source = eina_stringshare_add(font_source);
|
2004-01-22 18:14:45 -08:00
|
|
|
else o->cur.source = NULL;
|
2010-07-17 12:49:16 -07:00
|
|
|
*/
|
|
|
|
eina_stringshare_replace(&o->cur.source, font_source);
|
2004-01-22 18:14:45 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static const char*
|
|
|
|
_evas_text_font_source_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
return o->cur.source;
|
2004-01-22 18:14:45 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_font_set(Eo *eo_obj, Evas_Text_Data *o, const char *font, Evas_Font_Size size)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2012-10-21 22:02:53 -07:00
|
|
|
Eina_Bool is, was = EINA_FALSE;
|
|
|
|
Eina_Bool pass = EINA_FALSE, freeze = EINA_FALSE;
|
|
|
|
Eina_Bool source_invisible = EINA_FALSE;
|
2011-08-01 01:20:52 -07:00
|
|
|
Evas_Font_Description *fdesc;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2010-07-17 12:49:16 -07:00
|
|
|
if ((!font) || (size <= 0)) return;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2013-02-07 02:48:07 -08:00
|
|
|
if (!(o->cur.font && !strcmp(font, o->cur.font)))
|
|
|
|
{
|
2013-02-11 22:07:25 -08:00
|
|
|
fdesc = evas_font_desc_new();
|
2013-02-07 02:48:07 -08:00
|
|
|
evas_font_name_parse(fdesc, font);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fdesc = evas_font_desc_ref(o->cur.fdesc);
|
|
|
|
}
|
2014-03-09 00:31:28 -08:00
|
|
|
|
2011-08-01 01:20:52 -07:00
|
|
|
if (o->cur.fdesc && !evas_font_desc_cmp(fdesc, o->cur.fdesc) &&
|
2013-02-07 02:48:07 -08:00
|
|
|
(size == o->cur.size))
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2011-08-01 01:20:52 -07:00
|
|
|
evas_font_desc_unref(fdesc);
|
|
|
|
return;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2011-08-01 01:20:52 -07:00
|
|
|
|
|
|
|
if (o->cur.fdesc) evas_font_desc_unref(o->cur.fdesc);
|
|
|
|
o->cur.fdesc = fdesc;
|
|
|
|
|
|
|
|
o->cur.size = size;
|
|
|
|
eina_stringshare_replace(&o->cur.font, font);
|
|
|
|
o->prev.font = NULL;
|
|
|
|
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
if (!(obj->layer->evas->is_frozen))
|
2005-07-22 03:28:11 -07:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
pass = evas_event_passes_through(eo_obj, obj);
|
|
|
|
freeze = evas_event_freezes_through(eo_obj, obj);
|
2012-10-21 21:57:32 -07:00
|
|
|
source_invisible = evas_object_is_source_invisible(eo_obj, obj);
|
|
|
|
if ((!pass) && (!freeze) && (!source_invisible))
|
2012-10-08 18:58:41 -07:00
|
|
|
was = evas_object_is_in_output_rect(eo_obj, obj,
|
2011-10-31 07:50:00 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y, 1, 1);
|
2005-07-22 03:28:11 -07:00
|
|
|
}
|
2010-05-21 00:10:45 -07:00
|
|
|
|
2003-01-09 20:58:51 -08:00
|
|
|
/* DO IT */
|
2011-05-29 06:00:54 -07:00
|
|
|
if (o->font)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_font_free(obj->layer->evas->evas, o->font);
|
2011-10-31 07:50:00 -07:00
|
|
|
o->font = NULL;
|
2004-01-22 23:53:08 -08:00
|
|
|
}
|
2011-08-01 01:20:52 -07:00
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
o->font = evas_font_load(obj->layer->evas->evas, o->cur.fdesc, o->cur.source,
|
2013-03-12 05:58:19 -07:00
|
|
|
(int)(((double) o->cur.size) * obj->cur->scale));
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2011-01-30 02:44:23 -08:00
|
|
|
o->ascent = 0;
|
|
|
|
o->descent = 0;
|
|
|
|
o->max_ascent = 0;
|
|
|
|
o->max_descent = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2013-11-03 22:28:16 -08:00
|
|
|
_evas_object_text_items_clear(o);
|
2012-12-30 17:49:36 -08:00
|
|
|
_evas_object_text_recalc(eo_obj, o->cur.text);
|
2002-11-08 00:02:15 -08:00
|
|
|
o->changed = 1;
|
2014-01-02 18:11:40 -08:00
|
|
|
o->cur.filter.changed = EINA_TRUE;
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_change(eo_obj, obj);
|
|
|
|
evas_object_clip_dirty(eo_obj, obj);
|
|
|
|
evas_object_coords_recalc(eo_obj, obj);
|
|
|
|
if (!(obj->layer->evas->is_frozen))
|
2003-07-21 22:16:47 -07:00
|
|
|
{
|
2011-10-31 07:50:00 -07:00
|
|
|
if ((!pass) && (!freeze))
|
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
is = evas_object_is_in_output_rect(eo_obj, obj,
|
2011-10-31 07:50:00 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y,
|
|
|
|
1, 1);
|
2013-03-12 05:58:19 -07:00
|
|
|
if ((is ^ was) && obj->cur->visible)
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_event_feed_mouse_move(obj->layer->evas->evas,
|
2011-10-31 07:50:00 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y,
|
|
|
|
obj->layer->evas->last_timestamp,
|
|
|
|
NULL);
|
|
|
|
}
|
2003-07-21 22:16:47 -07:00
|
|
|
}
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_inform_call_resize(eo_obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_font_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o, const char **font, Evas_Font_Size *size)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2003-04-15 19:04:30 -07:00
|
|
|
if (font) *font = o->cur.font;
|
|
|
|
if (size) *size = o->cur.size;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2012-12-12 06:05:29 -08:00
|
|
|
static void
|
2014-03-09 00:31:28 -08:00
|
|
|
_evas_object_text_item_update_sizes(Evas_Object_Protected_Data *obj, Evas_Text_Data *o, Evas_Object_Text_Item *it)
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
|
|
|
ENFN->font_string_size_get(ENDT,
|
|
|
|
o->font,
|
|
|
|
&it->text_props,
|
|
|
|
&it->w, &it->h);
|
|
|
|
it->adv = ENFN->font_h_advance_get(ENDT, o->font,
|
|
|
|
&it->text_props);
|
|
|
|
}
|
2011-01-30 02:36:02 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* Create a new text layout item from the string and the format.
|
|
|
|
*
|
|
|
|
* @param c the context to work on - Not NULL.
|
|
|
|
* @param fmt the format to use.
|
|
|
|
* @param str the string to use.
|
|
|
|
*/
|
|
|
|
static Evas_Object_Text_Item *
|
2012-12-12 06:05:29 -08:00
|
|
|
_evas_object_text_item_new(Evas_Object_Protected_Data *obj,
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o,
|
2012-12-12 06:05:29 -08:00
|
|
|
Evas_Font_Instance *fi, const Eina_Unicode *str,
|
|
|
|
Evas_Script_Type script,
|
|
|
|
size_t pos, size_t visual_pos, size_t len)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Text_Item *it;
|
|
|
|
|
|
|
|
it = calloc(1, sizeof(Evas_Object_Text_Item));
|
|
|
|
it->text_pos = pos;
|
|
|
|
it->visual_pos = visual_pos;
|
2011-01-30 02:36:39 -08:00
|
|
|
evas_common_text_props_bidi_set(&it->text_props, o->bidi_par_props,
|
|
|
|
it->text_pos);
|
2011-05-29 02:20:18 -07:00
|
|
|
evas_common_text_props_script_set(&it->text_props, script);
|
|
|
|
|
2011-05-30 01:42:26 -07:00
|
|
|
if (fi)
|
2011-01-30 02:45:17 -08:00
|
|
|
{
|
2011-02-01 04:18:11 -08:00
|
|
|
ENFN->font_text_props_info_create(ENDT,
|
2011-05-29 02:20:18 -07:00
|
|
|
fi, str + pos, &it->text_props,
|
2012-06-12 07:14:52 -07:00
|
|
|
o->bidi_par_props, it->text_pos, len, EVAS_TEXT_PROPS_MODE_SHAPE);
|
2012-12-12 06:05:29 -08:00
|
|
|
_evas_object_text_item_update_sizes(obj, o, it);
|
2011-01-30 02:45:17 -08:00
|
|
|
}
|
2011-01-30 02:36:02 -08:00
|
|
|
o->items = (Evas_Object_Text_Item *)
|
|
|
|
eina_inlist_append(EINA_INLIST_GET(o->items), EINA_INLIST_GET(it));
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* Orders o->items according to the visual position.
|
|
|
|
*
|
|
|
|
* @param obj the evas object
|
|
|
|
* @param o the text object
|
|
|
|
*/
|
|
|
|
static void
|
2014-03-09 00:31:28 -08:00
|
|
|
_evas_object_text_item_order(Evas_Object *eo_obj, Evas_Text_Data *o)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
(void) eo_obj;
|
2011-01-30 02:36:02 -08:00
|
|
|
#ifdef BIDI_SUPPORT
|
|
|
|
/*FIXME: not very efficient, sort the items arrays. */
|
|
|
|
/* Reorder if it's a bidi text */
|
|
|
|
if (o->bidi_par_props)
|
|
|
|
{
|
|
|
|
Evas_Object_Text_Item *i, *j, *min;
|
|
|
|
i = o->items;
|
|
|
|
while (i)
|
|
|
|
{
|
|
|
|
min = i;
|
|
|
|
EINA_INLIST_FOREACH(i, j)
|
|
|
|
{
|
|
|
|
if (j->visual_pos < min->visual_pos)
|
|
|
|
{
|
|
|
|
min = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (min != i)
|
|
|
|
{
|
|
|
|
o->items = (Evas_Object_Text_Item *) eina_inlist_remove(EINA_INLIST_GET(o->items), EINA_INLIST_GET(min));
|
|
|
|
o->items = (Evas_Object_Text_Item *) eina_inlist_prepend_relative(EINA_INLIST_GET(o->items), EINA_INLIST_GET(min), EINA_INLIST_GET(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
i = (Evas_Object_Text_Item *) EINA_INLIST_GET(min)->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* calculate the positions according to the order. */
|
|
|
|
{
|
|
|
|
Evas_Object_Text_Item *it = o->items;
|
|
|
|
Evas_Coord x = 0;
|
|
|
|
|
|
|
|
while (it)
|
|
|
|
{
|
|
|
|
it->x = x;
|
|
|
|
x += it->adv;
|
|
|
|
it = (Evas_Object_Text_Item *) EINA_INLIST_GET(it)->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-12 06:05:29 -08:00
|
|
|
/**
|
|
|
|
* Create ellipsis.
|
|
|
|
*/
|
|
|
|
static const Eina_Unicode _ellip_str[2] = { 0x2026, '\0' };
|
|
|
|
|
|
|
|
/* FIXME: We currently leak ellipsis items. */
|
|
|
|
static Evas_Object_Text_Item *
|
2014-03-09 00:31:28 -08:00
|
|
|
_layout_ellipsis_item_new(Evas_Object_Protected_Data *obj, Evas_Text_Data *o)
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
2013-10-29 01:00:48 -07:00
|
|
|
Evas_Object_Text_Item *ellip_ti = NULL;
|
2013-10-16 01:57:34 -07:00
|
|
|
Evas_Script_Type script;
|
2013-10-29 01:00:48 -07:00
|
|
|
Evas_Font_Instance *script_fi = NULL, *cur_fi = NULL;
|
2012-12-12 06:05:29 -08:00
|
|
|
size_t len = 1; /* The length of _ellip_str */
|
|
|
|
|
2013-10-16 01:57:34 -07:00
|
|
|
script = evas_common_language_script_type_get(_ellip_str, 1);
|
|
|
|
|
|
|
|
if (o->font)
|
|
|
|
{
|
|
|
|
(void) ENFN->font_run_end_get(ENDT, o->font, &script_fi, &cur_fi,
|
|
|
|
script, _ellip_str, 1);
|
2013-10-29 01:00:48 -07:00
|
|
|
ellip_ti = _evas_object_text_item_new(obj, o, cur_fi,
|
|
|
|
_ellip_str, script, 0, 0, len);
|
2013-10-16 01:57:34 -07:00
|
|
|
}
|
|
|
|
|
2012-12-12 06:05:29 -08:00
|
|
|
return ellip_ti;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EINA_TRUE if this item is ok and should be included, false if should be
|
|
|
|
* discarded. */
|
|
|
|
static Eina_Bool
|
2014-03-09 00:31:28 -08:00
|
|
|
_layout_text_item_trim(Evas_Object_Protected_Data *obj, Evas_Text_Data *o, Evas_Object_Text_Item *ti, int idx, Eina_Bool want_start)
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
|
|
|
Evas_Text_Props new_text_props;
|
2014-05-21 02:39:36 -07:00
|
|
|
if (idx >= (int) ti->text_props.text_len)
|
2012-12-12 06:05:29 -08:00
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
memset(&new_text_props, 0, sizeof (new_text_props));
|
|
|
|
|
2012-12-13 02:36:00 -08:00
|
|
|
while (!evas_common_text_props_split(&ti->text_props, &new_text_props, idx))
|
|
|
|
idx--;
|
2012-12-12 06:05:29 -08:00
|
|
|
if (want_start)
|
|
|
|
{
|
|
|
|
evas_common_text_props_content_unref(&new_text_props);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_common_text_props_content_unref(&ti->text_props);
|
|
|
|
memcpy(&ti->text_props, &new_text_props, sizeof(ti->text_props));
|
|
|
|
ti->text_pos += idx;
|
|
|
|
ti->visual_pos += idx;
|
|
|
|
}
|
|
|
|
_evas_object_text_item_update_sizes(obj, o, ti);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2011-01-30 02:36:02 -08:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* Populates o->items with the items of the text according to text
|
|
|
|
*
|
|
|
|
* @param obj the evas object
|
|
|
|
* @param o the text object
|
|
|
|
* @param text the text to layout
|
|
|
|
*/
|
|
|
|
static void
|
2014-03-09 00:31:28 -08:00
|
|
|
_evas_object_text_layout(Evas_Object *eo_obj, Evas_Text_Data *o, Eina_Unicode *text)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2011-01-30 02:36:02 -08:00
|
|
|
EvasBiDiStrIndex *v_to_l = NULL;
|
2012-12-12 06:05:29 -08:00
|
|
|
Evas_Coord advance = 0;
|
2011-01-30 02:36:02 -08:00
|
|
|
size_t pos, visual_pos;
|
2012-01-18 15:33:21 -08:00
|
|
|
int len = eina_unicode_strlen(text);
|
2013-10-02 04:52:59 -07:00
|
|
|
int l = 0, r = 0;
|
2011-01-30 02:36:02 -08:00
|
|
|
#ifdef BIDI_SUPPORT
|
2012-01-18 15:33:21 -08:00
|
|
|
int par_len = len;
|
2011-04-14 08:34:01 -07:00
|
|
|
int *segment_idxs = NULL;
|
2012-12-12 21:12:14 -08:00
|
|
|
#endif
|
|
|
|
|
2012-12-17 05:04:35 -08:00
|
|
|
if (o->items &&
|
|
|
|
!memcmp(&o->cur, &o->prev, sizeof (o->cur)) &&
|
2012-12-16 19:34:08 -08:00
|
|
|
o->cur.text == text &&
|
2013-03-12 05:58:19 -07:00
|
|
|
obj->cur->scale == obj->prev->scale &&
|
2013-10-01 04:34:03 -07:00
|
|
|
((o->last_computed.advance <= obj->cur->geometry.w && !o->last_computed.ellipsis) ||
|
|
|
|
o->last_computed.w == obj->cur->geometry.w))
|
2013-06-20 04:28:18 -07:00
|
|
|
return;
|
2012-12-12 21:12:14 -08:00
|
|
|
|
2013-10-01 04:34:03 -07:00
|
|
|
o->last_computed.ellipsis = EINA_FALSE;
|
2013-02-28 13:36:32 -08:00
|
|
|
evas_object_content_change(eo_obj, obj);
|
|
|
|
|
2012-12-16 19:34:08 -08:00
|
|
|
if (o->items) _evas_object_text_items_clean(obj, o);
|
|
|
|
|
2013-02-21 05:39:37 -08:00
|
|
|
if (text && *text)
|
|
|
|
o->bidi_dir = EVAS_BIDI_DIRECTION_LTR;
|
|
|
|
else
|
|
|
|
o->bidi_dir = EVAS_BIDI_DIRECTION_NEUTRAL;
|
|
|
|
|
2012-12-12 21:12:14 -08:00
|
|
|
#ifdef BIDI_SUPPORT
|
2011-04-14 08:34:01 -07:00
|
|
|
if (o->bidi_delimiters)
|
|
|
|
segment_idxs = evas_bidi_segment_idxs_get(text, o->bidi_delimiters);
|
2011-01-30 02:36:02 -08:00
|
|
|
evas_bidi_paragraph_props_unref(o->bidi_par_props);
|
2011-04-14 08:34:01 -07:00
|
|
|
o->bidi_par_props = evas_bidi_paragraph_props_get(text, len, segment_idxs);
|
2013-02-21 05:39:37 -08:00
|
|
|
|
|
|
|
if (o->bidi_par_props)
|
|
|
|
o->bidi_dir = EVAS_BIDI_PAR_TYPE_TO_DIRECTION(o->bidi_par_props->direction);
|
|
|
|
|
2011-01-30 02:36:02 -08:00
|
|
|
evas_bidi_props_reorder_line(NULL, 0, len, o->bidi_par_props, &v_to_l);
|
2011-04-14 08:34:01 -07:00
|
|
|
if (segment_idxs) free(segment_idxs);
|
2011-01-30 02:36:02 -08:00
|
|
|
#endif
|
|
|
|
visual_pos = pos = 0;
|
|
|
|
|
2011-05-29 02:20:18 -07:00
|
|
|
while (len > 0)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-05-29 06:00:54 -07:00
|
|
|
Evas_Font_Instance *script_fi = NULL;
|
2011-05-29 02:20:18 -07:00
|
|
|
int script_len = len, tmp_cut;
|
|
|
|
Evas_Script_Type script;
|
|
|
|
tmp_cut = evas_common_language_script_end_of_run_get(
|
2011-01-30 02:39:09 -08:00
|
|
|
text + pos,
|
2011-01-30 02:36:02 -08:00
|
|
|
o->bidi_par_props,
|
2011-05-29 02:20:18 -07:00
|
|
|
pos, len);
|
|
|
|
if (tmp_cut > 0)
|
|
|
|
script_len = tmp_cut;
|
|
|
|
|
2013-02-18 22:55:40 -08:00
|
|
|
script = evas_common_language_script_type_get(text + pos, script_len);
|
2011-05-29 02:20:18 -07:00
|
|
|
|
|
|
|
while (script_len > 0)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2012-12-12 06:05:29 -08:00
|
|
|
const Evas_Object_Text_Item *it;
|
2011-05-30 03:55:31 -07:00
|
|
|
Evas_Font_Instance *cur_fi = NULL;
|
2011-05-29 02:20:18 -07:00
|
|
|
int run_len = script_len;
|
2011-05-29 06:00:54 -07:00
|
|
|
if (o->font)
|
2011-05-29 02:20:18 -07:00
|
|
|
{
|
|
|
|
run_len = ENFN->font_run_end_get(ENDT,
|
2011-05-29 06:00:54 -07:00
|
|
|
o->font, &script_fi, &cur_fi,
|
2011-05-29 02:20:18 -07:00
|
|
|
script, text + pos, script_len);
|
|
|
|
}
|
2011-01-30 02:36:02 -08:00
|
|
|
#ifdef BIDI_SUPPORT
|
|
|
|
visual_pos = evas_bidi_position_logical_to_visual(
|
2011-06-01 08:08:47 -07:00
|
|
|
v_to_l, par_len, pos);
|
2011-01-30 02:36:02 -08:00
|
|
|
#else
|
|
|
|
visual_pos = pos;
|
|
|
|
#endif
|
2012-12-12 06:05:29 -08:00
|
|
|
it = _evas_object_text_item_new(obj, o, cur_fi, text, script,
|
|
|
|
pos, visual_pos, run_len);
|
2011-05-29 02:20:18 -07:00
|
|
|
|
2012-12-12 06:05:29 -08:00
|
|
|
advance += it->adv;
|
2011-05-29 02:20:18 -07:00
|
|
|
pos += run_len;
|
|
|
|
script_len -= run_len;
|
|
|
|
len -= run_len;
|
2011-01-30 02:36:02 -08:00
|
|
|
}
|
|
|
|
}
|
2014-03-17 03:29:16 -07:00
|
|
|
o->last_computed.advance_without_ellipsis = advance;
|
2011-01-30 02:36:02 -08:00
|
|
|
|
2014-01-02 18:11:40 -08:00
|
|
|
if (!o->cur.filter.chain)
|
2013-12-09 03:55:38 -08:00
|
|
|
evas_text_style_pad_get(o->cur.style, &l, &r, NULL, NULL);
|
|
|
|
else
|
2014-01-02 18:11:40 -08:00
|
|
|
evas_filter_program_padding_get(o->cur.filter.chain, &l, &r, NULL, NULL);
|
2013-10-02 04:52:59 -07:00
|
|
|
|
2012-12-12 06:05:29 -08:00
|
|
|
/* Handle ellipsis */
|
2013-10-02 04:52:59 -07:00
|
|
|
if (pos && (o->cur.ellipsis >= 0.0) && (advance + l + r > obj->cur->geometry.w) && (obj->cur->geometry.w > 0))
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
2013-03-12 05:58:19 -07:00
|
|
|
Evas_Coord ellip_frame = obj->cur->geometry.w;
|
2012-12-12 06:05:29 -08:00
|
|
|
Evas_Object_Text_Item *start_ellip_it = NULL, *end_ellip_it = NULL;
|
2013-10-01 04:34:03 -07:00
|
|
|
|
2013-10-02 04:52:59 -07:00
|
|
|
o->last_computed.ellipsis = EINA_TRUE;
|
|
|
|
|
2012-12-12 06:05:29 -08:00
|
|
|
/* Account of the ellipsis item width. As long as ellipsis != 0
|
|
|
|
* we have a left ellipsis. And the same with 1 and right. */
|
|
|
|
if (o->cur.ellipsis != 0)
|
|
|
|
{
|
2012-12-12 22:50:08 -08:00
|
|
|
if (o->last_computed.ellipsis_start)
|
|
|
|
{
|
|
|
|
start_ellip_it = o->last_computed.ellipsis_start;
|
|
|
|
o->items = (Evas_Object_Text_Item *)
|
|
|
|
eina_inlist_append(EINA_INLIST_GET(o->items), EINA_INLIST_GET(start_ellip_it));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-16 01:57:34 -07:00
|
|
|
start_ellip_it = _layout_ellipsis_item_new(obj, o);
|
2012-12-12 22:50:08 -08:00
|
|
|
}
|
|
|
|
o->last_computed.ellipsis_start = start_ellip_it;
|
2012-12-12 06:05:29 -08:00
|
|
|
ellip_frame -= start_ellip_it->adv;
|
|
|
|
}
|
|
|
|
if (o->cur.ellipsis != 1)
|
|
|
|
{
|
|
|
|
/* FIXME: Should take the last item's font and style and etc. *//* weird it's a text, should always have the same style/font */
|
2012-12-12 22:50:08 -08:00
|
|
|
if (o->last_computed.ellipsis_end)
|
|
|
|
{
|
|
|
|
end_ellip_it = o->last_computed.ellipsis_end;
|
|
|
|
o->items = (Evas_Object_Text_Item *)
|
|
|
|
eina_inlist_append(EINA_INLIST_GET(o->items), EINA_INLIST_GET(end_ellip_it));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-16 01:57:34 -07:00
|
|
|
end_ellip_it = _layout_ellipsis_item_new(obj, o);
|
2012-12-12 22:50:08 -08:00
|
|
|
}
|
|
|
|
o->last_computed.ellipsis_end = end_ellip_it;
|
2012-12-12 06:05:29 -08:00
|
|
|
ellip_frame -= end_ellip_it->adv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The point where we should start from, going for the full
|
|
|
|
* ellip frame. */
|
|
|
|
Evas_Coord ellipsis_coord = o->cur.ellipsis * (advance - ellip_frame);
|
|
|
|
if (start_ellip_it)
|
|
|
|
{
|
|
|
|
Evas_Object_Text_Item *itr = o->items;
|
|
|
|
advance = 0;
|
|
|
|
|
2013-10-02 04:52:59 -07:00
|
|
|
while (itr && (advance + l + r + itr->adv < ellipsis_coord))
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
|
|
|
Eina_Inlist *itrn = EINA_INLIST_GET(itr)->next;
|
|
|
|
if ((itr != start_ellip_it) && (itr != end_ellip_it))
|
|
|
|
{
|
|
|
|
advance += itr->adv;
|
|
|
|
_evas_object_text_item_del(o, itr);
|
|
|
|
}
|
|
|
|
itr = (Evas_Object_Text_Item *) itrn;
|
|
|
|
}
|
|
|
|
if (itr && (itr != start_ellip_it))
|
|
|
|
{
|
2013-02-25 07:39:32 -08:00
|
|
|
int cut = 1 + ENFN->font_last_up_to_pos(ENDT,
|
2012-12-12 06:05:29 -08:00
|
|
|
o->font,
|
|
|
|
&itr->text_props,
|
2013-10-02 04:52:59 -07:00
|
|
|
ellipsis_coord - (advance + l + r),
|
2013-02-25 07:39:32 -08:00
|
|
|
0);
|
2012-12-12 06:05:29 -08:00
|
|
|
if (cut > 0)
|
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
|
2012-12-12 06:05:29 -08:00
|
|
|
start_ellip_it->text_pos = itr->text_pos;
|
|
|
|
start_ellip_it->visual_pos = itr->visual_pos;
|
|
|
|
if (!_layout_text_item_trim(obj, o, itr, cut, EINA_FALSE))
|
|
|
|
{
|
|
|
|
_evas_object_text_item_del(o, itr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
o->items = (Evas_Object_Text_Item *) eina_inlist_remove(EINA_INLIST_GET(o->items), EINA_INLIST_GET(start_ellip_it));
|
|
|
|
o->items = (Evas_Object_Text_Item *) eina_inlist_prepend(EINA_INLIST_GET(o->items), EINA_INLIST_GET(start_ellip_it));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (end_ellip_it)
|
|
|
|
{
|
|
|
|
Evas_Object_Text_Item *itr = o->items;
|
|
|
|
advance = 0;
|
|
|
|
|
|
|
|
while (itr)
|
|
|
|
{
|
|
|
|
if (itr != end_ellip_it) /* was start_ellip_it */
|
|
|
|
{
|
2013-10-02 04:52:59 -07:00
|
|
|
if (advance + l + r + itr->adv >= ellip_frame)
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
advance += itr->adv;
|
|
|
|
}
|
|
|
|
itr = (Evas_Object_Text_Item *) EINA_INLIST_GET(itr)->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itr == end_ellip_it)
|
|
|
|
{
|
|
|
|
/* FIXME: We shouldn't do anything. */
|
|
|
|
}
|
|
|
|
|
2013-02-25 07:39:32 -08:00
|
|
|
int cut = ENFN->font_last_up_to_pos(ENDT,
|
2012-12-12 06:05:29 -08:00
|
|
|
o->font,
|
|
|
|
&itr->text_props,
|
2013-10-02 04:52:59 -07:00
|
|
|
ellip_frame - (advance + l + r),
|
2013-02-25 07:39:32 -08:00
|
|
|
0);
|
2012-12-12 06:05:29 -08:00
|
|
|
if (cut >= 0)
|
|
|
|
{
|
|
|
|
end_ellip_it->text_pos = itr->text_pos + cut;
|
|
|
|
end_ellip_it->visual_pos = itr->visual_pos + cut;
|
|
|
|
if (_layout_text_item_trim(obj, o, itr, cut, EINA_TRUE))
|
|
|
|
{
|
|
|
|
itr = (Evas_Object_Text_Item *) EINA_INLIST_GET(itr)->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove the rest of the items */
|
|
|
|
while (itr)
|
|
|
|
{
|
|
|
|
Eina_Inlist *itrn = EINA_INLIST_GET(itr)->next;
|
|
|
|
if ((itr != start_ellip_it) && (itr != end_ellip_it))
|
2013-10-01 04:34:03 -07:00
|
|
|
_evas_object_text_item_del(o, itr);
|
2012-12-12 06:05:29 -08:00
|
|
|
itr = (Evas_Object_Text_Item *) itrn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-17 05:04:35 -08:00
|
|
|
if (o->cur.text != text) free(o->cur.text);
|
2012-12-16 19:34:08 -08:00
|
|
|
o->cur.text = text;
|
2012-12-12 21:12:14 -08:00
|
|
|
o->prev = o->cur;
|
2013-10-01 04:34:03 -07:00
|
|
|
|
|
|
|
{
|
|
|
|
Evas_Object_Text_Item *itr = o->items;
|
|
|
|
advance = 0;
|
|
|
|
|
|
|
|
while (itr)
|
|
|
|
{
|
|
|
|
advance += itr->adv;
|
|
|
|
itr = (Evas_Object_Text_Item *) EINA_INLIST_GET(itr)->next;
|
|
|
|
}
|
|
|
|
o->last_computed.advance = advance;
|
|
|
|
}
|
2012-12-12 06:05:29 -08:00
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
_evas_object_text_item_order(eo_obj, o);
|
2011-01-30 02:36:02 -08:00
|
|
|
|
|
|
|
if (v_to_l) free(v_to_l);
|
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_evas_object_size_set(Eo *eo_obj, Evas_Text_Data *o, Evas_Coord w, Evas_Coord h)
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-12-30 17:49:36 -08:00
|
|
|
|
2013-08-05 01:43:17 -07:00
|
|
|
EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
|
|
|
|
{
|
|
|
|
state_write->geometry.w = w;
|
|
|
|
state_write->geometry.h = h;
|
|
|
|
}
|
|
|
|
EINA_COW_STATE_WRITE_END(obj, state_write, cur);
|
|
|
|
|
|
|
|
_evas_object_text_recalc(eo_obj, o->cur.text);
|
2012-12-12 06:05:29 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_ellipsis_set(Eo *eo_obj, Evas_Text_Data *o, double ellipsis)
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-12-12 06:05:29 -08:00
|
|
|
|
2013-06-20 04:28:18 -07:00
|
|
|
if (o->cur.ellipsis == ellipsis) return;
|
2012-12-12 06:05:29 -08:00
|
|
|
|
|
|
|
o->cur.ellipsis = ellipsis;
|
|
|
|
o->changed = 1;
|
2014-01-02 18:11:40 -08:00
|
|
|
o->cur.filter.changed = EINA_TRUE;
|
2012-12-12 06:05:29 -08:00
|
|
|
evas_object_change(eo_obj, obj);
|
|
|
|
evas_object_clip_dirty(eo_obj, obj);
|
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static double
|
|
|
|
_evas_text_ellipsis_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
return o->cur.ellipsis;
|
2012-12-12 06:05:29 -08:00
|
|
|
}
|
2011-01-30 02:36:02 -08:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_eo_base_dbg_info_get(Eo *eo_obj, Evas_Text_Data *o EINA_UNUSED, Eo_Dbg_Info *root)
|
2013-01-28 22:36:23 -08:00
|
|
|
{
|
2013-03-18 08:33:54 -07:00
|
|
|
eo_do_super(eo_obj, MY_CLASS, eo_dbg_info_get(root));
|
2013-01-28 22:36:23 -08:00
|
|
|
Eo_Dbg_Info *group = EO_DBG_INFO_LIST_APPEND(root, MY_CLASS_NAME);
|
|
|
|
|
|
|
|
const char *text;
|
|
|
|
int size;
|
|
|
|
eo_do(eo_obj, evas_obj_text_font_get(&text, &size));
|
2013-01-29 08:36:01 -08:00
|
|
|
EO_DBG_INFO_APPEND(group, "Font", EINA_VALUE_TYPE_STRING, text);
|
|
|
|
EO_DBG_INFO_APPEND(group, "Text size", EINA_VALUE_TYPE_INT, size);
|
2013-01-28 22:36:23 -08:00
|
|
|
|
2014-04-02 03:16:09 -07:00
|
|
|
eo_do(eo_obj, text = evas_obj_text_font_source_get());
|
2013-01-29 08:36:01 -08:00
|
|
|
EO_DBG_INFO_APPEND(group, "Font source", EINA_VALUE_TYPE_STRING, text);
|
2013-01-28 22:36:23 -08:00
|
|
|
|
2014-06-20 08:53:51 -07:00
|
|
|
eo_do(eo_obj, text = evas_obj_text_get());
|
2013-01-29 08:36:01 -08:00
|
|
|
EO_DBG_INFO_APPEND(group, "Text", EINA_VALUE_TYPE_STRING, text);
|
2013-01-28 22:36:23 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_text_set(Eo *eo_obj, Evas_Text_Data *o, const char *_text)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
int is, was, len;
|
|
|
|
Eina_Unicode *text;
|
|
|
|
|
2011-02-20 22:12:28 -08:00
|
|
|
if ((o->cur.utf8_text) && (_text) && (!strcmp(o->cur.utf8_text, _text)))
|
|
|
|
return;
|
2011-02-16 08:00:17 -08:00
|
|
|
text = eina_unicode_utf8_to_unicode(_text, &len);
|
2011-01-30 02:36:02 -08:00
|
|
|
|
|
|
|
if (!text) text = eina_unicode_strdup(EINA_UNICODE_EMPTY_STRING);
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
was = evas_object_is_in_output_rect(eo_obj, obj,
|
2012-08-26 00:04:46 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y, 1, 1);
|
2002-11-08 00:02:15 -08:00
|
|
|
/* DO II */
|
2011-01-30 02:35:17 -08:00
|
|
|
/*Update bidi_props*/
|
2011-01-30 02:36:02 -08:00
|
|
|
|
2013-10-28 02:44:26 -07:00
|
|
|
_evas_object_text_items_clear(o);
|
2010-07-28 05:00:41 -07:00
|
|
|
|
2012-12-30 17:49:36 -08:00
|
|
|
_evas_object_text_recalc(eo_obj, text);
|
|
|
|
eina_stringshare_replace(&o->cur.utf8_text, _text);
|
|
|
|
o->prev.utf8_text = NULL;
|
|
|
|
|
2012-12-30 17:59:00 -08:00
|
|
|
if (o->cur.text != text) free(text);
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
o->changed = 1;
|
2014-01-02 18:11:40 -08:00
|
|
|
o->cur.filter.changed = EINA_TRUE;
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_change(eo_obj, obj);
|
|
|
|
evas_object_clip_dirty(eo_obj, obj);
|
|
|
|
evas_object_coords_recalc(eo_obj, obj);
|
|
|
|
is = evas_object_is_in_output_rect(eo_obj, obj,
|
2012-08-26 00:04:46 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y, 1, 1);
|
2013-03-12 05:58:19 -07:00
|
|
|
if ((is || was) && obj->cur->visible)
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_event_feed_mouse_move(obj->layer->evas->evas,
|
2012-08-26 00:04:46 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y,
|
|
|
|
obj->layer->evas->last_timestamp,
|
|
|
|
NULL);
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_inform_call_resize(eo_obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_bidi_delimiters_set(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o, const char *delim)
|
2011-04-14 08:34:01 -07:00
|
|
|
{
|
|
|
|
eina_stringshare_replace(&o->bidi_delimiters, delim);
|
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static const char*
|
|
|
|
_evas_text_bidi_delimiters_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
return o->bidi_delimiters;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static const char*
|
|
|
|
_evas_text_text_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
return o->cur.utf8_text;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static Evas_BiDi_Direction
|
|
|
|
_evas_text_direction_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
return o->bidi_dir;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static Evas_Coord
|
|
|
|
_evas_text_ascent_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
return o->ascent;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static Evas_Coord
|
|
|
|
_evas_text_descent_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
return o->descent;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static Evas_Coord
|
|
|
|
_evas_text_max_ascent_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
return o->max_ascent;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static Evas_Coord
|
|
|
|
_evas_text_max_descent_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
return o->max_descent;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static Evas_Coord
|
|
|
|
_evas_text_inset_get(Eo *eo_obj, Evas_Text_Data *o)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
Evas_Coord inset = 0;
|
2014-03-09 00:31:28 -08:00
|
|
|
if (!o->font) return inset;
|
|
|
|
if (!o->items) return inset;
|
|
|
|
inset = ENFN->font_inset_get(ENDT, o->font, &o->items->text_props);
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
return inset;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static Evas_Coord
|
|
|
|
_evas_text_horiz_advance_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
Evas_Coord horiz = 0;
|
2014-03-09 00:31:28 -08:00
|
|
|
if (!o->font) return horiz;
|
|
|
|
if (!o->items) return horiz;
|
|
|
|
horiz = _evas_object_text_horiz_advance_get(o);
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
return horiz;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static Evas_Coord
|
|
|
|
_evas_text_vert_advance_get(Eo *eo_obj, Evas_Text_Data *o)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Coord vert;
|
|
|
|
vert = 0;
|
|
|
|
if (!o->font) return vert;
|
2012-10-08 18:58:41 -07:00
|
|
|
if (!o->items)
|
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
vert = o->ascent + o->descent;
|
|
|
|
return vert;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
2014-03-09 00:31:28 -08:00
|
|
|
vert = _evas_object_text_vert_advance_get(eo_obj, o);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
return vert;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_evas_text_char_pos_get(Eo *eo_obj, Evas_Text_Data *o, int pos, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
Eina_Bool ret;
|
|
|
|
ret = EINA_FALSE;
|
2012-10-08 18:58:41 -07:00
|
|
|
|
|
|
|
int l = 0, r = 0, t = 0, b = 0;
|
|
|
|
int x = 0, y = 0, w = 0, h = 0;
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
if (!o->font) return ret;
|
|
|
|
if (!o->items || (pos < 0)) return ret;
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
|
|
|
|
Eina_Bool int_ret = _evas_object_text_char_coords_get(eo_obj, o, (size_t) pos,
|
2011-01-30 02:36:02 -08:00
|
|
|
&x, &y, &w, &h);
|
2014-01-02 18:11:40 -08:00
|
|
|
if (!o->cur.filter.chain)
|
2013-12-09 03:55:38 -08:00
|
|
|
evas_text_style_pad_get(o->cur.style, &l, &r, &t, &b);
|
|
|
|
else
|
2014-01-02 18:11:40 -08:00
|
|
|
evas_filter_program_padding_get(o->cur.filter.chain, &l, &r, &t, &b);
|
2005-11-26 00:04:20 -08:00
|
|
|
y += o->max_ascent - t;
|
2010-10-13 07:14:40 -07:00
|
|
|
x -= l;
|
2003-06-06 19:32:30 -07:00
|
|
|
if (x < 0)
|
|
|
|
{
|
2012-08-26 00:04:46 -07:00
|
|
|
w += x;
|
|
|
|
x = 0;
|
2003-06-06 19:32:30 -07:00
|
|
|
}
|
2013-03-12 05:58:19 -07:00
|
|
|
if ((x + w) > obj->cur->geometry.w) w = obj->cur->geometry.w - x;
|
2003-06-06 19:32:30 -07:00
|
|
|
if (w < 0) w = 0;
|
|
|
|
if (y < 0)
|
|
|
|
{
|
2012-08-26 00:04:46 -07:00
|
|
|
h += y;
|
|
|
|
y = 0;
|
2003-06-06 19:32:30 -07:00
|
|
|
}
|
2013-03-12 05:58:19 -07:00
|
|
|
if ((y + h) > obj->cur->geometry.h) h = obj->cur->geometry.h - y;
|
2003-06-06 19:32:30 -07:00
|
|
|
if (h < 0) h = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
if (cx) *cx = x;
|
|
|
|
if (cy) *cy = y;
|
2005-11-26 00:04:20 -08:00
|
|
|
if (cw) *cw = w + l + r;
|
|
|
|
if (ch) *ch = h + t + b;
|
2014-03-09 00:31:28 -08:00
|
|
|
ret = int_ret;
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
return ret;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static int
|
|
|
|
_evas_text_last_up_to_pos(Eo *eo_obj, Evas_Text_Data *o, Evas_Coord x, Evas_Coord y)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
int ret;
|
|
|
|
ret = -1;
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
if (!o->font) return ret;
|
|
|
|
if (!o->items) return ret;
|
2012-10-08 18:58:41 -07:00
|
|
|
int int_ret = _evas_object_text_last_up_to_pos(eo_obj, o, x, y - o->max_ascent);
|
2014-03-09 00:31:28 -08:00
|
|
|
ret = int_ret;
|
|
|
|
|
|
|
|
return ret;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static int
|
|
|
|
_evas_text_char_coords_get(Eo *eo_obj, Evas_Text_Data *o, Evas_Coord x, Evas_Coord y, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
int ret;
|
|
|
|
ret = -1;
|
2009-09-29 21:23:21 -07:00
|
|
|
|
2005-11-26 00:04:20 -08:00
|
|
|
int l = 0, r = 0, t = 0, b = 0;
|
2012-10-08 18:58:41 -07:00
|
|
|
int rx = 0, ry = 0, rw = 0, rh = 0;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
if (!o->font) return ret;
|
|
|
|
if (!o->items) return ret;
|
2012-10-08 18:58:41 -07:00
|
|
|
|
|
|
|
int int_ret = _evas_object_text_char_at_coords(eo_obj, o, x, y - o->max_ascent,
|
2011-01-30 02:36:02 -08:00
|
|
|
&rx, &ry, &rw, &rh);
|
2014-01-02 18:11:40 -08:00
|
|
|
if (!o->cur.filter.chain)
|
2013-12-09 03:55:38 -08:00
|
|
|
evas_text_style_pad_get(o->cur.style, &l, &r, &t, &b);
|
|
|
|
else
|
2014-01-02 18:11:40 -08:00
|
|
|
evas_filter_program_padding_get(o->cur.filter.chain, &l, &r, &t, &b);
|
2005-11-26 00:04:20 -08:00
|
|
|
ry += o->max_ascent - t;
|
2010-10-13 07:14:40 -07:00
|
|
|
rx -= l;
|
2003-06-06 19:32:30 -07:00
|
|
|
if (rx < 0)
|
|
|
|
{
|
2012-08-26 00:04:46 -07:00
|
|
|
rw += rx;
|
|
|
|
rx = 0;
|
2003-06-06 19:32:30 -07:00
|
|
|
}
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2013-03-12 05:58:19 -07:00
|
|
|
if ((rx + rw) > obj->cur->geometry.w) rw = obj->cur->geometry.w - rx;
|
2003-06-06 19:32:30 -07:00
|
|
|
if (rw < 0) rw = 0;
|
|
|
|
if (ry < 0)
|
|
|
|
{
|
2012-08-26 00:04:46 -07:00
|
|
|
rh += ry;
|
|
|
|
ry = 0;
|
2003-06-06 19:32:30 -07:00
|
|
|
}
|
2013-03-12 05:58:19 -07:00
|
|
|
if ((ry + rh) > obj->cur->geometry.h) rh = obj->cur->geometry.h - ry;
|
2003-06-06 19:32:30 -07:00
|
|
|
if (rh < 0) rh = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
if (cx) *cx = rx;
|
|
|
|
if (cy) *cy = ry;
|
2005-11-26 00:04:20 -08:00
|
|
|
if (cw) *cw = rw + l + r;
|
|
|
|
if (ch) *ch = rh + t + b;
|
2014-03-09 00:31:28 -08:00
|
|
|
ret = int_ret;
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
return ret;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_style_set(Eo *eo_obj, Evas_Text_Data *o, Evas_Text_Style_Type style)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
int pl = 0, pr = 0, pt = 0, pb = 0, l = 0, r = 0, t = 0, b = 0;
|
2013-08-05 01:43:17 -07:00
|
|
|
int w = 0, h = 0;
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2010-07-17 12:49:16 -07:00
|
|
|
if (o->cur.style == style) return;
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2006-05-24 19:40:09 -07:00
|
|
|
evas_text_style_pad_get(o->cur.style, &pl, &pr, &pt, &pb);
|
2005-11-26 00:04:20 -08:00
|
|
|
o->cur.style = style;
|
2006-05-24 19:40:09 -07:00
|
|
|
evas_text_style_pad_get(o->cur.style, &l, &r, &t, &b);
|
2013-03-12 05:58:19 -07:00
|
|
|
|
2013-08-05 01:43:17 -07:00
|
|
|
if (o->items) w = obj->cur->geometry.w + (l - pl) + (r - pr);
|
|
|
|
h = obj->cur->geometry.h + (t - pt) + (b - pb);
|
2013-03-12 05:58:19 -07:00
|
|
|
|
2013-08-05 01:43:17 -07:00
|
|
|
eo_do_super(eo_obj, MY_CLASS,
|
|
|
|
evas_obj_size_set(w, h));
|
2014-07-16 04:30:51 -07:00
|
|
|
evas_object_change(eo_obj, obj);
|
2005-11-26 00:04:20 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static Evas_Text_Style_Type
|
|
|
|
_evas_text_style_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
return o->cur.style;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_shadow_color_set(Eo *eo_obj, Evas_Text_Data *o, int r, int g, int b, int a)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2005-11-26 00:04:20 -08:00
|
|
|
if ((o->cur.shadow.r == r) && (o->cur.shadow.g == g) &&
|
|
|
|
(o->cur.shadow.b == b) && (o->cur.shadow.a == a))
|
|
|
|
return;
|
|
|
|
o->cur.shadow.r = r;
|
|
|
|
o->cur.shadow.g = g;
|
|
|
|
o->cur.shadow.b = b;
|
|
|
|
o->cur.shadow.a = a;
|
2010-03-06 20:48:52 -08:00
|
|
|
o->changed = 1;
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_change(eo_obj, obj);
|
2005-11-26 00:04:20 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_shadow_color_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o, int *r, int *g, int *b, int *a)
|
2005-11-26 00:04:20 -08:00
|
|
|
{
|
|
|
|
if (r) *r = o->cur.shadow.r;
|
|
|
|
if (g) *g = o->cur.shadow.g;
|
|
|
|
if (b) *b = o->cur.shadow.b;
|
|
|
|
if (a) *a = o->cur.shadow.a;
|
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_glow_color_set(Eo *eo_obj, Evas_Text_Data *o, int r, int g, int b, int a)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2005-11-26 00:04:20 -08:00
|
|
|
if ((o->cur.glow.r == r) && (o->cur.glow.g == g) &&
|
|
|
|
(o->cur.glow.b == b) && (o->cur.glow.a == a))
|
|
|
|
return;
|
|
|
|
o->cur.glow.r = r;
|
|
|
|
o->cur.glow.g = g;
|
|
|
|
o->cur.glow.b = b;
|
|
|
|
o->cur.glow.a = a;
|
2010-03-06 20:48:52 -08:00
|
|
|
o->changed = 1;
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_change(eo_obj, obj);
|
2005-11-26 00:04:20 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_glow_color_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o, int *r, int *g, int *b, int *a)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2005-11-26 00:04:20 -08:00
|
|
|
if (r) *r = o->cur.glow.r;
|
|
|
|
if (g) *g = o->cur.glow.g;
|
|
|
|
if (b) *b = o->cur.glow.b;
|
|
|
|
if (a) *a = o->cur.glow.a;
|
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_glow2_color_set(Eo *eo_obj, Evas_Text_Data *o, int r, int g, int b, int a)
|
2005-11-26 00:04:20 -08:00
|
|
|
{
|
|
|
|
if ((o->cur.glow2.r == r) && (o->cur.glow2.g == g) &&
|
|
|
|
(o->cur.glow2.b == b) && (o->cur.glow2.a == a))
|
|
|
|
return;
|
|
|
|
o->cur.glow2.r = r;
|
|
|
|
o->cur.glow2.g = g;
|
|
|
|
o->cur.glow2.b = b;
|
|
|
|
o->cur.glow2.a = a;
|
2010-03-06 20:48:52 -08:00
|
|
|
o->changed = 1;
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_change(eo_obj, obj);
|
2005-11-26 00:04:20 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_glow2_color_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o, int *r, int *g, int *b, int *a)
|
2005-11-26 00:04:20 -08:00
|
|
|
{
|
|
|
|
if (r) *r = o->cur.glow2.r;
|
|
|
|
if (g) *g = o->cur.glow2.g;
|
|
|
|
if (b) *b = o->cur.glow2.b;
|
|
|
|
if (a) *a = o->cur.glow2.a;
|
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_outline_color_set(Eo *eo_obj, Evas_Text_Data *o, int r, int g, int b, int a)
|
2005-11-26 00:04:20 -08:00
|
|
|
{
|
|
|
|
if ((o->cur.outline.r == r) && (o->cur.outline.g == g) &&
|
|
|
|
(o->cur.outline.b == b) && (o->cur.outline.a == a))
|
|
|
|
return;
|
|
|
|
o->cur.outline.r = r;
|
|
|
|
o->cur.outline.g = g;
|
|
|
|
o->cur.outline.b = b;
|
|
|
|
o->cur.outline.a = a;
|
2010-03-06 20:48:52 -08:00
|
|
|
o->changed = 1;
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_change(eo_obj, obj);
|
2005-11-26 00:04:20 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_outline_color_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o, int *r, int *g, int *b, int *a)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2005-11-26 00:04:20 -08:00
|
|
|
if (r) *r = o->cur.outline.r;
|
|
|
|
if (g) *g = o->cur.outline.g;
|
|
|
|
if (b) *b = o->cur.outline.b;
|
|
|
|
if (a) *a = o->cur.outline.a;
|
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_style_pad_get(Eo *eo_obj EINA_UNUSED, Evas_Text_Data *o, int *l, int *r, int *t, int *b)
|
2005-11-26 00:04:20 -08:00
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
int sl = 0, sr = 0, st = 0, sb = 0;
|
2005-11-26 00:04:20 -08:00
|
|
|
/* use temps to be certain we have initialized values */
|
2014-01-02 18:11:40 -08:00
|
|
|
if (!o->cur.filter.chain)
|
2013-12-09 03:55:38 -08:00
|
|
|
evas_text_style_pad_get(o->cur.style, &sl, &sr, &st, &sb);
|
|
|
|
else
|
2014-01-02 18:11:40 -08:00
|
|
|
evas_filter_program_padding_get(o->cur.filter.chain, &sl, &sr, &st, &sb);
|
2005-11-26 00:04:20 -08:00
|
|
|
if (l) *l = sl;
|
|
|
|
if (r) *r = sr;
|
|
|
|
if (t) *t = st;
|
|
|
|
if (b) *b = sb;
|
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI int
|
2003-06-04 23:08:43 -07:00
|
|
|
evas_string_char_next_get(const char *str, int pos, int *decoded)
|
|
|
|
{
|
|
|
|
int p, d;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2013-01-17 01:38:49 -08:00
|
|
|
if ((!str) || (pos < 0))
|
|
|
|
{
|
|
|
|
if (decoded) *decoded = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
2003-06-04 23:08:43 -07:00
|
|
|
p = pos;
|
2013-01-21 18:14:07 -08:00
|
|
|
d = eina_unicode_utf8_next_get(str, &p);
|
2003-06-04 23:08:43 -07:00
|
|
|
if (decoded) *decoded = d;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2006-01-06 15:05:17 -08:00
|
|
|
EAPI int
|
2003-06-04 23:08:43 -07:00
|
|
|
evas_string_char_prev_get(const char *str, int pos, int *decoded)
|
|
|
|
{
|
|
|
|
int p, d;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2003-06-04 23:08:43 -07:00
|
|
|
if (decoded) *decoded = 0;
|
2010-07-17 12:49:16 -07:00
|
|
|
if ((!str) || (pos < 1)) return 0;
|
2003-06-04 23:08:43 -07:00
|
|
|
p = pos;
|
2011-02-16 08:00:17 -08:00
|
|
|
d = eina_unicode_utf8_get_prev(str, &p);
|
2003-06-04 23:08:43 -07:00
|
|
|
if (decoded) *decoded = d;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2008-12-15 14:03:04 -08:00
|
|
|
EAPI int
|
|
|
|
evas_string_char_len_get(const char *str)
|
|
|
|
{
|
2010-07-17 12:49:16 -07:00
|
|
|
if (!str) return 0;
|
2011-02-16 08:00:17 -08:00
|
|
|
return eina_unicode_utf8_get_len(str);
|
2008-12-15 14:03:04 -08:00
|
|
|
}
|
|
|
|
|
2005-11-26 00:04:20 -08:00
|
|
|
void
|
|
|
|
evas_text_style_pad_get(Evas_Text_Style_Type style, int *l, int *r, int *t, int *b)
|
|
|
|
{
|
2011-04-11 05:05:59 -07:00
|
|
|
int sl = 0, sr = 0, st = 0, sb = 0;
|
2011-05-08 08:43:44 -07:00
|
|
|
|
|
|
|
/* Don't calc anything if there's no style. */
|
2011-05-09 00:40:14 -07:00
|
|
|
if (style != EVAS_TEXT_STYLE_PLAIN)
|
2011-04-11 05:05:59 -07:00
|
|
|
{
|
2011-05-09 00:40:14 -07:00
|
|
|
int shad_sz = 0, shad_dst = 0, out_sz = 0;
|
|
|
|
int dx = 0, minx = 0, maxx = 0;
|
|
|
|
int dy = 0, miny = 0, maxy = 0;
|
|
|
|
Eina_Bool have_shadow = EINA_FALSE;
|
2011-05-08 08:43:44 -07:00
|
|
|
|
2011-05-09 00:40:14 -07:00
|
|
|
switch (style & EVAS_TEXT_STYLE_MASK_BASIC)
|
2011-05-08 08:43:44 -07:00
|
|
|
{
|
2011-05-09 00:40:14 -07:00
|
|
|
case EVAS_TEXT_STYLE_SHADOW:
|
|
|
|
shad_dst = 1;
|
|
|
|
have_shadow = EINA_TRUE;
|
2011-05-08 08:43:44 -07:00
|
|
|
break;
|
2011-05-09 00:40:14 -07:00
|
|
|
case EVAS_TEXT_STYLE_OUTLINE_SHADOW:
|
|
|
|
case EVAS_TEXT_STYLE_FAR_SHADOW:
|
|
|
|
shad_dst = 2;
|
|
|
|
out_sz = 1;
|
|
|
|
have_shadow = EINA_TRUE;
|
2011-05-08 08:43:44 -07:00
|
|
|
break;
|
2011-05-09 00:40:14 -07:00
|
|
|
case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW:
|
|
|
|
shad_dst = 1;
|
|
|
|
shad_sz = 2;
|
|
|
|
out_sz = 1;
|
|
|
|
have_shadow = EINA_TRUE;
|
2011-05-08 08:43:44 -07:00
|
|
|
break;
|
2011-05-09 00:40:14 -07:00
|
|
|
case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW:
|
|
|
|
shad_dst = 2;
|
|
|
|
shad_sz = 2;
|
|
|
|
have_shadow = EINA_TRUE;
|
2011-05-08 08:43:44 -07:00
|
|
|
break;
|
2011-05-09 00:40:14 -07:00
|
|
|
case EVAS_TEXT_STYLE_SOFT_SHADOW:
|
|
|
|
shad_dst = 1;
|
|
|
|
shad_sz = 2;
|
|
|
|
have_shadow = EINA_TRUE;
|
2011-05-08 08:43:44 -07:00
|
|
|
break;
|
2011-05-09 00:40:14 -07:00
|
|
|
case EVAS_TEXT_STYLE_GLOW:
|
|
|
|
case EVAS_TEXT_STYLE_SOFT_OUTLINE:
|
|
|
|
out_sz = 2;
|
2011-05-08 08:43:44 -07:00
|
|
|
break;
|
2011-05-09 00:40:14 -07:00
|
|
|
case EVAS_TEXT_STYLE_OUTLINE:
|
|
|
|
out_sz = 1;
|
2011-05-08 08:43:44 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-11-26 00:04:20 -08:00
|
|
|
|
2011-05-09 00:40:14 -07:00
|
|
|
minx = -out_sz;
|
|
|
|
maxx = out_sz;
|
|
|
|
miny = -out_sz;
|
|
|
|
maxy = out_sz;
|
|
|
|
if (have_shadow)
|
|
|
|
{
|
|
|
|
int shx1, shx2, shy1, shy2;
|
|
|
|
switch (style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
|
|
|
|
{
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
|
|
|
|
dx = 1;
|
|
|
|
dy = 1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
|
|
|
|
dx = 0;
|
|
|
|
dy = 1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
|
|
|
|
dx = -1;
|
|
|
|
dy = 1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
|
|
|
|
dx = -1;
|
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
|
|
|
|
dx = -1;
|
|
|
|
dy = -1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
|
|
|
|
dx = 0;
|
|
|
|
dy = -1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
|
|
|
|
dx = 1;
|
|
|
|
dy = -1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
|
|
|
|
dx = 1;
|
|
|
|
dy = 0;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
shx1 = dx * shad_dst;
|
|
|
|
shx1 -= shad_sz;
|
|
|
|
shx2 = dx * shad_dst;
|
|
|
|
shx2 += shad_sz;
|
|
|
|
if (shx1 < minx) minx = shx1;
|
|
|
|
if (shx2 > maxx) maxx = shx2;
|
|
|
|
|
|
|
|
shy1 = dy * shad_dst;
|
|
|
|
shy1 -= shad_sz;
|
|
|
|
shy2 = dy * shad_dst;
|
|
|
|
shy2 += shad_sz;
|
|
|
|
if (shy1 < miny) miny = shy1;
|
|
|
|
if (shy2 > maxy) maxy = shy2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l) sl = *l;
|
|
|
|
if (r) sr = *r;
|
|
|
|
if (t) st = *t;
|
|
|
|
if (b) sb = *b;
|
2005-11-26 00:04:20 -08:00
|
|
|
|
2011-05-09 00:40:14 -07:00
|
|
|
if (sr < maxx) sr = maxx;
|
|
|
|
if (sl < -minx) sl = -minx;
|
|
|
|
if (sb < maxy) sb = maxy;
|
|
|
|
if (st < -miny) st = -miny;
|
|
|
|
}
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2005-11-26 00:04:20 -08:00
|
|
|
if (l) *l = sl;
|
|
|
|
if (r) *r = sr;
|
|
|
|
if (t) *t = st;
|
2005-11-26 05:58:33 -08:00
|
|
|
if (b) *b = sb;
|
2005-11-26 00:04:20 -08:00
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
|
|
|
|
/* all nice and private */
|
|
|
|
static void
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_text_init(Evas_Object *eo_obj)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2002-11-08 00:02:15 -08:00
|
|
|
/* set up methods (compulsory) */
|
|
|
|
obj->func = &object_func;
|
2013-07-08 17:46:15 -07:00
|
|
|
obj->private_data = eo_data_ref(eo_obj, MY_CLASS);
|
2002-11-08 00:02:15 -08:00
|
|
|
obj->type = o_type;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = obj->private_data;
|
2002-11-08 00:02:15 -08:00
|
|
|
/* alloc obj private data */
|
2012-12-12 06:05:29 -08:00
|
|
|
o->cur.ellipsis = -1.0;
|
2002-11-08 00:02:15 -08:00
|
|
|
o->prev = o->cur;
|
2010-09-01 07:26:55 -07:00
|
|
|
#ifdef BIDI_SUPPORT
|
2011-01-30 02:36:02 -08:00
|
|
|
o->bidi_par_props = evas_bidi_paragraph_props_new();
|
2010-09-01 07:26:55 -07:00
|
|
|
#endif
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
2014-03-18 07:01:24 -07:00
|
|
|
_evas_text_eo_base_destructor(Eo *eo_obj, Evas_Text_Data *o EINA_UNUSED)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_text_free(eo_obj, obj);
|
2013-03-18 08:33:54 -07:00
|
|
|
eo_do_super(eo_obj, MY_CLASS, eo_destructor());
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_text_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
|
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2014-01-02 18:11:40 -08:00
|
|
|
/* free filter output */
|
|
|
|
if (o->cur.filter.output)
|
2014-02-05 03:09:05 -08:00
|
|
|
ENFN->image_free(ENDT, o->cur.filter.output);
|
|
|
|
eina_hash_free(o->cur.filter.sources);
|
2014-01-02 18:11:40 -08:00
|
|
|
evas_filter_program_del(o->cur.filter.chain);
|
2014-02-04 22:34:28 -08:00
|
|
|
eina_stringshare_del(o->cur.filter.code);
|
2014-02-05 03:09:05 -08:00
|
|
|
o->cur.filter.output = NULL;
|
2014-01-02 18:11:40 -08:00
|
|
|
o->cur.filter.chain = NULL;
|
2014-02-05 03:09:05 -08:00
|
|
|
o->cur.filter.sources = NULL;
|
|
|
|
o->cur.filter.code = NULL;
|
|
|
|
o->cur.filter.sources_count = 0;
|
2014-01-02 18:11:40 -08:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
/* free obj */
|
2013-08-27 01:20:56 -07:00
|
|
|
_evas_object_text_items_clear(o);
|
2010-07-28 05:00:41 -07:00
|
|
|
if (o->cur.utf8_text) eina_stringshare_del(o->cur.utf8_text);
|
2008-10-15 07:38:34 -07:00
|
|
|
if (o->cur.font) eina_stringshare_del(o->cur.font);
|
2011-08-01 01:20:52 -07:00
|
|
|
if (o->cur.fdesc) evas_font_desc_unref(o->cur.fdesc);
|
2008-10-15 07:38:34 -07:00
|
|
|
if (o->cur.source) eina_stringshare_del(o->cur.source);
|
2012-12-17 05:04:35 -08:00
|
|
|
if (o->cur.text) free(o->cur.text);
|
2013-03-26 04:09:41 -07:00
|
|
|
if (o->font && obj->layer && obj->layer->evas)
|
|
|
|
evas_font_free(obj->layer->evas->evas, o->font);
|
2013-08-26 20:43:22 -07:00
|
|
|
o->font = NULL;
|
2010-09-01 07:26:55 -07:00
|
|
|
#ifdef BIDI_SUPPORT
|
2011-01-30 02:36:02 -08:00
|
|
|
evas_bidi_paragraph_props_unref(o->bidi_par_props);
|
2010-09-01 07:26:55 -07:00
|
|
|
#endif
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2013-01-11 11:55:40 -08:00
|
|
|
void
|
|
|
|
evas_font_draw_async_check(Evas_Object_Protected_Data *obj,
|
|
|
|
void *data, void *context, void *surface,
|
|
|
|
Evas_Font_Set *font,
|
|
|
|
int x, int y, int w, int h, int ow, int oh,
|
|
|
|
Evas_Text_Props *intl_props, Eina_Bool do_async)
|
|
|
|
{
|
|
|
|
Eina_Bool async_unref;
|
|
|
|
|
|
|
|
async_unref = obj->layer->evas->engine.func->font_draw(data, context, surface,
|
|
|
|
font, x, y, w, h, ow, oh,
|
|
|
|
intl_props, do_async);
|
|
|
|
if (do_async && async_unref)
|
|
|
|
{
|
|
|
|
evas_common_font_glyphs_ref(intl_props->glyphs);
|
|
|
|
evas_unref_queue_glyph_put(obj->layer->evas, intl_props->glyphs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
static void
|
2014-03-03 22:17:11 -08:00
|
|
|
_filter_cb(Evas_Filter_Context *ctx, void *data, Eina_Bool success)
|
|
|
|
{
|
|
|
|
Eo *eo_obj = data;
|
|
|
|
|
|
|
|
// Destroy context as we won't reuse it.
|
|
|
|
evas_filter_context_destroy(ctx);
|
|
|
|
|
|
|
|
// Redraw text with normal styles in case of failure
|
|
|
|
if (!success)
|
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = (Evas_Text_Data *) obj->private_data;
|
2014-03-03 22:17:11 -08:00
|
|
|
|
|
|
|
ERR("Filter failed at runtime!");
|
|
|
|
o->cur.filter.invalid = EINA_TRUE;
|
|
|
|
|
|
|
|
// Update object
|
|
|
|
_evas_object_text_items_clear(o);
|
|
|
|
o->changed = 1;
|
|
|
|
_evas_object_text_recalc(eo_obj, o->cur.text);
|
|
|
|
evas_object_change(eo_obj, obj);
|
|
|
|
evas_object_clip_dirty(eo_obj, obj);
|
|
|
|
evas_object_coords_recalc(eo_obj, obj);
|
|
|
|
evas_object_inform_call_resize(eo_obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_text_render(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *obj,
|
|
|
|
void *type_private_data,
|
2013-12-09 03:55:38 -08:00
|
|
|
void *output, void *context, void *surface,
|
|
|
|
int x, int y, Eina_Bool do_async)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2005-11-26 00:04:20 -08:00
|
|
|
int i, j;
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = type_private_data;
|
2011-01-30 02:36:02 -08:00
|
|
|
Evas_Object_Text_Item *it;
|
2005-11-26 00:04:20 -08:00
|
|
|
const char vals[5][5] =
|
|
|
|
{
|
2012-08-26 00:04:46 -07:00
|
|
|
{0, 1, 2, 1, 0},
|
|
|
|
{1, 3, 4, 3, 1},
|
|
|
|
{2, 4, 5, 4, 2},
|
|
|
|
{1, 3, 4, 3, 1},
|
|
|
|
{0, 1, 2, 1, 0}
|
2005-11-26 00:04:20 -08:00
|
|
|
};
|
2006-02-15 18:06:55 -08:00
|
|
|
int sl = 0, st = 0;
|
2013-12-09 03:55:38 -08:00
|
|
|
int shad_dst = 0, shad_sz = 0, dx = 0, dy = 0, haveshad = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
|
|
|
|
/* render object to surface with context, and offxet by x,y */
|
2014-01-02 18:11:40 -08:00
|
|
|
if (!o->cur.filter.chain)
|
2013-12-09 03:55:38 -08:00
|
|
|
evas_text_style_pad_get(o->cur.style, &sl, NULL, &st, NULL);
|
|
|
|
else
|
2014-01-02 18:11:40 -08:00
|
|
|
evas_filter_program_padding_get(o->cur.filter.chain, &sl, NULL, &st, NULL);
|
2005-11-26 07:56:51 -08:00
|
|
|
ENFN->context_multiplier_unset(output, context);
|
2013-03-12 05:58:19 -07:00
|
|
|
ENFN->context_render_op_set(output, context, obj->cur->render_op);
|
2011-03-29 06:52:42 -07:00
|
|
|
/* FIXME: This clipping is just until we fix inset handling correctly. */
|
|
|
|
ENFN->context_clip_clip(output, context,
|
2013-03-12 05:58:19 -07:00
|
|
|
obj->cur->geometry.x + x,
|
|
|
|
obj->cur->geometry.y + y,
|
|
|
|
obj->cur->geometry.w,
|
|
|
|
obj->cur->geometry.h);
|
2013-12-09 03:55:38 -08:00
|
|
|
|
2005-05-21 19:49:50 -07:00
|
|
|
/*
|
2005-11-26 00:04:20 -08:00
|
|
|
ENFN->context_color_set(output,
|
2009-02-22 23:21:37 -08:00
|
|
|
context,
|
|
|
|
230, 160, 30, 100);
|
2005-11-26 00:04:20 -08:00
|
|
|
ENFN->rectangle_draw(output,
|
2009-02-22 23:21:37 -08:00
|
|
|
context,
|
|
|
|
surface,
|
2013-03-12 05:58:19 -07:00
|
|
|
obj->cur->geometry.x + x,
|
|
|
|
obj->cur->geometry.y + y,
|
|
|
|
obj->cur->geometry.w,
|
|
|
|
obj->cur->geometry.h);
|
2003-04-20 01:26:32 -07:00
|
|
|
*/
|
2005-11-26 07:56:51 -08:00
|
|
|
#define COLOR_ONLY_SET(object, sub, col) \
|
2012-08-26 00:04:46 -07:00
|
|
|
ENFN->context_color_set(output, context, \
|
|
|
|
object->sub.col.r, \
|
|
|
|
object->sub.col.g, \
|
|
|
|
object->sub.col.b, \
|
|
|
|
object->sub.col.a);
|
2005-11-26 00:04:20 -08:00
|
|
|
|
2005-11-26 07:56:51 -08:00
|
|
|
#define COLOR_SET(object, sub, col) \
|
2013-03-12 05:58:19 -07:00
|
|
|
if (obj->cur->clipper)\
|
2012-10-08 18:58:41 -07:00
|
|
|
{ \
|
2012-08-26 00:04:46 -07:00
|
|
|
ENFN->context_color_set(output, context, \
|
2013-03-12 05:58:19 -07:00
|
|
|
((int)object->sub.col.r * ((int)obj->cur->clipper->cur->cache.clip.r + 1)) >> 8, \
|
|
|
|
((int)object->sub.col.g * ((int)obj->cur->clipper->cur->cache.clip.g + 1)) >> 8, \
|
|
|
|
((int)object->sub.col.b * ((int)obj->cur->clipper->cur->cache.clip.b + 1)) >> 8, \
|
|
|
|
((int)object->sub.col.a * ((int)obj->cur->clipper->cur->cache.clip.a + 1)) >> 8); \
|
2012-10-08 18:58:41 -07:00
|
|
|
} \
|
2006-01-14 01:26:22 -08:00
|
|
|
else\
|
2012-08-26 00:04:46 -07:00
|
|
|
ENFN->context_color_set(output, context, \
|
|
|
|
object->sub.col.r, \
|
|
|
|
object->sub.col.g, \
|
|
|
|
object->sub.col.b, \
|
|
|
|
object->sub.col.a);
|
2005-11-26 07:56:51 -08:00
|
|
|
|
2005-11-26 00:04:20 -08:00
|
|
|
#define COLOR_SET_AMUL(object, sub, col, amul) \
|
2013-03-12 05:58:19 -07:00
|
|
|
if (obj->cur->clipper) \
|
2012-10-08 18:58:41 -07:00
|
|
|
{ \
|
2012-08-26 00:04:46 -07:00
|
|
|
ENFN->context_color_set(output, context, \
|
2013-03-12 05:58:19 -07:00
|
|
|
(((int)object->sub.col.r) * ((int)obj->cur->clipper->cur->cache.clip.r) * (amul)) / 65025, \
|
|
|
|
(((int)object->sub.col.g) * ((int)obj->cur->clipper->cur->cache.clip.g) * (amul)) / 65025, \
|
|
|
|
(((int)object->sub.col.b) * ((int)obj->cur->clipper->cur->cache.clip.b) * (amul)) / 65025, \
|
|
|
|
(((int)object->sub.col.a) * ((int)obj->cur->clipper->cur->cache.clip.a) * (amul)) / 65025); \
|
2012-10-08 18:58:41 -07:00
|
|
|
} \
|
2006-01-14 01:26:22 -08:00
|
|
|
else \
|
2012-08-26 00:04:46 -07:00
|
|
|
ENFN->context_color_set(output, context, \
|
|
|
|
(((int)object->sub.col.r) * (amul)) / 255, \
|
|
|
|
(((int)object->sub.col.g) * (amul)) / 255, \
|
|
|
|
(((int)object->sub.col.b) * (amul)) / 255, \
|
|
|
|
(((int)object->sub.col.a) * (amul)) / 255);
|
2005-11-26 00:04:20 -08:00
|
|
|
|
2013-01-11 11:55:40 -08:00
|
|
|
#define DRAW_TEXT(ox, oy) \
|
|
|
|
if ((o->font) && (it->text_props.len > 0)) \
|
|
|
|
evas_font_draw_async_check(obj, output, \
|
|
|
|
context, \
|
|
|
|
surface, \
|
|
|
|
o->font, \
|
2013-03-12 05:58:19 -07:00
|
|
|
obj->cur->geometry.x + x + sl + ox + it->x, \
|
|
|
|
obj->cur->geometry.y + y + st + oy + \
|
2013-06-06 06:21:16 -07:00
|
|
|
(int) o->max_ascent, \
|
2013-03-12 05:58:19 -07:00
|
|
|
obj->cur->geometry.w, \
|
|
|
|
obj->cur->geometry.h, \
|
|
|
|
obj->cur->geometry.w, \
|
|
|
|
obj->cur->geometry.h, \
|
2013-01-11 11:55:40 -08:00
|
|
|
&it->text_props, \
|
|
|
|
do_async);
|
2011-04-11 05:05:59 -07:00
|
|
|
|
2013-12-09 03:55:38 -08:00
|
|
|
/* FIXME/WARNING
|
|
|
|
* The code below is EXPERIMENTAL, and not to be considered usable or even
|
|
|
|
* remotely similar to its final form. You've been warned :)
|
|
|
|
*/
|
|
|
|
|
2014-03-03 18:50:35 -08:00
|
|
|
if (!o->cur.filter.invalid && (o->cur.filter.chain || o->cur.filter.code))
|
2013-12-09 03:55:38 -08:00
|
|
|
{
|
|
|
|
int X, Y, W, H;
|
|
|
|
Evas_Filter_Context *filter;
|
2014-01-16 22:05:23 -08:00
|
|
|
const int inbuf = 1;
|
|
|
|
const int outbuf = 2;
|
2013-12-09 03:55:38 -08:00
|
|
|
void *filter_ctx;
|
|
|
|
Eina_Bool ok;
|
2014-01-16 20:32:25 -08:00
|
|
|
int ox = 0, oy = 0;
|
2014-03-05 01:04:35 -08:00
|
|
|
void *previous = o->cur.filter.output;
|
2013-12-09 03:55:38 -08:00
|
|
|
|
2014-01-16 18:19:02 -08:00
|
|
|
/* NOTE: Font effect rendering is now done ENTIRELY on CPU.
|
|
|
|
* So we rely on cache/cache2 to allocate a real image buffer,
|
|
|
|
* that we can draw to. The OpenGL texture will be created only
|
|
|
|
* after the rendering has been done, as we simply push the output
|
|
|
|
* image to GL.
|
|
|
|
*/
|
|
|
|
|
2014-01-02 18:11:40 -08:00
|
|
|
W = obj->cur->geometry.w;
|
|
|
|
H = obj->cur->geometry.h;
|
|
|
|
X = obj->cur->geometry.x;
|
|
|
|
Y = obj->cur->geometry.y;
|
|
|
|
|
2014-06-10 23:59:31 -07:00
|
|
|
// Prepare color multiplier
|
|
|
|
ENFN->context_color_set(ENDT, context, 255, 255, 255, 255);
|
|
|
|
if ((obj->cur->cache.clip.r == 255) && (obj->cur->cache.clip.g == 255) &&
|
|
|
|
(obj->cur->cache.clip.b == 255) && (obj->cur->cache.clip.a == 255))
|
|
|
|
ENFN->context_multiplier_unset(ENDT, context);
|
|
|
|
else
|
|
|
|
ENFN->context_multiplier_set(ENDT, context,
|
|
|
|
obj->cur->cache.clip.r,
|
|
|
|
obj->cur->cache.clip.g,
|
|
|
|
obj->cur->cache.clip.b,
|
|
|
|
obj->cur->cache.clip.a);
|
|
|
|
|
2014-02-06 21:23:29 -08:00
|
|
|
if (!o->cur.filter.chain)
|
|
|
|
{
|
|
|
|
Evas_Filter_Program *pgm;
|
2014-03-17 00:10:03 -07:00
|
|
|
pgm = evas_filter_program_new("Evas_Text", EINA_TRUE);
|
2014-02-06 21:23:29 -08:00
|
|
|
evas_filter_program_source_set_all(pgm, o->cur.filter.sources);
|
|
|
|
if (!evas_filter_program_parse(pgm, o->cur.filter.code))
|
|
|
|
{
|
|
|
|
ERR("Filter program parsing failed");
|
|
|
|
evas_filter_program_del(pgm);
|
|
|
|
o->cur.filter.invalid = EINA_TRUE;
|
|
|
|
goto normal_render;
|
|
|
|
}
|
|
|
|
o->cur.filter.chain = pgm;
|
|
|
|
o->cur.filter.invalid = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else if (previous)
|
2014-01-02 18:11:40 -08:00
|
|
|
{
|
2014-01-06 02:13:36 -08:00
|
|
|
Eina_Bool redraw = o->cur.filter.changed;
|
|
|
|
|
|
|
|
// Scan proxies to find if any changed
|
|
|
|
if (!redraw && o->cur.filter.sources)
|
|
|
|
{
|
2014-02-05 03:09:05 -08:00
|
|
|
Evas_Filter_Proxy_Binding *pb;
|
2014-01-06 02:13:36 -08:00
|
|
|
Evas_Object_Protected_Data *source;
|
2014-02-11 17:14:38 -08:00
|
|
|
Eina_Iterator *iter;
|
2014-01-06 02:13:36 -08:00
|
|
|
|
2014-02-11 17:14:38 -08:00
|
|
|
iter = eina_hash_iterator_data_new(o->cur.filter.sources);
|
|
|
|
EINA_ITERATOR_FOREACH(iter, pb)
|
2014-01-06 02:13:36 -08:00
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
source = eo_data_scope_get(pb->eo_source, EVAS_OBJECT_CLASS);
|
2014-01-06 02:13:36 -08:00
|
|
|
if (source->changed)
|
|
|
|
{
|
|
|
|
redraw = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-02-11 17:14:38 -08:00
|
|
|
eina_iterator_free(iter);
|
2014-01-06 02:13:36 -08:00
|
|
|
}
|
|
|
|
|
2014-01-22 21:58:05 -08:00
|
|
|
if (!redraw)
|
2014-01-02 18:11:40 -08:00
|
|
|
{
|
|
|
|
// Render this image only
|
|
|
|
ENFN->image_draw(ENDT, context,
|
2014-01-22 21:58:05 -08:00
|
|
|
surface, previous,
|
2014-01-02 18:11:40 -08:00
|
|
|
0, 0, W, H, // src
|
|
|
|
X + x, Y + y, W, H, // dst
|
|
|
|
EINA_FALSE, // smooth
|
|
|
|
do_async);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-22 23:54:50 -08:00
|
|
|
filter = evas_filter_context_new(obj->layer->evas, do_async);
|
2014-02-05 03:09:05 -08:00
|
|
|
ok = evas_filter_context_program_use(filter, o->cur.filter.chain);
|
2013-12-09 03:55:38 -08:00
|
|
|
if (!filter || !ok)
|
|
|
|
{
|
|
|
|
ERR("Parsing failed?");
|
|
|
|
evas_filter_context_destroy(filter);
|
|
|
|
goto normal_render;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Proxies
|
|
|
|
evas_filter_context_proxy_render_all(filter, eo_obj, EINA_FALSE);
|
|
|
|
|
2014-03-02 02:08:22 -08:00
|
|
|
// Draw Context
|
2013-12-09 03:55:38 -08:00
|
|
|
filter_ctx = ENFN->context_new(ENDT);
|
|
|
|
ENFN->context_color_set(ENDT, filter_ctx, 255, 255, 255, 255);
|
|
|
|
|
2014-01-22 23:54:50 -08:00
|
|
|
// Allocate all buffers now
|
2014-01-22 21:58:05 -08:00
|
|
|
evas_filter_context_buffers_allocate_all(filter, W, H);
|
2014-01-16 22:05:23 -08:00
|
|
|
evas_filter_target_set(filter, context, surface, X + x, Y + y);
|
2014-01-22 21:58:05 -08:00
|
|
|
|
|
|
|
// Steal output and release previous
|
2014-01-16 22:05:23 -08:00
|
|
|
o->cur.filter.output = evas_filter_buffer_backing_steal(filter, outbuf);
|
2014-01-22 21:58:05 -08:00
|
|
|
if (o->cur.filter.output != previous)
|
|
|
|
evas_filter_buffer_backing_release(filter, previous);
|
2014-01-02 18:11:40 -08:00
|
|
|
|
2013-12-09 03:55:38 -08:00
|
|
|
// Render text to input buffer
|
2014-01-16 20:32:25 -08:00
|
|
|
EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it)
|
|
|
|
if ((o->font) && (it->text_props.len > 0))
|
|
|
|
{
|
|
|
|
evas_filter_font_draw(filter, filter_ctx, inbuf, o->font,
|
|
|
|
sl + ox + it->x,
|
|
|
|
st + oy + (int) o->max_ascent,
|
|
|
|
&it->text_props,
|
|
|
|
do_async);
|
|
|
|
}
|
2013-12-09 03:55:38 -08:00
|
|
|
|
|
|
|
ENFN->context_free(ENDT, filter_ctx);
|
|
|
|
|
|
|
|
// Add post-run callback and run filter
|
2014-03-03 22:17:11 -08:00
|
|
|
evas_filter_context_post_run_callback_set(filter, _filter_cb, eo_obj);
|
2014-03-02 23:58:18 -08:00
|
|
|
ok = evas_filter_run(filter);
|
2014-01-02 18:11:40 -08:00
|
|
|
o->cur.filter.changed = EINA_FALSE;
|
2013-12-09 03:55:38 -08:00
|
|
|
|
2014-03-02 23:58:18 -08:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
DBG("Effect rendering done.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Rendering failed");
|
|
|
|
o->cur.filter.invalid = EINA_TRUE;
|
|
|
|
goto normal_render;
|
|
|
|
}
|
2013-12-09 03:55:38 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* End of the EXPERIMENTAL code */
|
|
|
|
|
|
|
|
normal_render:
|
|
|
|
|
2011-04-29 12:26:56 -07:00
|
|
|
/* shadows */
|
|
|
|
switch (o->cur.style & EVAS_TEXT_STYLE_MASK_BASIC)
|
|
|
|
{
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW:
|
|
|
|
case EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW:
|
|
|
|
shad_dst = 1;
|
|
|
|
haveshad = 1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_OUTLINE_SHADOW:
|
|
|
|
case EVAS_TEXT_STYLE_FAR_SHADOW:
|
|
|
|
shad_dst = 2;
|
|
|
|
haveshad = 1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_FAR_SOFT_SHADOW:
|
|
|
|
shad_dst = 2;
|
|
|
|
shad_sz = 2;
|
|
|
|
haveshad = 1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SOFT_SHADOW:
|
|
|
|
shad_dst = 1;
|
|
|
|
shad_sz = 2;
|
|
|
|
haveshad = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (haveshad)
|
|
|
|
{
|
|
|
|
if (shad_dst > 0)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-04-29 12:26:56 -07:00
|
|
|
switch (o->cur.style & EVAS_TEXT_STYLE_MASK_SHADOW_DIRECTION)
|
|
|
|
{
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT:
|
|
|
|
dx = 1;
|
|
|
|
dy = 1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM:
|
|
|
|
dx = 0;
|
|
|
|
dy = 1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT:
|
|
|
|
dx = -1;
|
|
|
|
dy = 1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT:
|
|
|
|
dx = -1;
|
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT:
|
|
|
|
dx = -1;
|
|
|
|
dy = -1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP:
|
|
|
|
dx = 0;
|
|
|
|
dy = -1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT:
|
|
|
|
dx = 1;
|
|
|
|
dy = -1;
|
|
|
|
break;
|
|
|
|
case EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT:
|
|
|
|
dx = 1;
|
|
|
|
dy = 0;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dx *= shad_dst;
|
|
|
|
dy *= shad_dst;
|
2011-01-30 02:36:02 -08:00
|
|
|
}
|
2011-04-29 12:26:56 -07:00
|
|
|
}
|
|
|
|
EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it)
|
|
|
|
{
|
|
|
|
/* Shadows */
|
2011-04-13 02:29:45 -07:00
|
|
|
if (haveshad)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-04-13 02:29:45 -07:00
|
|
|
switch (shad_sz)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-04-13 02:29:45 -07:00
|
|
|
case 0:
|
|
|
|
COLOR_SET(o, cur, shadow);
|
|
|
|
DRAW_TEXT(dx, dy);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
for (j = 0; j < 5; j++)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-04-13 02:29:45 -07:00
|
|
|
for (i = 0; i < 5; i++)
|
2011-01-30 02:36:02 -08:00
|
|
|
{
|
2011-04-13 02:29:45 -07:00
|
|
|
if (vals[i][j] != 0)
|
|
|
|
{
|
|
|
|
COLOR_SET_AMUL(o, cur, shadow, vals[i][j] * 50);
|
|
|
|
DRAW_TEXT(i - 2 + dx, j - 2 + dy);
|
|
|
|
}
|
2011-01-30 02:36:02 -08:00
|
|
|
}
|
|
|
|
}
|
2011-04-13 02:29:45 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2011-01-30 02:36:02 -08:00
|
|
|
}
|
|
|
|
}
|
2011-04-29 12:26:56 -07:00
|
|
|
|
2011-01-30 02:36:02 -08:00
|
|
|
/* glows */
|
|
|
|
if (o->cur.style == EVAS_TEXT_STYLE_GLOW)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 5; j++)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
if (vals[i][j] != 0)
|
|
|
|
{
|
|
|
|
COLOR_SET_AMUL(o, cur, glow, vals[i][j] * 50);
|
|
|
|
DRAW_TEXT(i - 2, j - 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
COLOR_SET(o, cur, glow2);
|
|
|
|
DRAW_TEXT(-1, 0);
|
|
|
|
DRAW_TEXT(1, 0);
|
|
|
|
DRAW_TEXT(0, -1);
|
|
|
|
DRAW_TEXT(0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* outlines */
|
|
|
|
if ((o->cur.style == EVAS_TEXT_STYLE_OUTLINE) ||
|
|
|
|
(o->cur.style == EVAS_TEXT_STYLE_OUTLINE_SHADOW) ||
|
|
|
|
(o->cur.style == EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW))
|
|
|
|
{
|
|
|
|
COLOR_SET(o, cur, outline);
|
|
|
|
DRAW_TEXT(-1, 0);
|
|
|
|
DRAW_TEXT(1, 0);
|
|
|
|
DRAW_TEXT(0, -1);
|
|
|
|
DRAW_TEXT(0, 1);
|
|
|
|
}
|
|
|
|
else if (o->cur.style == EVAS_TEXT_STYLE_SOFT_OUTLINE)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 5; j++)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
if (((i != 2) || (j != 2)) && (vals[i][j] != 0))
|
|
|
|
{
|
|
|
|
COLOR_SET_AMUL(o, cur, outline, vals[i][j] * 50);
|
|
|
|
DRAW_TEXT(i - 2, j - 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* normal text */
|
2013-03-12 05:58:19 -07:00
|
|
|
COLOR_ONLY_SET(obj, cur->cache, clip);
|
2011-01-30 02:36:02 -08:00
|
|
|
DRAW_TEXT(0, 0);
|
2005-11-26 00:04:20 -08:00
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-07-08 17:46:15 -07:00
|
|
|
evas_object_text_render_pre(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *obj,
|
|
|
|
void *type_private_data)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = type_private_data;
|
2012-12-15 17:49:36 -08:00
|
|
|
int is_v = 0, was_v = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
/* dont pre-render the obj twice! */
|
|
|
|
if (obj->pre_render_done) return;
|
2013-01-02 21:38:03 -08:00
|
|
|
obj->pre_render_done = EINA_TRUE;
|
2010-07-17 12:49:16 -07:00
|
|
|
/* pre-render phase. this does anything an object needs to do just before
|
2014-03-09 00:31:28 -08:00
|
|
|
rendering. This could mean loading the image data, retrieving it from
|
2010-07-17 12:49:16 -07:00
|
|
|
elsewhere, decoding video etc.
|
2014-03-09 00:31:28 -08:00
|
|
|
Then when this is done the object needs to figure if it changed and
|
2010-07-17 12:49:16 -07:00
|
|
|
if so what and where and add the appropriate redraw rectangles */
|
2002-11-08 00:02:15 -08:00
|
|
|
/* if someone is clipping this obj - go calculate the clipper */
|
2013-03-12 05:58:19 -07:00
|
|
|
if (obj->cur->clipper)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2013-03-12 05:58:19 -07:00
|
|
|
if (obj->cur->cache.clip.dirty)
|
2013-04-06 22:00:10 -07:00
|
|
|
evas_object_clip_recalc(obj->cur->clipper);
|
2013-07-08 17:46:15 -07:00
|
|
|
obj->cur->clipper->func->render_pre(obj->cur->clipper->object,
|
|
|
|
obj->cur->clipper,
|
|
|
|
obj->cur->clipper->private_data);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2012-12-12 06:05:29 -08:00
|
|
|
/* If object size changed and ellipsis is set */
|
2012-12-15 06:16:08 -08:00
|
|
|
if (((o->cur.ellipsis >= 0.0 ||
|
|
|
|
o->cur.ellipsis != o->prev.ellipsis) &&
|
2013-03-12 05:58:19 -07:00
|
|
|
((obj->cur->geometry.w != o->last_computed.w) ||
|
|
|
|
(obj->cur->geometry.h != o->last_computed.h))) ||
|
|
|
|
(obj->cur->scale != obj->prev->scale))
|
2012-12-12 06:05:29 -08:00
|
|
|
{
|
2013-09-30 23:29:38 -07:00
|
|
|
_evas_object_text_recalc(eo_obj, o->cur.text);
|
|
|
|
evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes,
|
2012-12-14 01:07:38 -08:00
|
|
|
eo_obj, obj);
|
2013-09-30 23:29:38 -07:00
|
|
|
goto done;
|
2012-12-12 06:05:29 -08:00
|
|
|
}
|
2010-07-17 12:49:16 -07:00
|
|
|
/* now figure what changed and add draw rects
|
|
|
|
if it just became visible or invisible */
|
2012-10-08 18:58:41 -07:00
|
|
|
is_v = evas_object_is_visible(eo_obj, obj);
|
|
|
|
was_v = evas_object_was_visible(eo_obj, obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (is_v != was_v)
|
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
evas_object_render_pre_visible_change(&obj->layer->evas->clip_changes,
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_obj, is_v, was_v);
|
2012-08-26 00:04:46 -07:00
|
|
|
goto done;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2012-10-25 08:24:27 -07:00
|
|
|
if (obj->changed_map || obj->changed_src_visible)
|
2009-11-06 00:44:49 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes,
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_obj, obj);
|
2009-11-06 00:44:49 -08:00
|
|
|
goto done;
|
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
/* its 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 */
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_render_pre_clipper_change(&obj->layer->evas->clip_changes, eo_obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
/* if we restacked (layer or just within a layer) and dont clip anyone */
|
|
|
|
if (obj->restack)
|
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes,
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_obj, obj);
|
2012-08-26 00:04:46 -07:00
|
|
|
goto done;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
/* if it changed color */
|
2013-03-12 05:58:19 -07:00
|
|
|
if ((obj->cur->color.r != obj->prev->color.r) ||
|
|
|
|
(obj->cur->color.g != obj->prev->color.g) ||
|
|
|
|
(obj->cur->color.b != obj->prev->color.b) ||
|
|
|
|
(obj->cur->color.a != obj->prev->color.a))
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes,
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_obj, obj);
|
2012-08-26 00:04:46 -07:00
|
|
|
goto done;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2010-07-17 12:49:16 -07:00
|
|
|
/* if it changed geometry - and obviously not visibility or color
|
|
|
|
calculate differences since we have a constant color fill
|
|
|
|
we really only need to update the differences */
|
2013-03-12 05:58:19 -07:00
|
|
|
if ((obj->cur->geometry.x != obj->prev->geometry.x) ||
|
|
|
|
(obj->cur->geometry.y != obj->prev->geometry.y) ||
|
|
|
|
(obj->cur->geometry.w != obj->prev->geometry.w) ||
|
|
|
|
(obj->cur->geometry.h != obj->prev->geometry.h))
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes,
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_obj, obj);
|
2012-08-26 00:04:46 -07:00
|
|
|
goto done;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2013-03-12 05:58:19 -07:00
|
|
|
if (obj->cur->render_op != obj->prev->render_op)
|
2006-05-02 00:28:49 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes,
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_obj, obj);
|
2012-08-26 00:04:46 -07:00
|
|
|
goto done;
|
2006-05-02 00:28:49 -07:00
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
if (o->changed)
|
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes,
|
2012-12-14 01:07:38 -08:00
|
|
|
eo_obj, obj);
|
|
|
|
goto done;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
done:
|
2014-03-09 00:31:28 -08:00
|
|
|
evas_object_render_pre_effect_updates(&obj->layer->evas->clip_changes,
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_obj, is_v, was_v);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-07-08 17:46:15 -07:00
|
|
|
evas_object_text_render_post(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *obj EINA_UNUSED,
|
|
|
|
void *type_private_data EINA_UNUSED)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2010-07-17 12:49:16 -07:00
|
|
|
/* 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 */
|
2002-11-08 00:02:15 -08:00
|
|
|
/* remove those pesky changes */
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_clip_changes_clean(eo_obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
/* move cur to prev safely for object data */
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_cur_prev(eo_obj);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
static unsigned int
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_text_id_get(Evas_Object *eo_obj)
|
2008-08-30 19:04:31 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
|
2008-08-30 19:04:31 -07:00
|
|
|
if (!o) return 0;
|
|
|
|
return MAGIC_OBJ_TEXT;
|
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
static unsigned int
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_text_visual_id_get(Evas_Object *eo_obj)
|
2008-08-25 22:45:04 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
|
2008-08-25 22:45:04 -07:00
|
|
|
if (!o) return 0;
|
|
|
|
return MAGIC_OBJ_SHAPE;
|
|
|
|
}
|
|
|
|
|
2010-07-17 12:49:16 -07:00
|
|
|
static void *
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_text_engine_data_get(Evas_Object *eo_obj)
|
2008-08-25 22:45:04 -07:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
|
2008-08-25 22:45:04 -07:00
|
|
|
if (!o) return NULL;
|
2011-05-29 06:00:54 -07:00
|
|
|
return o->font;
|
2008-08-25 22:45:04 -07:00
|
|
|
}
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
static int
|
2013-07-08 17:46:15 -07:00
|
|
|
evas_object_text_is_opaque(Evas_Object *eo_obj EINA_UNUSED,
|
|
|
|
Evas_Object_Protected_Data *obj EINA_UNUSED,
|
|
|
|
void *type_private_data EINA_UNUSED)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
/* this returns 1 if the internal object data implies that the object is
|
2010-07-17 12:49:16 -07:00
|
|
|
currently fully opaque over the entire gradient it occupies */
|
2002-11-08 00:02:15 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-07-08 17:46:15 -07:00
|
|
|
evas_object_text_was_opaque(Evas_Object *eo_obj EINA_UNUSED,
|
|
|
|
Evas_Object_Protected_Data *obj EINA_UNUSED,
|
|
|
|
void *type_private_data EINA_UNUSED)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2010-07-17 12:49:16 -07:00
|
|
|
/* this returns 1 if the internal object data implies that the object was
|
|
|
|
currently fully opaque over the entire gradient it occupies */
|
2002-11-08 00:02:15 -08:00
|
|
|
return 0;
|
|
|
|
}
|
2006-02-28 19:48:02 -08:00
|
|
|
|
2008-11-15 02:39:46 -08:00
|
|
|
static void
|
2013-07-08 17:46:15 -07:00
|
|
|
evas_object_text_scale_update(Evas_Object *eo_obj,
|
|
|
|
Evas_Object_Protected_Data *pd EINA_UNUSED,
|
|
|
|
void *type_private_data)
|
2008-11-15 02:39:46 -08:00
|
|
|
{
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = type_private_data;
|
2008-11-15 02:39:46 -08:00
|
|
|
int size;
|
|
|
|
const char *font;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2008-11-15 02:39:46 -08:00
|
|
|
font = eina_stringshare_add(o->cur.font);
|
|
|
|
size = o->cur.size;
|
|
|
|
if (o->cur.font) eina_stringshare_del(o->cur.font);
|
|
|
|
o->cur.font = NULL;
|
|
|
|
o->prev.font = NULL;
|
|
|
|
o->cur.size = 0;
|
|
|
|
o->prev.size = 0;
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_text_font_set(eo_obj, font, size);
|
2008-11-15 02:39:46 -08:00
|
|
|
}
|
|
|
|
|
2006-02-28 19:48:02 -08:00
|
|
|
void
|
2012-10-08 18:58:41 -07:00
|
|
|
_evas_object_text_rehint(Evas_Object *eo_obj)
|
2006-02-28 19:48:02 -08:00
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
|
2006-02-28 19:48:02 -08:00
|
|
|
int is, was;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2011-05-29 06:00:54 -07:00
|
|
|
if (!o->font) return;
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_font_load_hinting_set(obj->layer->evas->evas, o->font,
|
2012-08-26 00:04:46 -07:00
|
|
|
obj->layer->evas->hinting);
|
2012-10-08 18:58:41 -07:00
|
|
|
was = evas_object_is_in_output_rect(eo_obj, obj,
|
2012-08-26 00:04:46 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y, 1, 1);
|
2006-02-28 19:48:02 -08:00
|
|
|
/* DO II */
|
2012-12-30 17:49:36 -08:00
|
|
|
_evas_object_text_recalc(eo_obj, o->cur.text);
|
2011-01-30 02:44:23 -08:00
|
|
|
o->changed = 1;
|
2014-01-02 18:11:40 -08:00
|
|
|
o->cur.filter.changed = EINA_TRUE;
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_change(eo_obj, obj);
|
|
|
|
evas_object_clip_dirty(eo_obj, obj);
|
|
|
|
evas_object_coords_recalc(eo_obj, obj);
|
|
|
|
is = evas_object_is_in_output_rect(eo_obj, obj,
|
2012-08-26 00:04:46 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y, 1, 1);
|
2013-03-12 05:58:19 -07:00
|
|
|
if ((is || was) && obj->cur->visible)
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_event_feed_mouse_move(obj->layer->evas->evas,
|
2012-08-26 00:04:46 -07:00
|
|
|
obj->layer->evas->pointer.x,
|
|
|
|
obj->layer->evas->pointer.y,
|
|
|
|
obj->layer->evas->last_timestamp,
|
|
|
|
NULL);
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_inform_call_resize(eo_obj);
|
2011-01-30 02:44:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-30 17:49:36 -08:00
|
|
|
_evas_object_text_recalc(Evas_Object *eo_obj, Eina_Unicode *text)
|
2011-01-30 02:44:23 -08:00
|
|
|
{
|
2014-06-02 06:47:59 -07:00
|
|
|
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
|
2011-01-30 02:44:23 -08:00
|
|
|
|
|
|
|
if (!text) text = eina_unicode_strdup(EINA_UNICODE_EMPTY_STRING);
|
|
|
|
|
2012-10-08 18:58:41 -07:00
|
|
|
_evas_object_text_layout(eo_obj, o, text);
|
2011-01-30 02:44:23 -08:00
|
|
|
|
2013-05-10 09:44:30 -07:00
|
|
|
/* Calc ascent/descent. */
|
2013-06-07 10:09:30 -07:00
|
|
|
if (o->items)
|
2013-05-10 09:44:30 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Text_Item *item;
|
|
|
|
|
|
|
|
for (item = o->items ; item ;
|
|
|
|
item = EINA_INLIST_CONTAINER_GET(
|
|
|
|
EINA_INLIST_GET(item)->next, Evas_Object_Text_Item))
|
|
|
|
{
|
|
|
|
int asc = 0, desc = 0;
|
|
|
|
|
|
|
|
/* Skip items without meaning full information. */
|
2013-06-09 01:30:34 -07:00
|
|
|
if (!item->text_props.font_instance) continue;
|
2013-05-10 09:44:30 -07:00
|
|
|
|
|
|
|
asc = evas_common_font_instance_ascent_get(item->text_props.font_instance);
|
|
|
|
desc = evas_common_font_instance_descent_get(item->text_props.font_instance);
|
2013-06-09 01:30:34 -07:00
|
|
|
if (asc > o->ascent) o->ascent = asc;
|
|
|
|
if (desc > o->descent) o->descent = desc;
|
2013-05-10 09:44:30 -07:00
|
|
|
|
2013-06-09 01:30:34 -07:00
|
|
|
asc = evas_common_font_instance_max_ascent_get(item->text_props.font_instance);
|
|
|
|
desc = evas_common_font_instance_max_descent_get(item->text_props.font_instance);
|
|
|
|
if (asc > o->max_ascent) o->max_ascent = asc;
|
|
|
|
if (desc > o->max_descent) o->max_descent = desc;
|
2013-05-10 09:44:30 -07:00
|
|
|
}
|
|
|
|
}
|
2013-06-07 10:09:30 -07:00
|
|
|
else if (o->font)
|
|
|
|
{
|
|
|
|
o->ascent = ENFN->font_ascent_get(ENDT, o->font);
|
|
|
|
o->descent = ENFN->font_descent_get(ENDT, o->font);
|
2013-06-09 01:30:34 -07:00
|
|
|
o->max_ascent = ENFN->font_max_ascent_get(ENDT, o->font);
|
|
|
|
o->max_descent = ENFN->font_max_descent_get(ENDT, o->font);
|
2013-06-07 10:09:30 -07:00
|
|
|
}
|
|
|
|
|
2011-05-29 06:00:54 -07:00
|
|
|
if ((o->font) && (o->items))
|
2006-02-28 19:48:02 -08:00
|
|
|
{
|
2013-10-02 03:07:48 -07:00
|
|
|
int w, h;
|
|
|
|
int l = 0, r = 0, t = 0, b = 0;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2014-03-17 03:29:16 -07:00
|
|
|
w = _evas_object_text_horiz_advance_without_ellipsis_get(o);
|
2012-10-08 18:58:41 -07:00
|
|
|
h = _evas_object_text_vert_advance_get(eo_obj, o);
|
2014-01-02 18:11:40 -08:00
|
|
|
if (!o->cur.filter.chain)
|
2013-12-09 03:55:38 -08:00
|
|
|
evas_text_style_pad_get(o->cur.style, &l, &r, &t, &b);
|
|
|
|
else
|
2014-01-02 18:11:40 -08:00
|
|
|
evas_filter_program_padding_get(o->cur.filter.chain, &l, &r, &t, &b);
|
2013-03-12 05:58:19 -07:00
|
|
|
|
2013-10-01 04:34:03 -07:00
|
|
|
if (o->cur.ellipsis >= 0.0)
|
2013-10-01 19:02:05 -07:00
|
|
|
{
|
|
|
|
int min;
|
|
|
|
|
2013-10-02 04:52:59 -07:00
|
|
|
min = w + l + r < obj->cur->geometry.w || obj->cur->geometry.w == 0 ? w + l + r : obj->cur->geometry.w;
|
2013-10-01 19:02:05 -07:00
|
|
|
eo_do_super(eo_obj, MY_CLASS,
|
|
|
|
evas_obj_size_set(min, h + t + b));
|
|
|
|
}
|
2013-10-01 04:34:03 -07:00
|
|
|
else
|
2013-10-01 19:02:05 -07:00
|
|
|
{
|
|
|
|
eo_do_super(eo_obj, MY_CLASS,
|
|
|
|
evas_obj_size_set(w + l + r, h + t + b));
|
|
|
|
}
|
2013-03-12 05:58:19 -07:00
|
|
|
//// obj->cur->cache.geometry.validity = 0;
|
2006-02-28 19:48:02 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-09 03:55:38 -08:00
|
|
|
int t = 0, b = 0, l = 0, r = 0;
|
2009-09-03 22:13:19 -07:00
|
|
|
|
2014-01-02 18:11:40 -08:00
|
|
|
if (!o->cur.filter.chain)
|
2013-12-09 03:55:38 -08:00
|
|
|
evas_text_style_pad_get(o->cur.style, &l, &r, &t, &b);
|
|
|
|
else
|
2014-01-02 18:11:40 -08:00
|
|
|
evas_filter_program_padding_get(o->cur.filter.chain, &l, &r, &t, &b);
|
2013-10-01 04:34:03 -07:00
|
|
|
|
2013-08-05 01:43:17 -07:00
|
|
|
eo_do_super(eo_obj, MY_CLASS,
|
|
|
|
evas_obj_size_set(0, o->max_ascent + o->max_descent + t + b));
|
2013-03-12 05:58:19 -07:00
|
|
|
//// obj->cur->cache.geometry.validity = 0;
|
2006-02-28 19:48:02 -08:00
|
|
|
}
|
2013-03-12 05:58:19 -07:00
|
|
|
o->last_computed.w = obj->cur->geometry.w;
|
|
|
|
o->last_computed.h = obj->cur->geometry.h;
|
2006-02-28 19:48:02 -08:00
|
|
|
}
|
2011-01-30 02:44:23 -08:00
|
|
|
|
2013-12-09 03:55:38 -08:00
|
|
|
/* EXPERIMENTAL CODE BEGIN */
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_filter_program_set(Eo *eo_obj, Evas_Text_Data *o, const char *arg)
|
2013-12-09 03:55:38 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Protected_Data *obj;
|
|
|
|
Evas_Filter_Program *pgm = NULL;
|
|
|
|
|
|
|
|
if (!o) return;
|
2014-02-04 22:34:28 -08:00
|
|
|
if (o->cur.filter.code == arg) return;
|
|
|
|
if (o->cur.filter.code && arg && !strcmp(arg, o->cur.filter.code)) return;
|
2013-12-09 03:55:38 -08:00
|
|
|
|
|
|
|
// Parse filter program
|
2014-01-02 18:11:40 -08:00
|
|
|
evas_filter_program_del(o->cur.filter.chain);
|
2013-12-09 03:55:38 -08:00
|
|
|
if (arg)
|
|
|
|
{
|
2014-03-17 00:10:03 -07:00
|
|
|
pgm = evas_filter_program_new("Evas_Text: Filter Program", EINA_TRUE);
|
2014-02-04 18:40:10 -08:00
|
|
|
evas_filter_program_source_set_all(pgm, o->cur.filter.sources);
|
2013-12-09 03:55:38 -08:00
|
|
|
if (!evas_filter_program_parse(pgm, arg))
|
|
|
|
{
|
|
|
|
ERR("Parsing failed!");
|
|
|
|
evas_filter_program_del(pgm);
|
|
|
|
pgm = NULL;
|
|
|
|
}
|
|
|
|
}
|
2014-01-02 18:11:40 -08:00
|
|
|
o->cur.filter.chain = pgm;
|
|
|
|
o->cur.filter.changed = EINA_TRUE;
|
2014-02-06 21:23:29 -08:00
|
|
|
o->cur.filter.invalid = (pgm == NULL);
|
2014-02-04 22:34:28 -08:00
|
|
|
eina_stringshare_replace(&o->cur.filter.code, arg);
|
2013-12-09 03:55:38 -08:00
|
|
|
|
|
|
|
// Update object
|
2014-06-02 06:47:59 -07:00
|
|
|
obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
2013-12-09 03:55:38 -08:00
|
|
|
_evas_object_text_items_clear(o);
|
|
|
|
o->changed = 1;
|
|
|
|
_evas_object_text_recalc(eo_obj, o->cur.text);
|
|
|
|
evas_object_change(eo_obj, obj);
|
|
|
|
evas_object_clip_dirty(eo_obj, obj);
|
|
|
|
evas_object_coords_recalc(eo_obj, obj);
|
|
|
|
evas_object_inform_call_resize(eo_obj);
|
|
|
|
}
|
|
|
|
|
2014-02-05 03:09:05 -08:00
|
|
|
static void
|
|
|
|
_filter_source_hash_free_cb(void *data)
|
|
|
|
{
|
|
|
|
Evas_Filter_Proxy_Binding *pb = data;
|
|
|
|
Evas_Object_Protected_Data *proxy, *source;
|
2014-03-09 00:31:28 -08:00
|
|
|
Evas_Text_Data *o;
|
2014-02-05 03:09:05 -08:00
|
|
|
|
2014-06-02 06:47:59 -07:00
|
|
|
proxy = eo_data_scope_get(pb->eo_proxy, EVAS_OBJECT_CLASS);
|
|
|
|
source = eo_data_scope_get(pb->eo_source, EVAS_OBJECT_CLASS);
|
2014-02-05 03:09:05 -08:00
|
|
|
|
|
|
|
if (source)
|
|
|
|
{
|
|
|
|
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, source->proxy,
|
|
|
|
Evas_Object_Proxy_Data, source_write)
|
|
|
|
source_write->proxies = eina_list_remove(source_write->proxies, pb->eo_proxy);
|
|
|
|
EINA_COW_WRITE_END(evas_object_proxy_cow, source->proxy, source_write)
|
|
|
|
}
|
|
|
|
|
|
|
|
o = eo_data_scope_get(pb->eo_proxy, MY_CLASS);
|
|
|
|
|
|
|
|
if (o && proxy)
|
|
|
|
{
|
|
|
|
o->cur.filter.sources_count--;
|
|
|
|
if (!o->cur.filter.sources_count)
|
|
|
|
{
|
|
|
|
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, proxy->proxy,
|
|
|
|
Evas_Object_Proxy_Data, proxy_write)
|
|
|
|
proxy_write->is_proxy = EINA_FALSE;
|
|
|
|
EINA_COW_WRITE_END(evas_object_proxy_cow, source->proxy, proxy_write)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eina_stringshare_del(pb->name);
|
|
|
|
free(pb);
|
|
|
|
}
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_text_filter_source_set(Eo *eo_obj, Evas_Text_Data *o, const char *name, Evas_Object *eo_source)
|
2013-12-09 03:55:38 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Protected_Data *obj;
|
2014-02-05 03:09:05 -08:00
|
|
|
Evas_Filter_Program *pgm = o->cur.filter.chain;
|
|
|
|
Evas_Filter_Proxy_Binding *pb, *pb_old = NULL;
|
2014-02-06 21:23:29 -08:00
|
|
|
Evas_Object_Protected_Data *source = NULL;
|
|
|
|
|
2014-06-02 06:47:59 -07:00
|
|
|
obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
|
|
|
if (eo_source) source = eo_data_scope_get(eo_source, EVAS_OBJECT_CLASS);
|
2013-12-09 03:55:38 -08:00
|
|
|
|
2014-03-03 21:14:15 -08:00
|
|
|
if (!name)
|
|
|
|
{
|
|
|
|
if (!eo_source || !o->cur.filter.sources) return;
|
|
|
|
if (eina_hash_del_by_data(o->cur.filter.sources, eo_source))
|
|
|
|
goto update;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-05 03:09:05 -08:00
|
|
|
if (!o->cur.filter.sources)
|
2013-12-13 01:17:59 -08:00
|
|
|
{
|
2014-03-17 00:54:48 -07:00
|
|
|
if (!source) return;
|
2014-02-05 03:09:05 -08:00
|
|
|
o->cur.filter.sources = eina_hash_string_small_new
|
|
|
|
(EINA_FREE_CB(_filter_source_hash_free_cb));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pb_old = eina_hash_find(o->cur.filter.sources, name);
|
2014-02-06 21:23:29 -08:00
|
|
|
if (pb_old)
|
|
|
|
{
|
|
|
|
if (pb_old->eo_source == eo_source) goto update;
|
|
|
|
eina_hash_del(o->cur.filter.sources, name, pb_old);
|
|
|
|
}
|
2013-12-13 01:17:59 -08:00
|
|
|
}
|
2013-12-09 03:55:38 -08:00
|
|
|
|
2014-02-06 21:23:29 -08:00
|
|
|
if (!source)
|
|
|
|
{
|
|
|
|
pb_old = eina_hash_find(o->cur.filter.sources, name);
|
|
|
|
if (!pb_old) return;
|
|
|
|
eina_hash_del_by_key(o->cur.filter.sources, name);
|
|
|
|
goto update;
|
|
|
|
}
|
2014-02-05 03:09:05 -08:00
|
|
|
|
|
|
|
pb = calloc(1, sizeof(*pb));
|
|
|
|
pb->eo_proxy = eo_obj;
|
|
|
|
pb->eo_source = eo_source;
|
|
|
|
pb->name = eina_stringshare_add(name);
|
|
|
|
|
|
|
|
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, source->proxy,
|
|
|
|
Evas_Object_Proxy_Data, source_write)
|
|
|
|
if (!eina_list_data_find(source_write->proxies, eo_obj))
|
|
|
|
source_write->proxies = eina_list_append(source_write->proxies, eo_obj);
|
|
|
|
EINA_COW_WRITE_END(evas_object_proxy_cow, source->proxy, source_write)
|
|
|
|
|
|
|
|
EINA_COW_WRITE_BEGIN(evas_object_proxy_cow, obj->proxy,
|
|
|
|
Evas_Object_Proxy_Data, proxy_write)
|
|
|
|
proxy_write->is_proxy = EINA_TRUE;
|
|
|
|
EINA_COW_WRITE_END(evas_object_proxy_cow, obj->proxy, proxy_write)
|
|
|
|
|
|
|
|
eina_hash_add(o->cur.filter.sources, pb->name, pb);
|
|
|
|
o->cur.filter.sources_count++;
|
|
|
|
|
|
|
|
evas_filter_program_source_set_all(pgm, o->cur.filter.sources);
|
2013-12-09 03:55:38 -08:00
|
|
|
|
|
|
|
// Update object
|
2014-02-06 21:23:29 -08:00
|
|
|
update:
|
2014-02-05 03:09:05 -08:00
|
|
|
o->cur.filter.changed = EINA_TRUE;
|
2014-02-06 21:23:29 -08:00
|
|
|
o->cur.filter.invalid = EINA_FALSE;
|
2013-12-09 03:55:38 -08:00
|
|
|
_evas_object_text_items_clear(o);
|
|
|
|
o->changed = 1;
|
|
|
|
_evas_object_text_recalc(eo_obj, o->cur.text);
|
|
|
|
evas_object_change(eo_obj, obj);
|
|
|
|
evas_object_clip_dirty(eo_obj, obj);
|
|
|
|
evas_object_coords_recalc(eo_obj, obj);
|
|
|
|
evas_object_inform_call_resize(eo_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EXPERIMENTAL CODE END */
|
|
|
|
|
2014-03-09 00:31:28 -08:00
|
|
|
#include "canvas/evas_text.eo.c"
|