forked from enlightenment/efl
Canvas layout: support markup for efl_part
Users can now do either: efl_text_set(efl_part(obj, "part"), "text"); efl_text_markup_set(efl_part(obj, "part"), "text"); Also have efl_text_get/markup_get. Using markup_set will allow to choose whether to set a markup or a text to the text part.
This commit is contained in:
parent
e34efbed96
commit
3642b3ae67
|
@ -11,7 +11,7 @@ _efl_canvas_layout_part_text_efl_text_text_set(Eo *obj,
|
||||||
void *_pd EINA_UNUSED, const char *text)
|
void *_pd EINA_UNUSED, const char *text)
|
||||||
{
|
{
|
||||||
PROXY_DATA_GET(obj, pd);
|
PROXY_DATA_GET(obj, pd);
|
||||||
_edje_efl_text_set(obj, pd->ed, pd->part, text);
|
_edje_efl_text_set(obj, pd->ed, pd->part, text, EINA_FALSE);
|
||||||
RETURN_VOID;
|
RETURN_VOID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,27 @@ _efl_canvas_layout_part_text_efl_text_text_get(Eo *obj,
|
||||||
void *_pd EINA_UNUSED)
|
void *_pd EINA_UNUSED)
|
||||||
{
|
{
|
||||||
PROXY_DATA_GET(obj, pd);
|
PROXY_DATA_GET(obj, pd);
|
||||||
RETURN_VAL(_edje_efl_text_get(obj, pd->ed, pd->part));
|
RETURN_VAL(_edje_efl_text_get(obj, pd->ed, pd->part, EINA_FALSE, EINA_FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EOLIAN static const char *
|
||||||
|
_efl_canvas_layout_part_text_efl_text_markup_markup_get(Eo *obj,
|
||||||
|
void *_pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
PROXY_DATA_GET(obj, pd);
|
||||||
|
RETURN_VAL(_edje_efl_text_get(obj, pd->ed, pd->part, EINA_FALSE, EINA_TRUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_efl_canvas_layout_part_text_efl_text_markup_markup_set(Eo *obj,
|
||||||
|
void *_pd EINA_UNUSED, const char *text)
|
||||||
|
{
|
||||||
|
PROXY_DATA_GET(obj, pd);
|
||||||
|
_edje_efl_text_set(obj, pd->ed, pd->part, text, EINA_TRUE);
|
||||||
|
RETURN_VOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EOLIAN static Efl_Text_Cursor_Cursor *
|
EOLIAN static Efl_Text_Cursor_Cursor *
|
||||||
_efl_canvas_layout_part_text_efl_text_cursor_cursor_get(Eo *obj,
|
_efl_canvas_layout_part_text_efl_text_cursor_cursor_get(Eo *obj,
|
||||||
void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Get_Type get_type)
|
void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor_Get_Type get_type)
|
||||||
|
@ -180,8 +198,8 @@ _efl_canvas_layout_part_text_efl_text_cursor_cursor_geometry_get(Eo *obj,
|
||||||
RETURN_VAL(EINA_FALSE);
|
RETURN_VAL(EINA_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static int
|
EOLIAN static void
|
||||||
_efl_canvas_layout_part_text_efl_text_cursor_cursor_text_insert(Eo *obj,
|
_efl_canvas_layout_part_text_efl_text_markup_cursor_markup_insert(Eo *obj,
|
||||||
void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor *cur EINA_UNUSED,
|
void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor *cur EINA_UNUSED,
|
||||||
const char *text)
|
const char *text)
|
||||||
{
|
{
|
||||||
|
@ -189,7 +207,6 @@ _efl_canvas_layout_part_text_efl_text_cursor_cursor_text_insert(Eo *obj,
|
||||||
// Ignoring cursor type and always inserting with main cursor
|
// Ignoring cursor type and always inserting with main cursor
|
||||||
_edje_object_part_text_insert(pd->ed, pd->rp, text);
|
_edje_object_part_text_insert(pd->ed, pd->rp, text);
|
||||||
// FIXME: entry should report the length of inserted text (after filtering)
|
// FIXME: entry should report the length of inserted text (after filtering)
|
||||||
RETURN_VAL(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "efl_canvas_layout_part_text.eo.c"
|
#include "efl_canvas_layout_part_text.eo.c"
|
||||||
|
|
|
@ -3160,8 +3160,10 @@ Evas_Object *_edje_object_part_external_content_get(Edje *ed, const char *part,
|
||||||
|
|
||||||
/* part text */
|
/* part text */
|
||||||
Eo *_edje_text_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp);
|
Eo *_edje_text_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp);
|
||||||
Eina_Bool _edje_efl_text_set(Eo *obj, Edje *ed, const char *part, const char *text);
|
Eina_Bool _edje_efl_text_set(Eo *obj, Edje *ed, const char *part, const char *text, Eina_Bool set_markup);
|
||||||
const char *_edje_efl_text_get(Eo *obj, Edje *ed, const char *part);
|
const char *_edje_efl_text_get(Eo *obj, Edje *ed, const char *part, Eina_Bool legacy, Eina_Bool get_markup);
|
||||||
|
Eina_Bool _edje_efl_text_markup_set(Eo *obj, Edje *ed, const char *part, const char *markup);
|
||||||
|
const char *_edje_efl_text_markup_get(Eo *obj, Edje *ed, const char *part);
|
||||||
Evas_Textblock_Cursor *_edje_text_cursor_get(Edje_Real_Part *rp, Edje_Cursor cur);
|
Evas_Textblock_Cursor *_edje_text_cursor_get(Edje_Real_Part *rp, Edje_Cursor cur);
|
||||||
void _edje_text_cursor_begin(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor *cur);
|
void _edje_text_cursor_begin(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor *cur);
|
||||||
void _edje_text_cursor_end(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor *cur);
|
void _edje_text_cursor_end(Edje_Real_Part *rp, Efl_Text_Cursor_Cursor *cur);
|
||||||
|
|
|
@ -1842,7 +1842,7 @@ _edje_object_text_change_cb_set(Eo *obj EINA_UNUSED, Edje *ed, Edje_Text_Change_
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
_edje_object_part_text_raw_set(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text)
|
_edje_object_part_text_raw_generic_set(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text, Eina_Bool set_markup)
|
||||||
{
|
{
|
||||||
if ((rp->type != EDJE_RP_TYPE_TEXT) ||
|
if ((rp->type != EDJE_RP_TYPE_TEXT) ||
|
||||||
(!rp->typedata.text)) return EINA_TRUE;
|
(!rp->typedata.text)) return EINA_TRUE;
|
||||||
|
@ -1860,7 +1860,21 @@ _edje_object_part_text_raw_set(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, c
|
||||||
_edje_entry_text_markup_set(rp, text);
|
_edje_entry_text_markup_set(rp, text);
|
||||||
else
|
else
|
||||||
if (text)
|
if (text)
|
||||||
rp->typedata.text->text = eina_stringshare_add(text);
|
{
|
||||||
|
if (set_markup)
|
||||||
|
{
|
||||||
|
char *mkup;
|
||||||
|
mkup =
|
||||||
|
efl_text_markup_util_text_to_markup(EFL_TEXT_MARKUP_UTIL_CLASS,
|
||||||
|
text);
|
||||||
|
rp->typedata.text->text = eina_stringshare_add(mkup);
|
||||||
|
free(mkup);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rp->typedata.text->text = eina_stringshare_add(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
ed->dirty = EINA_TRUE;
|
ed->dirty = EINA_TRUE;
|
||||||
ed->recalc_call = EINA_TRUE;
|
ed->recalc_call = EINA_TRUE;
|
||||||
ed->recalc_hints = EINA_TRUE;
|
ed->recalc_hints = EINA_TRUE;
|
||||||
|
@ -1873,6 +1887,13 @@ _edje_object_part_text_raw_set(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, c
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
|
_edje_object_part_text_raw_set(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text)
|
||||||
|
{
|
||||||
|
return _edje_object_part_text_raw_generic_set(ed, obj, rp, part, text,
|
||||||
|
EINA_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_edje_user_define_string(Edje *ed, const char *part, const char *raw_text, Edje_Text_Type type)
|
_edje_user_define_string(Edje *ed, const char *part, const char *raw_text, Edje_Text_Type type)
|
||||||
{
|
{
|
||||||
|
@ -1902,7 +1923,8 @@ _edje_user_define_string(Edje *ed, const char *part, const char *raw_text, Edje_
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
_edje_efl_text_set(Eo *obj, Edje *ed, const char *part, const char *text)
|
_edje_efl_text_set(Eo *obj, Edje *ed, const char *part, const char *text,
|
||||||
|
Eina_Bool set_markup)
|
||||||
{
|
{
|
||||||
Edje_Real_Part *rp;
|
Edje_Real_Part *rp;
|
||||||
Eina_Bool int_ret;
|
Eina_Bool int_ret;
|
||||||
|
@ -1917,13 +1939,15 @@ _edje_efl_text_set(Eo *obj, Edje *ed, const char *part, const char *text)
|
||||||
{
|
{
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
int_ret = _edje_object_part_text_raw_set(ed, obj, rp, part, text);
|
int_ret = _edje_object_part_text_raw_generic_set(ed, obj, rp, part, text,
|
||||||
|
set_markup);
|
||||||
_edje_user_define_string(ed, part, rp->typedata.text->text, EDJE_TEXT_TYPE_NORMAL);
|
_edje_user_define_string(ed, part, rp->typedata.text->text, EDJE_TEXT_TYPE_NORMAL);
|
||||||
return int_ret;
|
return int_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
_edje_efl_text_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part)
|
_edje_efl_text_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part,
|
||||||
|
Eina_Bool legacy, Eina_Bool get_markup)
|
||||||
{
|
{
|
||||||
Edje_Real_Part *rp;
|
Edje_Real_Part *rp;
|
||||||
|
|
||||||
|
@ -1958,7 +1982,24 @@ _edje_efl_text_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part)
|
||||||
}
|
}
|
||||||
if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
|
if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
|
||||||
{
|
{
|
||||||
return evas_object_textblock_text_markup_get(rp->object);
|
const char *entry;
|
||||||
|
if (legacy)
|
||||||
|
{
|
||||||
|
entry = evas_object_textblock_text_markup_get(rp->object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (get_markup)
|
||||||
|
{
|
||||||
|
entry = efl_text_markup_get(rp->object);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entry = efl_text_get(rp->object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6093,14 +6134,25 @@ edje_object_part_swallow_get(const Edje_Object *obj, const char *part)
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
edje_object_part_text_set(const Edje_Object *obj, const char *part, const char *text)
|
edje_object_part_text_set(const Edje_Object *obj, const char *part, const char *text)
|
||||||
{
|
{
|
||||||
efl_text_set(efl_part(obj, part), text);
|
efl_text_markup_set(efl_part(obj, part), text);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI const char *
|
EAPI const char *
|
||||||
edje_object_part_text_get(const Edje_Object *obj, const char *part)
|
edje_object_part_text_get(const Edje_Object *obj, const char *part)
|
||||||
{
|
{
|
||||||
return efl_text_get(efl_part(obj, part));
|
Edje_Real_Part *rp;
|
||||||
|
Edje *ed;
|
||||||
|
|
||||||
|
if (!_edje_part_fetch(obj, part, &ed, &rp)) return NULL;
|
||||||
|
|
||||||
|
if ((rp->part->type != EDJE_PART_TYPE_TEXT) &&
|
||||||
|
(rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
|
||||||
|
{
|
||||||
|
ERR("Invalid call on a non-text or non-textblock part: '%s' in group '%s'", part, ed->group);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return _edje_efl_text_get((Eo *)obj, ed, part, EINA_TRUE, EINA_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
|
/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class Efl.Canvas.Layout.Part_Text (Efl.Canvas.Layout.Part, Efl.Text,
|
class Efl.Canvas.Layout.Part_Text (Efl.Canvas.Layout.Part, Efl.Text,
|
||||||
Efl.Text.Cursor)
|
Efl.Text.Markup, Efl.Text.Cursor)
|
||||||
{
|
{
|
||||||
[[Represents a TEXT part of a layout
|
[[Represents a TEXT part of a layout
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ class Efl.Canvas.Layout.Part_Text (Efl.Canvas.Layout.Part, Efl.Text,
|
||||||
data: null;
|
data: null;
|
||||||
implements {
|
implements {
|
||||||
Efl.Text.text { set; get; }
|
Efl.Text.text { set; get; }
|
||||||
|
Efl.Text.Markup.markup { get; set; }
|
||||||
Efl.Text.Cursor.cursor { get; }
|
Efl.Text.Cursor.cursor { get; }
|
||||||
Efl.Text.Cursor.cursor_paragraph_first;
|
Efl.Text.Cursor.cursor_paragraph_first;
|
||||||
Efl.Text.Cursor.cursor_paragraph_last;
|
Efl.Text.Cursor.cursor_paragraph_last;
|
||||||
|
@ -22,6 +23,6 @@ class Efl.Canvas.Layout.Part_Text (Efl.Canvas.Layout.Part, Efl.Text,
|
||||||
Efl.Text.Cursor.cursor_copy;
|
Efl.Text.Cursor.cursor_copy;
|
||||||
Efl.Text.Cursor.cursor_content { get; }
|
Efl.Text.Cursor.cursor_content { get; }
|
||||||
Efl.Text.Cursor.cursor_geometry { get; }
|
Efl.Text.Cursor.cursor_geometry { get; }
|
||||||
Efl.Text.Cursor.cursor_text_insert;
|
Efl.Text.Markup.cursor_markup_insert;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue