elm: Add a test case for evas masking

This tests masks of masks in a genlist, with maybe a map.
Nothing crazy.
devs/sung/evas_gl_thread
Jean-Philippe Andre 6 years ago
parent 584e17ae84
commit a07877bd57
  1. 6
      data/Makefile.am
  2. 1
      data/elementary/images/Makefile.am
  3. BIN
      data/elementary/images/pm_fill.png
  4. 4
      data/elementary/objects/Makefile.am
  5. BIN
      data/elementary/objects/roundedrect.png
  6. 70
      data/elementary/objects/test_masking.edc
  7. 1
      src/Makefile_Elementary.am
  8. 6
      src/bin/elementary/test.c
  9. 175
      src/bin/elementary/test_evas_mask.c

@ -210,6 +210,7 @@ elementaryobjectsdir = $(datadir)/elementary/objects
elementaryobjects_DATA = \
elementary/objects/test.edj \
elementary/objects/test_external.edj \
elementary/objects/test_masking.edj \
elementary/objects/multip.edj \
elementary/objects/cursors.edj \
elementary/objects/font_preview.edj \
@ -232,6 +233,11 @@ elementary/objects/test_external.edj: elementary/objects/test_external.edc
$(MKDIR_P) elementary/objects/; \
$(EDJE_CC) $(EDJE_CC_FLAGS) $< $@
elementary/objects/test_masking.edj: elementary/objects/test_masking.edc
$(AM_V_EDJ) \
$(MKDIR_P) elementary/objects/; \
$(EDJE_CC) $(EDJE_CC_FLAGS) $< $@
elementary/objects/multip.edj: elementary/objects/multip.edc
$(AM_V_EDJ) \
$(MKDIR_P) elementary/objects/; \

@ -46,6 +46,7 @@ elementary_images_files = \
elementary/images/mystrale.jpg \
elementary/images/mystrale_2.jpg \
elementary/images/twofish.jpg \
elementary/images/pm_fill.png \
elementary/images/pt.png \
elementary/images/earth_normal.png \
elementary/images/space.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

@ -3,6 +3,7 @@ EDJE_CC_FLAGS += -id $(top_srcdir)/data/elementary/objects -fd $(top_srcdir)/dat
EXTRA_DIST += \
elementary/objects/test.edc \
elementary/objects/test_external.edc \
elementary/objects/test_masking.edc \
elementary/objects/test_prefs.edc \
elementary/objects/test_prefs.epc \
elementary/objects/multip.edc \
@ -21,4 +22,5 @@ elementary/objects/border2.png \
elementary/objects/border3.png \
elementary/objects/border4.png \
elementary/objects/border5.png \
elementary/objects/border6.png
elementary/objects/border6.png \
elementary/objects/roundedrect.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

@ -0,0 +1,70 @@
collections {
images {
image: "roundedrect.png" COMP;
}
filters {
filter { name: "aura";
script {
padding_set { 5 }
fill { color = '#2228' }
blur { 5, color = 'red' }
blur { 2, color = 'orange' }
blend {}
}
}
}
group { "masking";
parts {
rect { "clip"; norender; }
image { "mask";
norender;
desc { "default";
image {
normal: "roundedrect.png";
border: 22 22 22 22;
}
}
}
swallow { "content";
desc { "default";
clip_to: "mask";
}
desc { "unclipped";
clip_to: "clip";
}
}
}
programs {
program {
signal: "unclip";
source: "*";
action: STATE_SET "unclipped";
target: "content";
}
program {
signal: "clip";
source: "*";
action: STATE_SET "default";
target: "content";
}
}
}
group { "text";
parts {
text { "text";
desc { "default";
text {
font: "Sans";
size: 32;
text: "HELLO";
ellipsis: -1;
}
fixed: 1 1;
filter.code: "aura";
rel1.offset: -5 -5;
rel2.offset: 4 4;
}
}
}
}
}

@ -758,6 +758,7 @@ bin/elementary/test_entry.c \
bin/elementary/test_entry_anchor.c \
bin/elementary/test_entry_anchor2.c \
bin/elementary/test_events.c \
bin/elementary/test_evas_mask.c \
bin/elementary/test_external.c \
bin/elementary/test_fileselector_button.c \
bin/elementary/test_fileselector.c \

@ -299,6 +299,7 @@ void test_code_diff_inline(void *data, Evas_Object *obj, void *event_info);
void test_efl_ui_text(void *data, Evas_Object *obj, void *event_info);
void test_efl_ui_text_label(void *data, Evas_Object *obj, void *event_info);
void test_evas_mask(void *data, Edje_Object *obj, void *event_info);
void test_gfx_filters(void *data, Evas_Object *obj, void *event_info);
Evas_Object *win, *tbx; // TODO: refactoring
@ -998,7 +999,10 @@ add_tests:
ADD_TEST(NULL, "Miscellaneous", "Accessibility2", test_access2);
ADD_TEST(NULL, "Miscellaneous", "Accessibility3", test_access3);
ADD_TEST(NULL, "Miscellaneous", "Font overlay", test_config_font_overlay);
ADD_TEST(NULL, "Miscellaneous", "Gfx Filters", test_gfx_filters);
//------------------------------//
ADD_TEST(NULL, "Evas", "Masking", test_evas_mask);
ADD_TEST(NULL, "Evas", "Gfx Filters", test_gfx_filters);
//------------------------------//
ADD_TEST(NULL, "Widgets Disable/Enable", "Box", test_box_disable);

