2016-12-12 01:36:49 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
2017-10-31 23:16:30 -07:00
|
|
|
|
2016-12-12 01:36:49 -08:00
|
|
|
#include <Elementary.h>
|
2019-03-07 07:39:06 -08:00
|
|
|
#include <Efl_Ui.h>
|
|
|
|
#include "elm_spinner_eo.h"
|
2019-09-27 08:07:17 -07:00
|
|
|
#include "elm_priv.h" //FIXME remove this once efl.ui.text doesn't need elm_general.h
|
2017-12-04 23:47:15 -08:00
|
|
|
static const int default_font_size = 48;
|
2016-12-12 01:36:49 -08:00
|
|
|
|
|
|
|
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);
|
2017-12-04 23:47:15 -08:00
|
|
|
elm_spinner_wrap_set(obj, 1);
|
2016-12-12 01:36:49 -08:00
|
|
|
}
|
|
|
|
|
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
|
2017-12-04 23:47:15 -08:00
|
|
|
_spinner_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2016-12-12 01:36:49 -08:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-11 13:16:47 -08:00
|
|
|
static Eina_Value
|
|
|
|
_code_changed(void *data, const Eina_Value v,
|
|
|
|
const Eina_Future *dead EINA_UNUSED)
|
2016-12-12 01:36:49 -08:00
|
|
|
{
|
|
|
|
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);
|
2017-12-11 13:16:47 -08:00
|
|
|
|
|
|
|
return v;
|
2016-12-12 01:36:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_code_changed_hack(void *data, const Efl_Event *ev EINA_UNUSED)
|
|
|
|
{
|
2017-12-11 13:16:47 -08:00
|
|
|
Eina_Future *f;
|
|
|
|
|
2017-12-11 13:51:52 -08:00
|
|
|
f = eina_future_then(efl_loop_job(efl_loop_get(data)),
|
2018-11-07 06:52:41 -08:00
|
|
|
_code_changed, data, NULL);
|
2018-11-21 17:33:10 -08:00
|
|
|
efl_future_then(data, f);
|
2016-12-12 01:36:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_text_resize(void *data EINA_UNUSED, const Efl_Event *ev)
|
|
|
|
{
|
2017-09-15 02:37:25 -07:00
|
|
|
Eina_Size2D sz;
|
2016-12-12 01:36:49 -08:00
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
sz = efl_gfx_entity_size_get(ev->object);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_size_min_set(ev->object, sz);
|
2016-12-12 01:36:49 -08:00
|
|
|
}
|
|
|
|
|
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);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_size_min_set(ev->object, EINA_SIZE2D(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");
|
2018-02-12 13:02:06 -08:00
|
|
|
efl_text_font_get(text, &font, NULL);
|
|
|
|
efl_text_font_set(text, font, elm_spinner_value_get(ev->object));
|
2016-12-12 01:36:49 -08:00
|
|
|
}
|
|
|
|
|
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!?) */
|
2019-03-05 14:00:37 -08:00
|
|
|
efl_ui_flip_go(flip, EFL_UI_FLIP_MODE_CROSS_FADE);
|
2017-01-04 02:54:48 -08:00
|
|
|
}
|
|
|
|
|
2017-01-04 18:25:21 -08:00
|
|
|
static void
|
2017-12-04 23:47:15 -08:00
|
|
|
_colsel_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2017-01-04 18:25:21 -08:00
|
|
|
{
|
|
|
|
Eo *win = data;
|
2017-12-04 23:47:15 -08:00
|
|
|
Eo *colsel = obj;
|
2017-01-04 18:25:21 -08:00
|
|
|
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
|
|
|
|
2018-04-11 10:38:21 -07:00
|
|
|
win = efl_add_ref(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,
|
2019-05-24 09:30:31 -07:00
|
|
|
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL));
|
2016-12-12 01:36:49 -08:00
|
|
|
|
|
|
|
efl_content_set(win, box);
|
|
|
|
|
|
|
|
{
|
|
|
|
box2 = efl_add(EFL_UI_BOX_CLASS, win,
|
2019-05-24 09:30:31 -07:00
|
|
|
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(efl_added, 1.0, 0.0),
|
|
|
|
efl_gfx_hint_align_set(efl_added, 0.5, 0.0),
|
|
|
|
efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE));
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_pack(box, box2);
|
|
|
|
|
|
|
|
/* FIXME: Efl.Ui.Text doesn't work as expected. */
|
|
|
|
o = efl_add(EFL_UI_TEXT_CLASS, win,
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(efl_added, 0.0, 1.0),
|
|
|
|
efl_gfx_hint_align_set(efl_added, 1.0, 0.5));
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_text_set(o, "Filter:");
|
|
|
|
efl_pack(box2, o);
|
|
|
|
|
2017-12-04 23:47:15 -08:00
|
|
|
o = spinner = elm_spinner_add(win);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(o, 1.0, 1.0);
|
|
|
|
efl_gfx_hint_align_set(o, -1.0, 0.5);
|
2016-12-12 01:36:49 -08:00
|
|
|
_spinner_fill(o);
|
|
|
|
efl_pack(box2, o);
|
2017-12-04 23:47:15 -08:00
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
o = elm_spinner_add(win);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(o, 0.0, 1.0);
|
|
|
|
efl_gfx_hint_align_set(o, -1.0, 0.5);
|
2017-12-04 23:47:15 -08:00
|
|
|
elm_spinner_min_max_set(o, 6, 120);
|
|
|
|
elm_spinner_value_set(o, default_font_size);
|
|
|
|
efl_event_callback_add(o, ELM_SPINNER_EVENT_DELAY_CHANGED, _font_size_change, win);
|
2017-01-04 02:54:48 -08:00
|
|
|
efl_pack(box2, o);
|
2017-12-04 23:47:15 -08:00
|
|
|
evas_object_show(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"),
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(efl_added, 0.0, 1.0),
|
|
|
|
efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
|
2019-07-29 02:42:34 -07:00
|
|
|
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _flip_click, win));
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_pack(box2, o);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
box2 = efl_add(EFL_UI_BOX_CLASS, win,
|
2019-05-24 09:30:31 -07:00
|
|
|
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(efl_added, 1.0, 0.0),
|
|
|
|
efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
|
2019-10-02 03:04:12 -07:00
|
|
|
efl_gfx_arrangement_content_padding_set(efl_added, 5, 5),
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_margin_set(efl_added, 5, 5, 5, 5),
|
2019-04-24 06:41:39 -07:00
|
|
|
efl_gfx_arrangement_content_align_set(efl_added, 0, 0.5));
|
2016-12-12 01:36:49 -08:00
|
|
|
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
|
|
|
{
|
2017-09-17 22:07:56 -07:00
|
|
|
Eina_Size2D size = { ELM_SCALE_SIZE(48), ELM_SCALE_SIZE(48) };
|
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,
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(efl_added, 0.0, 0.0),
|
|
|
|
efl_gfx_hint_align_set(efl_added, 0.5, 0.5),
|
|
|
|
efl_gfx_hint_size_max_set(efl_added, size),
|
|
|
|
efl_gfx_hint_size_min_set(efl_added, size),
|
2019-02-27 10:17:09 -08:00
|
|
|
efl_file_set(efl_added, buf),
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_name_set(efl_added, images[k].src_name),
|
2017-07-06 01:22:41 -07:00
|
|
|
elm_object_tooltip_text_set(efl_added, images[k].src_name));
|
2019-09-24 06:39:21 -07:00
|
|
|
if (efl_playable_get(o))
|
2019-09-24 08:18:57 -07:00
|
|
|
efl_player_playing_set(o, 1);
|
2019-07-29 02:42:34 -07:00
|
|
|
efl_event_callback_add(o, EFL_INPUT_EVENT_CLICKED, _img_click, win);
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_pack(box2, o);
|
|
|
|
}
|
|
|
|
|
2017-09-17 22:07:56 -07:00
|
|
|
Eina_Size2D maxsz = { -1, ELM_SCALE_SIZE(48 * 2) };
|
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 }
|
|
|
|
};
|
|
|
|
|
2017-12-04 23:47:15 -08:00
|
|
|
o = elm_colorselector_add(win);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(o, 1.0, 0);
|
|
|
|
efl_gfx_hint_align_set(o, -1.0, 0);
|
2017-12-04 23:47:15 -08:00
|
|
|
elm_colorselector_mode_set(o, ELM_COLORSELECTOR_PALETTE);
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_size_max_set(o, maxsz);
|
2017-12-04 23:47:15 -08:00
|
|
|
efl_name_set(o, "myColor");
|
|
|
|
elm_object_tooltip_text_set(o, "Pick a color to use as variable 'myColor'");
|
|
|
|
evas_object_smart_callback_add(o, "changed", _colsel_cb, win);
|
2017-01-04 18:25:21 -08:00
|
|
|
efl_pack(box2, o);
|
2017-12-04 23:47:15 -08:00
|
|
|
evas_object_show(o);
|
2017-01-04 18:25:21 -08:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-08-01 18:32:30 -07:00
|
|
|
o = split = efl_add(EFL_UI_PANES_CLASS, win,
|
2019-05-24 09:30:31 -07:00
|
|
|
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL));
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_pack(box, split);
|
|
|
|
|
|
|
|
{
|
2017-08-22 23:54:03 -07:00
|
|
|
flip = efl_add(EFL_UI_FLIP_CLASS, win);
|
2017-12-04 23:47:15 -08:00
|
|
|
efl_content_set(efl_part(split, "first"), 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,
|
2019-05-24 09:30:31 -07:00
|
|
|
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(efl_added, 1.0, 0.0),
|
|
|
|
efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_TRUE),
|
2019-04-24 06:41:39 -07:00
|
|
|
efl_gfx_arrangement_content_align_set(efl_added, 0.5, 0.5));
|
2017-01-04 02:54:48 -08:00
|
|
|
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));
|
2019-02-21 10:01:56 -08:00
|
|
|
efl_event_callback_add(o, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED, _text_resize, NULL);
|
2018-02-12 13:02:06 -08:00
|
|
|
efl_text_font_set(o, "Sans:style=Bold", default_font_size);
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_scale_set(text, elm_config_scale_get());
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_set(o, "EFL");
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_visible_set(o, 1);
|
2016-12-12 01:36:49 -08:00
|
|
|
efl_pack(box2, o);
|
2017-01-04 02:54:48 -08:00
|
|
|
|
|
|
|
o = box2 = efl_add(EFL_UI_BOX_STACK_CLASS, win,
|
2019-05-24 09:30:31 -07:00
|
|
|
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
|
2019-02-21 09:19:45 -08:00
|
|
|
efl_gfx_hint_weight_set(efl_added, 1.0, 0.0),
|
|
|
|
efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_TRUE),
|
2019-04-24 06:41:39 -07:00
|
|
|
efl_gfx_arrangement_content_align_set(efl_added, 0.5, 0.5));
|
2017-01-04 02:54:48 -08:00
|
|
|
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);
|
2019-02-21 10:01:56 -08:00
|
|
|
efl_event_callback_add(o, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED, _textblock_resize, NULL);
|
2016-12-22 02:43:45 -08:00
|
|
|
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);
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_scale_set(o, elm_config_scale_get());
|
2016-12-22 02:43:45 -08:00
|
|
|
efl_pack(box2, o);
|
|
|
|
evas_object_resize(o, 1, 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,
|
2017-05-31 00:36:54 -07:00
|
|
|
efl_ui_text_scrollable_set(efl_added, 1),
|
2017-06-11 14:16:40 -07:00
|
|
|
efl_text_multiline_set(efl_added, 1));
|
2017-12-11 13:16:47 -08:00
|
|
|
efl_event_callback_add(o, EFL_UI_TEXT_EVENT_CHANGED_USER, _code_changed_hack, win);
|
2016-12-12 01:36:49 -08:00
|
|
|
|
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-06-11 14:16:40 -07:00
|
|
|
efl_text_gfx_filter_set(o, "code");
|
2017-01-10 02:04:46 -08:00
|
|
|
|
2017-12-04 23:47:15 -08:00
|
|
|
efl_content_set(efl_part(split, "second"), code);
|
2016-12-12 01:36:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2017-12-04 23:47:15 -08:00
|
|
|
evas_object_smart_callback_add(spinner, "changed", _spinner_cb, win);
|
2016-12-12 01:36:49 -08:00
|
|
|
elm_spinner_value_set(spinner, 1.0);
|
2017-12-04 23:47:15 -08:00
|
|
|
_spinner_cb(win, spinner, NULL);
|
2016-12-12 01:36:49 -08:00
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(win, EINA_SIZE2D(500, 600));
|
2016-12-12 01:36:49 -08:00
|
|
|
}
|