forked from enlightenment/efl
add max text size for text objects - object wont get bigger than its text
contents. useful for some things. SVN revision: 26439
This commit is contained in:
parent
e2a72da538
commit
54184c2c37
|
@ -91,6 +91,7 @@ static void st_collections_group_parts_part_description_text_style(void);
|
|||
static void st_collections_group_parts_part_description_text_size(void);
|
||||
static void st_collections_group_parts_part_description_text_fit(void);
|
||||
static void st_collections_group_parts_part_description_text_min(void);
|
||||
static void st_collections_group_parts_part_description_text_max(void);
|
||||
static void st_collections_group_parts_part_description_text_align(void);
|
||||
static void st_collections_group_parts_part_description_text_source(void);
|
||||
static void st_collections_group_parts_part_description_text_text_source(void);
|
||||
|
@ -233,6 +234,7 @@ New_Statement_Handler statement_handlers[] =
|
|||
{"collections.group.parts.part.description.text.size", st_collections_group_parts_part_description_text_size},
|
||||
{"collections.group.parts.part.description.text.fit", st_collections_group_parts_part_description_text_fit},
|
||||
{"collections.group.parts.part.description.text.min", st_collections_group_parts_part_description_text_min},
|
||||
{"collections.group.parts.part.description.text.max", st_collections_group_parts_part_description_text_max},
|
||||
{"collections.group.parts.part.description.text.align", st_collections_group_parts_part_description_text_align},
|
||||
{"collections.group.parts.part.description.text.source", st_collections_group_parts_part_description_text_source},
|
||||
{"collections.group.parts.part.description.text.text_source", st_collections_group_parts_part_description_text_text_source},
|
||||
|
@ -2143,6 +2145,33 @@ st_collections_group_parts_part_description_text_min(void)
|
|||
ed->text.min_y = parse_bool(1);
|
||||
}
|
||||
|
||||
static void
|
||||
st_collections_group_parts_part_description_text_max(void)
|
||||
{
|
||||
Edje_Part_Collection *pc;
|
||||
Edje_Part *ep;
|
||||
Edje_Part_Description *ed;
|
||||
|
||||
check_arg_count(2);
|
||||
|
||||
pc = evas_list_data(evas_list_last(edje_collections));
|
||||
ep = evas_list_data(evas_list_last(pc->parts));
|
||||
|
||||
if ((ep->type != EDJE_PART_TYPE_TEXT) &&
|
||||
(ep->type != EDJE_PART_TYPE_TEXTBLOCK))
|
||||
{
|
||||
fprintf(stderr, "%s: Error. parse error %s:%i. "
|
||||
"text attributes in non-TEXT part.\n",
|
||||
progname, file_in, line - 1);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
ed = ep->default_desc;
|
||||
if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
|
||||
ed->text.max_x = parse_bool(0);
|
||||
ed->text.max_y = parse_bool(1);
|
||||
}
|
||||
|
||||
static void
|
||||
st_collections_group_parts_part_description_text_align(void)
|
||||
{
|
||||
|
|
|
@ -290,6 +290,7 @@ int
|
|||
main(int argc, char **argv)
|
||||
{
|
||||
Evas_Object *o;
|
||||
Evas_Coord mw, mh;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
|
@ -344,6 +345,8 @@ main(int argc, char **argv)
|
|||
evas_object_show(o);
|
||||
o_edje = o;
|
||||
|
||||
// edje_object_size_min_calc(o, &mw, &mh);
|
||||
// evas_object_resize(o_edje, mw, mh);
|
||||
/*
|
||||
{
|
||||
Evas_Coord mw, mh;
|
||||
|
|
|
@ -718,7 +718,8 @@ _edje_part_recalc_single(Edje *ed,
|
|||
}
|
||||
else
|
||||
evas_object_text_font_set(ep->object, font, size);
|
||||
if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
|
||||
if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y) ||
|
||||
(chosen_desc->text.max_x) || (chosen_desc->text.max_y))
|
||||
{
|
||||
int mw, mh;
|
||||
Evas_Text_Style_Type style;
|
||||
|
@ -742,6 +743,20 @@ _edje_part_recalc_single(Edje *ed,
|
|||
evas_object_text_style_set(ep->object, style);
|
||||
evas_object_text_text_set(ep->object, text);
|
||||
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
|
||||
if (chosen_desc->text.max_x)
|
||||
{
|
||||
int l, r;
|
||||
evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
|
||||
mw = tw + l + r;
|
||||
if ((maxw < 0) || (mw < maxw)) maxw = mw;
|
||||
}
|
||||
if (chosen_desc->text.max_y)
|
||||
{
|
||||
int t, b;
|
||||
evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b);
|
||||
mh = th + t + b;
|
||||
if ((maxh < 0) || (mh < maxh)) maxh = mh;
|
||||
}
|
||||
if (chosen_desc->text.min_x)
|
||||
{
|
||||
int l, r;
|
||||
|
|
|
@ -315,6 +315,8 @@ _edje_edd_setup(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.fit_y", text.fit_y, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.min_x", text.min_x, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.min_y", text.min_y, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.max_x", text.max_x, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.max_y", text.max_y, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.align.x", text.align.x, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.align.y", text.align.y, EET_T_DOUBLE);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.id_source", text.id_source, EET_T_INT);
|
||||
|
|
|
@ -1819,6 +1819,16 @@ _edje_embryo_fn_set_state_val(Embryo_Program *ep, Embryo_Cell *params)
|
|||
GETINT(rp->custom.description->text.min_x, params[3]);
|
||||
GETINT(rp->custom.description->text.min_y, params[4]);
|
||||
|
||||
break;
|
||||
case EDJE_STATE_PARAM_TEXT_MAX:
|
||||
if ( (rp->part->type != EDJE_PART_TYPE_TEXT) && \
|
||||
(rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
|
||||
return 0;
|
||||
CHKPARAM(4);
|
||||
|
||||
GETINT(rp->custom.description->text.max_x, params[3]);
|
||||
GETINT(rp->custom.description->text.max_y, params[4]);
|
||||
|
||||
break;
|
||||
case EDJE_STATE_PARAM_TEXT_ALIGN:
|
||||
if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0;
|
||||
|
@ -2087,6 +2097,16 @@ _edje_embryo_fn_get_state_val(Embryo_Program *ep, Embryo_Cell *params)
|
|||
SETINT(rp->custom.description->text.min_x, params[3]);
|
||||
SETINT(rp->custom.description->text.min_y, params[4]);
|
||||
|
||||
break;
|
||||
case EDJE_STATE_PARAM_TEXT_MAX:
|
||||
if ( (rp->part->type != EDJE_PART_TYPE_TEXT) && \
|
||||
(rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
|
||||
return 0;
|
||||
CHKPARAM(4);
|
||||
|
||||
SETINT(rp->custom.description->text.max_x, params[3]);
|
||||
SETINT(rp->custom.description->text.max_y, params[4]);
|
||||
|
||||
break;
|
||||
case EDJE_STATE_PARAM_TEXT_ALIGN:
|
||||
if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0;
|
||||
|
|
|
@ -203,9 +203,10 @@ typedef struct _Edje_Spectrum_Color Edje_Spectrum_Color;
|
|||
#define EDJE_STATE_PARAM_TEXT_SIZE 26
|
||||
#define EDJE_STATE_PARAM_TEXT_FIT 27
|
||||
#define EDJE_STATE_PARAM_TEXT_MIN 28
|
||||
#define EDJE_STATE_PARAM_TEXT_ALIGN 29
|
||||
#define EDJE_STATE_PARAM_VISIBLE 30
|
||||
#define EDJE_STATE_PARAM_LAST 31
|
||||
#define EDJE_STATE_PARAM_TEXT_MAX 29
|
||||
#define EDJE_STATE_PARAM_TEXT_ALIGN 30
|
||||
#define EDJE_STATE_PARAM_VISIBLE 31
|
||||
#define EDJE_STATE_PARAM_LAST 32
|
||||
|
||||
/*----------*/
|
||||
|
||||
|
@ -517,6 +518,8 @@ struct _Edje_Part_Description
|
|||
unsigned char fit_y; /* resize font size down to fit in y dir */
|
||||
unsigned char min_x; /* if text size should be part min size */
|
||||
unsigned char min_y; /* if text size should be part min size */
|
||||
unsigned char max_x; /* if text size should be part max size */
|
||||
unsigned char max_y; /* if text size should be part max size */
|
||||
|
||||
struct {
|
||||
double x, y; /* text alignment within bounds */
|
||||
|
|
|
@ -1105,7 +1105,7 @@ edje_object_size_min_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
|
|||
ed->w += maxw;
|
||||
ed->h += maxh;
|
||||
}
|
||||
if ((ed->w > 8000) || (ed->h > 8000))
|
||||
if ((ed->w > 4000) || (ed->h > 4000))
|
||||
{
|
||||
printf("EDJE ERROR: file %s, group %s has a non-fixed part. add fixed: 1 1; ???\n",
|
||||
ed->path, ed->part);
|
||||
|
|
Loading…
Reference in New Issue