forked from enlightenment/efl
allow individual objects to have differing scaling factors (object scale
overrides edje global scale) SVN revision: 38908
This commit is contained in:
parent
43e8963919
commit
b6f51da478
|
@ -181,6 +181,8 @@ extern "C" {
|
||||||
EAPI const char *edje_fontset_append_get (void);
|
EAPI const char *edje_fontset_append_get (void);
|
||||||
EAPI void edje_scale_set (double scale);
|
EAPI void edje_scale_set (double scale);
|
||||||
EAPI double edje_scale_get (void);
|
EAPI double edje_scale_get (void);
|
||||||
|
EAPI void edje_object_scale_set (Evas_Object *obj, double scale);
|
||||||
|
EAPI double edje_object_scale_get (const Evas_Object *obj);
|
||||||
|
|
||||||
/* edje_load.c */
|
/* edje_load.c */
|
||||||
EAPI Eina_List *edje_file_collection_list (const char *file);
|
EAPI Eina_List *edje_file_collection_list (const char *file);
|
||||||
|
|
|
@ -270,13 +270,16 @@ _edje_part_recalc_single(Edje *ed,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
int minw = 0, minh = 0, maxw = 0, maxh = 0;
|
int minw = 0, minh = 0, maxw = 0, maxh = 0;
|
||||||
|
double sc;
|
||||||
|
|
||||||
flags = FLAG_XY;
|
flags = FLAG_XY;
|
||||||
|
|
||||||
|
sc = ed->scale;
|
||||||
|
if (sc == 0.0) sc = _edje_scale;
|
||||||
// if (flags & FLAG_X)
|
// if (flags & FLAG_X)
|
||||||
{
|
{
|
||||||
minw = desc->min.w;
|
minw = desc->min.w;
|
||||||
if (ep->part->scale) minw = (int)(((double)minw) * _edje_scale);
|
if (ep->part->scale) minw = (int)(((double)minw) * sc);
|
||||||
if (ep->swallow_params.min.w > desc->min.w)
|
if (ep->swallow_params.min.w > desc->min.w)
|
||||||
minw = ep->swallow_params.min.w;
|
minw = ep->swallow_params.min.w;
|
||||||
|
|
||||||
|
@ -287,7 +290,7 @@ _edje_part_recalc_single(Edje *ed,
|
||||||
maxw = desc->max.w;
|
maxw = desc->max.w;
|
||||||
if (maxw > 0)
|
if (maxw > 0)
|
||||||
{
|
{
|
||||||
if (ep->part->scale) maxw = (int)(((double)maxw) * _edje_scale);
|
if (ep->part->scale) maxw = (int)(((double)maxw) * sc);
|
||||||
if (maxw < 1) maxw = 1;
|
if (maxw < 1) maxw = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +303,7 @@ _edje_part_recalc_single(Edje *ed,
|
||||||
maxw = desc->max.w;
|
maxw = desc->max.w;
|
||||||
if (maxw > 0)
|
if (maxw > 0)
|
||||||
{
|
{
|
||||||
if (ep->part->scale) maxw = (int)(((double)maxw) * _edje_scale);
|
if (ep->part->scale) maxw = (int)(((double)maxw) * sc);
|
||||||
if (maxw < 1) maxw = 1;
|
if (maxw < 1) maxw = 1;
|
||||||
}
|
}
|
||||||
if (ep->swallow_params.max.w < maxw)
|
if (ep->swallow_params.max.w < maxw)
|
||||||
|
@ -315,7 +318,7 @@ _edje_part_recalc_single(Edje *ed,
|
||||||
// if (flags & FLAG_Y)
|
// if (flags & FLAG_Y)
|
||||||
{
|
{
|
||||||
minh = desc->min.h;
|
minh = desc->min.h;
|
||||||
if (ep->part->scale) minh = (int)(((double)minh) * _edje_scale);
|
if (ep->part->scale) minh = (int)(((double)minh) * sc);
|
||||||
if (ep->swallow_params.min.h > desc->min.h)
|
if (ep->swallow_params.min.h > desc->min.h)
|
||||||
minh = ep->swallow_params.min.h;
|
minh = ep->swallow_params.min.h;
|
||||||
|
|
||||||
|
@ -326,7 +329,7 @@ _edje_part_recalc_single(Edje *ed,
|
||||||
maxh = desc->max.h;
|
maxh = desc->max.h;
|
||||||
if (maxh > 0)
|
if (maxh > 0)
|
||||||
{
|
{
|
||||||
if (ep->part->scale) maxh = (int)(((double)maxh) * _edje_scale);
|
if (ep->part->scale) maxh = (int)(((double)maxh) * sc);
|
||||||
if (maxh < 1) maxh = 1;
|
if (maxh < 1) maxh = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,7 +342,7 @@ _edje_part_recalc_single(Edje *ed,
|
||||||
maxh = desc->max.h;
|
maxh = desc->max.h;
|
||||||
if (maxh > 0)
|
if (maxh > 0)
|
||||||
{
|
{
|
||||||
if (ep->part->scale) maxh = (int)(((double)maxh) * _edje_scale);
|
if (ep->part->scale) maxh = (int)(((double)maxh) * sc);
|
||||||
if (maxh < 1) maxh = 1;
|
if (maxh < 1) maxh = 1;
|
||||||
}
|
}
|
||||||
if (ep->swallow_params.max.h < maxh)
|
if (ep->swallow_params.max.h < maxh)
|
||||||
|
@ -647,7 +650,7 @@ _edje_part_recalc_single(Edje *ed,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ep->part->scale)
|
if (ep->part->scale)
|
||||||
evas_object_scale_set(ep->object, _edje_scale);
|
evas_object_scale_set(ep->object, sc);
|
||||||
|
|
||||||
if (stl)
|
if (stl)
|
||||||
{
|
{
|
||||||
|
@ -786,7 +789,7 @@ _edje_part_recalc_single(Edje *ed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ep->part->scale)
|
if (ep->part->scale)
|
||||||
evas_object_scale_set(ep->object, _edje_scale);
|
evas_object_scale_set(ep->object, sc);
|
||||||
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
||||||
else evas_object_text_font_source_set(ep->object, NULL);
|
else evas_object_text_font_source_set(ep->object, NULL);
|
||||||
|
|
||||||
|
|
|
@ -684,6 +684,7 @@ struct _Edje
|
||||||
int block;
|
int block;
|
||||||
int load_error;
|
int load_error;
|
||||||
int freeze;
|
int freeze;
|
||||||
|
double scale;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
void (*func) (void *data, Evas_Object *obj, const char *part);
|
void (*func) (void *data, Evas_Object *obj, const char *part);
|
||||||
|
|
|
@ -147,11 +147,15 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
|
||||||
char *buf;
|
char *buf;
|
||||||
int c1 = -1, c2 = -1, loop = 0, extra;
|
int c1 = -1, c2 = -1, loop = 0, extra;
|
||||||
size_t orig_len;
|
size_t orig_len;
|
||||||
|
double sc;
|
||||||
|
|
||||||
|
sc = ed->scale;
|
||||||
|
if (sc == 0.0) sc = _edje_scale;
|
||||||
|
|
||||||
*free_text = 0;
|
*free_text = 0;
|
||||||
if (sw <= 1) return "";
|
if (sw <= 1) return "";
|
||||||
|
|
||||||
if (ep->part->scale) evas_object_scale_set(ep->object, _edje_scale);
|
if (ep->part->scale) evas_object_scale_set(ep->object, sc);
|
||||||
evas_object_text_font_set(ep->object, font, size);
|
evas_object_text_font_set(ep->object, font, size);
|
||||||
evas_object_text_text_set(ep->object, text);
|
evas_object_text_text_set(ep->object, text);
|
||||||
|
|
||||||
|
@ -331,8 +335,10 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||||
Evas_Coord tw, th;
|
Evas_Coord tw, th;
|
||||||
Evas_Coord sw, sh;
|
Evas_Coord sw, sh;
|
||||||
int inlined_font = 0, free_text = 0;
|
int inlined_font = 0, free_text = 0;
|
||||||
|
double sc;
|
||||||
|
|
||||||
|
sc = ed->scale;
|
||||||
|
if (sc == 0.0) sc = _edje_scale;
|
||||||
text = chosen_desc->text.text;
|
text = chosen_desc->text.text;
|
||||||
font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
|
font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
|
||||||
|
|
||||||
|
@ -413,7 +419,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||||
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
||||||
else evas_object_text_font_source_set(ep->object, NULL);
|
else evas_object_text_font_source_set(ep->object, NULL);
|
||||||
|
|
||||||
if (ep->part->scale) evas_object_scale_set(ep->object, _edje_scale);
|
if (ep->part->scale) evas_object_scale_set(ep->object, sc);
|
||||||
evas_object_text_font_set(ep->object, font, size);
|
evas_object_text_font_set(ep->object, font, size);
|
||||||
evas_object_text_text_set(ep->object, text);
|
evas_object_text_text_set(ep->object, text);
|
||||||
part_get_geometry(ep, &tw, &th);
|
part_get_geometry(ep, &tw, &th);
|
||||||
|
@ -430,7 +436,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||||
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
||||||
else evas_object_text_font_source_set(ep->object, NULL);
|
else evas_object_text_font_source_set(ep->object, NULL);
|
||||||
|
|
||||||
if (ep->part->scale) evas_object_scale_set(ep->object, _edje_scale);
|
if (ep->part->scale) evas_object_scale_set(ep->object, sc);
|
||||||
evas_object_text_font_set(ep->object, font, size);
|
evas_object_text_font_set(ep->object, font, size);
|
||||||
part_get_geometry(ep, &tw, &th);
|
part_get_geometry(ep, &tw, &th);
|
||||||
if ((size > 0) && (tw == 0)) break;
|
if ((size > 0) && (tw == 0)) break;
|
||||||
|
@ -449,7 +455,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||||
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
||||||
else evas_object_text_font_source_set(ep->object, NULL);
|
else evas_object_text_font_source_set(ep->object, NULL);
|
||||||
|
|
||||||
if (ep->part->scale) evas_object_scale_set(ep->object, _edje_scale);
|
if (ep->part->scale) evas_object_scale_set(ep->object, sc);
|
||||||
evas_object_text_font_set(ep->object, font, size);
|
evas_object_text_font_set(ep->object, font, size);
|
||||||
part_get_geometry(ep, &tw, &th);
|
part_get_geometry(ep, &tw, &th);
|
||||||
if ((size > 0) && (tw == 0)) break;
|
if ((size > 0) && (tw == 0)) break;
|
||||||
|
@ -467,7 +473,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||||
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
||||||
else evas_object_text_font_source_set(ep->object, NULL);
|
else evas_object_text_font_source_set(ep->object, NULL);
|
||||||
|
|
||||||
if (ep->part->scale) evas_object_scale_set(ep->object, _edje_scale);
|
if (ep->part->scale) evas_object_scale_set(ep->object, sc);
|
||||||
evas_object_text_font_set(ep->object, font, size);
|
evas_object_text_font_set(ep->object, font, size);
|
||||||
evas_object_text_text_set(ep->object, text);
|
evas_object_text_text_set(ep->object, text);
|
||||||
part_get_geometry(ep, &tw, &th);
|
part_get_geometry(ep, &tw, &th);
|
||||||
|
@ -488,7 +494,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||||
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
||||||
else evas_object_text_font_source_set(ep->object, NULL);
|
else evas_object_text_font_source_set(ep->object, NULL);
|
||||||
|
|
||||||
if (ep->part->scale) evas_object_scale_set(ep->object, _edje_scale);
|
if (ep->part->scale) evas_object_scale_set(ep->object, sc);
|
||||||
evas_object_text_font_set(ep->object, font, size);
|
evas_object_text_font_set(ep->object, font, size);
|
||||||
part_get_geometry(ep, &tw, &th);
|
part_get_geometry(ep, &tw, &th);
|
||||||
if ((size > 0) && (th == 0)) break;
|
if ((size > 0) && (th == 0)) break;
|
||||||
|
@ -499,7 +505,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||||
{
|
{
|
||||||
int current;
|
int current;
|
||||||
|
|
||||||
if (ep->part->scale) evas_object_scale_set(ep->object, _edje_scale);
|
if (ep->part->scale) evas_object_scale_set(ep->object, sc);
|
||||||
evas_object_text_font_set(ep->object, font, 10);
|
evas_object_text_font_set(ep->object, font, 10);
|
||||||
part_get_geometry(ep, &tw, &th);
|
part_get_geometry(ep, &tw, &th);
|
||||||
|
|
||||||
|
@ -524,7 +530,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||||
{
|
{
|
||||||
current = (top + bottom) / 2;
|
current = (top + bottom) / 2;
|
||||||
|
|
||||||
if (ep->part->scale) evas_object_scale_set(ep->object, _edje_scale);
|
if (ep->part->scale) evas_object_scale_set(ep->object, sc);
|
||||||
evas_object_text_font_set(ep->object, font, current);
|
evas_object_text_font_set(ep->object, font, current);
|
||||||
part_get_geometry(ep, &tw, &th);
|
part_get_geometry(ep, &tw, &th);
|
||||||
|
|
||||||
|
@ -538,7 +544,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||||
{
|
{
|
||||||
current++;
|
current++;
|
||||||
|
|
||||||
if (ep->part->scale) evas_object_scale_set(ep->object, _edje_scale);
|
if (ep->part->scale) evas_object_scale_set(ep->object, sc);
|
||||||
evas_object_text_font_set(ep->object, font, current);
|
evas_object_text_font_set(ep->object, font, current);
|
||||||
part_get_geometry(ep, &tw, &th);
|
part_get_geometry(ep, &tw, &th);
|
||||||
} while (th <= sh);
|
} while (th <= sh);
|
||||||
|
@ -570,7 +576,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||||
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
||||||
else evas_object_text_font_source_set(ep->object, NULL);
|
else evas_object_text_font_source_set(ep->object, NULL);
|
||||||
|
|
||||||
if (ep->part->scale) evas_object_scale_set(ep->object, _edje_scale);
|
if (ep->part->scale) evas_object_scale_set(ep->object, sc);
|
||||||
evas_object_text_font_set(ep->object, font, size);
|
evas_object_text_font_set(ep->object, font, size);
|
||||||
evas_object_text_text_set(ep->object, text);
|
evas_object_text_text_set(ep->object, text);
|
||||||
part_get_geometry(ep, &tw, &th);
|
part_get_geometry(ep, &tw, &th);
|
||||||
|
|
|
@ -163,6 +163,28 @@ edje_scale_get(void)
|
||||||
return _edje_scale;
|
return _edje_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
edje_object_scale_set(Evas_Object *obj, double scale)
|
||||||
|
{
|
||||||
|
Edje *ed;
|
||||||
|
|
||||||
|
ed = _edje_fetch(obj);
|
||||||
|
if (!ed) return;
|
||||||
|
if (ed->scale == scale) return;
|
||||||
|
ed->scale = scale;
|
||||||
|
edje_object_calc_force(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI double
|
||||||
|
edje_object_scale_get(const Evas_Object *obj)
|
||||||
|
{
|
||||||
|
Edje *ed;
|
||||||
|
|
||||||
|
ed = _edje_fetch(obj);
|
||||||
|
if (!ed) return 0.0;
|
||||||
|
return ed->scale;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXDOC: Verify/Expand */
|
/* FIXDOC: Verify/Expand */
|
||||||
/** Get Edje object data
|
/** Get Edje object data
|
||||||
* @param obj A valid Evas_Object handle
|
* @param obj A valid Evas_Object handle
|
||||||
|
|
Loading…
Reference in New Issue