aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/edje
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2017-09-28 09:46:42 +0300
committerDaniel Hirt <hirt.danny@gmail.com>2017-09-28 19:32:02 +0300
commit3642b3ae679e3bedba4155fb9e54b44483b3b9e1 (patch)
tree0798f219f754bf10c3ce72345354160be4df10c3 /src/lib/edje
parentCanvas text: use EINA_UNUSED for unused variables (diff)
downloadefl-3642b3ae679e3bedba4155fb9e54b44483b3b9e1.tar.gz
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.
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/edje_part_text.c27
-rw-r--r--src/lib/edje/edje_private.h6
-rw-r--r--src/lib/edje/edje_util.c68
-rw-r--r--src/lib/edje/efl_canvas_layout_part_text.eo5
4 files changed, 89 insertions, 17 deletions
diff --git a/src/lib/edje/edje_part_text.c b/src/lib/edje/edje_part_text.c
index dc5a944743..0e5e4aa4ae 100644
--- a/src/lib/edje/edje_part_text.c
+++ b/src/lib/edje/edje_part_text.c
@@ -11,7 +11,7 @@ _efl_canvas_layout_part_text_efl_text_text_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);
+ _edje_efl_text_set(obj, pd->ed, pd->part, text, EINA_FALSE);
RETURN_VOID;
}
@@ -20,9 +20,27 @@ _efl_canvas_layout_part_text_efl_text_text_get(Eo *obj,
void *_pd EINA_UNUSED)
{
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 *
_efl_canvas_layout_part_text_efl_text_cursor_cursor_get(Eo *obj,
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);
}
-EOLIAN static int
-_efl_canvas_layout_part_text_efl_text_cursor_cursor_text_insert(Eo *obj,
+EOLIAN static void
+_efl_canvas_layout_part_text_efl_text_markup_cursor_markup_insert(Eo *obj,
void *_pd EINA_UNUSED, Efl_Text_Cursor_Cursor *cur EINA_UNUSED,
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
_edje_object_part_text_insert(pd->ed, pd->rp, text);
// FIXME: entry should report the length of inserted text (after filtering)
- RETURN_VAL(0);
}
#include "efl_canvas_layout_part_text.eo.c"
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 19421c03ed..c65f560071 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -3160,8 +3160,10 @@ Evas_Object *_edje_object_part_external_content_get(Edje *ed, const char *part,
/* part text */
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);
-const char *_edje_efl_text_get(Eo *obj, Edje *ed, const char *part);
+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, 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);
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);
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 36f7ce3eda..8ed6cc3d0a 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -1842,7 +1842,7 @@ _edje_object_text_change_cb_set(Eo *obj EINA_UNUSED, Edje *ed, Edje_Text_Change_
}
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) ||
(!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);
else
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->recalc_call = 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;
}
+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
_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
-_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;
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;
}
- 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);
return int_ret;
}
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;
@@ -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)
{
- 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
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;
}
EAPI const char *
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 :*/
diff --git a/src/lib/edje/efl_canvas_layout_part_text.eo b/src/lib/edje/efl_canvas_layout_part_text.eo
index 67cb7c396f..7a2211e46e 100644
--- a/src/lib/edje/efl_canvas_layout_part_text.eo
+++ b/src/lib/edje/efl_canvas_layout_part_text.eo
@@ -1,5 +1,5 @@
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
@@ -9,6 +9,7 @@ class Efl.Canvas.Layout.Part_Text (Efl.Canvas.Layout.Part, Efl.Text,
data: null;
implements {
Efl.Text.text { set; get; }
+ Efl.Text.Markup.markup { get; set; }
Efl.Text.Cursor.cursor { get; }
Efl.Text.Cursor.cursor_paragraph_first;
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_content { get; }
Efl.Text.Cursor.cursor_geometry { get; }
- Efl.Text.Cursor.cursor_text_insert;
+ Efl.Text.Markup.cursor_markup_insert;
}
}