@ -0,0 +1,175 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>
static Evas_Object *
_gl_content_get(void *data, Evas_Object *obj, const char *part)
{
const int size = ELM_SCALE_SIZE(48);
Evas_Object *content, *ly;
int num = (int)(uintptr_t)data;
char buf[PATH_MAX], bufimg[PATH_MAX], buftxt[256];
snprintf(buf, sizeof(buf), "%s/objects/test_masking.edj", elm_app_data_dir_get());
ly = elm_layout_add(obj);
elm_layout_file_set(ly, buf, "masking");
if (!strcmp(part, "elm.swallow.icon"))
{
content = elm_icon_add(ly);
//elm_image_async_open_set(icon, 1);
snprintf(bufimg, sizeof(bufimg), "%s/images/%s",
elm_app_data_dir_get(), (num&1) ? "sky_01.jpg" : "rock_01.jpg");
elm_image_file_set(content, bufimg, NULL);
evas_object_size_hint_min_set(content, size, size);
evas_object_size_hint_max_set(content, size, size);
}
else // if (!strcmp(part, "elm.swallow.end"))
{
content = elm_layout_add(obj);
elm_layout_file_set(content, buf, "text");
sprintf(buftxt, "# %d #", num);
elm_layout_text_set(content, "text", buftxt);
}
elm_object_part_content_set(ly, "content", content);
return ly;
}
static char *
_gl_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
char buf[64];
sprintf(buf, "Genlist item %u", (unsigned)(uintptr_t)data);
return strdup(buf);
}
static Eina_Bool
_gl_state_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
return EINA_FALSE;
}
static void
_gl_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
{
}
static void
_toggle_mask(void *data, const Efl_Event *ev EINA_UNUSED)
{
Eo *ly = data;
if (!efl_key_data_get(ly, "unclipped"))
{
elm_layout_signal_emit(ly, "unclip", "elm_test");
efl_key_data_set(ly, "unclipped", "yup");
}
else
{
elm_layout_signal_emit(ly, "clip", "elm_test");
efl_key_data_set(ly, "unclipped", NULL);
}
}
static void
_toggle_map(void *data, const Efl_Event *ev EINA_UNUSED)
{
Eo *ly = data;
if (!efl_gfx_map_enable_get(ly))
{
int x, y, w, h;
efl_gfx_geometry_get(ly, &x, &y, &w, &h);
efl_gfx_map_populate(ly, 0.0);
efl_gfx_map_zoom(ly, 0.8, 0.8, x + w / 2, y + h / 2);
efl_gfx_map_enable_set(ly, 1);
}
else
{
efl_gfx_map_enable_set(ly, 0);
}
}
void
test_evas_mask(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Eo *win, *box, *o, *gl, *ly, *box2;
Elm_Genlist_Item_Class *itc;
char buf[PATH_MAX];
win = efl_add(EFL_UI_WIN_STANDARD_CLASS, NULL,
efl_text_set(efl_added, "Evas masking demo"),
efl_ui_win_autodel_set(efl_added, 1));
box = efl_add(EFL_UI_BOX_CLASS, win,
efl_orientation_set(efl_added, EFL_ORIENT_DOWN),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 1.0));
efl_content_set(win, box);
// FIXME: No API to set background as "tile" :(
snprintf(buf, sizeof(buf), "%s/images/pm_fill.png", elm_app_data_dir_get());
efl_file_set(efl_part(win, "background"), buf, NULL);
// FIXME: layout EO API
snprintf(buf, sizeof(buf), "%s/objects/test_masking.edj", elm_app_data_dir_get());
ly = efl_add(ELM_LAYOUT_CLASS, win,
efl_file_set(efl_added, buf, "masking"),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 1.0),
efl_gfx_size_hint_align_set(efl_added, -1.0, -1.0),
efl_gfx_visible_set(efl_added, 1));
efl_pack(box, ly);
// FIXME: No genlist in EO API
o = gl = elm_genlist_add(win);
elm_genlist_homogeneous_set(gl, 1);
efl_gfx_size_hint_align_set(o, -1, -1);
efl_gfx_size_hint_weight_set(o, 1, 1);
itc = elm_genlist_item_class_new();
itc->item_style = "default";
itc->func.content_get = _gl_content_get;
itc->func.text_get = _gl_text_get;
itc->func.state_get = _gl_state_get;
itc->func.del = _gl_del;
for (int i = 0; i < 64; i++)
{
elm_genlist_item_append(gl, itc,
(void *)(uintptr_t)i,
NULL, // parent
ELM_GENLIST_ITEM_NONE,
NULL, // func
NULL); // data
}
elm_genlist_item_class_free(itc);
efl_content_set(efl_part(ly, "content"), gl);
box2 = efl_add(EFL_UI_BOX_CLASS, win,
efl_orientation_set(efl_added, EFL_ORIENT_RIGHT),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0),
efl_gfx_size_hint_align_set(efl_added, -1.0, -1.0),
efl_pack(box, efl_added),
efl_gfx_visible_set(efl_added, 1));
// FIXME: button EO API
efl_add(ELM_BUTTON_CLASS, win,
efl_text_set(efl_added, "Toggle mask"),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _toggle_mask, ly),
efl_pack(box2, efl_added),
efl_gfx_visible_set(efl_added, 1));
efl_add(ELM_BUTTON_CLASS, win,
efl_text_set(efl_added, "Toggle map"),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _toggle_map, ly),
efl_pack(box2, efl_added),
efl_gfx_visible_set(efl_added, 1));
efl_gfx_size_set(win, 500, 600);
efl_gfx_visible_set(win, 1);
}
Loading…
Cancel
Save