summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-01-04 17:21:56 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-01-17 14:35:28 +0900
commit421df2eec6ffb573118f4be29946b805691ac9e7 (patch)
tree3ecfa5222d05df8cd7cc34d2e3b0fc95edb90b8d /src
parent26221aac1f9e06979a73b3b73be1303d8caa2e58 (diff)
evas: Adjust tb padding from gfx filters padding
This makes gfx filters padding work just like the standard style padding, which means the tb user must offset the object position by -l, -t and increase the object size by l+r,t+b.
Diffstat (limited to 'src')
-rw-r--r--src/bin/elementary/test_gfx_filters.c5
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c133
2 files changed, 91 insertions, 47 deletions
diff --git a/src/bin/elementary/test_gfx_filters.c b/src/bin/elementary/test_gfx_filters.c
index 74737b99e9..9ccdd71777 100644
--- a/src/bin/elementary/test_gfx_filters.c
+++ b/src/bin/elementary/test_gfx_filters.c
@@ -202,10 +202,11 @@ _text_resize(void *data EINA_UNUSED, const Efl_Event *ev)
202static void 202static void
203_textblock_resize(void *data EINA_UNUSED, const Efl_Event *ev) 203_textblock_resize(void *data EINA_UNUSED, const Efl_Event *ev)
204{ 204{
205 int w = 0, h = 0; 205 int w = 0, h = 0, l = 0, r = 0, t = 0, b = 0;
206 206
207 evas_object_textblock_size_native_get(ev->object, &w, &h); 207 evas_object_textblock_size_native_get(ev->object, &w, &h);
208 efl_gfx_size_hint_min_set(ev->object, w + 1, h + 1); 208 evas_object_textblock_style_insets_get(ev->object, &l, &r, &t, &b);
209 efl_gfx_size_hint_min_set(ev->object, w + l + r, h + t + b);
209} 210}
210 211
211static Evas_Object * 212static Evas_Object *
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 441b57f638..7ad8030e89 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -718,6 +718,7 @@ static void _evas_textblock_cursor_at_format_set(Efl_Canvas_Text_Cursor_Data *cu
718static void _evas_textblock_cursor_paragraph_char_last(Efl_Canvas_Text_Cursor_Data *cur); 718static void _evas_textblock_cursor_paragraph_char_last(Efl_Canvas_Text_Cursor_Data *cur);
719static void _evas_textblock_cursor_init(Efl_Canvas_Text_Cursor_Data *cur, const Evas_Object *tb); 719static void _evas_textblock_cursor_init(Efl_Canvas_Text_Cursor_Data *cur, const Evas_Object *tb);
720static int _efl_canvas_text_cursor_text_append(Efl_Canvas_Text_Cursor_Data *cur, const char *text); 720static int _efl_canvas_text_cursor_text_append(Efl_Canvas_Text_Cursor_Data *cur, const char *text);
721static Evas_Filter_Program *_format_filter_program_get(Efl_Canvas_Text_Data *o, Evas_Object_Textblock_Format *fmt);
721 722
722#ifdef HAVE_HYPHEN 723#ifdef HAVE_HYPHEN
723/* Hyphenation */ 724/* Hyphenation */
@@ -3991,6 +3992,23 @@ _text_item_update_sizes(Ctxt *c, Evas_Object_Textblock_Text_Item *ti)
3991 &ti->text_props); 3992 &ti->text_props);
3992 } 3993 }
3993 3994
3995 if (EINA_UNLIKELY(ti->parent.format->gfx_filter != NULL))
3996 {
3997 int l = 0, r = 0, t = 0, b = 0;
3998 Evas_Filter_Program *pgm;
3999
4000 pgm = _format_filter_program_get(c->o, ti->parent.format);
4001 evas_filter_program_padding_get(pgm, &l, &r, &t, &b);
4002
4003 // FIXME: Those values are very very strange
4004 ti->x_adjustment = r + l;
4005 ti->parent.w = tw + ti->x_adjustment;
4006 ti->parent.h = th;
4007 ti->parent.adv = advw;
4008 ti->parent.x = 0;
4009 return;
4010 }
4011
3994 /* These adjustments are calculated and thus heavily linked to those in 4012 /* These adjustments are calculated and thus heavily linked to those in
3995 * textblock_render!!! Don't change one without the other. */ 4013 * textblock_render!!! Don't change one without the other. */
3996 4014
@@ -4321,6 +4339,54 @@ _format_finalize(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt)
4321 if (of) evas_font_free(obj->layer->evas->evas, of); 4339 if (of) evas_font_free(obj->layer->evas->evas, of);
4322} 4340}
4323 4341
4342static Efl_Canvas_Text_Filter_Program *
4343_filter_program_find(Efl_Canvas_Text_Data *o, const char *name)
4344{
4345 Efl_Canvas_Text_Filter_Program *prg;
4346
4347 EINA_INLIST_FOREACH(o->gfx_filter.programs, prg)
4348 {
4349 if (eina_streq(name, prg->name))
4350 return prg;
4351 }
4352
4353 return NULL;
4354}
4355
4356static Evas_Filter_Program *
4357_format_filter_program_get(Efl_Canvas_Text_Data *o, Evas_Object_Textblock_Format *fmt)
4358{
4359 Efl_Canvas_Text_Filter_Program *program;
4360 Efl_Canvas_Text_Filter *filter;
4361 Evas_Filter_Program *pgm;
4362
4363 filter = fmt->gfx_filter;
4364 if (!filter->name) return NULL;
4365
4366 program = _filter_program_find(o, filter->name);
4367 if (program->changed)
4368 {
4369 evas_filter_program_del(program->pgm);
4370 program->pgm = NULL;
4371 }
4372 pgm = program->pgm;
4373 if (!pgm)
4374 {
4375 // TODO: data set
4376 pgm = evas_filter_program_new(program->name, EINA_FALSE);
4377 if (!evas_filter_program_parse(pgm, program->code))
4378 {
4379 evas_filter_program_del(pgm);
4380 filter->invalid = EINA_TRUE;
4381 return NULL;
4382 }
4383 filter->invalid = EINA_FALSE;
4384 program->pgm = pgm;
4385 }
4386
4387 return pgm;
4388}
4389
4324/** 4390/**
4325 * @internal 4391 * @internal
4326 * Returns true if the item is a tab 4392 * Returns true if the item is a tab
@@ -4371,7 +4437,7 @@ _format_finalize(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt)
4371 * @return fi if created. 4437 * @return fi if created.
4372 */ 4438 */
4373static Evas_Object_Textblock_Format_Item * 4439static Evas_Object_Textblock_Format_Item *
4374_layout_do_format(const Evas_Object *obj EINA_UNUSED, Ctxt *c, 4440_layout_do_format(const Evas_Object *obj, Ctxt *c,
4375 Evas_Object_Textblock_Format **_fmt, Evas_Object_Textblock_Node_Format *n, 4441 Evas_Object_Textblock_Format **_fmt, Evas_Object_Textblock_Node_Format *n,
4376 int *style_pad_l, int *style_pad_r, int *style_pad_t, int *style_pad_b, 4442 int *style_pad_l, int *style_pad_r, int *style_pad_t, int *style_pad_b,
4377 Eina_Bool create_item) 4443 Eina_Bool create_item)
@@ -4520,7 +4586,18 @@ _layout_do_format(const Evas_Object *obj EINA_UNUSED, Ctxt *c,
4520 { 4586 {
4521 Evas_Coord pad_l, pad_r, pad_t, pad_b; 4587 Evas_Coord pad_l, pad_r, pad_t, pad_b;
4522 pad_l = pad_r = pad_t = pad_b = 0; 4588 pad_l = pad_r = pad_t = pad_b = 0;
4523 evas_text_style_pad_get(fmt->style, &pad_l, &pad_r, &pad_t, &pad_b); 4589
4590 if (EINA_LIKELY(!fmt->gfx_filter))
4591 evas_text_style_pad_get(fmt->style, &pad_l, &pad_r, &pad_t, &pad_b);
4592 else
4593 {
4594 Evas_Filter_Program *pgm;
4595 Efl_Canvas_Text_Data *o;
4596
4597 o = efl_data_scope_get(obj, MY_CLASS);
4598 pgm = _format_filter_program_get(o, fmt);
4599 evas_filter_program_padding_get(pgm, &pad_l, &pad_r, &pad_t, &pad_b);
4600 }
4524 if (pad_l > *style_pad_l) *style_pad_l = pad_l; 4601 if (pad_l > *style_pad_l) *style_pad_l = pad_l;
4525 if (pad_r > *style_pad_r) *style_pad_r = pad_r; 4602 if (pad_r > *style_pad_r) *style_pad_r = pad_r;
4526 if (pad_t > *style_pad_t) *style_pad_t = pad_t; 4603 if (pad_t > *style_pad_t) *style_pad_t = pad_t;
@@ -12854,20 +12931,6 @@ _filter_cb(Evas_Filter_Context *ctx, void *data, Eina_Bool success)
12854 evas_post_render_job_add(filter->evas, _filter_post_render_cb, post_data); 12931 evas_post_render_job_add(filter->evas, _filter_post_render_cb, post_data);
12855} 12932}
12856 12933
12857static Efl_Canvas_Text_Filter_Program *
12858_filter_program_find(Efl_Canvas_Text_Data *o, const char *name)
12859{
12860 Efl_Canvas_Text_Filter_Program *prg;
12861
12862 EINA_INLIST_FOREACH(o->gfx_filter.programs, prg)
12863 {
12864 if (eina_streq(name, prg->name))
12865 return prg;
12866 }
12867
12868 return NULL;
12869}
12870
12871static void 12934static void
12872evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED, 12935evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED,
12873 Evas_Object_Protected_Data *obj, 12936 Evas_Object_Protected_Data *obj,
@@ -13174,7 +13237,6 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED,
13174 { 13237 {
13175 Efl_Canvas_Filter_State state = EFL_CANVAS_FILTER_STATE_DEFAULT; 13238 Efl_Canvas_Filter_State state = EFL_CANVAS_FILTER_STATE_DEFAULT;
13176 Evas_Object_Textblock_Text_Item *ti = _ITEM_TEXT(itr); 13239 Evas_Object_Textblock_Text_Item *ti = _ITEM_TEXT(itr);
13177 Efl_Canvas_Text_Filter_Program *program;
13178 Efl_Canvas_Text_Filter *filter; 13240 Efl_Canvas_Text_Filter *filter;
13179 Evas_Filter_Program *pgm; 13241 Evas_Filter_Program *pgm;
13180 Evas_Filter_Context *ctx; 13242 Evas_Filter_Context *ctx;
@@ -13182,36 +13244,14 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED,
13182 Eina_Bool ok; 13244 Eina_Bool ok;
13183 13245
13184 filter = ti->parent.format->gfx_filter; 13246 filter = ti->parent.format->gfx_filter;
13185 if (!filter->name || filter->invalid) 13247 pgm = _format_filter_program_get(o, ti->parent.format);
13186 { 13248 if (!pgm)
13187 ti->gfx_filter_id = 0;
13188 continue;
13189 }
13190
13191 program = _filter_program_find(o, filter->name);
13192 if (!program)
13193 { 13249 {
13194 WRN("Filter '%s' not found on this object", filter->name); 13250 WRN("Filter '%s' not found on this object", filter->name);
13195 ti->gfx_filter_id = 0; 13251 ti->gfx_filter_id = 0;
13196 continue; 13252 continue;
13197 } 13253 }
13198 13254
13199 pgm = program->pgm;
13200 if (!pgm)
13201 {
13202 // TODO: data set
13203 pgm = evas_filter_program_new(program->name, EINA_FALSE);
13204 ok = evas_filter_program_parse(pgm, program->code);
13205 if (!ok)
13206 {
13207 evas_filter_program_del(pgm);
13208 filter->invalid = EINA_TRUE;
13209 ti->gfx_filter_id = 0;
13210 continue;
13211 }
13212 program->pgm = pgm;
13213 }
13214
13215#ifdef DEBUG 13255#ifdef DEBUG
13216 if (filter->contexts) WRN("Previous filter context was not deleted"); 13256 if (filter->contexts) WRN("Previous filter context was not deleted");
13217#endif 13257#endif
@@ -13246,8 +13286,8 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED,
13246 &filter->pad.t, &filter->pad.b); 13286 &filter->pad.t, &filter->pad.b);
13247 evas_filter_context_buffers_allocate_all(ctx); 13287 evas_filter_context_buffers_allocate_all(ctx);
13248 evas_filter_target_set(ctx, context, surface, 13288 evas_filter_target_set(ctx, context, surface,
13249 obj->cur->geometry.x + ti->parent.x + x - filter->pad.l, 13289 obj->cur->geometry.x + ln->x + ti->parent.x + x - filter->pad.l,
13250 obj->cur->geometry.y + ln->par->y + y - filter->pad.t); 13290 obj->cur->geometry.y + ln->par->y + ln->y + y - filter->pad.t);
13251 if (!filter->dc) 13291 if (!filter->dc)
13252 { 13292 {
13253 filter->dc = ENFN->context_new(ENDT); 13293 filter->dc = ENFN->context_new(ENDT);
@@ -13573,7 +13613,7 @@ _efl_canvas_text_efl_canvas_filter_internal_filter_state_prepare(
13573 13613
13574 program = _filter_program_find(o, ti->parent.format->gfx_filter->name); 13614 program = _filter_program_find(o, ti->parent.format->gfx_filter->name);
13575 if (program) evas_filter_program_padding_get(program->pgm, &l, &r, &t, &b); 13615 if (program) evas_filter_program_padding_get(program->pgm, &l, &r, &t, &b);
13576 state->w = ti->parent.w + l + r; 13616 state->w = ti->parent.w; // + l + r; (already included)
13577 state->h = ti->parent.h + t + b; 13617 state->h = ti->parent.h + t + b;
13578 state->scale = obj->cur->scale; 13618 state->scale = obj->cur->scale;
13579} 13619}
@@ -13588,7 +13628,7 @@ _efl_canvas_text_efl_canvas_filter_internal_filter_input_render(
13588 return evas_filter_font_draw(filter, drawctx, 13628 return evas_filter_font_draw(filter, drawctx,
13589 EVAS_FILTER_BUFFER_INPUT_ID, 13629 EVAS_FILTER_BUFFER_INPUT_ID,
13590 ti->parent.format->font.font, 13630 ti->parent.format->font.font,
13591 l, t + ti->parent.ln->y + ti->parent.yoff, 13631 l, t + ti->parent.yoff,
13592 &ti->text_props, do_async); 13632 &ti->text_props, do_async);
13593} 13633}
13594 13634
@@ -13619,6 +13659,9 @@ _efl_canvas_text_efl_gfx_filter_filter_program_set(Eo *eo_obj, Efl_Canvas_Text_D
13619 } 13659 }
13620 eina_stringshare_replace(&prg->code, code); 13660 eina_stringshare_replace(&prg->code, code);
13621 prg->changed = EINA_TRUE; 13661 prg->changed = EINA_TRUE;
13662 pd->format_changed = EINA_TRUE;
13663 _evas_textblock_invalidate_all(pd);
13664 _evas_textblock_changed(pd, eo_obj);
13622 13665
13623 evas_object_change(eo_obj, obj); 13666 evas_object_change(eo_obj, obj);
13624} 13667}