summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2015-03-19 19:00:56 +0200
committerDaniel Hirt <daniel.hirt@samsung.com>2015-03-24 17:30:00 +0200
commit4b32fe6debdd87edc53efddb333aad4a5cac9849 (patch)
treefb8cacba95fa5c52219f06229cdfee7813764d90
parentd78bbda675316f350a3447ce9b598042823770ef (diff)
downloadefl-devs/herdsman/tb_feature_obstacles.tar.gz
evas/textblock obstacles: add margin propertydevs/herdsman/tb_feature_obstacles
This is a property that uses a (registered) object as key, and updates its margin values (left, right, top, bottom). This helps the obstacles to fit better visually within the text layout. By default the margins of a registered object are 0. @feature
-rw-r--r--src/examples/evas/evas-textblock-obstacles.c21
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c66
-rw-r--r--src/lib/evas/canvas/evas_textblock.eo31
3 files changed, 114 insertions, 4 deletions
diff --git a/src/examples/evas/evas-textblock-obstacles.c b/src/examples/evas/evas-textblock-obstacles.c
index ff1ee3053c..ffa768264c 100644
--- a/src/examples/evas/evas-textblock-obstacles.c
+++ b/src/examples/evas/evas-textblock-obstacles.c
@@ -46,6 +46,7 @@ static const char *commands = \
"\tp - change obstacle's position\n"
"\tt - change obstacle's type (rectangle/image)\n"
"\tf - change obstacle's format\n"
+ "\tm - change obstacle's margin\n"
"\th - print help\n";
static const char *obs_img_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/kitty.png";
@@ -63,6 +64,9 @@ struct text_preset_data
Evas_Coord *obs_size_ptr;
Evas_Coord obs_size[3];
+ Evas_Coord *obs_margin_ptr;
+ Evas_Coord obs_margin[3];
+
const Evas_Textblock_Obstacle_Format *obs_fmt_ptr;
Evas_Textblock_Obstacle_Format obs_fmt[3];
@@ -172,6 +176,22 @@ _on_keydown(void *data EINA_UNUSED,
return;
}
+
+ if (strcmp(ev->key, "m") == 0) /* change obstacle size */
+ {
+ Evas_Coord margin;
+ (d.t_data.obs_margin_ptr)++;
+ POINTER_CYCLE(d.t_data.obs_margin_ptr, d.t_data.obs_margin);
+ margin = *d.t_data.obs_margin_ptr;
+
+ evas_object_textblock_obstacle_margin_set(d.text, *d.t_data.obs_ptr,
+ margin, margin, margin, margin);
+
+ fprintf(stdout, "Changing obstacle margin to: %d\n", margin);
+
+ return;
+ }
+
if (strcmp(ev->key, "p") == 0) /* change obstacle position */
{
Evas_Coord x, y;
@@ -235,6 +255,7 @@ main(void)
{
.font = {"DejaVu", "Courier", "Utopia"},
.obs_size = {50, 70, 100},
+ .obs_margin = {1, 5, 10},
.obs_fmt = {EVAS_TEXTBLOCK_OBSTACLE_DISABLED,
EVAS_TEXTBLOCK_OBSTACLE_LINE,
EVAS_TEXTBLOCK_OBSTACLE_FLOAT},
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 2b52fac9f8..0e657bd29f 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -487,6 +487,7 @@ struct _Evas_Textblock_Obstacle
Evas_Textblock_Obstacle_Format fmt;
Evas_Coord x, y, w, h;
Evas_Coord dx, dy;
+ Evas_Coord marginl, marginr, margint, marginb;
Eina_Bool changed : 1;
Eina_Bool handled : 1;
};
@@ -7097,11 +7098,11 @@ _obstacle_update(Evas_Textblock_Obstacle *obs, Eo *obj, Eo *eo_obj)
eo_do(eo_obj, evas_obj_position_get(&ox, &oy), evas_obj_size_get(&ow, &oh));
evas_object_geometry_get(obj, &x, &y, &w, &h);
- obs->x = ox - x;
- obs->y = oy - y;
+ obs->x = ox - obs->marginl - x;
+ obs->y = oy - obs->margint - y;
+ obs->w = ow + obs->marginr + obs->marginl;
+ obs->h = oh + obs->marginb + obs->margint;
obs->changed = EINA_TRUE;
- obs->w = ow;
- obs->h = oh;
}
static Evas_Textblock_Obstacle *
@@ -7265,6 +7266,63 @@ _evas_textblock_obstacle_unregister(Eo *eo_obj EINA_UNUSED, Evas_Textblock_Data
return EINA_TRUE;
}
+EOLIAN static Eina_Bool
+_evas_textblock_obstacle_margin_set(Eo *eo_obj EINA_UNUSED, Evas_Textblock_Data *obj, Eo *eo_obs,
+ Evas_Coord marginl, Evas_Coord marginr,
+ Evas_Coord margint, Evas_Coord marginb)
+{
+ Evas_Textblock_Obstacle *obs;
+ Eina_List *i;
+
+ if (!eo_isa(eo_obs, EVAS_OBJECT_CLASS))
+ return EINA_FALSE;
+
+ EINA_LIST_FOREACH(obj->obstacles, i, obs)
+ {
+ if (eo_obs == obs->eo_obj)
+ {
+ break;
+ }
+ }
+ if (!i) return EINA_FALSE;
+
+ obs->marginl = marginl;
+ obs->marginr = marginr;
+ obs->margint = margint;
+ obs->marginb = marginb;
+ _obstacle_update(obs, eo_obj, eo_obs);
+ _evas_textblock_changed(obj, eo_obj);
+ obj->obstacle_changed = EINA_TRUE;
+
+ return EINA_TRUE;
+}
+
+EOLIAN static Eina_Bool
+_evas_textblock_obstacle_margin_get(Eo *eo_obj EINA_UNUSED, Evas_Textblock_Data *obj, Eo *eo_obs, Evas_Coord *marginl, Evas_Coord *marginr, Evas_Coord *margint, Evas_Coord *marginb)
+{
+ Evas_Textblock_Obstacle *obs;
+ Eina_List *i;
+
+ if (!eo_isa(eo_obs, EVAS_OBJECT_CLASS))
+ return EINA_FALSE;
+
+ EINA_LIST_FOREACH(obj->obstacles, i, obs)
+ {
+ if (eo_obs == obs->eo_obj)
+ {
+ break;
+ }
+ }
+ if (!i) return EINA_FALSE;
+
+ if (marginl) *marginl = obs->marginl;
+ if (marginr) *marginr = obs->marginr;
+ if (margint) *margint = obs->margint;
+ if (marginb) *marginb = obs->marginb;
+
+ return EINA_TRUE;
+}
+
/* cursors */
/**
diff --git a/src/lib/evas/canvas/evas_textblock.eo b/src/lib/evas/canvas/evas_textblock.eo
index 7f5e551cc5..320ed77f4c 100644
--- a/src/lib/evas/canvas/evas_textblock.eo
+++ b/src/lib/evas/canvas/evas_textblock.eo
@@ -202,6 +202,37 @@ class Evas.Textblock (Evas.Object)
Evas_Coord b;
}
}
+ obstacle_margin {
+ get {
+ /*@
+ Get margin to @eo_obs obstacle object
+
+ @return Returns true on success, false on failure or if @eo_obs
+ isn't a registered object.
+
+ @since 1.14 */
+ return: bool;
+ }
+ set {
+ /*@
+ Get margin to @eo_obs obstacle object
+
+ @return Returns true on success, false on failure or if @eo_obs
+ isn't a registered object.
+
+ @since 1.14 */
+ return: bool;
+ }
+ keys {
+ Eo *eo_obs; /*@ the registered object */
+ }
+ values {
+ Evas_Coord marginl; /*@ left margin. */
+ Evas_Coord marginr; /*@ right margin. */
+ Evas_Coord margint; /*@ top margin. */
+ Evas_Coord marginb; /*@ bottom margin. */
+ }
+ }
}
methods {
line_number_geometry_get @const {