summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2020-01-06 12:59:40 +0900
committerHermet Park <hermetpark@gmail.com>2020-01-06 12:59:40 +0900
commitcae037964696e2892cb3264aa97a45e6000e4a57 (patch)
tree9eccf082f689e656036cfe9177047ccc649179ed
parent21c043f5fa78c0eb756440826468856252c35264 (diff)
parent207da69c97d86ccd6f1e354b60b579a3d81f375c (diff)
downloadefl-cae037964696e2892cb3264aa97a45e6000e4a57.tar.gz
Merge branch 'master' into devs/hermet/lottie
-rw-r--r--src/examples/elementary/.gitignore1
-rw-r--r--src/examples/elementary/efl_canvas_textblock_obstacles_example.c273
-rw-r--r--src/examples/elementary/meson.build3
-rw-r--r--src/lib/elementary/efl_ui_widget.c19
-rw-r--r--src/lib/elementary/elm_code_text.c3
-rw-r--r--src/lib/evas/canvas/efl_canvas_animation_scale.eo4
-rw-r--r--src/lib/evas/canvas/efl_canvas_textblock.eo2
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c2
-rw-r--r--src/modules/evas/engines/gl_drm/evas_engine.c2
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c8
-rw-r--r--src/modules/evas/engines/wayland_egl/evas_engine.c2
11 files changed, 304 insertions, 15 deletions
diff --git a/src/examples/elementary/.gitignore b/src/examples/elementary/.gitignore
index 89ec3ec650..84d951ef90 100644
--- a/src/examples/elementary/.gitignore
+++ b/src/examples/elementary/.gitignore
@@ -171,3 +171,4 @@
/efl_ui_theme_example_02
/efl_ui_relative_container_example_01
/efl_ui_relative_container_example_02
+/efl_canvas_textblock_obstacles_example
diff --git a/src/examples/elementary/efl_canvas_textblock_obstacles_example.c b/src/examples/elementary/efl_canvas_textblock_obstacles_example.c
new file mode 100644
index 0000000000..d14123a801
--- /dev/null
+++ b/src/examples/elementary/efl_canvas_textblock_obstacles_example.c
@@ -0,0 +1,273 @@
+#define EFL_BETA_API_SUPPORT 1
+
+#include <Efl_Ui.h>
+
+ /**
+ * Example of canvas textblock obstacles.
+ *
+ * You start with two registered obstacle objects. They are not visible
+ * at first, so the canvas textblock simply shows the text that has been set to it.
+ * Once the obstacle is visible (show/hide keys in the example), the text will
+ * wrap around it.
+ * This example allows you to test two obstacles registered to the same
+ * canvas textblock object. Also, you can play with size and position for each.
+ * Use the 'h' key to show the provided options for this test.
+ *
+ * @verbatim
+ * gcc -g efl_canvas_textblock_obstacles_example.c -o efl_canvas_textblock_obstacles_example `pkg-config --cflags --libs elementary`
+ * @endverbatim
+ */
+
+#define WIDTH (360)
+#define HEIGHT (240)
+
+#define POINTER_CYCLE(_ptr, _array) \
+ do \
+ { \
+ if ((unsigned int)(((unsigned char *)(_ptr)) - ((unsigned char *)(_array))) >= \
+ sizeof(_array)) \
+ _ptr = _array; \
+ } \
+ while(0)
+
+static const char *commands = \
+ "commands are:\n"
+ "\tt - change currently controlled obstacle\n"
+ "\tv - show/hide current obstacle\n"
+ "\ts - cycle current obstacle's size\n"
+ "\tp - change current obstacle's position (random)\n"
+ "\tw - cycle text wrapping modes (none/word/char/mixed)\n"
+ "\th - print help\n";
+
+struct text_preset_data
+{
+ const char **font_ptr;
+ const char *font[3];
+
+ const char **wrap_ptr;
+ const char *wrap[4];
+
+ int *obs_size_ptr;
+ int obs_size[3];
+
+ Eo **obs_ptr; /* pointer to the currently controlled obstacle object */
+ Eo *obs[2];
+};
+
+struct test_data
+{
+ Eo *win, *box, *bg, *text;
+ struct text_preset_data t_data;
+ Eina_Size2D size;
+};
+
+static struct test_data d = {0};
+
+static unsigned int
+_getrand(unsigned int low, unsigned int high)
+{
+ return (rand() % (high - low)) + low;
+}
+
+static void
+_style_set(const char *wrap)
+{
+ char buf[2000];
+ snprintf(buf,
+ 2000,
+ "font=Sans font_size=16 color=#000 wrap=%s",
+ wrap);
+
+ efl_canvas_textblock_style_apply(d.text, buf);
+}
+
+static void
+_key_down(void *data EINA_UNUSED, const Efl_Event *ev)
+{
+ const char *key = efl_input_key_string_get(ev->info);
+ if (!key)
+ return;
+
+ if (strcmp(key, "h") == 0) /* print help */
+ {
+ printf("%s\n", commands);
+ return;
+ }
+
+ if (strcmp(key, "t") == 0) /* change obstacle type */
+ {
+ (d.t_data.obs_ptr)++;
+ POINTER_CYCLE(d.t_data.obs_ptr, d.t_data.obs);
+
+ printf("Now controlling obstacle: %p\n", *d.t_data.obs_ptr);
+
+ return;
+ }
+
+ if (strcmp(key, "v") == 0) /* change obstacle visibility */
+ {
+ Eo *obj = *d.t_data.obs_ptr;
+ if (efl_gfx_entity_visible_get(obj))
+ efl_gfx_entity_visible_set(obj, EINA_FALSE);
+ else
+ efl_gfx_entity_visible_set(obj, EINA_TRUE);
+
+ printf("Show/hide toggle for obstacle %p\n",
+ *d.t_data.obs_ptr);
+
+ efl_canvas_textblock_obstacles_update(d.text);
+
+ return;
+ }
+
+ if (strcmp(key, "s") == 0) /* change obstacle size */
+ {
+ (d.t_data.obs_size_ptr)++;
+ POINTER_CYCLE(d.t_data.obs_size_ptr, d.t_data.obs_size);
+
+ efl_gfx_entity_size_set(*d.t_data.obs_ptr, EINA_SIZE2D(*d.t_data.obs_size_ptr, *d.t_data.obs_size_ptr));
+
+ efl_canvas_textblock_obstacles_update(d.text);
+
+ printf("Changing obstacle size to: %d,%d\n",
+ *d.t_data.obs_size_ptr, *d.t_data.obs_size_ptr);
+
+ return;
+ }
+
+ if (strcmp(key, "p") == 0) /* change obstacle position */
+ {
+ int x, y;
+ x = _getrand(0, d.size.w);
+ y = _getrand(0, d.size.h);
+
+ efl_gfx_entity_position_set(*d.t_data.obs_ptr, EINA_POSITION2D(x, y));
+ efl_canvas_textblock_obstacles_update(d.text);
+
+ printf("Changing obstacles position\n");
+ efl_gfx_entity_position_set(*d.t_data.obs_ptr, EINA_POSITION2D(x, y));
+
+ Eina_Position2D r_rec = efl_gfx_entity_position_get(d.t_data.obs[0]);
+ Eina_Position2D g_rec = efl_gfx_entity_position_get(d.t_data.obs[1]);
+
+ printf("Obstacle #1 (red) : [%d,%d]\n", r_rec.x, r_rec.y);
+ printf("Obstacle #2 (green): [%d,%d]\n", g_rec.x, g_rec.y);
+
+ return;
+ }
+
+ if (strcmp(key, "w") == 0) /* change obstacle position */
+ {
+ (d.t_data.wrap_ptr)++;
+ POINTER_CYCLE(d.t_data.wrap_ptr, d.t_data.wrap);
+ printf("Changing wrap mode to: %s\n",
+ *d.t_data.wrap_ptr);
+ _style_set(*d.t_data.wrap_ptr);
+ efl_canvas_textblock_obstacles_update(d.text);
+
+ return;
+ }
+}
+
+static void
+_win_resize(void *data EINA_UNUSED, const Efl_Event *ev)
+{
+ Eina_Size2D sz;
+
+ sz = efl_gfx_entity_size_get(ev->object);
+ efl_gfx_entity_size_set(d.bg, sz);
+ efl_gfx_entity_size_set(d.text, sz);
+
+ d.size = sz;
+}
+
+static void
+_text_init()
+{
+ _style_set("word");
+
+ efl_text_markup_set(d.text,
+ "This example text demonstrates the textblock object"
+ " with obstacle objects support."
+ " Any evas object <item size=72x16></item>can register itself as an obstacle to the textblock"
+ " object. Upon regi<color=#0ff>stering, it aff</color>ects the layout of the text in"
+ " certain situations. Usually, when the obstacle shows above the text"
+ " area, it will cause the layout of the text to split and move"
+ " parts of it, so that all text area is apparent."
+ );
+}
+
+static void
+_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
+{
+ efl_exit(0);
+}
+
+static void
+_gui_setup()
+{
+ /* init values one is going to cycle through while running this
+ * example */
+ struct text_preset_data init_data =
+ {
+ .font = {"DejaVu", "Courier", "Utopia"},
+ .wrap = {"word", "char", "mixed", "none"},
+ .obs_size = {50, 70, 100},
+ .obs = {NULL, NULL},
+ };
+
+ d.t_data = init_data;
+ d.t_data.font_ptr = d.t_data.font;
+ d.t_data.obs_size_ptr = d.t_data.obs_size;
+ d.t_data.obs_ptr = d.t_data.obs;
+
+ d.win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
+ efl_text_set(efl_added, "Obstacles Example"),
+ efl_ui_win_autodel_set(efl_added, EINA_TRUE));
+
+ efl_gfx_entity_size_set(d.win, EINA_SIZE2D(WIDTH, HEIGHT));
+ printf("Window size set to [%d,%d]\n", WIDTH, HEIGHT);
+
+ efl_event_callback_add(d.win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL);
+ efl_event_callback_add(d.win, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED, _win_resize, NULL);
+ efl_event_callback_add(d.win, EFL_EVENT_KEY_DOWN, _key_down, NULL);
+
+ d.bg = efl_add(EFL_CANVAS_RECTANGLE_CLASS, d.win,
+ efl_gfx_color_set(efl_added, 255, 255, 255, 255));
+
+ efl_gfx_entity_size_set(d.bg, EINA_SIZE2D(WIDTH, HEIGHT));
+ efl_gfx_entity_position_set(d.bg, EINA_POSITION2D(0, 0));
+
+ d.text = efl_add(EFL_CANVAS_TEXTBLOCK_CLASS, d.win,
+ efl_text_multiline_set(efl_added, EINA_TRUE));
+
+ _text_init();
+ efl_gfx_entity_size_set(d.text, EINA_SIZE2D(WIDTH, HEIGHT));
+ efl_gfx_entity_position_set(d.text, EINA_POSITION2D(0, 0));
+
+ d.size.w = WIDTH;
+ d.size.h = HEIGHT;
+
+ /* init obstacles */
+ d.t_data.obs[0] = efl_add(EFL_CANVAS_RECTANGLE_CLASS, d.win,
+ efl_gfx_color_set(efl_added, 255, 0, 0, 255));
+
+ efl_gfx_entity_size_set(d.t_data.obs[0], EINA_SIZE2D(50,50));
+
+ d.t_data.obs[1] = efl_add(EFL_CANVAS_RECTANGLE_CLASS, d.win,
+ efl_gfx_color_set(efl_added, 0, 255, 0, 255));
+
+ efl_gfx_entity_size_set(d.t_data.obs[1], EINA_SIZE2D(50,50));
+
+ efl_canvas_textblock_obstacle_add(d.text, d.t_data.obs[0]);
+ efl_canvas_textblock_obstacle_add(d.text, d.t_data.obs[1]);
+
+ printf("%s\n", commands);
+}
+
+EAPI_MAIN void
+efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
+{
+ _gui_setup();
+}
+EFL_MAIN()
diff --git a/src/examples/elementary/meson.build b/src/examples/elementary/meson.build
index e88ddfe567..cdb08d4b35 100644
--- a/src/examples/elementary/meson.build
+++ b/src/examples/elementary/meson.build
@@ -120,7 +120,8 @@ examples = [
'efl_ui_slideshow_example',
'efl_ui_radio_example_01',
'efl_ui_grid_example_1',
- 'efl_ui_grid_view_example_1'
+ 'efl_ui_grid_view_example_1',
+ 'efl_canvas_textblock_obstacles_example'
]
foreach example : examples
diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c
index 768d934fae..7218b8b063 100644
--- a/src/lib/elementary/efl_ui_widget.c
+++ b/src/lib/elementary/efl_ui_widget.c
@@ -525,13 +525,13 @@ _full_eval(Eo *obj, Elm_Widget_Smart_Data *pd)
{
//emit signal and focus eval old and new
ELM_WIDGET_DATA_GET(old_parent, old_pd);
- _full_eval(old_parent, old_pd);
+ if (old_pd) _full_eval(old_parent, old_pd);
}
if (efl_isa(pd->logical.parent, EFL_UI_WIDGET_CLASS))
{
ELM_WIDGET_DATA_GET(pd->logical.parent, new_pd);
- _full_eval(pd->logical.parent, new_pd);
+ if (new_pd) _full_eval(pd->logical.parent, new_pd);
}
}
@@ -562,8 +562,7 @@ void
_elm_widget_full_eval(Eo *obj)
{
ELM_WIDGET_DATA_GET(obj, pd);
-
- _full_eval(obj, pd);
+ if (pd) _full_eval(obj, pd);
}
/**
@@ -652,6 +651,7 @@ _obj_mouse_down(void *data,
Evas_Object *top;
ELM_WIDGET_DATA_GET(data, sd);
+ if (!sd) return;
Evas_Event_Mouse_Down *ev = event_info;
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
@@ -667,6 +667,7 @@ _obj_mouse_move(void *data,
void *event_info)
{
ELM_WIDGET_DATA_GET(data, sd);
+ if (!sd) return;
Evas_Event_Mouse_Move *ev = event_info;
if (!sd->still_in) return;
@@ -688,6 +689,7 @@ _obj_mouse_up(void *data,
void *event_info)
{
ELM_WIDGET_DATA_GET(data, sd);
+ if (!sd) return;
Evas_Event_Mouse_Up *ev = event_info;
if (sd->still_in && (ev->flags == EVAS_BUTTON_NONE) &&
@@ -705,6 +707,7 @@ _obj_mouse_in(void *data,
void *event_info EINA_UNUSED)
{
ELM_WIDGET_DATA_GET(data, sd);
+ if (!sd) return;
if (sd->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN &&
!efl_invalidated_get(data))
elm_widget_focus_mouse_up_handle(evas_object_widget_parent_find(obj));
@@ -4804,7 +4807,8 @@ _efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UN
else
{
ELM_WIDGET_DATA_GET(parent, parent_sd);
- sd->shared_win_data = parent_sd->shared_win_data;
+ if (parent_sd)
+ sd->shared_win_data = parent_sd->shared_win_data;
}
}
else
@@ -5161,6 +5165,7 @@ elm_widget_on_show_region_hook_set(Eo *obj, void *data, Elm_Widget_On_Show_Regio
{
ELM_WIDGET_DATA_GET(obj, sd);
+ if (!sd) return;
if ((sd->on_show_region_data == data) && (sd->on_show_region == func))
return;
@@ -5854,6 +5859,7 @@ _efl_ui_model_property_bind_changed(void *data, const Efl_Event *event)
const char *prop;
unsigned int i;
+ if (!pd) return;
EINA_ARRAY_ITER_NEXT(evt->changed_properties, i, prop, it)
{
Efl_Ui_Property_Bound *lookup;
@@ -5872,6 +5878,7 @@ _efl_ui_view_property_bind_changed(void *data, const Efl_Event *event)
Eina_Stringshare *prop;
unsigned int i;
+ if (!pd) return;
EINA_ARRAY_ITER_NEXT(evt->changed_properties, i, prop, it)
{
Efl_Ui_Property_Bound *lookup;
@@ -5905,6 +5912,7 @@ _efl_ui_widget_model_provider_model_change(void *data, const Efl_Event *event)
{
ELM_WIDGET_DATA_GET(data, pd);
+ if (!pd) return;
efl_replace(&pd->properties.model,
efl_ui_view_model_get(pd->properties.provider));
_efl_ui_widget_model_update(data, pd);
@@ -5917,6 +5925,7 @@ _efl_ui_widget_model_provider_invalidate(void *data, const Efl_Event *event EINA
{
ELM_WIDGET_DATA_GET(data, pd);
+ if (!pd) return;
efl_event_callback_array_del(pd->properties.provider,
efl_ui_widget_model_provider_callbacks(),
data);
diff --git a/src/lib/elementary/elm_code_text.c b/src/lib/elementary/elm_code_text.c
index d27081a251..56fc1a07c5 100644
--- a/src/lib/elementary/elm_code_text.c
+++ b/src/lib/elementary/elm_code_text.c
@@ -19,6 +19,9 @@ elm_code_line_text_get(Elm_Code_Line *line, unsigned int *length)
if (length)
*length = line->length;
+ if (!line->length)
+ return "";
+
if (line->modified)
return line->modified;
return line->content;
diff --git a/src/lib/evas/canvas/efl_canvas_animation_scale.eo b/src/lib/evas/canvas/efl_canvas_animation_scale.eo
index ab691617b4..1bde1a07f6 100644
--- a/src/lib/evas/canvas/efl_canvas_animation_scale.eo
+++ b/src/lib/evas/canvas/efl_canvas_animation_scale.eo
@@ -48,7 +48,9 @@ class Efl.Canvas.Animation_Scale extends Efl.Canvas.Animation
values {
from_scale: Eina.Vector2; [[Initial scale value.]]
to_scale: Eina.Vector2; [[Ending scale value.]]
- pivot_point: Eina.Position2D; [[Position of the pivot point relative to the canvas. If $null the target passed to @Efl.Canvas.Animation.animation_apply is used as pivot element]]
+ pivot_point: Eina.Position2D; [[Position of the pivot point relative to the canvas.
+ If $null the target passed to @Efl.Canvas.Animation.animation_apply
+ is used as pivot element.]]
}
}
}
diff --git a/src/lib/evas/canvas/efl_canvas_textblock.eo b/src/lib/evas/canvas/efl_canvas_textblock.eo
index 031f74a13e..d66ee55fec 100644
--- a/src/lib/evas/canvas/efl_canvas_textblock.eo
+++ b/src/lib/evas/canvas/efl_canvas_textblock.eo
@@ -398,7 +398,7 @@ class @beta Efl.Canvas.Textblock extends Efl.Canvas.Object implements Efl.Text,
}
// Obstacles
obstacle_add {
- [[Add obstacle evas object $eo_obs to be observed during layout
+ [[Add obstacle object $eo_obs to be avoided during layout
of text.
The textblock does the layout of the text according to the
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 817008c889..3c0d5bf1d1 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -6569,7 +6569,7 @@ _layout_par(Ctxt *c)
Evas_Coord cw = c->w;
if (obs)
{
- cw -= obs->w;
+ cw = obs->x;
}
if (it->format->wrap_word)
wrap = _layout_get_wordwrap(c, it->format, it,
diff --git a/src/modules/evas/engines/gl_drm/evas_engine.c b/src/modules/evas/engines/gl_drm/evas_engine.c
index 8c1d6013e7..281ec9f154 100644
--- a/src/modules/evas/engines/gl_drm/evas_engine.c
+++ b/src/modules/evas/engines/gl_drm/evas_engine.c
@@ -1459,7 +1459,7 @@ eng_image_native_set(void *engine, void *image, void *native)
if (!n->ns_data.wl_surface.surface)
{
- ERR("eglCreatePixmapSurface() for %p failed", wl_buf);
+ WRN("eglCreatePixmapSurface() for %p failed", wl_buf);
eina_hash_del(ob->gl_context->shared->native_wl_hash,
&wlid, img);
glsym_evas_gl_common_image_free(img);
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c
index 1d63eaace6..a22e9d95db 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -1964,7 +1964,7 @@ _native_bind_cb(void *image)
(void *)n->ns_data.x11.pixmap,
NULL);
if (!n->ns_data.x11.surface)
- ERR("eglCreateImage() for Pixmap 0x%#lx failed: %#x", n->ns_data.x11.pixmap, eglGetError());
+ WRN("eglCreateImage() for Pixmap 0x%#lx failed: %#x", n->ns_data.x11.pixmap, eglGetError());
}
if (glsym_glEGLImageTargetTexture2DOES)
@@ -2567,7 +2567,7 @@ eng_image_native_set(void *engine, void *image, void *native)
if (!n->ns_data.x11.surface)
{
- ERR("eglCreateImage() for Pixmap %#lx failed: %#x", pm, eglGetError());
+ WRN("eglCreateImage() for Pixmap %#lx failed: %#x", pm, eglGetError());
free(n);
return NULL;
}
@@ -2854,7 +2854,7 @@ eng_image_native_set(void *engine, void *image, void *native)
else
ERR("Try eglCreateImage on EGL with no support");
if (!n->ns_data.tbm.surface)
- ERR("eglCreateImage() for %p failed", buffer);
+ WRN("eglCreateImage() for %p failed", buffer);
im->native.yinvert = 1;
im->native.loose = 0;
im->native.disp = ob->egl_disp;
@@ -2965,7 +2965,7 @@ eng_image_native_set(void *engine, void *image, void *native)
if (!n->ns_data.wl_surface.surface)
{
- ERR("eglCreatePixmapSurface() for %p failed", wl_buf);
+ WRN("eglCreatePixmapSurface() for %p failed", wl_buf);
eina_hash_del(gl_context->shared->native_wl_hash,
&wlid, im);
glsym_evas_gl_common_image_free(im);
diff --git a/src/modules/evas/engines/wayland_egl/evas_engine.c b/src/modules/evas/engines/wayland_egl/evas_engine.c
index 024e794ac4..58eb54a467 100644
--- a/src/modules/evas/engines/wayland_egl/evas_engine.c
+++ b/src/modules/evas/engines/wayland_egl/evas_engine.c
@@ -1317,7 +1317,7 @@ eng_image_native_set(void *engine, void *image, void *native)
else
ERR("Try eglCreateImage on EGL with no support");
if (!n->ns_data.tbm.surface)
- ERR("eglCreateImage() for %p failed", buffer);
+ WRN("eglCreateImage() for %p failed", buffer);
img->native.yinvert = 1;
img->native.loose = 0;
img->native.disp = ob->egl_disp;