2016-12-12 01:36:49 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
#include <Elementary.h>
|
2016-12-12 01:17:30 -08:00
|
|
|
|
2016-12-12 01:36:49 -08:00
|
|
|
const int default_font_size = 48;
|
|
|
|
|
|
|
|
typedef struct _Filter_Image
|
|
|
|
{
|
|
|
|
const char *path;
|
|
|
|
const char *src_name;
|
|
|
|
} Filter_Image;
|
|
|
|
|
|
|
|
typedef struct _Filter
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *code;
|
|
|
|
const Filter_Image *images;
|
|
|
|
} Filter;
|
|
|
|
|
|
|
|
static const Filter_Image images[] = {
|
|
|
|
{ "plant_01.jpg", "plant" },
|
|
|
|
{ "rock_01.jpg", "rock" },
|
|
|
|
{ "rock_02.jpg", "roll" },
|
|
|
|
{ "sky_01.jpg", "sky" },
|
|
|
|
{ "sky_04.jpg", "cloud" },
|
|
|
|
{ "wood_01.jpg", "wood" },
|
2017-01-15 22:52:04 -08:00
|
|
|
{ "fire.gif", "logo" },
|
2016-12-12 01:36:49 -08:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const Filter_Image images_wood[] = {
|
|
|
|
{ "wood_01.jpg", "wood" },
|
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const Filter_Image images_cloud[] = {
|
|
|
|
{ "sky_04.jpg", "cloud" },
|
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
|
|
|
|
2017-01-05 00:56:04 -08:00
|
|
|
static const Filter_Image images_anim[] = {
|
2017-01-15 22:52:04 -08:00
|
|
|
{ "fire.gif", "logo" },
|
2017-01-05 00:56:04 -08:00
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
|
|
|
|
2016-12-12 01:36:49 -08:00
|
|
|
/* builtin filter examples */
|
|
|
|
static const Filter templates[] = {
|
|
|
|
{ "Custom", NULL, NULL },
|
2017-01-25 01:06:29 -08:00
|
|
|
{ "BLUR",
|
|
|
|
"blur { 15, color = 'darkblue' }", NULL },
|
evas filters: Refactor ector and gfx filters A LOT
Alright, so this is a massive patch that is the result of
trying to get rid of unused or poorly implemented classes in
ector. Originally ector was meant to support VG but extend to
things like filters as well. At the moment, ector's design
makes it quite hard to plug in the filters.
For now I think it's easier to implement the GL support for
the filters directly in the engine, where I hope to interfere
as little as possible.
This massive patch keeps only the required minimum to support
a versatile gl buffer that can be mapped, drawn or rendered to (FBO).
It's extremely inefficient as it relies on glReadPixels and lots
of texture uploads, as well as conversions between ARGB and Alpha.
Another type of GL buffer is a wrap around an existing GL image,
but that one is read-only (map or draw: no write map, no FBO).
No, all the filters run fine, and the high-level implementation
(evas_filters.c) does not need to know whether the underlying engine
is SW or GL. One problem though appears with the blending or blurring
of some Alpha buffers, the colors are wrong.
This patch removes more lines than it adds so it must be good ;)
2017-01-17 18:47:25 -08:00
|
|
|
{ "Simple blend",
|
|
|
|
"blend { color = 'darkblue' }", NULL },
|
2016-12-12 01:36:49 -08:00
|
|
|
{ "Black shadow",
|
2017-01-04 18:25:21 -08:00
|
|
|
"if not myColor then myColor = color('yellow') end\n"
|
2016-12-12 01:36:49 -08:00
|
|
|
"blur { 6, ox = 2, oy = 2, color = 'black' }\n"
|
2017-01-04 18:25:21 -08:00
|
|
|
"blend { color = myColor }", NULL },
|
2016-12-12 01:36:49 -08:00
|
|
|
{ "Fire glow",
|
|
|
|
"a = buffer { 'alpha' }\n"
|
|
|
|
"grow { 10, dst = a }\n"
|
|
|
|
"blur { 15, oy = -4, ox = 1, src = a, color = '#900' }\n"
|
|
|
|
"blur { 5, oy = -1, color = 'orange' }\n"
|
|
|
|
"blur { 2, color = 'yellow' }\n"
|
|
|
|
"grow { -2 }\n", NULL },
|
|
|
|
{ "Outer glow",
|
|
|
|
"inv = function (x) return 255 - x end\n\n"
|
|
|
|
"a = buffer {'alpha'}\n"
|
|
|
|
"curve { inv, dst = a }\n\n"
|
|
|
|
"b = buffer { 'alpha' }\n"
|
|
|
|
"grow { 3, dst = b }\n\n"
|
|
|
|
"c = buffer {}\n"
|
|
|
|
"blur { 6, color = 'blue', dst = c, src = b }\n"
|
|
|
|
"blur { 2, color = 'cyan', dst = c, src = b }\n"
|
|
|
|
"mask { a, c }", NULL },
|
|
|
|
{ "Inset light",
|
|
|
|
"inv = function (x) return 255 - x end\n\n"
|
|
|
|
"a = buffer {'alpha'}\n"
|
|
|
|
"curve { inv, dst = a }\n\n"
|
|
|
|
"b = buffer {}\n"
|
|
|
|
"blur { 2, ox = 1, oy = 1, src = a, dst = b, color = 'yellow' }\n\n"
|
|
|
|
"blend { color = 'black' }\n"
|
|
|
|
"mask { input, b }\n", NULL },
|
|
|
|
{ "Rocking it",
|
|
|
|
"local len = state.scale * 10\n\n"
|
2017-01-04 18:25:21 -08:00
|
|
|
"padding_set { len * 2 }\n"
|
2016-12-12 01:36:49 -08:00
|
|
|
"a = buffer { 'alpha' }\n"
|
|
|
|
"grow { len / 2, dst = a }\n"
|
|
|
|
"blur { len * 2, oy = len, ox = len / 2, color = 'black', src = a }\n"
|
|
|
|
"for i = len,0,-1 do\n"
|
|
|
|
" c = 128 / len * (len - i)\n"
|
|
|
|
" blur { 2, oy = i, ox = i/2, color = color { c * 0.8, c * 0.9, c } }\n"
|
|
|
|
"end\n"
|
|
|
|
"blend {}\n", NULL },
|
|
|
|
{ "Bumping on",
|
|
|
|
"a = buffer { 'alpha' }\n"
|
|
|
|
"grow { 2, dst = a }\n"
|
|
|
|
"blur { 4, src = a, dst = a }\n\n"
|
|
|
|
"bump { a, color = '#333', specular = 10, compensate = true, depth = 15 }\n", NULL },
|
|
|
|
{ "Modern art",
|
|
|
|
"local inv = function (x) return 255 - x end\n\n"
|
|
|
|
"a = buffer {}\n"
|
|
|
|
"b = buffer {'alpha'}\n"
|
|
|
|
"blend { dst = a, ox = 6, oy = -6, color = '#0f0' }\n"
|
|
|
|
"blend { dst = a, ox = -6, oy = 6, color = '#f00' }\n"
|
|
|
|
"blend { dst = a, ox = -3, oy = -3, color = '#f8f' }\n"
|
|
|
|
"blend { dst = a, ox = 3, oy = 3, color = '#00f' }\n"
|
|
|
|
"curve { inv, dst = b }\n"
|
|
|
|
"blur { 20, color = '#fffa' }\n"
|
|
|
|
"mask { a, b }\n", NULL },
|
|
|
|
{ "Forestry",
|
|
|
|
"wood = buffer { src = 'wood' }\n"
|
|
|
|
"mask { wood, fillmode = 'stretch' }", images_wood },
|
|
|
|
{ "Displaced cloud",
|
|
|
|
"cloud = buffer { src = 'cloud' }\n"
|
|
|
|
"displace { cloud, intensity = 10, fillmode = 'stretch' }", images_cloud },
|
2017-01-15 22:52:04 -08:00
|
|
|
{ "Text on fire",
|
|
|
|
"-- set padding to 15 pixels max\n"
|
|
|
|
"padding_set { 15 }\n\n"
|
|
|
|
"-- our buffer: 1 source (fire gif) and 3 internal buffers\n"
|
2017-01-05 00:56:04 -08:00
|
|
|
"logo = buffer { src = 'logo' }\n"
|
2017-01-15 22:52:04 -08:00
|
|
|
"a = buffer { 'alpha' }\n"
|
|
|
|
"b = buffer { 'rgba' }\n"
|
|
|
|
"c = buffer { 'alpha' }\n\n"
|
|
|
|
"-- create a massive blur: a\n"
|
2017-01-05 00:56:04 -08:00
|
|
|
"grow { 5, dst = a }\n"
|
2017-01-15 22:52:04 -08:00
|
|
|
"blur { 20, ox = -5, oy = -3, src = a, dst = a }\n\n"
|
|
|
|
"-- draw fire using a as a mask\n"
|
|
|
|
"mask { logo, a, fillmode = 'stretch_y_repeat_x' }\n\n"
|
|
|
|
"-- create a displacement map: blur the fire a lot\n"
|
|
|
|
"blend { src = logo, dst = b, fillmode = 'stretch' }\n"
|
|
|
|
"blur { 30, src = logo, dst = b, src = b }\n"
|
|
|
|
"displace { map = b, dst = c }\n\n"
|
|
|
|
"-- draw the moving text\n"
|
|
|
|
"blur { 4, src = c, color = '#ac180280' }\n"
|
|
|
|
"blur { 2, src = c, color = '#dea80080' }\n"
|
|
|
|
"mask { a, c }", images_anim }
|
2016-12-12 01:36:49 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
_spinner_fill(Eo *obj)
|
|
|
|
{
|
|
|
|
const Filter *f;
|
|
|
|
size_t k;
|
|
|
|
|
|
|
|
for (k = 0; k < EINA_C_ARRAY_LENGTH(templates); k++)
|
|
|
|
{
|
|
|
|
f = &templates[k];
|
|
|
|
elm_spinner_special_value_add(obj, (double) k, f->name);
|
|
|
|
}
|
|
|
|
elm_spinner_editable_set(obj, EINA_FALSE);
|
|
|
|
elm_spinner_min_max_set(obj, 0, k - 1);
|
|
|
|
elm_obj_spinner_wrap_set(obj, 1);
|
|
|
|
}
|
|
|
|
|
2017-01-04 02:54:48 -08:00
|
|
|
static void
|
|
|
|
_filter_apply(Eo *win, const char *code, const char *name)
|
|
|
|
{
|
|
|
|
Eo *text, *tb;
|
|
|
|
|
|
|
|
text = efl_key_wref_get(win, "text");
|
|
|
|
tb = efl_key_wref_get(win, "textblock");
|
|
|
|
|
|
|
|
efl_gfx_filter_program_set(text, code, name);
|
|
|
|
efl_gfx_filter_program_set(tb, code, "main");
|
|
|
|
}
|
|
|
|
|
2016-12-12 01:36:49 -08:00
|
|
|
static void
|
|
|
|
_spinner_cb(void *data, const Efl_Event *ev EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Eo *win = data;
|
2017-01-05 00:56:04 -08:00
|
|
|
Eo *text, *code, *spinner, *tb;
|
2016-12-12 01:36:49 -08:00
|
|
|
int k;
|
|
|
|
|
|
|
|
text = efl_key_wref_get(win, "text");
|
2017-01-05 00:56:04 -08:00
|
|
|
tb = efl_key_wref_get(win, "textblock");
|
2016-12-12 01:36:49 -08:00
|
|
|
code = efl_key_wref_get(win, "code");
|
|
|
|
spinner = efl_key_wref_get(win, "spinner");
|
|
|
|
k = (int) round(elm_spinner_value_get(spinner));
|
|
|
|
if (k > 0)
|
|
|
|
{
|
|
|
|
const Filter *f = &templates[k];
|
|
|
|
|
2017-01-04 02:54:48 -08:00
|
|
|
_filter_apply(win, f->code, f->name);
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_text_set(code, f->code);
|
|
|
|
|
|
|
|
if (f->images)
|
|
|
|
{
|
|
|
|
for (size_t j = 0; f->images[j].path; j++)
|
|
|
|
{
|
|
|
|
const char *name = f->images[j].src_name;
|
|
|
|
Eo *source_obj = efl_name_find(win, name);
|
|
|
|
efl_gfx_filter_source_set(text, name, source_obj);
|
2017-01-05 00:56:04 -08:00
|
|
|
efl_gfx_filter_source_set(tb, name, source_obj);
|
2016-12-12 01:36:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_code_changed(void *data, const Efl_Event *ev EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Eo *win = data;
|
2017-01-23 06:35:13 -08:00
|
|
|
Eo *code, *spinner;
|
2016-12-12 01:36:49 -08:00
|
|
|
Eina_Strbuf *buf = NULL;
|
|
|
|
const char *source;
|
|
|
|
|
|
|
|
code = efl_key_wref_get(win, "code");
|
|
|
|
spinner = efl_key_wref_get(win, "spinner");
|
|
|
|
|
|
|
|
source = efl_text_get(code);
|
|
|
|
{
|
|
|
|
// Fix up paragrah separators from the UTF-8 input. :(
|
|
|
|
const char *paragraph = "\u2029";
|
|
|
|
|
|
|
|
if (source && strstr(source, paragraph))
|
|
|
|
{
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
eina_strbuf_append(buf, source);
|
|
|
|
eina_strbuf_replace_all(buf, paragraph, "\n");
|
|
|
|
source = eina_strbuf_string_get(buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_spinner_value_set(spinner, 0);
|
2017-01-04 02:54:48 -08:00
|
|
|
_filter_apply(win, source, elm_spinner_special_value_get(spinner, 0));
|
2016-12-12 01:36:49 -08:00
|
|
|
eina_strbuf_free(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_code_changed_hack(void *data, const Efl_Event *ev EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Efl_Future *p = efl_loop_job(efl_loop_get(data), NULL);
|
|
|
|
efl_future_then(p, _code_changed, NULL, NULL, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_text_resize(void *data EINA_UNUSED, const Efl_Event *ev)
|
|
|
|
{
|
|
|
|
int w = 0, h = 0;
|
|
|
|
|
|
|
|
efl_gfx_size_get(ev->object, &w, &h);
|
|
|
|
efl_gfx_size_hint_min_set(ev->object, w, h);
|
|
|
|
}
|
|
|
|
|
2016-12-22 02:43:45 -08:00
|
|
|
static void
|
|
|
|
_textblock_resize(void *data EINA_UNUSED, const Efl_Event *ev)
|
|
|
|
{
|
2017-01-04 00:21:56 -08:00
|
|
|
int w = 0, h = 0, l = 0, r = 0, t = 0, b = 0;
|
2016-12-22 02:43:45 -08:00
|
|
|
|
|
|
|
evas_object_textblock_size_native_get(ev->object, &w, &h);
|
2017-01-04 00:21:56 -08:00
|
|
|
evas_object_textblock_style_insets_get(ev->object, &l, &r, &t, &b);
|
|
|
|
efl_gfx_size_hint_min_set(ev->object, w + l + r, h + t + b);
|
2016-12-22 02:43:45 -08:00
|
|
|
}
|
|
|
|
|
2016-12-12 01:36:49 -08:00
|
|
|
static void
|
|
|
|
_img_click(void *data, const Efl_Event *ev)
|
|
|
|
{
|
|
|
|
Eina_Strbuf *buf;
|
|
|
|
Eo *win = data;
|
|
|
|
Eo *img = ev->object;
|
2017-01-05 00:56:04 -08:00
|
|
|
Eo *code, *text, *tb;
|
2016-12-12 01:36:49 -08:00
|
|
|
const char *name;
|
|
|
|
|
|
|
|
name = efl_name_get(img);
|
|
|
|
if (!name) return;
|
|
|
|
|
|
|
|
code = efl_key_wref_get(win, "code");
|
|
|
|
text = efl_key_wref_get(win, "text");
|
2017-01-05 00:56:04 -08:00
|
|
|
tb = efl_key_wref_get(win, "textblock");
|
2016-12-12 01:36:49 -08:00
|
|
|
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
eina_strbuf_append_printf(buf, "%s = buffer { src = '%s' }\n", name, name);
|
|
|
|
|
|
|
|
eina_strbuf_append(buf, efl_text_get(code));
|
|
|
|
efl_text_set(code, eina_strbuf_string_get(buf));
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
|
|
|
|
efl_gfx_filter_source_set(text, name, ev->object);
|
2017-01-05 00:56:04 -08:00
|
|
|
efl_gfx_filter_source_set(tb, name, ev->object);
|
2016-12-12 01:36:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_font_size_change(void *data, const Efl_Event *ev)
|
|
|
|
{
|
|
|
|
Eo *win = data;
|
|
|
|
Eo *text;
|
|
|
|
const char *font;
|
|
|
|
|
|
|
|
text = efl_key_wref_get(win, "text");
|
|
|
|
efl_text_properties_font_get(text, &font, NULL);
|
|
|
|
efl_text_properties_font_set(text, font, elm_spinner_value_get(ev->object));
|
|
|
|
}
|
|
|
|
|
2017-01-04 02:54:48 -08:00
|
|
|
static void
|
|
|
|
_flip_click(void *data, const Efl_Event *ev EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Eo *win = data;
|
|
|
|
Eo *flip = efl_key_wref_get(win, "flip");
|
|
|
|
|
|
|
|
/* FIXME: The flip APIs don't make sense for N items (front!?) */
|
|
|
|
efl_ui_flip_go(flip, EFL_UI_FLIP_CROSS_FADE);
|
|
|
|
}
|
|
|
|
|
2017-01-04 18:25:21 -08:00
|
|
|
static void
|
|
|
|
_colsel_cb(void *data, const Efl_Event *ev)
|
|
|
|
{
|
|
|
|
Eo *win = data;
|
|
|
|
Eo *colsel = ev->object;
|
|
|
|
Eo *text, *tb;
|
|
|
|
int r = 0, g = 0, b = 0, a = 255;
|
|
|
|
char buf[64];
|
|
|
|
|
|
|
|
text = efl_key_wref_get(win, "text");
|
|
|
|
tb = efl_key_wref_get(win, "textblock");
|
|
|
|
elm_colorselector_color_get(colsel, &r, &g, &b, &a);
|
|
|
|
sprintf(buf, "color(%d, %d, %d, %d)", r, g, b, a);
|
|
|
|
|
|
|
|
efl_gfx_filter_data_set(text, efl_name_get(colsel), buf, 1);
|
|
|
|
efl_gfx_filter_data_set(tb, efl_name_get(colsel), buf, 1);
|
|
|
|
}
|
|
|
|
|
2016-12-12 01:36:49 -08:00
|
|
|
void
|
|
|
|
test_gfx_filters(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2017-01-04 02:54:48 -08:00
|
|
|
Eo *win, *box, *box2, *o, *text = NULL, *spinner, *code, *split, *flip, *tb;
|
2016-12-12 01:36:49 -08:00
|
|
|
|
2017-05-16 05:47:52 -07:00
|
|
|
win = efl_add(EFL_UI_WIN_CLASS, NULL,
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_text_set(efl_added, "Gfx Filter Editor"),
|
|
|
|
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);
|
|
|
|
|
|
|
|
{
|
|
|
|
box2 = efl_add(EFL_UI_BOX_CLASS, win,
|
|
|
|
efl_orientation_set(efl_added, EFL_ORIENT_HORIZONTAL),
|
|
|
|
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0),
|
|
|
|
efl_gfx_size_hint_align_set(efl_added, -1.0, 0.0),
|
|
|
|
efl_gfx_visible_set(efl_added, 1));
|
|
|
|
efl_pack(box, box2);
|
|
|
|
|
|
|
|
/* FIXME: Efl.Ui.Text doesn't work as expected. */
|
|
|
|
o = efl_add(EFL_UI_TEXT_CLASS, win,
|
|
|
|
efl_gfx_size_hint_weight_set(efl_added, 0.0, 1.0),
|
|
|
|
efl_gfx_size_hint_align_set(efl_added, 1.0, 0.5),
|
|
|
|
efl_gfx_visible_set(efl_added, 1));
|
|
|
|
efl_text_set(o, "Filter:");
|
|
|
|
efl_pack(box2, o);
|
|
|
|
|
|
|
|
o = spinner = efl_add(ELM_SPINNER_CLASS, win,
|
|
|
|
efl_gfx_size_hint_weight_set(efl_added, 1.0, 1.0),
|
|
|
|
efl_gfx_size_hint_align_set(efl_added, -1.0, 0.5),
|
|
|
|
efl_gfx_visible_set(efl_added, 1));
|
|
|
|
_spinner_fill(o);
|
|
|
|
efl_pack(box2, o);
|
|
|
|
spinner = o;
|
|
|
|
|
|
|
|
o = efl_add(ELM_SPINNER_CLASS, win,
|
|
|
|
efl_gfx_size_hint_weight_set(efl_added, 0.0, 1.0),
|
|
|
|
efl_gfx_size_hint_align_set(efl_added, -1.0, 0.5),
|
|
|
|
elm_spinner_min_max_set(efl_added, 6, 120),
|
|
|
|
elm_spinner_value_set(efl_added, default_font_size),
|
|
|
|
efl_event_callback_add(efl_added, ELM_SPINNER_EVENT_DELAY_CHANGED, _font_size_change, win),
|
|
|
|
efl_gfx_visible_set(efl_added, 1));
|
2017-01-04 02:54:48 -08:00
|
|
|
efl_pack(box2, o);
|
2016-12-12 01:36:49 -08:00
|
|
|
|
2017-05-21 20:48:12 -07:00
|
|
|
o = efl_add(EFL_UI_BUTTON_CLASS, win,
|
2017-01-04 02:54:48 -08:00
|
|
|
efl_text_set(efl_added, "Flip"),
|
|
|
|
efl_gfx_size_hint_weight_set(efl_added, 0.0, 1.0),
|
|
|
|
efl_gfx_size_hint_align_set(efl_added, -1.0, 0.5),
|
|
|
|
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _flip_click, win),
|
|
|
|
efl_gfx_visible_set(efl_added, 1));
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_pack(box2, o);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
box2 = efl_add(EFL_UI_BOX_CLASS, win,
|
|
|
|
efl_orientation_set(efl_added, EFL_ORIENT_HORIZONTAL),
|
|
|
|
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.0),
|
2017-01-04 18:25:21 -08:00
|
|
|
efl_gfx_size_hint_align_set(efl_added, -1.0, 0.5),
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_pack_padding_set(efl_added, 5, 5, 1),
|
|
|
|
efl_gfx_size_hint_margin_set(efl_added, 5, 5, 5, 5),
|
|
|
|
efl_pack_align_set(efl_added, 0, 0.5));
|
|
|
|
efl_pack(box, box2);
|
|
|
|
|
2017-01-04 18:25:21 -08:00
|
|
|
for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(images); k++)
|
2016-12-12 01:36:49 -08:00
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
if (!images[k].path) break;
|
|
|
|
snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), images[k].path);
|
|
|
|
o = efl_add(EFL_UI_IMAGE_CLASS, win,
|
2017-01-04 18:25:21 -08:00
|
|
|
efl_gfx_size_hint_weight_set(efl_added, 0.0, 0.0),
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5),
|
|
|
|
efl_gfx_size_hint_max_set(efl_added, ELM_SCALE_SIZE(48), ELM_SCALE_SIZE(48)),
|
|
|
|
efl_gfx_size_hint_min_set(efl_added, ELM_SCALE_SIZE(48), ELM_SCALE_SIZE(48)),
|
|
|
|
efl_file_set(efl_added, buf, NULL),
|
|
|
|
efl_name_set(efl_added, images[k].src_name),
|
2017-01-04 18:25:21 -08:00
|
|
|
elm_object_tooltip_text_set(efl_added, images[k].src_name),
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_gfx_visible_set(efl_added, 1));
|
2017-01-05 00:56:04 -08:00
|
|
|
if (efl_player_playable_get(o))
|
|
|
|
efl_player_play_set(o, 1);
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_event_callback_add(o, EFL_UI_EVENT_CLICKED, _img_click, win);
|
|
|
|
efl_pack(box2, o);
|
|
|
|
}
|
|
|
|
|
2017-01-04 18:25:21 -08:00
|
|
|
const struct { int r, g, b, a; } colors[] = {
|
|
|
|
{ 255, 255, 255, 255 },
|
|
|
|
{ 0, 0, 0, 255 },
|
|
|
|
{ 64, 64, 64, 255 },
|
|
|
|
{ 128, 128, 128, 255 },
|
|
|
|
{ 196, 196, 196, 255 },
|
|
|
|
{ 255, 0, 0, 255 },
|
|
|
|
{ 0, 255, 0, 255 },
|
|
|
|
{ 0, 0, 255, 255 },
|
|
|
|
{ 255, 255, 0, 255 },
|
|
|
|
{ 255, 0, 255, 255 },
|
|
|
|
{ 0, 255, 255, 255 },
|
|
|
|
{ 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
o = efl_add(ELM_COLORSELECTOR_CLASS, win,
|
|
|
|
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0),
|
|
|
|
efl_gfx_size_hint_align_set(efl_added, -1.0, 0),
|
|
|
|
elm_colorselector_mode_set(efl_added, ELM_COLORSELECTOR_PALETTE),
|
|
|
|
efl_gfx_size_hint_max_set(efl_added, -1, ELM_SCALE_SIZE(48 * 2)),
|
|
|
|
efl_name_set(efl_added, "myColor"),
|
|
|
|
elm_object_tooltip_text_set(efl_added, "Pick a color to use as variable 'myColor'"),
|
|
|
|
efl_event_callback_add(efl_added, ELM_COLORSELECTOR_EVENT_CHANGED, _colsel_cb, win),
|
|
|
|
efl_gfx_visible_set(efl_added, 1));
|
|
|
|
efl_pack(box2, o);
|
|
|
|
|
|
|
|
for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(colors); k++)
|
|
|
|
elm_colorselector_palette_color_add(o, colors[k].r, colors[k].g, colors[k].b, colors[k].a);
|
|
|
|
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_gfx_visible_set(box2, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: No panes in EO APIs. */
|
|
|
|
o = split = efl_add(ELM_PANES_CLASS, win,
|
|
|
|
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_orientation_set(efl_added, EFL_ORIENT_HORIZONTAL),
|
|
|
|
efl_gfx_visible_set(efl_added, 1));
|
|
|
|
efl_pack(box, split);
|
|
|
|
|
|
|
|
{
|
2017-01-04 02:54:48 -08:00
|
|
|
flip = efl_add(EFL_UI_FLIP_CLASS, win,
|
|
|
|
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_gfx_visible_set(efl_added, 1));
|
|
|
|
efl_content_set(efl_part(split, "top"), flip);
|
2016-12-12 01:36:49 -08:00
|
|
|
|
2017-01-04 02:54:48 -08:00
|
|
|
box2 = efl_add(EFL_UI_BOX_STACK_CLASS, win,
|
|
|
|
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_align_set(efl_added, 0.5, 0.5),
|
|
|
|
efl_gfx_visible_set(efl_added, 1));
|
|
|
|
efl_pack(flip, box2);
|
|
|
|
|
|
|
|
// Note: No TEXT object with EO APIs
|
2016-12-12 01:36:49 -08:00
|
|
|
o = text = evas_object_text_add(evas_object_evas_get(win));
|
|
|
|
efl_event_callback_add(o, EFL_GFX_EVENT_RESIZE, _text_resize, NULL);
|
|
|
|
efl_text_properties_font_set(o, "Sans:style=Bold", default_font_size);
|
|
|
|
efl_canvas_object_scale_set(text, elm_config_scale_get());
|
|
|
|
efl_text_set(o, "EFL");
|
|
|
|
efl_gfx_visible_set(o, 1);
|
|
|
|
efl_pack(box2, o);
|
2017-01-04 02:54:48 -08:00
|
|
|
|
|
|
|
o = box2 = efl_add(EFL_UI_BOX_STACK_CLASS, win,
|
|
|
|
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_align_set(efl_added, 0.5, 0.5));
|
|
|
|
efl_pack(flip, box2);
|
2016-12-22 02:43:45 -08:00
|
|
|
|
2017-01-04 18:25:21 -08:00
|
|
|
const struct { const char *name, *code; } programs [] = {
|
|
|
|
{ "one", "blur { 5, color = 'darkblue' } blend {}" },
|
|
|
|
{ "two", "blur { 15, color = 'red' } blend {}" },
|
|
|
|
{ "main", "blend {}" }
|
2016-12-22 15:09:51 -08:00
|
|
|
};
|
2017-01-04 18:25:21 -08:00
|
|
|
|
|
|
|
const struct { const char *name, *value; int exec; } prg_data [] = {
|
|
|
|
{ "myColor", "color(255, 0, 255)", EINA_TRUE },
|
2016-12-22 15:09:51 -08:00
|
|
|
};
|
2017-01-04 18:25:21 -08:00
|
|
|
|
2017-01-04 02:54:48 -08:00
|
|
|
const char *tbtxt = "Classic <gfx_filter='one'>hello</> world!<br>"
|
|
|
|
"And <gfx_filter='two'>This filter over<br>"
|
|
|
|
"multiple lines</> :)<br/>"
|
|
|
|
"<gfx_filter='main'>Main filter</>";
|
2016-12-22 02:43:45 -08:00
|
|
|
|
2017-01-04 02:54:48 -08:00
|
|
|
// Experimental textblock support
|
|
|
|
o = tb = evas_object_textblock_add(evas_object_evas_get(win));
|
2017-01-05 22:22:54 -08:00
|
|
|
efl_event_callback_add(o, EFL_CANVAS_TEXT_EVENT_STYLE_INSETS_CHANGED, _textblock_resize, NULL);
|
2016-12-22 02:43:45 -08:00
|
|
|
efl_event_callback_add(o, EFL_GFX_EVENT_RESIZE, _textblock_resize, NULL);
|
|
|
|
Evas_Textblock_Style *st = evas_textblock_style_new();
|
2017-01-04 02:54:48 -08:00
|
|
|
evas_textblock_style_set(st, "DEFAULT='font=Sans font_size=20 color=#FFF wrap=word'");
|
2017-01-04 18:25:21 -08:00
|
|
|
for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(programs); k++)
|
|
|
|
efl_gfx_filter_program_set(o, programs[k].code, programs[k].name);
|
|
|
|
for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(prg_data); k++)
|
|
|
|
efl_gfx_filter_data_set(o, prg_data[k].name, prg_data[k].value, prg_data[k].exec);
|
2016-12-22 02:43:45 -08:00
|
|
|
evas_object_textblock_style_set(o, st);
|
|
|
|
evas_object_textblock_text_markup_set(o, tbtxt);
|
|
|
|
efl_canvas_object_scale_set(o, elm_config_scale_get());
|
|
|
|
efl_pack(box2, o);
|
|
|
|
evas_object_resize(o, 1, 1);
|
|
|
|
efl_gfx_visible_set(o, 1);
|
2016-12-12 01:36:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2017-01-10 02:04:46 -08:00
|
|
|
const char *code_filter =
|
|
|
|
"a = buffer { 'alpha' }"
|
|
|
|
"grow { 2, dst = a } "
|
|
|
|
"blur { 6, ox = 1, oy = 1, src = a, color = '#004' }"
|
|
|
|
"blur { 3, ox = 1, oy = 1, color = 'black' }"
|
|
|
|
"blend { color = 'lime' }";
|
|
|
|
|
2016-12-12 01:36:49 -08:00
|
|
|
o = code = efl_add(EFL_UI_TEXT_EDITABLE_CLASS, win,
|
|
|
|
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_ui_text_scrollable_set(efl_added, 1));
|
|
|
|
efl_event_callback_add(o, EFL_UI_TEXT_EVENT_CHANGED_USER, _code_changed, win);
|
|
|
|
|
2017-03-22 03:18:41 -07:00
|
|
|
// Insert filter code inside style string: DEFAULT='blah blah <here>'
|
|
|
|
efl_gfx_filter_program_set(o, code_filter, "code");
|
2017-05-30 03:48:05 -07:00
|
|
|
efl_text_style_gfx_filter_set(o, "code");
|
2017-01-10 02:04:46 -08:00
|
|
|
|
2016-12-12 01:36:49 -08:00
|
|
|
// FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
|
2017-01-10 02:04:46 -08:00
|
|
|
// Efl.Ui.Text doesn't seem to trigger the proper events during edit
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_event_callback_add(o, EFL_EVENT_KEY_DOWN, _code_changed_hack, win);
|
|
|
|
|
|
|
|
efl_content_set(efl_part(split, "bottom"), code);
|
|
|
|
}
|
|
|
|
|
|
|
|
efl_key_wref_set(win, "text", text);
|
2017-01-04 02:54:48 -08:00
|
|
|
efl_key_wref_set(win, "textblock", tb);
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_key_wref_set(win, "code", code);
|
2017-01-04 02:54:48 -08:00
|
|
|
efl_key_wref_set(win, "flip", flip);
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_key_wref_set(win, "spinner", spinner);
|
|
|
|
efl_event_callback_add(spinner, ELM_SPINNER_EVENT_CHANGED, _spinner_cb, win);
|
|
|
|
elm_spinner_value_set(spinner, 1.0);
|
|
|
|
_spinner_cb(win, NULL);
|
|
|
|
|
|
|
|
efl_gfx_size_set(win, 500, 600);
|
|
|
|
efl_gfx_visible_set(win, 1);
|
|
|
|
}
|