efl/src/lib/edje/edje_textblock.c

595 lines
21 KiB
C
Raw Permalink Normal View History

#include "edje_private.h"
/*
* Legacy function for min/max calculation of textblock part.
* It can't calculate min/max properly in many cases.
*
* To keep backward compatibility, it will be used for old version of EDJ files.
* You can't see proper min/max result accroding to documents with this function.
*/
static void
_edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
Edje_Part_Description_Text *chosen_desc,
Edje_Calc_Params *params,
int *minw, int *minh,
int *maxw, int *maxh)
{
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
Eina_Size2D size;
Evas_Coord ins_l, ins_r, ins_t, ins_b;
unsigned char minx2 = 0, miny2 = 0, maxx2 = 0, maxy2 = 0;
minx2 = chosen_desc->text.min_x;
miny2 = chosen_desc->text.min_y;
maxx2 = chosen_desc->text.max_x;
maxy2 = chosen_desc->text.max_y;
// Do not use size from new api if min/max are non-zero in the theme
if (!chosen_desc->text.min_x && !chosen_desc->text.min_y &&
!chosen_desc->text.max_x && !chosen_desc->text.max_y)
{
minx2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_X;
miny2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_Y;
maxx2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_X;
maxy2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_Y;
}
/* Legacy code for Textblock min/max calculation */
if (minx2 || miny2)
{
int mw = 0, mh = 0;
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
size.w = size.h = 0;
if (!minx2)
{
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(TO_INT(params->eval.w), TO_INT(params->eval.h)));
size = efl_canvas_textblock_size_formatted_get(ep->object);
}
else
size = efl_canvas_textblock_size_native_get(ep->object);
evas_object_textblock_style_insets_get(ep->object, &ins_l,
&ins_r, &ins_t, &ins_b);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
mw = ins_l + size.w + ins_r;
mh = ins_t + size.h + ins_b;
if (minw && minx2)
{
if (mw > *minw) *minw = mw;
}
if (minh && miny2)
{
if (mh > *minh) *minh = mh;
}
}
if ((maxx2) || (maxy2))
{
int mw = 0, mh = 0;
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
size.w = size.h = 0;
if (!maxx2)
{
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(TO_INT(params->eval.w), TO_INT(params->eval.h)));
size = efl_canvas_textblock_size_formatted_get(ep->object);
}
else
size = efl_canvas_textblock_size_native_get(ep->object);
evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
&ins_t, &ins_b);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
mw = ins_l + size.w + ins_r;
mh = ins_t + size.h + ins_b;
if (maxw && maxx2)
{
if (mw > *maxw) *maxw = mw;
if (minw && (*maxw < *minw)) *maxw = *minw;
}
if (maxh && maxy2)
{
if (mh > *maxh) *maxh = mh;
if (minh && (*maxh < *minh)) *maxh = *minh;
}
}
}
static void
_edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
Edje_Part_Description_Text *chosen_desc,
Edje_Calc_Params *params,
int *minw, int *minh,
int *maxw, int *maxh)
{
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
Eina_Size2D size;
Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
Evas_Coord min_calc_w = 0, min_calc_h = 0;
unsigned char dminx, dminy, dmaxx, dmaxy;
dminx = chosen_desc->text.min_x;
dminy = chosen_desc->text.min_y;
dmaxx = chosen_desc->text.max_x;
dmaxy = chosen_desc->text.max_y;
// Do not use size from new api if min/max are non-zero in the theme
if (!chosen_desc->text.min_x && !chosen_desc->text.min_y &&
!chosen_desc->text.max_x && !chosen_desc->text.max_y)
{
dminx = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_X;
dminy = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_Y;
dmaxx = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_X;
dmaxy = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_Y;
}
/* min_calc_* values need to save calculated minumum size
* for maximum size calculation */
if (minw) min_calc_w = *minw;
if (minh) min_calc_h = *minh;
if (dminx || dminy)
{
evas_object_textblock_style_insets_get(ep->object, &ins_l,
&ins_r, &ins_t, &ins_b);
tw = th = 0;
if (!dminx)
{
/* text.min: 0 1
* text.max: X X */
int temp_h = TO_INT(params->eval.h);
int temp_w = TO_INT(params->eval.w);
if (min_calc_w > temp_w)
temp_w = min_calc_w;
if ((!dmaxx) &&
maxw && (*maxw > -1) && (*maxw < temp_w))
temp_w = *maxw;
if (dmaxy)
{
/* text.min: 0 1
* text.max: X 1 */
temp_h = INT_MAX / 10000;
}
else if (maxh && (*maxh > TO_INT(params->eval.h)))
{
/* text.min: 0 1
* text.max: X 0
* And there is a limit for height. */
temp_h = *maxh;
}
/* If base width for calculation is 0,
* don't get meaningless height for multiline */
if (temp_w > 0)
{
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(temp_w, temp_h));
size = efl_canvas_textblock_size_formatted_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
tw = size.w;
th = size.h;
tw += ins_l + ins_r;
th += ins_t + ins_b;
}
else
{
size = efl_canvas_textblock_size_native_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
th = size.h;
th += ins_t + ins_b;
}
}
else
{
/* text.min: 1 X
* text.max: X X */
if (dminy && (!dmaxx) &&
maxw && (*maxw > -1))
{
/* text.min: 1 1
* text.max: 0 X */
int temp_w, temp_h;
temp_w = *maxw;
temp_h = INT_MAX / 10000;
if (min_calc_w > temp_w)
temp_w = min_calc_w;
if ((!dmaxy) && maxh && (*maxh > -1))
{
/* text.min: 1 1
* text.max: 0 0
* There is limit for height. */
temp_h = *maxh;
}
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(temp_w, temp_h));
size = efl_canvas_textblock_size_formatted_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
tw = size.w;
th = size.h;
tw += ins_l + ins_r;
th += ins_t + ins_b;
/* If base width for calculation is 0,
* don't get meaningless height for multiline */
if (temp_w <= 0)
{
size = efl_canvas_textblock_size_native_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
th = size.h;
th += ins_t + ins_b;
}
}
else
{
/* text.min: 1 X
* text.max: 1 X
* Or,
* text.min: 1 X
* text.max: 0 X without max width.
* It is a singleline Textblock. */
size = efl_canvas_textblock_size_native_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
tw = size.w;
th = size.h;
tw += ins_l + ins_r;
th += ins_t + ins_b;
if (!dmaxx &&
(maxw && (*maxw > -1) && (*maxw < tw)))
{
/* text.min: 1 0
* text.max: 0 X */
tw = *maxw;
}
}
}
if (tw > min_calc_w) min_calc_w = tw;
if (th > min_calc_h) min_calc_h = th;
if (dminx && minw) *minw = min_calc_w;
if (dminy && minh) *minh = min_calc_h;
}
if ((dmaxx) || (dmaxy))
{
evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
&ins_t, &ins_b);
tw = th = 0;
if (!dmaxx)
{
/* text.min: X X
* text.max: 0 1 */
int temp_w, temp_h;
if (dminy)
{
/* text.min: X 1
* text.max: 0 1
* Already calculated in text for height. */
tw = TO_INT(params->eval.w);
if (min_calc_w > tw)
tw = min_calc_w;
th = min_calc_h;
}
else
{
/* text.min: X 0
* text.max: 0 1 */
temp_w = TO_INT(params->eval.w);
temp_h = TO_INT(params->eval.h);
if (min_calc_w > temp_w)
temp_w = min_calc_w;
if (maxw && (*maxw > -1) && (*maxw < temp_w))
temp_w = *maxw;
if (min_calc_h > temp_h)
temp_h = min_calc_h;
/* If base width for calculation is 0,
* don't get meaningless height for multiline */
if (temp_w > 0)
{
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(temp_w, temp_h));
size = efl_canvas_textblock_size_formatted_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
tw = size.w;
th = size.h;
tw += ins_l + ins_r;
th += ins_t + ins_b;
}
else
{
size = efl_canvas_textblock_size_native_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
th = size.h;
th += ins_t + ins_b;
}
}
}
else
{
/* text.max: 1 X */
if (dminx)
{
/* text.min: 1 X
* text.max: 1 X
* Singleline. */
size = efl_canvas_textblock_size_native_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
tw = size.w;
th = size.h;
tw += ins_l + ins_r;
th += ins_t + ins_b;
}
else
{
/* text.min: 0 X
* text.max: 1 X */
if (dmaxy)
{
/* text.min: 0 X
* text.max: 1 1 */
int temp_w, temp_h;
temp_w = TO_INT(params->eval.w);
temp_h = TO_INT(params->eval.h);
if (min_calc_w > temp_w)
temp_w = min_calc_w;
if (min_calc_h > temp_h)
temp_h = min_calc_h;
if (dminy)
{
/* text.min: 0 1
* text.max: 1 1
* There is no need to calculate it again. */
tw = min_calc_w;
th = min_calc_h;
}
else
{
/* text.min: 0 0
* text.max: 1 1 */
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(temp_w, temp_h));
size = efl_canvas_textblock_size_formatted_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
tw = size.w;
th = size.h;
tw += ins_l + ins_r;
th += ins_t + ins_b;
/* If base width for calculation is 0,
* don't get meaningless height for multiline */
if (temp_w <= 0)
{
size = efl_canvas_textblock_size_native_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
th = size.h;
th += ins_t + ins_b;
}
}
}
else
{
/* text.min: 0 X
* text.max: 1 0 */
int temp_w, temp_h;
temp_w = TO_INT(params->eval.w);
if (min_calc_w > temp_w)
temp_w = min_calc_w;
temp_h = efl_gfx_entity_size_get(ep->object).h;
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(temp_w, temp_h));
size = efl_canvas_textblock_size_formatted_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
tw = size.w;
th = size.h;
tw += ins_l + ins_r;
th += ins_t + ins_b;
/* If base width for calculation is 0,
* don't get meaningless height for multiline */
if (temp_w <= 0)
{
size = efl_canvas_textblock_size_native_get(ep->object);
Efl.Text.Cursor Summary: Implementation of new cursor text object. This Patch Contains : 1- Remove Efl.Text.Cursor & Efl.Text_Markup_Interactive interfaces and replace them with one Class Efl.Text.Cursor => there are some modifications on cursor methods 2- Update all related classes to use Efl.Text.Cursor object instead of the old interfaces 3- If class uses Efl.Text_Cursor_Cursor (handle), mainly annotation it will stay as it is until we update other annotations into attribute_factory 4- Add main cursor property into efl.text.interactive 5- Add cursor_new method in efl.ui.text (I think we may move it into efl.text.interactive interface) There still some parts that need discussion: especially cursor movement functionality, I prefer to move function with Enum, instead of special function for each movement. ``` enum @beta Efl.Text.Cursor_Move_Type { [[Text cursor movement types]] char_next, [[Advances to the next character]] char_prev, [[Advances to the previous character]] cluster_next, [[Advances to the next grapheme cluster]] cluster_prev, [[Advances to the previous grapheme cluster]] paragraph_start, [[Advances to the first character in this paragraph]] paragraph_end, [[Advances to the last character in this paragraph]] word_start, [[Advance to current word start]] word_end, [[Advance to current word end]] line_start, [[Advance to current line first character]] line_end, [[Advance to current line last character]] paragraph_first, [[Advance to current paragraph first character]] paragraph_last, [[Advance to current paragraph last character]] paragraph_next, [[Advances to the start of the next text node]] paragraph_prev [[Advances to the end of the previous text node]] } move { [[Move the cursor]] params { @in type: Efl.Text.Cursor_Move_Type; [[The type of movement]] } return: bool; [[True if actually moved]] } ``` or old way: ``` char_next { [[Advances to the next character]] // FIXME: Make the number of characters we moved by? Useful for all the other functions return: bool; [[True if actually moved]] } char_prev { [[Advances to the previous character]] return: bool; [[True if actually moved]] } char_delete { [[Deletes a single character from position pointed by given cursor.]] } cluster_next { [[Advances to the next grapheme cluster]] return: bool; [[True if actually moved]] } cluster_prev { [[Advances to the previous grapheme cluster]] return: bool; [[True if actually moved]] } // FIXME: paragraph_end is inconsistent with word_end. The one goes to the last character and the other after the last character. paragraph_start { [[Advances to the first character in this paragraph]] return: bool; [[True if actually moved]] } paragraph_end { [[Advances to the last character in this paragraph]] return: bool; [[True if actually moved]] } word_start { [[Advance to current word start]] return: bool; [[True if actually moved]] } word_end { [[Advance to current word end]] return: bool; [[True if actually moved]] } line_start { [[Advance to current line first character]] return: bool; [[True if actually moved]] } line_end { [[Advance to current line last character]] return: bool; [[True if actually moved]] } paragraph_first { [[Advance to current paragraph first character]] return: bool; [[True if actually moved]] } paragraph_last { [[Advance to current paragraph last character]] return: bool; [[True if actually moved]] } paragraph_next { [[Advances to the start of the next text node]] return: bool; [[True if actually moved]] } paragraph_prev { [[Advances to the end of the previous text node]] return: bool; [[True if actually moved]] } ``` Reviewers: woohyun, tasn, segfaultxavi Reviewed By: woohyun Subscribers: a.srour, bu5hm4n, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10542
2019-11-22 00:35:54 -08:00
th = size.h;
th += ins_t + ins_b;
}
}
}
}
if (maxw && dmaxx)
{
if (tw > *maxw) *maxw = tw;
if (minw && (*maxw < *minw)) *maxw = *minw;
}
if (maxh && dmaxy)
{
if (th > *maxh) *maxh = th;
if (minh && (*maxh < *minh)) *maxh = *minh;
}
}
}
Eina_Bool
_edje_part_textblock_style_text_set(Edje *ed,
Edje_Real_Part *ep,
Edje_Part_Description_Text *chosen_desc)
{
const char *text = "";
const char *style = "";
Evas_Textblock_Style *stl = NULL;
const char *tmp;
if (chosen_desc->text.id_source >= 0)
{
Edje_Part_Description_Text *et;
ep->typedata.text->source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
et = _edje_real_part_text_source_description_get(ep, NULL);
tmp = edje_string_get(&et->text.style);
if (tmp) style = tmp;
}
else
{
ep->typedata.text->source = NULL;
tmp = edje_string_get(&chosen_desc->text.style);
if (tmp) style = tmp;
}
if (chosen_desc->text.id_text_source >= 0)
{
Edje_Part_Description_Text *et;
Edje_Real_Part *rp;
ep->typedata.text->text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
et = _edje_real_part_text_text_source_description_get(ep, &rp);
text = edje_string_get(&et->text.text);
if (rp->typedata.text->text) text = rp->typedata.text->text;
}
else
{
ep->typedata.text->text_source = NULL;
text = NULL;
if (chosen_desc->text.domain)
{
if (!chosen_desc->text.text.translated)
chosen_desc->text.text.translated = _set_translated_string(ed, ep);
if (chosen_desc->text.text.translated)
text = chosen_desc->text.text.translated;
}
if (!text) text = edje_string_get(&chosen_desc->text.text);
if (ep->typedata.text->text) text = ep->typedata.text->text;
}
stl = _edje_textblock_style_get(ed, style);
if (stl)
{
if (evas_object_textblock_style_get(ep->object) != stl)
evas_object_textblock_style_set(ep->object, stl);
// FIXME: need to account for editing
if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
{
// do nothing - should be done elsewhere
}
else
{
evas_object_textblock_text_markup_set(ep->object, text);
}
return EINA_TRUE;
}
return EINA_FALSE;
}
static char*
strrstr(const char* haystack, const char* violate)
{
char *s_ret = NULL;
char *tmp = NULL;
const char *_haystack = haystack;
size_t len = strlen(violate);
while((tmp = strstr(_haystack, violate))){
s_ret = tmp;
_haystack = tmp + len;
}
return s_ret;
}
void
_edje_part_recalc_single_textblock(FLOAT_T sc,
Edje *ed,
Edje_Real_Part *ep,
Edje_Part_Description_Text *chosen_desc,
Edje_Calc_Params *params,
int *minw, int *minh,
int *maxw, int *maxh)
{
if ((ep->type != EDJE_RP_TYPE_TEXT) ||
(!ep->typedata.text))
return;
if (chosen_desc)
{
if (ep->part->scale)
evas_object_scale_set(ep->object, TO_DOUBLE(sc));
//Gets textblock's style and text to set evas_object_textblock properties.
//If there is no style for it. don't need to calc.
if (_edje_part_textblock_style_text_set(ed, ep, chosen_desc))
{
if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
{
evas_textblock: content fit feature Summary: **Content Fit Feature for Evas_Object_Textblock** This Feature is available at **Evas **object level. And **Edje **level (where it is internally use evas functionality) This feature will allow text block to fit its content font size to proper size to fit its area. **Main Properties:** Fit Modes : None=Default, Width, Height, All [Width+Height] Fit Size Range : Contains maximum and minimum font size to be used (and in between). Fit Step Size : Step(Jump) value when trying fonts sizes between Size_Range max and min. Fit Size Array : Other way to resize font, where you explicitly select font sizes to be uses (for example [20, 50, 100] it will try 3 sizes only) Text Fit feature was available in Edje but: 1- It doesn't effected by ellipsis or warping in font style (or do not handle the in right way) 2- Accuracy is not good (specially if you have fix pixel size elements (spaces,tabs,items)) 3- No (Step size, Size Array) available. Test Plan: To check the Feature > elementary_test > fit > textbock fit You can modify all the modes and properties These are two examples, One using Evas other uses Edje **Evas** ``` #include <Elementary.h> enum BUTTON{ BUTTON_MODE = 0, BUTTON_MAX = 1, BUTTON_MIN = 2, BUTTON_STEP = 3, BUTTON_ARRAY = 4, BUTTON_CONTENT = 5, BUTTON_STYLE = 6, BUTTON_ALL = BUTTON_STYLE+1, }; char* BUTTON_STR[BUTTON_ALL] ={ "MODE", "MAX", "MIN", "STEP", "ARRAY", "CONTENT", "STYLE", }; char *contents[] = { "Hello World", "This is Line<br>THis is other Line", "This text contains <font_size=20 color=#F00>SPECIFIC SIZE</font_size> that does not effected by fit mode" }; char *styles[] = { "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed'", "DEFAULT='font=sans font_size=30 color=#000 ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000'", }; char *styles_names[] = { "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>NONE</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>NONE</color>", }; typedef struct _APP { Evas_Object *win, *box, *txtblock,*bg, *boxHor, *boxHor2; Eo *btn[BUTTON_ALL]; Eo *lbl_status; char * str; unsigned int i_contnet, i_style; } APP; APP *app; char * get_fit_status(Eo * textblock); static void _btn_clicked(void *data EINA_UNUSED, Eo *obj, void *eventInfo EINA_UNUSED){ if (obj == app->btn[BUTTON_MODE]) { unsigned int options; evas_textblock_fit_options_get(app->txtblock, &options); if (options == TEXTBLOCK_FIT_MODE_NONE) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_HEIGHT); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_WIDTH); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_ALL); else if (options == TEXTBLOCK_FIT_MODE_ALL) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_NONE); } else if (obj == app->btn[BUTTON_MAX]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); max -= 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_MIN]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); min += 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_STEP]) { unsigned int step; evas_textblock_fit_step_size_get(app->txtblock, &step); step++; evas_textblock_fit_step_size_set(app->txtblock, step); } else if (obj == app->btn[BUTTON_ARRAY]) { unsigned int font_size[] = {10, 50, 100 ,150}; evas_textblock_fit_size_array_set(app->txtblock,font_size,4); } else if (obj == app->btn[BUTTON_CONTENT]) { app->i_contnet++; if(app->i_contnet>=sizeof(contents)/sizeof(char*)) app->i_contnet=0; evas_object_textblock_text_markup_set(app->txtblock,contents[app->i_contnet]); } else if (obj == app->btn[BUTTON_STYLE]) { app->i_style++; if(app->i_style>=sizeof(styles)/sizeof(char*)) app->i_style=0; Evas_Textblock_Style *style = evas_object_textblock_style_get(app->txtblock); evas_textblock_style_set(style,styles[app->i_style]); } elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); } char * get_fit_status(Eo * textblock) { static char status[0xFFF]; unsigned int options,min,max,step,size_array[256]; size_t size_array_len; evas_textblock_fit_options_get(textblock,&options); evas_textblock_fit_size_range_get(textblock,&min,&max); evas_textblock_fit_step_size_get(textblock,&step); evas_textblock_fit_size_array_get(textblock,NULL,&size_array_len,0); if (size_array_len>255) size_array_len = 255; evas_textblock_fit_size_array_get(textblock,size_array,NULL,size_array_len); strcpy(status,"Mode : "); if (options == TEXTBLOCK_FIT_MODE_NONE) strcat(status,"MODE_NONE"); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) strcat(status,"MODE_HEIGHT"); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) strcat(status,"MODE_WIDTH"); else if (options == TEXTBLOCK_FIT_MODE_ALL) strcat(status,"MODE_ALL"); strcat(status,"<br>"); sprintf(status + strlen(status),"Max : %d<br>",max); sprintf(status + strlen(status),"Min : %d<br>",min); sprintf(status + strlen(status),"Step : %d<br>",step); sprintf(status + strlen(status),"Array : [ "); for (size_t i = 0 ; i < 10 ; i++) { if(i<size_array_len) sprintf(status + strlen(status)," %d,",size_array[i]); } if(10<size_array_len) sprintf(status + strlen(status)," ... "); sprintf(status + strlen(status)," ]"); sprintf(status + strlen(status),"<br>"); sprintf(status + strlen(status),"%s",styles_names[app->i_style]); return status; } int elm_main(int argc, char **argv) { app = calloc(sizeof(APP), 1); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); app->win = elm_win_util_standard_add("Main", "App"); elm_win_autodel_set(app->win, EINA_TRUE); app->box = elm_box_add(app->win); app->boxHor = elm_box_add(app->box); app->boxHor2 = elm_box_add(app->box); app->txtblock = evas_object_textblock_add(app->box); app->bg = elm_bg_add(app->box); elm_bg_color_set(app->bg,255,255,255); Evas_Textblock_Style *style = evas_textblock_style_new(); evas_textblock_style_set(style,styles[0]); evas_object_textblock_style_set(app->txtblock,style); evas_object_textblock_text_markup_set(app->txtblock,contents[0]); elm_box_horizontal_set(app->boxHor, EINA_TRUE); elm_box_horizontal_set(app->boxHor2, EINA_TRUE); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->txtblock); evas_object_show(app->bg); evas_object_show(app->box); evas_object_show(app->boxHor); evas_object_show(app->boxHor2); elm_box_pack_end(app->box, app->bg); elm_box_pack_end(app->box, app->boxHor); elm_box_pack_end(app->box, app->boxHor2); elm_object_content_set(app->bg,app->txtblock); elm_win_resize_object_add(app->win, app->box); evas_object_resize(app->win, 320, 480); for(int i = 0 ; i < BUTTON_ALL ; i++) { app->btn[i] = elm_button_add(app->boxHor); evas_object_smart_callback_add(app->btn[i], "clicked", _btn_clicked, NULL); elm_object_text_set(app->btn[i], BUTTON_STR[i]); elm_box_pack_end(app->boxHor, app->btn[i]); evas_object_show(app->btn[i]); } app->lbl_status = elm_label_add(app->boxHor2); elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); elm_box_pack_end(app->boxHor2, app->lbl_status); evas_object_show(app->lbl_status); evas_object_size_hint_weight_set(app->txtblock, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->txtblock, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->bg, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->bg, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->win); elm_run(); return 0; } ELM_MAIN() ``` **Edje** ``` // compile: edje_cc source.edc // run: edje_player source.edje collections { styles { style { name: "text_style"; base: "font=sans font_size=30 color=#FFF wrap=mixed ellipsis=1.0"; tag: "br" "\n"; tag: "ps" "ps"; tag: "tab" "\t"; tag: "b" "+ font_weight=Bold"; } } group { name: "my_group"; // must be the same as in source.c parts { part { name: "background"; type: RECT; scale: 1; description { color: 0 0 0 0; rel1.relative: 0.0 0.0; rel2.relative: 1.0 1.0; } } part { name: "text"; type: TEXTBLOCK; scale: 1; entry_mode: NONE; effect: OUTLINE_SHADOW; description { state: "default" 0.0; rel1.to : "background"; rel1.relative: 0.0 0.0; rel2.to : "background"; rel2.relative: 1.0 1.0; text { style: "text_style"; align: 0.0 0.0; text: "Hello World This is Me"; fit: 1 1; fit_step: 1; size_range: 30 200; //fit_size_array: 20 40 60 80 100 200; } } } } } } ``` Found Task T5724 relative to this Feature Reviewers: woohyun, bowonryu, cedric, raster Reviewed By: woohyun Subscribers: a.srour, #committers, #reviewers, cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D9280
2019-12-11 21:22:45 -08:00
unsigned int size_array[255];
size_t size_array_len = 0;
Eina_List *l;
unsigned int *value;
Evas_Textblock_Style *st = _edje_textblock_style_get(ed, chosen_desc->text.style.str);
const char *text_style = evas_textblock_style_get(st);
char *s_font_size = (text_style) ? strrstr(text_style,"font_size=") : NULL;
if (s_font_size && s_font_size[10])
{
int font_size = (int) strtol(&s_font_size[10], NULL, 10);
if (font_size > 0)
{
chosen_desc->text.size_range_max = font_size;
if (chosen_desc->text.size_range_min > chosen_desc->text.size_range_max)
chosen_desc->text.size_range_min = chosen_desc->text.size_range_max;
}
}
evas_textblock: content fit feature Summary: **Content Fit Feature for Evas_Object_Textblock** This Feature is available at **Evas **object level. And **Edje **level (where it is internally use evas functionality) This feature will allow text block to fit its content font size to proper size to fit its area. **Main Properties:** Fit Modes : None=Default, Width, Height, All [Width+Height] Fit Size Range : Contains maximum and minimum font size to be used (and in between). Fit Step Size : Step(Jump) value when trying fonts sizes between Size_Range max and min. Fit Size Array : Other way to resize font, where you explicitly select font sizes to be uses (for example [20, 50, 100] it will try 3 sizes only) Text Fit feature was available in Edje but: 1- It doesn't effected by ellipsis or warping in font style (or do not handle the in right way) 2- Accuracy is not good (specially if you have fix pixel size elements (spaces,tabs,items)) 3- No (Step size, Size Array) available. Test Plan: To check the Feature > elementary_test > fit > textbock fit You can modify all the modes and properties These are two examples, One using Evas other uses Edje **Evas** ``` #include <Elementary.h> enum BUTTON{ BUTTON_MODE = 0, BUTTON_MAX = 1, BUTTON_MIN = 2, BUTTON_STEP = 3, BUTTON_ARRAY = 4, BUTTON_CONTENT = 5, BUTTON_STYLE = 6, BUTTON_ALL = BUTTON_STYLE+1, }; char* BUTTON_STR[BUTTON_ALL] ={ "MODE", "MAX", "MIN", "STEP", "ARRAY", "CONTENT", "STYLE", }; char *contents[] = { "Hello World", "This is Line<br>THis is other Line", "This text contains <font_size=20 color=#F00>SPECIFIC SIZE</font_size> that does not effected by fit mode" }; char *styles[] = { "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed'", "DEFAULT='font=sans font_size=30 color=#000 ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000'", }; char *styles_names[] = { "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>NONE</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>NONE</color>", }; typedef struct _APP { Evas_Object *win, *box, *txtblock,*bg, *boxHor, *boxHor2; Eo *btn[BUTTON_ALL]; Eo *lbl_status; char * str; unsigned int i_contnet, i_style; } APP; APP *app; char * get_fit_status(Eo * textblock); static void _btn_clicked(void *data EINA_UNUSED, Eo *obj, void *eventInfo EINA_UNUSED){ if (obj == app->btn[BUTTON_MODE]) { unsigned int options; evas_textblock_fit_options_get(app->txtblock, &options); if (options == TEXTBLOCK_FIT_MODE_NONE) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_HEIGHT); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_WIDTH); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_ALL); else if (options == TEXTBLOCK_FIT_MODE_ALL) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_NONE); } else if (obj == app->btn[BUTTON_MAX]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); max -= 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_MIN]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); min += 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_STEP]) { unsigned int step; evas_textblock_fit_step_size_get(app->txtblock, &step); step++; evas_textblock_fit_step_size_set(app->txtblock, step); } else if (obj == app->btn[BUTTON_ARRAY]) { unsigned int font_size[] = {10, 50, 100 ,150}; evas_textblock_fit_size_array_set(app->txtblock,font_size,4); } else if (obj == app->btn[BUTTON_CONTENT]) { app->i_contnet++; if(app->i_contnet>=sizeof(contents)/sizeof(char*)) app->i_contnet=0; evas_object_textblock_text_markup_set(app->txtblock,contents[app->i_contnet]); } else if (obj == app->btn[BUTTON_STYLE]) { app->i_style++; if(app->i_style>=sizeof(styles)/sizeof(char*)) app->i_style=0; Evas_Textblock_Style *style = evas_object_textblock_style_get(app->txtblock); evas_textblock_style_set(style,styles[app->i_style]); } elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); } char * get_fit_status(Eo * textblock) { static char status[0xFFF]; unsigned int options,min,max,step,size_array[256]; size_t size_array_len; evas_textblock_fit_options_get(textblock,&options); evas_textblock_fit_size_range_get(textblock,&min,&max); evas_textblock_fit_step_size_get(textblock,&step); evas_textblock_fit_size_array_get(textblock,NULL,&size_array_len,0); if (size_array_len>255) size_array_len = 255; evas_textblock_fit_size_array_get(textblock,size_array,NULL,size_array_len); strcpy(status,"Mode : "); if (options == TEXTBLOCK_FIT_MODE_NONE) strcat(status,"MODE_NONE"); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) strcat(status,"MODE_HEIGHT"); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) strcat(status,"MODE_WIDTH"); else if (options == TEXTBLOCK_FIT_MODE_ALL) strcat(status,"MODE_ALL"); strcat(status,"<br>"); sprintf(status + strlen(status),"Max : %d<br>",max); sprintf(status + strlen(status),"Min : %d<br>",min); sprintf(status + strlen(status),"Step : %d<br>",step); sprintf(status + strlen(status),"Array : [ "); for (size_t i = 0 ; i < 10 ; i++) { if(i<size_array_len) sprintf(status + strlen(status)," %d,",size_array[i]); } if(10<size_array_len) sprintf(status + strlen(status)," ... "); sprintf(status + strlen(status)," ]"); sprintf(status + strlen(status),"<br>"); sprintf(status + strlen(status),"%s",styles_names[app->i_style]); return status; } int elm_main(int argc, char **argv) { app = calloc(sizeof(APP), 1); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); app->win = elm_win_util_standard_add("Main", "App"); elm_win_autodel_set(app->win, EINA_TRUE); app->box = elm_box_add(app->win); app->boxHor = elm_box_add(app->box); app->boxHor2 = elm_box_add(app->box); app->txtblock = evas_object_textblock_add(app->box); app->bg = elm_bg_add(app->box); elm_bg_color_set(app->bg,255,255,255); Evas_Textblock_Style *style = evas_textblock_style_new(); evas_textblock_style_set(style,styles[0]); evas_object_textblock_style_set(app->txtblock,style); evas_object_textblock_text_markup_set(app->txtblock,contents[0]); elm_box_horizontal_set(app->boxHor, EINA_TRUE); elm_box_horizontal_set(app->boxHor2, EINA_TRUE); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->txtblock); evas_object_show(app->bg); evas_object_show(app->box); evas_object_show(app->boxHor); evas_object_show(app->boxHor2); elm_box_pack_end(app->box, app->bg); elm_box_pack_end(app->box, app->boxHor); elm_box_pack_end(app->box, app->boxHor2); elm_object_content_set(app->bg,app->txtblock); elm_win_resize_object_add(app->win, app->box); evas_object_resize(app->win, 320, 480); for(int i = 0 ; i < BUTTON_ALL ; i++) { app->btn[i] = elm_button_add(app->boxHor); evas_object_smart_callback_add(app->btn[i], "clicked", _btn_clicked, NULL); elm_object_text_set(app->btn[i], BUTTON_STR[i]); elm_box_pack_end(app->boxHor, app->btn[i]); evas_object_show(app->btn[i]); } app->lbl_status = elm_label_add(app->boxHor2); elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); elm_box_pack_end(app->boxHor2, app->lbl_status); evas_object_show(app->lbl_status); evas_object_size_hint_weight_set(app->txtblock, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->txtblock, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->bg, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->bg, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->win); elm_run(); return 0; } ELM_MAIN() ``` **Edje** ``` // compile: edje_cc source.edc // run: edje_player source.edje collections { styles { style { name: "text_style"; base: "font=sans font_size=30 color=#FFF wrap=mixed ellipsis=1.0"; tag: "br" "\n"; tag: "ps" "ps"; tag: "tab" "\t"; tag: "b" "+ font_weight=Bold"; } } group { name: "my_group"; // must be the same as in source.c parts { part { name: "background"; type: RECT; scale: 1; description { color: 0 0 0 0; rel1.relative: 0.0 0.0; rel2.relative: 1.0 1.0; } } part { name: "text"; type: TEXTBLOCK; scale: 1; entry_mode: NONE; effect: OUTLINE_SHADOW; description { state: "default" 0.0; rel1.to : "background"; rel1.relative: 0.0 0.0; rel2.to : "background"; rel2.relative: 1.0 1.0; text { style: "text_style"; align: 0.0 0.0; text: "Hello World This is Me"; fit: 1 1; fit_step: 1; size_range: 30 200; //fit_size_array: 20 40 60 80 100 200; } } } } } } ``` Found Task T5724 relative to this Feature Reviewers: woohyun, bowonryu, cedric, raster Reviewed By: woohyun Subscribers: a.srour, #committers, #reviewers, cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D9280
2019-12-11 21:22:45 -08:00
EINA_LIST_FOREACH(chosen_desc->text.fit_size_array, l, value)
Revert "evas_textblock: content fit feature" This reverts commit 2f676a6591c117e15d65f263ebd267866963b627. This causes segv's in edje_cc - i suspect the eet changes (or in combo to how they are used in edje): AddressSanitizer:DEADLYSIGNAL ================================================================= ==8991==ERROR: AddressSanitizer: SEGV on unknown address 0x000001010000 (pc 0xffff9f002604 bp 0xfffffa747700 sp 0xfffffa747700 T0) ==8991==The signal is caused by a READ memory access. #0 0xffff9f002600 in _eet_hash_gen ../src/lib/eet/eet_utils.c:25 #1 0xffff9efdd024 in eet_dictionary_string_add ../src/lib/eet/eet_dictionary.c:103 #2 0xffff9efbe324 in eet_data_put_string ../src/lib/eet/eet_data.c:849 #3 0xffff9efc1c4c in eet_data_put_type ../src/lib/eet/eet_data.c:1427 #4 0xffff9efd9128 in eet_data_put_unknown ../src/lib/eet/eet_data.c:4730 #5 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108 #6 0xffff9efd5958 in eet_data_put_variant ../src/lib/eet/eet_data.c:4309 #7 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108 #8 0xffff9efd9270 in eet_data_put_unknown ../src/lib/eet/eet_data.c:4739 #9 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108 #10 0xffff9efd8ca0 in eet_data_put_array ../src/lib/eet/eet_data.c:4692 #11 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108 #12 0xffff9efc7768 in eet_data_write_cipher ../src/lib/eet/eet_data.c:2403 #13 0xffff9efc78a4 in eet_data_write ../src/lib/eet/eet_data.c:2420 #14 0xaaaabb151dcc in data_thread_group ../src/bin/edje/edje_cc_out.c:2045 #15 0xaaaabb152130 in data_write_groups ../src/bin/edje/edje_cc_out.c:2086 #16 0xaaaabb157734 in data_write ../src/bin/edje/edje_cc_out.c:2866 #17 0xaaaabb14122c in main ../src/bin/edje/edje_cc.c:456 #18 0xffff9dbd92a0 in __libc_start_main (/usr/lib/aarch64-linux-gnu/libc.so.6+0x242a0) #19 0xaaaabb13ea00 (/home/raster/C/git/efl/build/src/bin/edje/edje_cc+0x38a00) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV ../src/lib/eet/eet_utils.c:25 in _eet_hash_gen ==8991==ABORTING Aborted (core dumped) When compiling breaks... it's certainly time to revert ASAP :(
2019-11-07 02:23:58 -08:00
{
evas_textblock: content fit feature Summary: **Content Fit Feature for Evas_Object_Textblock** This Feature is available at **Evas **object level. And **Edje **level (where it is internally use evas functionality) This feature will allow text block to fit its content font size to proper size to fit its area. **Main Properties:** Fit Modes : None=Default, Width, Height, All [Width+Height] Fit Size Range : Contains maximum and minimum font size to be used (and in between). Fit Step Size : Step(Jump) value when trying fonts sizes between Size_Range max and min. Fit Size Array : Other way to resize font, where you explicitly select font sizes to be uses (for example [20, 50, 100] it will try 3 sizes only) Text Fit feature was available in Edje but: 1- It doesn't effected by ellipsis or warping in font style (or do not handle the in right way) 2- Accuracy is not good (specially if you have fix pixel size elements (spaces,tabs,items)) 3- No (Step size, Size Array) available. Test Plan: To check the Feature > elementary_test > fit > textbock fit You can modify all the modes and properties These are two examples, One using Evas other uses Edje **Evas** ``` #include <Elementary.h> enum BUTTON{ BUTTON_MODE = 0, BUTTON_MAX = 1, BUTTON_MIN = 2, BUTTON_STEP = 3, BUTTON_ARRAY = 4, BUTTON_CONTENT = 5, BUTTON_STYLE = 6, BUTTON_ALL = BUTTON_STYLE+1, }; char* BUTTON_STR[BUTTON_ALL] ={ "MODE", "MAX", "MIN", "STEP", "ARRAY", "CONTENT", "STYLE", }; char *contents[] = { "Hello World", "This is Line<br>THis is other Line", "This text contains <font_size=20 color=#F00>SPECIFIC SIZE</font_size> that does not effected by fit mode" }; char *styles[] = { "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed'", "DEFAULT='font=sans font_size=30 color=#000 ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000'", }; char *styles_names[] = { "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>NONE</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>NONE</color>", }; typedef struct _APP { Evas_Object *win, *box, *txtblock,*bg, *boxHor, *boxHor2; Eo *btn[BUTTON_ALL]; Eo *lbl_status; char * str; unsigned int i_contnet, i_style; } APP; APP *app; char * get_fit_status(Eo * textblock); static void _btn_clicked(void *data EINA_UNUSED, Eo *obj, void *eventInfo EINA_UNUSED){ if (obj == app->btn[BUTTON_MODE]) { unsigned int options; evas_textblock_fit_options_get(app->txtblock, &options); if (options == TEXTBLOCK_FIT_MODE_NONE) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_HEIGHT); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_WIDTH); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_ALL); else if (options == TEXTBLOCK_FIT_MODE_ALL) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_NONE); } else if (obj == app->btn[BUTTON_MAX]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); max -= 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_MIN]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); min += 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_STEP]) { unsigned int step; evas_textblock_fit_step_size_get(app->txtblock, &step); step++; evas_textblock_fit_step_size_set(app->txtblock, step); } else if (obj == app->btn[BUTTON_ARRAY]) { unsigned int font_size[] = {10, 50, 100 ,150}; evas_textblock_fit_size_array_set(app->txtblock,font_size,4); } else if (obj == app->btn[BUTTON_CONTENT]) { app->i_contnet++; if(app->i_contnet>=sizeof(contents)/sizeof(char*)) app->i_contnet=0; evas_object_textblock_text_markup_set(app->txtblock,contents[app->i_contnet]); } else if (obj == app->btn[BUTTON_STYLE]) { app->i_style++; if(app->i_style>=sizeof(styles)/sizeof(char*)) app->i_style=0; Evas_Textblock_Style *style = evas_object_textblock_style_get(app->txtblock); evas_textblock_style_set(style,styles[app->i_style]); } elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); } char * get_fit_status(Eo * textblock) { static char status[0xFFF]; unsigned int options,min,max,step,size_array[256]; size_t size_array_len; evas_textblock_fit_options_get(textblock,&options); evas_textblock_fit_size_range_get(textblock,&min,&max); evas_textblock_fit_step_size_get(textblock,&step); evas_textblock_fit_size_array_get(textblock,NULL,&size_array_len,0); if (size_array_len>255) size_array_len = 255; evas_textblock_fit_size_array_get(textblock,size_array,NULL,size_array_len); strcpy(status,"Mode : "); if (options == TEXTBLOCK_FIT_MODE_NONE) strcat(status,"MODE_NONE"); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) strcat(status,"MODE_HEIGHT"); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) strcat(status,"MODE_WIDTH"); else if (options == TEXTBLOCK_FIT_MODE_ALL) strcat(status,"MODE_ALL"); strcat(status,"<br>"); sprintf(status + strlen(status),"Max : %d<br>",max); sprintf(status + strlen(status),"Min : %d<br>",min); sprintf(status + strlen(status),"Step : %d<br>",step); sprintf(status + strlen(status),"Array : [ "); for (size_t i = 0 ; i < 10 ; i++) { if(i<size_array_len) sprintf(status + strlen(status)," %d,",size_array[i]); } if(10<size_array_len) sprintf(status + strlen(status)," ... "); sprintf(status + strlen(status)," ]"); sprintf(status + strlen(status),"<br>"); sprintf(status + strlen(status),"%s",styles_names[app->i_style]); return status; } int elm_main(int argc, char **argv) { app = calloc(sizeof(APP), 1); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); app->win = elm_win_util_standard_add("Main", "App"); elm_win_autodel_set(app->win, EINA_TRUE); app->box = elm_box_add(app->win); app->boxHor = elm_box_add(app->box); app->boxHor2 = elm_box_add(app->box); app->txtblock = evas_object_textblock_add(app->box); app->bg = elm_bg_add(app->box); elm_bg_color_set(app->bg,255,255,255); Evas_Textblock_Style *style = evas_textblock_style_new(); evas_textblock_style_set(style,styles[0]); evas_object_textblock_style_set(app->txtblock,style); evas_object_textblock_text_markup_set(app->txtblock,contents[0]); elm_box_horizontal_set(app->boxHor, EINA_TRUE); elm_box_horizontal_set(app->boxHor2, EINA_TRUE); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->txtblock); evas_object_show(app->bg); evas_object_show(app->box); evas_object_show(app->boxHor); evas_object_show(app->boxHor2); elm_box_pack_end(app->box, app->bg); elm_box_pack_end(app->box, app->boxHor); elm_box_pack_end(app->box, app->boxHor2); elm_object_content_set(app->bg,app->txtblock); elm_win_resize_object_add(app->win, app->box); evas_object_resize(app->win, 320, 480); for(int i = 0 ; i < BUTTON_ALL ; i++) { app->btn[i] = elm_button_add(app->boxHor); evas_object_smart_callback_add(app->btn[i], "clicked", _btn_clicked, NULL); elm_object_text_set(app->btn[i], BUTTON_STR[i]); elm_box_pack_end(app->boxHor, app->btn[i]); evas_object_show(app->btn[i]); } app->lbl_status = elm_label_add(app->boxHor2); elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); elm_box_pack_end(app->boxHor2, app->lbl_status); evas_object_show(app->lbl_status); evas_object_size_hint_weight_set(app->txtblock, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->txtblock, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->bg, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->bg, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->win); elm_run(); return 0; } ELM_MAIN() ``` **Edje** ``` // compile: edje_cc source.edc // run: edje_player source.edje collections { styles { style { name: "text_style"; base: "font=sans font_size=30 color=#FFF wrap=mixed ellipsis=1.0"; tag: "br" "\n"; tag: "ps" "ps"; tag: "tab" "\t"; tag: "b" "+ font_weight=Bold"; } } group { name: "my_group"; // must be the same as in source.c parts { part { name: "background"; type: RECT; scale: 1; description { color: 0 0 0 0; rel1.relative: 0.0 0.0; rel2.relative: 1.0 1.0; } } part { name: "text"; type: TEXTBLOCK; scale: 1; entry_mode: NONE; effect: OUTLINE_SHADOW; description { state: "default" 0.0; rel1.to : "background"; rel1.relative: 0.0 0.0; rel2.to : "background"; rel2.relative: 1.0 1.0; text { style: "text_style"; align: 0.0 0.0; text: "Hello World This is Me"; fit: 1 1; fit_step: 1; size_range: 30 200; //fit_size_array: 20 40 60 80 100 200; } } } } } } ``` Found Task T5724 relative to this Feature Reviewers: woohyun, bowonryu, cedric, raster Reviewed By: woohyun Subscribers: a.srour, #committers, #reviewers, cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D9280
2019-12-11 21:22:45 -08:00
size_array[size_array_len++] = *value;
Revert "evas_textblock: content fit feature" This reverts commit 2f676a6591c117e15d65f263ebd267866963b627. This causes segv's in edje_cc - i suspect the eet changes (or in combo to how they are used in edje): AddressSanitizer:DEADLYSIGNAL ================================================================= ==8991==ERROR: AddressSanitizer: SEGV on unknown address 0x000001010000 (pc 0xffff9f002604 bp 0xfffffa747700 sp 0xfffffa747700 T0) ==8991==The signal is caused by a READ memory access. #0 0xffff9f002600 in _eet_hash_gen ../src/lib/eet/eet_utils.c:25 #1 0xffff9efdd024 in eet_dictionary_string_add ../src/lib/eet/eet_dictionary.c:103 #2 0xffff9efbe324 in eet_data_put_string ../src/lib/eet/eet_data.c:849 #3 0xffff9efc1c4c in eet_data_put_type ../src/lib/eet/eet_data.c:1427 #4 0xffff9efd9128 in eet_data_put_unknown ../src/lib/eet/eet_data.c:4730 #5 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108 #6 0xffff9efd5958 in eet_data_put_variant ../src/lib/eet/eet_data.c:4309 #7 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108 #8 0xffff9efd9270 in eet_data_put_unknown ../src/lib/eet/eet_data.c:4739 #9 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108 #10 0xffff9efd8ca0 in eet_data_put_array ../src/lib/eet/eet_data.c:4692 #11 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108 #12 0xffff9efc7768 in eet_data_write_cipher ../src/lib/eet/eet_data.c:2403 #13 0xffff9efc78a4 in eet_data_write ../src/lib/eet/eet_data.c:2420 #14 0xaaaabb151dcc in data_thread_group ../src/bin/edje/edje_cc_out.c:2045 #15 0xaaaabb152130 in data_write_groups ../src/bin/edje/edje_cc_out.c:2086 #16 0xaaaabb157734 in data_write ../src/bin/edje/edje_cc_out.c:2866 #17 0xaaaabb14122c in main ../src/bin/edje/edje_cc.c:456 #18 0xffff9dbd92a0 in __libc_start_main (/usr/lib/aarch64-linux-gnu/libc.so.6+0x242a0) #19 0xaaaabb13ea00 (/home/raster/C/git/efl/build/src/bin/edje/edje_cc+0x38a00) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV ../src/lib/eet/eet_utils.c:25 in _eet_hash_gen ==8991==ABORTING Aborted (core dumped) When compiling breaks... it's certainly time to revert ASAP :(
2019-11-07 02:23:58 -08:00
}
unsigned int mode = TEXTBLOCK_FIT_MODE_NONE;
evas_textblock: content fit feature Summary: **Content Fit Feature for Evas_Object_Textblock** This Feature is available at **Evas **object level. And **Edje **level (where it is internally use evas functionality) This feature will allow text block to fit its content font size to proper size to fit its area. **Main Properties:** Fit Modes : None=Default, Width, Height, All [Width+Height] Fit Size Range : Contains maximum and minimum font size to be used (and in between). Fit Step Size : Step(Jump) value when trying fonts sizes between Size_Range max and min. Fit Size Array : Other way to resize font, where you explicitly select font sizes to be uses (for example [20, 50, 100] it will try 3 sizes only) Text Fit feature was available in Edje but: 1- It doesn't effected by ellipsis or warping in font style (or do not handle the in right way) 2- Accuracy is not good (specially if you have fix pixel size elements (spaces,tabs,items)) 3- No (Step size, Size Array) available. Test Plan: To check the Feature > elementary_test > fit > textbock fit You can modify all the modes and properties These are two examples, One using Evas other uses Edje **Evas** ``` #include <Elementary.h> enum BUTTON{ BUTTON_MODE = 0, BUTTON_MAX = 1, BUTTON_MIN = 2, BUTTON_STEP = 3, BUTTON_ARRAY = 4, BUTTON_CONTENT = 5, BUTTON_STYLE = 6, BUTTON_ALL = BUTTON_STYLE+1, }; char* BUTTON_STR[BUTTON_ALL] ={ "MODE", "MAX", "MIN", "STEP", "ARRAY", "CONTENT", "STYLE", }; char *contents[] = { "Hello World", "This is Line<br>THis is other Line", "This text contains <font_size=20 color=#F00>SPECIFIC SIZE</font_size> that does not effected by fit mode" }; char *styles[] = { "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed'", "DEFAULT='font=sans font_size=30 color=#000 ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000'", }; char *styles_names[] = { "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>NONE</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>NONE</color>", }; typedef struct _APP { Evas_Object *win, *box, *txtblock,*bg, *boxHor, *boxHor2; Eo *btn[BUTTON_ALL]; Eo *lbl_status; char * str; unsigned int i_contnet, i_style; } APP; APP *app; char * get_fit_status(Eo * textblock); static void _btn_clicked(void *data EINA_UNUSED, Eo *obj, void *eventInfo EINA_UNUSED){ if (obj == app->btn[BUTTON_MODE]) { unsigned int options; evas_textblock_fit_options_get(app->txtblock, &options); if (options == TEXTBLOCK_FIT_MODE_NONE) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_HEIGHT); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_WIDTH); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_ALL); else if (options == TEXTBLOCK_FIT_MODE_ALL) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_NONE); } else if (obj == app->btn[BUTTON_MAX]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); max -= 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_MIN]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); min += 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_STEP]) { unsigned int step; evas_textblock_fit_step_size_get(app->txtblock, &step); step++; evas_textblock_fit_step_size_set(app->txtblock, step); } else if (obj == app->btn[BUTTON_ARRAY]) { unsigned int font_size[] = {10, 50, 100 ,150}; evas_textblock_fit_size_array_set(app->txtblock,font_size,4); } else if (obj == app->btn[BUTTON_CONTENT]) { app->i_contnet++; if(app->i_contnet>=sizeof(contents)/sizeof(char*)) app->i_contnet=0; evas_object_textblock_text_markup_set(app->txtblock,contents[app->i_contnet]); } else if (obj == app->btn[BUTTON_STYLE]) { app->i_style++; if(app->i_style>=sizeof(styles)/sizeof(char*)) app->i_style=0; Evas_Textblock_Style *style = evas_object_textblock_style_get(app->txtblock); evas_textblock_style_set(style,styles[app->i_style]); } elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); } char * get_fit_status(Eo * textblock) { static char status[0xFFF]; unsigned int options,min,max,step,size_array[256]; size_t size_array_len; evas_textblock_fit_options_get(textblock,&options); evas_textblock_fit_size_range_get(textblock,&min,&max); evas_textblock_fit_step_size_get(textblock,&step); evas_textblock_fit_size_array_get(textblock,NULL,&size_array_len,0); if (size_array_len>255) size_array_len = 255; evas_textblock_fit_size_array_get(textblock,size_array,NULL,size_array_len); strcpy(status,"Mode : "); if (options == TEXTBLOCK_FIT_MODE_NONE) strcat(status,"MODE_NONE"); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) strcat(status,"MODE_HEIGHT"); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) strcat(status,"MODE_WIDTH"); else if (options == TEXTBLOCK_FIT_MODE_ALL) strcat(status,"MODE_ALL"); strcat(status,"<br>"); sprintf(status + strlen(status),"Max : %d<br>",max); sprintf(status + strlen(status),"Min : %d<br>",min); sprintf(status + strlen(status),"Step : %d<br>",step); sprintf(status + strlen(status),"Array : [ "); for (size_t i = 0 ; i < 10 ; i++) { if(i<size_array_len) sprintf(status + strlen(status)," %d,",size_array[i]); } if(10<size_array_len) sprintf(status + strlen(status)," ... "); sprintf(status + strlen(status)," ]"); sprintf(status + strlen(status),"<br>"); sprintf(status + strlen(status),"%s",styles_names[app->i_style]); return status; } int elm_main(int argc, char **argv) { app = calloc(sizeof(APP), 1); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); app->win = elm_win_util_standard_add("Main", "App"); elm_win_autodel_set(app->win, EINA_TRUE); app->box = elm_box_add(app->win); app->boxHor = elm_box_add(app->box); app->boxHor2 = elm_box_add(app->box); app->txtblock = evas_object_textblock_add(app->box); app->bg = elm_bg_add(app->box); elm_bg_color_set(app->bg,255,255,255); Evas_Textblock_Style *style = evas_textblock_style_new(); evas_textblock_style_set(style,styles[0]); evas_object_textblock_style_set(app->txtblock,style); evas_object_textblock_text_markup_set(app->txtblock,contents[0]); elm_box_horizontal_set(app->boxHor, EINA_TRUE); elm_box_horizontal_set(app->boxHor2, EINA_TRUE); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->txtblock); evas_object_show(app->bg); evas_object_show(app->box); evas_object_show(app->boxHor); evas_object_show(app->boxHor2); elm_box_pack_end(app->box, app->bg); elm_box_pack_end(app->box, app->boxHor); elm_box_pack_end(app->box, app->boxHor2); elm_object_content_set(app->bg,app->txtblock); elm_win_resize_object_add(app->win, app->box); evas_object_resize(app->win, 320, 480); for(int i = 0 ; i < BUTTON_ALL ; i++) { app->btn[i] = elm_button_add(app->boxHor); evas_object_smart_callback_add(app->btn[i], "clicked", _btn_clicked, NULL); elm_object_text_set(app->btn[i], BUTTON_STR[i]); elm_box_pack_end(app->boxHor, app->btn[i]); evas_object_show(app->btn[i]); } app->lbl_status = elm_label_add(app->boxHor2); elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); elm_box_pack_end(app->boxHor2, app->lbl_status); evas_object_show(app->lbl_status); evas_object_size_hint_weight_set(app->txtblock, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->txtblock, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->bg, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->bg, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->win); elm_run(); return 0; } ELM_MAIN() ``` **Edje** ``` // compile: edje_cc source.edc // run: edje_player source.edje collections { styles { style { name: "text_style"; base: "font=sans font_size=30 color=#FFF wrap=mixed ellipsis=1.0"; tag: "br" "\n"; tag: "ps" "ps"; tag: "tab" "\t"; tag: "b" "+ font_weight=Bold"; } } group { name: "my_group"; // must be the same as in source.c parts { part { name: "background"; type: RECT; scale: 1; description { color: 0 0 0 0; rel1.relative: 0.0 0.0; rel2.relative: 1.0 1.0; } } part { name: "text"; type: TEXTBLOCK; scale: 1; entry_mode: NONE; effect: OUTLINE_SHADOW; description { state: "default" 0.0; rel1.to : "background"; rel1.relative: 0.0 0.0; rel2.to : "background"; rel2.relative: 1.0 1.0; text { style: "text_style"; align: 0.0 0.0; text: "Hello World This is Me"; fit: 1 1; fit_step: 1; size_range: 30 200; //fit_size_array: 20 40 60 80 100 200; } } } } } } ``` Found Task T5724 relative to this Feature Reviewers: woohyun, bowonryu, cedric, raster Reviewed By: woohyun Subscribers: a.srour, #committers, #reviewers, cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D9280
2019-12-11 21:22:45 -08:00
if (chosen_desc->text.fit_x)
mode |= TEXTBLOCK_FIT_MODE_WIDTH;
if (chosen_desc->text.fit_y)
evas_textblock: content fit feature Summary: **Content Fit Feature for Evas_Object_Textblock** This Feature is available at **Evas **object level. And **Edje **level (where it is internally use evas functionality) This feature will allow text block to fit its content font size to proper size to fit its area. **Main Properties:** Fit Modes : None=Default, Width, Height, All [Width+Height] Fit Size Range : Contains maximum and minimum font size to be used (and in between). Fit Step Size : Step(Jump) value when trying fonts sizes between Size_Range max and min. Fit Size Array : Other way to resize font, where you explicitly select font sizes to be uses (for example [20, 50, 100] it will try 3 sizes only) Text Fit feature was available in Edje but: 1- It doesn't effected by ellipsis or warping in font style (or do not handle the in right way) 2- Accuracy is not good (specially if you have fix pixel size elements (spaces,tabs,items)) 3- No (Step size, Size Array) available. Test Plan: To check the Feature > elementary_test > fit > textbock fit You can modify all the modes and properties These are two examples, One using Evas other uses Edje **Evas** ``` #include <Elementary.h> enum BUTTON{ BUTTON_MODE = 0, BUTTON_MAX = 1, BUTTON_MIN = 2, BUTTON_STEP = 3, BUTTON_ARRAY = 4, BUTTON_CONTENT = 5, BUTTON_STYLE = 6, BUTTON_ALL = BUTTON_STYLE+1, }; char* BUTTON_STR[BUTTON_ALL] ={ "MODE", "MAX", "MIN", "STEP", "ARRAY", "CONTENT", "STYLE", }; char *contents[] = { "Hello World", "This is Line<br>THis is other Line", "This text contains <font_size=20 color=#F00>SPECIFIC SIZE</font_size> that does not effected by fit mode" }; char *styles[] = { "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed'", "DEFAULT='font=sans font_size=30 color=#000 ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000'", }; char *styles_names[] = { "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>NONE</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>NONE</color>", }; typedef struct _APP { Evas_Object *win, *box, *txtblock,*bg, *boxHor, *boxHor2; Eo *btn[BUTTON_ALL]; Eo *lbl_status; char * str; unsigned int i_contnet, i_style; } APP; APP *app; char * get_fit_status(Eo * textblock); static void _btn_clicked(void *data EINA_UNUSED, Eo *obj, void *eventInfo EINA_UNUSED){ if (obj == app->btn[BUTTON_MODE]) { unsigned int options; evas_textblock_fit_options_get(app->txtblock, &options); if (options == TEXTBLOCK_FIT_MODE_NONE) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_HEIGHT); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_WIDTH); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_ALL); else if (options == TEXTBLOCK_FIT_MODE_ALL) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_NONE); } else if (obj == app->btn[BUTTON_MAX]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); max -= 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_MIN]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); min += 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_STEP]) { unsigned int step; evas_textblock_fit_step_size_get(app->txtblock, &step); step++; evas_textblock_fit_step_size_set(app->txtblock, step); } else if (obj == app->btn[BUTTON_ARRAY]) { unsigned int font_size[] = {10, 50, 100 ,150}; evas_textblock_fit_size_array_set(app->txtblock,font_size,4); } else if (obj == app->btn[BUTTON_CONTENT]) { app->i_contnet++; if(app->i_contnet>=sizeof(contents)/sizeof(char*)) app->i_contnet=0; evas_object_textblock_text_markup_set(app->txtblock,contents[app->i_contnet]); } else if (obj == app->btn[BUTTON_STYLE]) { app->i_style++; if(app->i_style>=sizeof(styles)/sizeof(char*)) app->i_style=0; Evas_Textblock_Style *style = evas_object_textblock_style_get(app->txtblock); evas_textblock_style_set(style,styles[app->i_style]); } elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); } char * get_fit_status(Eo * textblock) { static char status[0xFFF]; unsigned int options,min,max,step,size_array[256]; size_t size_array_len; evas_textblock_fit_options_get(textblock,&options); evas_textblock_fit_size_range_get(textblock,&min,&max); evas_textblock_fit_step_size_get(textblock,&step); evas_textblock_fit_size_array_get(textblock,NULL,&size_array_len,0); if (size_array_len>255) size_array_len = 255; evas_textblock_fit_size_array_get(textblock,size_array,NULL,size_array_len); strcpy(status,"Mode : "); if (options == TEXTBLOCK_FIT_MODE_NONE) strcat(status,"MODE_NONE"); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) strcat(status,"MODE_HEIGHT"); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) strcat(status,"MODE_WIDTH"); else if (options == TEXTBLOCK_FIT_MODE_ALL) strcat(status,"MODE_ALL"); strcat(status,"<br>"); sprintf(status + strlen(status),"Max : %d<br>",max); sprintf(status + strlen(status),"Min : %d<br>",min); sprintf(status + strlen(status),"Step : %d<br>",step); sprintf(status + strlen(status),"Array : [ "); for (size_t i = 0 ; i < 10 ; i++) { if(i<size_array_len) sprintf(status + strlen(status)," %d,",size_array[i]); } if(10<size_array_len) sprintf(status + strlen(status)," ... "); sprintf(status + strlen(status)," ]"); sprintf(status + strlen(status),"<br>"); sprintf(status + strlen(status),"%s",styles_names[app->i_style]); return status; } int elm_main(int argc, char **argv) { app = calloc(sizeof(APP), 1); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); app->win = elm_win_util_standard_add("Main", "App"); elm_win_autodel_set(app->win, EINA_TRUE); app->box = elm_box_add(app->win); app->boxHor = elm_box_add(app->box); app->boxHor2 = elm_box_add(app->box); app->txtblock = evas_object_textblock_add(app->box); app->bg = elm_bg_add(app->box); elm_bg_color_set(app->bg,255,255,255); Evas_Textblock_Style *style = evas_textblock_style_new(); evas_textblock_style_set(style,styles[0]); evas_object_textblock_style_set(app->txtblock,style); evas_object_textblock_text_markup_set(app->txtblock,contents[0]); elm_box_horizontal_set(app->boxHor, EINA_TRUE); elm_box_horizontal_set(app->boxHor2, EINA_TRUE); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->txtblock); evas_object_show(app->bg); evas_object_show(app->box); evas_object_show(app->boxHor); evas_object_show(app->boxHor2); elm_box_pack_end(app->box, app->bg); elm_box_pack_end(app->box, app->boxHor); elm_box_pack_end(app->box, app->boxHor2); elm_object_content_set(app->bg,app->txtblock); elm_win_resize_object_add(app->win, app->box); evas_object_resize(app->win, 320, 480); for(int i = 0 ; i < BUTTON_ALL ; i++) { app->btn[i] = elm_button_add(app->boxHor); evas_object_smart_callback_add(app->btn[i], "clicked", _btn_clicked, NULL); elm_object_text_set(app->btn[i], BUTTON_STR[i]); elm_box_pack_end(app->boxHor, app->btn[i]); evas_object_show(app->btn[i]); } app->lbl_status = elm_label_add(app->boxHor2); elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); elm_box_pack_end(app->boxHor2, app->lbl_status); evas_object_show(app->lbl_status); evas_object_size_hint_weight_set(app->txtblock, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->txtblock, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->bg, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->bg, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->win); elm_run(); return 0; } ELM_MAIN() ``` **Edje** ``` // compile: edje_cc source.edc // run: edje_player source.edje collections { styles { style { name: "text_style"; base: "font=sans font_size=30 color=#FFF wrap=mixed ellipsis=1.0"; tag: "br" "\n"; tag: "ps" "ps"; tag: "tab" "\t"; tag: "b" "+ font_weight=Bold"; } } group { name: "my_group"; // must be the same as in source.c parts { part { name: "background"; type: RECT; scale: 1; description { color: 0 0 0 0; rel1.relative: 0.0 0.0; rel2.relative: 1.0 1.0; } } part { name: "text"; type: TEXTBLOCK; scale: 1; entry_mode: NONE; effect: OUTLINE_SHADOW; description { state: "default" 0.0; rel1.to : "background"; rel1.relative: 0.0 0.0; rel2.to : "background"; rel2.relative: 1.0 1.0; text { style: "text_style"; align: 0.0 0.0; text: "Hello World This is Me"; fit: 1 1; fit_step: 1; size_range: 30 200; //fit_size_array: 20 40 60 80 100 200; } } } } } } ``` Found Task T5724 relative to this Feature Reviewers: woohyun, bowonryu, cedric, raster Reviewed By: woohyun Subscribers: a.srour, #committers, #reviewers, cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D9280
2019-12-11 21:22:45 -08:00
mode |= TEXTBLOCK_FIT_MODE_HEIGHT;
evas_textblock_fit_options_set(ep->object, mode);
evas_textblock_fit_step_size_set(ep->object, chosen_desc->text.fit_step);
if (size_array_len > 0)
{
evas_textblock: content fit feature Summary: **Content Fit Feature for Evas_Object_Textblock** This Feature is available at **Evas **object level. And **Edje **level (where it is internally use evas functionality) This feature will allow text block to fit its content font size to proper size to fit its area. **Main Properties:** Fit Modes : None=Default, Width, Height, All [Width+Height] Fit Size Range : Contains maximum and minimum font size to be used (and in between). Fit Step Size : Step(Jump) value when trying fonts sizes between Size_Range max and min. Fit Size Array : Other way to resize font, where you explicitly select font sizes to be uses (for example [20, 50, 100] it will try 3 sizes only) Text Fit feature was available in Edje but: 1- It doesn't effected by ellipsis or warping in font style (or do not handle the in right way) 2- Accuracy is not good (specially if you have fix pixel size elements (spaces,tabs,items)) 3- No (Step size, Size Array) available. Test Plan: To check the Feature > elementary_test > fit > textbock fit You can modify all the modes and properties These are two examples, One using Evas other uses Edje **Evas** ``` #include <Elementary.h> enum BUTTON{ BUTTON_MODE = 0, BUTTON_MAX = 1, BUTTON_MIN = 2, BUTTON_STEP = 3, BUTTON_ARRAY = 4, BUTTON_CONTENT = 5, BUTTON_STYLE = 6, BUTTON_ALL = BUTTON_STYLE+1, }; char* BUTTON_STR[BUTTON_ALL] ={ "MODE", "MAX", "MIN", "STEP", "ARRAY", "CONTENT", "STYLE", }; char *contents[] = { "Hello World", "This is Line<br>THis is other Line", "This text contains <font_size=20 color=#F00>SPECIFIC SIZE</font_size> that does not effected by fit mode" }; char *styles[] = { "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed'", "DEFAULT='font=sans font_size=30 color=#000 ellipsis=1.0'", "DEFAULT='font=sans font_size=30 color=#000'", }; char *styles_names[] = { "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>NONE</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>1.0</color>", "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>NONE</color>", }; typedef struct _APP { Evas_Object *win, *box, *txtblock,*bg, *boxHor, *boxHor2; Eo *btn[BUTTON_ALL]; Eo *lbl_status; char * str; unsigned int i_contnet, i_style; } APP; APP *app; char * get_fit_status(Eo * textblock); static void _btn_clicked(void *data EINA_UNUSED, Eo *obj, void *eventInfo EINA_UNUSED){ if (obj == app->btn[BUTTON_MODE]) { unsigned int options; evas_textblock_fit_options_get(app->txtblock, &options); if (options == TEXTBLOCK_FIT_MODE_NONE) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_HEIGHT); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_WIDTH); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_ALL); else if (options == TEXTBLOCK_FIT_MODE_ALL) evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_NONE); } else if (obj == app->btn[BUTTON_MAX]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); max -= 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_MIN]) { unsigned int min, max; evas_textblock_fit_size_range_get(app->txtblock, &min, &max); min += 5; evas_textblock_fit_size_range_set(app->txtblock, min, max); } else if (obj == app->btn[BUTTON_STEP]) { unsigned int step; evas_textblock_fit_step_size_get(app->txtblock, &step); step++; evas_textblock_fit_step_size_set(app->txtblock, step); } else if (obj == app->btn[BUTTON_ARRAY]) { unsigned int font_size[] = {10, 50, 100 ,150}; evas_textblock_fit_size_array_set(app->txtblock,font_size,4); } else if (obj == app->btn[BUTTON_CONTENT]) { app->i_contnet++; if(app->i_contnet>=sizeof(contents)/sizeof(char*)) app->i_contnet=0; evas_object_textblock_text_markup_set(app->txtblock,contents[app->i_contnet]); } else if (obj == app->btn[BUTTON_STYLE]) { app->i_style++; if(app->i_style>=sizeof(styles)/sizeof(char*)) app->i_style=0; Evas_Textblock_Style *style = evas_object_textblock_style_get(app->txtblock); evas_textblock_style_set(style,styles[app->i_style]); } elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); } char * get_fit_status(Eo * textblock) { static char status[0xFFF]; unsigned int options,min,max,step,size_array[256]; size_t size_array_len; evas_textblock_fit_options_get(textblock,&options); evas_textblock_fit_size_range_get(textblock,&min,&max); evas_textblock_fit_step_size_get(textblock,&step); evas_textblock_fit_size_array_get(textblock,NULL,&size_array_len,0); if (size_array_len>255) size_array_len = 255; evas_textblock_fit_size_array_get(textblock,size_array,NULL,size_array_len); strcpy(status,"Mode : "); if (options == TEXTBLOCK_FIT_MODE_NONE) strcat(status,"MODE_NONE"); else if (options == TEXTBLOCK_FIT_MODE_HEIGHT) strcat(status,"MODE_HEIGHT"); else if (options == TEXTBLOCK_FIT_MODE_WIDTH) strcat(status,"MODE_WIDTH"); else if (options == TEXTBLOCK_FIT_MODE_ALL) strcat(status,"MODE_ALL"); strcat(status,"<br>"); sprintf(status + strlen(status),"Max : %d<br>",max); sprintf(status + strlen(status),"Min : %d<br>",min); sprintf(status + strlen(status),"Step : %d<br>",step); sprintf(status + strlen(status),"Array : [ "); for (size_t i = 0 ; i < 10 ; i++) { if(i<size_array_len) sprintf(status + strlen(status)," %d,",size_array[i]); } if(10<size_array_len) sprintf(status + strlen(status)," ... "); sprintf(status + strlen(status)," ]"); sprintf(status + strlen(status),"<br>"); sprintf(status + strlen(status),"%s",styles_names[app->i_style]); return status; } int elm_main(int argc, char **argv) { app = calloc(sizeof(APP), 1); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); app->win = elm_win_util_standard_add("Main", "App"); elm_win_autodel_set(app->win, EINA_TRUE); app->box = elm_box_add(app->win); app->boxHor = elm_box_add(app->box); app->boxHor2 = elm_box_add(app->box); app->txtblock = evas_object_textblock_add(app->box); app->bg = elm_bg_add(app->box); elm_bg_color_set(app->bg,255,255,255); Evas_Textblock_Style *style = evas_textblock_style_new(); evas_textblock_style_set(style,styles[0]); evas_object_textblock_style_set(app->txtblock,style); evas_object_textblock_text_markup_set(app->txtblock,contents[0]); elm_box_horizontal_set(app->boxHor, EINA_TRUE); elm_box_horizontal_set(app->boxHor2, EINA_TRUE); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->txtblock); evas_object_show(app->bg); evas_object_show(app->box); evas_object_show(app->boxHor); evas_object_show(app->boxHor2); elm_box_pack_end(app->box, app->bg); elm_box_pack_end(app->box, app->boxHor); elm_box_pack_end(app->box, app->boxHor2); elm_object_content_set(app->bg,app->txtblock); elm_win_resize_object_add(app->win, app->box); evas_object_resize(app->win, 320, 480); for(int i = 0 ; i < BUTTON_ALL ; i++) { app->btn[i] = elm_button_add(app->boxHor); evas_object_smart_callback_add(app->btn[i], "clicked", _btn_clicked, NULL); elm_object_text_set(app->btn[i], BUTTON_STR[i]); elm_box_pack_end(app->boxHor, app->btn[i]); evas_object_show(app->btn[i]); } app->lbl_status = elm_label_add(app->boxHor2); elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock)); elm_box_pack_end(app->boxHor2, app->lbl_status); evas_object_show(app->lbl_status); evas_object_size_hint_weight_set(app->txtblock, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->txtblock, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(app->bg, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND); evas_object_size_hint_align_set(app->bg, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(app->win); elm_run(); return 0; } ELM_MAIN() ``` **Edje** ``` // compile: edje_cc source.edc // run: edje_player source.edje collections { styles { style { name: "text_style"; base: "font=sans font_size=30 color=#FFF wrap=mixed ellipsis=1.0"; tag: "br" "\n"; tag: "ps" "ps"; tag: "tab" "\t"; tag: "b" "+ font_weight=Bold"; } } group { name: "my_group"; // must be the same as in source.c parts { part { name: "background"; type: RECT; scale: 1; description { color: 0 0 0 0; rel1.relative: 0.0 0.0; rel2.relative: 1.0 1.0; } } part { name: "text"; type: TEXTBLOCK; scale: 1; entry_mode: NONE; effect: OUTLINE_SHADOW; description { state: "default" 0.0; rel1.to : "background"; rel1.relative: 0.0 0.0; rel2.to : "background"; rel2.relative: 1.0 1.0; text { style: "text_style"; align: 0.0 0.0; text: "Hello World This is Me"; fit: 1 1; fit_step: 1; size_range: 30 200; //fit_size_array: 20 40 60 80 100 200; } } } } } } ``` Found Task T5724 relative to this Feature Reviewers: woohyun, bowonryu, cedric, raster Reviewed By: woohyun Subscribers: a.srour, #committers, #reviewers, cedric Tags: #efl Differential Revision: https://phab.enlightenment.org/D9280
2019-12-11 21:22:45 -08:00
evas_textblock_fit_size_array_set(ep->object,size_array,size_array_len);
}
else if ( chosen_desc->text.size_range_min || chosen_desc->text.size_range_max)
{
evas_textblock_fit_size_range_set(ep->object, chosen_desc->text.size_range_min, chosen_desc->text.size_range_max);
}
}
if ((ed->file->efl_version.major >= 1) && (ed->file->efl_version.minor >= 19))
{
_edje_part_recalc_single_textblock_min_max_calc(ep,
chosen_desc,
params,
minw, minh,
maxw, maxh);
}
else
{
_edje_part_recalc_single_textblock_min_max_calc_legacy(ep,
chosen_desc,
params,
minw, minh,
maxw, maxh);
}
}
evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y));
}
}