2017-10-15 07:55:20 -07:00
|
|
|
#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;
|
2018-11-06 06:52:53 -08:00
|
|
|
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;
|
|
|
|
}
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
/* Legacy code for Textblock min/max calculation */
|
2018-11-06 06:52:53 -08:00
|
|
|
if (minx2 || miny2)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
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;
|
2018-11-06 06:52:53 -08:00
|
|
|
if (!minx2)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(TO_INT(params->eval.w), TO_INT(params->eval.h)));
|
2019-12-10 00:39:59 -08:00
|
|
|
size = efl_canvas_textblock_size_formatted_get(ep->object);
|
2017-10-15 07:55:20 -07:00
|
|
|
}
|
|
|
|
else
|
2019-12-10 00:39:59 -08:00
|
|
|
size = efl_canvas_textblock_size_native_get(ep->object);
|
2017-10-15 07:55:20 -07:00
|
|
|
evas_object_textblock_style_insets_get(ep->object, &ins_l,
|
2017-11-10 19:10:32 -08:00
|
|
|
&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;
|
2018-11-06 06:52:53 -08:00
|
|
|
if (minw && minx2)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
if (mw > *minw) *minw = mw;
|
|
|
|
}
|
2018-11-06 06:52:53 -08:00
|
|
|
if (minh && miny2)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
if (mh > *minh) *minh = mh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-06 06:52:53 -08:00
|
|
|
if ((maxx2) || (maxy2))
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
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;
|
2018-11-06 06:52:53 -08:00
|
|
|
if (!maxx2)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(TO_INT(params->eval.w), TO_INT(params->eval.h)));
|
2019-12-10 00:39:59 -08:00
|
|
|
size = efl_canvas_textblock_size_formatted_get(ep->object);
|
2017-10-15 07:55:20 -07:00
|
|
|
}
|
|
|
|
else
|
2019-12-10 00:39:59 -08:00
|
|
|
size = efl_canvas_textblock_size_native_get(ep->object);
|
2017-11-10 19:10:32 -08:00
|
|
|
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;
|
2018-11-06 06:52:53 -08:00
|
|
|
if (maxw && maxx2)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
if (mw > *maxw) *maxw = mw;
|
|
|
|
if (minw && (*maxw < *minw)) *maxw = *minw;
|
|
|
|
}
|
2018-11-06 06:52:53 -08:00
|
|
|
if (maxh && maxy2)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
|
|
|
|
Evas_Coord min_calc_w = 0, min_calc_h = 0;
|
|
|
|
|
2018-11-06 06:52:53 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-10-15 07:55:20 -07:00
|
|
|
/* 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;
|
|
|
|
|
2018-11-06 06:52:53 -08:00
|
|
|
if (dminx || dminy)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
evas_object_textblock_style_insets_get(ep->object, &ins_l,
|
2017-11-10 19:10:32 -08:00
|
|
|
&ins_r, &ins_t, &ins_b);
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
tw = th = 0;
|
2018-11-06 06:52:53 -08:00
|
|
|
if (!dminx)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
/* 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;
|
2018-11-06 06:52:53 -08:00
|
|
|
if ((!dmaxx) &&
|
2017-10-15 07:55:20 -07:00
|
|
|
maxw && (*maxw > -1) && (*maxw < temp_w))
|
|
|
|
temp_w = *maxw;
|
|
|
|
|
2018-11-06 06:52:53 -08:00
|
|
|
if (dmaxy)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
/* 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)
|
|
|
|
{
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(temp_w, temp_h));
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
tw += ins_l + ins_r;
|
|
|
|
th += ins_t + ins_b;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
th += ins_t + ins_b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* text.min: 1 X
|
|
|
|
* text.max: X X */
|
2018-11-06 06:52:53 -08:00
|
|
|
if (dminy && (!dmaxx) &&
|
2017-10-15 07:55:20 -07:00
|
|
|
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;
|
|
|
|
|
2018-11-06 06:52:53 -08:00
|
|
|
if ((!dmaxy) && maxh && (*maxh > -1))
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
/* text.min: 1 1
|
|
|
|
* text.max: 0 0
|
|
|
|
* There is limit for height. */
|
|
|
|
temp_h = *maxh;
|
|
|
|
}
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(temp_w, temp_h));
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
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. */
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
tw += ins_l + ins_r;
|
|
|
|
th += ins_t + ins_b;
|
|
|
|
|
2018-11-06 06:52:53 -08:00
|
|
|
if (!dmaxx &&
|
2017-10-15 07:55:20 -07:00
|
|
|
(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;
|
2018-11-06 06:52:53 -08:00
|
|
|
if (dminx && minw) *minw = min_calc_w;
|
|
|
|
if (dminy && minh) *minh = min_calc_h;
|
2017-10-15 07:55:20 -07:00
|
|
|
}
|
|
|
|
|
2018-11-06 06:52:53 -08:00
|
|
|
if ((dmaxx) || (dmaxy))
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
2017-11-10 19:10:32 -08:00
|
|
|
evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
|
|
|
|
&ins_t, &ins_b);
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
tw = th = 0;
|
2018-11-06 06:52:53 -08:00
|
|
|
if (!dmaxx)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
/* text.min: X X
|
|
|
|
* text.max: 0 1 */
|
|
|
|
int temp_w, temp_h;
|
|
|
|
|
2018-11-06 06:52:53 -08:00
|
|
|
if (dminy)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
/* 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)
|
|
|
|
{
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(temp_w, temp_h));
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
tw += ins_l + ins_r;
|
|
|
|
th += ins_t + ins_b;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
th += ins_t + ins_b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* text.max: 1 X */
|
2018-11-06 06:52:53 -08:00
|
|
|
if (dminx)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
/* text.min: 1 X
|
|
|
|
* text.max: 1 X
|
|
|
|
* Singleline. */
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
tw += ins_l + ins_r;
|
|
|
|
th += ins_t + ins_b;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* text.min: 0 X
|
|
|
|
* text.max: 1 X */
|
2018-11-06 06:52:53 -08:00
|
|
|
if (dmaxy)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
/* 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;
|
|
|
|
|
2018-11-06 06:52:53 -08:00
|
|
|
if (dminy)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
/* 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 */
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(temp_w, temp_h));
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
temp_h = efl_gfx_entity_size_get(ep->object).h;
|
|
|
|
efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(temp_w, temp_h));
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-12-10 00:39:59 -08:00
|
|
|
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;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
|
|
|
th += ins_t + ins_b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-06 06:52:53 -08:00
|
|
|
if (maxw && dmaxx)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
if (tw > *maxw) *maxw = tw;
|
|
|
|
if (minw && (*maxw < *minw)) *maxw = *minw;
|
|
|
|
}
|
2018-11-06 06:52:53 -08:00
|
|
|
if (maxh && dmaxy)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
|
|
|
if (th > *maxh) *maxh = th;
|
|
|
|
if (minh && (*maxh < *minh)) *maxh = *minh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
Eina_Bool
|
|
|
|
_edje_part_textblock_style_text_set(Edje *ed,
|
|
|
|
Edje_Real_Part *ep,
|
|
|
|
Edje_Part_Description_Text *chosen_desc)
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
2019-11-13 21:16:18 -08:00
|
|
|
const char *text = "";
|
|
|
|
const char *style = "";
|
|
|
|
Evas_Textblock_Style *stl = NULL;
|
|
|
|
const char *tmp;
|
2017-10-15 07:55:20 -07:00
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
if (chosen_desc->text.id_source >= 0)
|
2017-10-15 07:57:38 -07:00
|
|
|
{
|
2019-11-13 21:16:18 -08:00
|
|
|
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;
|
2017-11-10 19:10:32 -08:00
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
tmp = edje_string_get(&chosen_desc->text.style);
|
|
|
|
if (tmp) style = tmp;
|
|
|
|
}
|
2017-11-10 19:10:32 -08:00
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
if (chosen_desc->text.id_text_source >= 0)
|
|
|
|
{
|
|
|
|
Edje_Part_Description_Text *et;
|
|
|
|
Edje_Real_Part *rp;
|
2017-11-10 19:10:32 -08:00
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
ep->typedata.text->text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
|
2017-10-15 07:55:20 -07:00
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
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)
|
2017-11-10 19:10:32 -08:00
|
|
|
{
|
2019-11-13 21:16:18 -08:00
|
|
|
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;
|
|
|
|
}
|
2017-10-15 07:55:20 -07:00
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
if (!text) text = edje_string_get(&chosen_desc->text.text);
|
2017-11-10 19:10:32 -08:00
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
if (ep->typedata.text->text) text = ep->typedata.text->text;
|
|
|
|
}
|
2017-10-15 07:55:20 -07:00
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
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
|
2017-11-10 19:10:32 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-13 21:16:18 -08:00
|
|
|
evas_object_textblock_text_markup_set(ep->object, text);
|
2017-11-10 19:10:32 -08:00
|
|
|
}
|
2017-10-15 07:55:20 -07:00
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2020-03-12 04:07:12 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
|
2017-10-15 07:55:20 -07:00
|
|
|
if (ep->part->scale)
|
|
|
|
evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
|
|
|
|
2019-11-13 21:16:18 -08:00
|
|
|
//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))
|
2017-10-15 07:55:20 -07:00
|
|
|
{
|
2018-09-16 14:28:22 -07:00
|
|
|
if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
|
2017-11-10 19:10:32 -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
|
|
|
unsigned int size_array[255];
|
|
|
|
size_t size_array_len = 0;
|
|
|
|
Eina_List *l;
|
|
|
|
unsigned int *value;
|
2020-03-12 04:07:12 -07:00
|
|
|
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;
|
2020-05-06 04:33:42 -07:00
|
|
|
if (s_font_size && s_font_size[10])
|
2020-03-12 04:07:12 -07:00
|
|
|
{
|
2020-05-06 04:33:42 -07:00
|
|
|
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;
|
|
|
|
}
|
2020-03-12 04:07:12 -07: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
|
|
|
EINA_LIST_FOREACH(chosen_desc->text.fit_size_array, l, value)
|
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;
|
2019-11-07 02:23:58 -08:00
|
|
|
}
|
2020-03-12 04:07:12 -07: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;
|
2018-09-16 14:28:22 -07:00
|
|
|
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);
|
2020-05-06 04:30:14 -07:00
|
|
|
if (size_array_len > 0)
|
2018-09-16 14:28:22 -07: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
|
|
|
evas_textblock_fit_size_array_set(ep->object,size_array,size_array_len);
|
2017-11-10 19:10:32 -08:00
|
|
|
}
|
2020-05-06 04:30:14 -07:00
|
|
|
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);
|
|
|
|
}
|
2017-11-10 19:10:32 -08:00
|
|
|
}
|
2017-10-15 07:55:20 -07:00
|
|
|
|
2017-11-10 19:10:32 -08:00
|
|
|
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);
|
|
|
|
}
|
2017-10-15 07:57:38 -07:00
|
|
|
}
|
|
|
|
|
2017-11-10 19:10:32 -08:00
|
|
|
evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y));
|
2017-10-15 07:55:20 -07:00
|
|
|
}
|
|
|
|
}
|