allow individual objects to have differing scaling factors (object scale

overrides edje global scale)



SVN revision: 38908
This commit is contained in:
Carsten Haitzler 2009-02-03 05:07:58 +00:00
parent 43e8963919
commit b6f51da478
5 changed files with 54 additions and 20 deletions

View File

@ -181,7 +181,9 @@ extern "C" {
EAPI const char *edje_fontset_append_get (void);
EAPI void edje_scale_set (double scale);
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 */
EAPI Eina_List *edje_file_collection_list (const char *file);
EAPI void edje_file_collection_list_free (Eina_List *lst);

View File

@ -270,13 +270,16 @@ _edje_part_recalc_single(Edje *ed,
int flags)
{
int minw = 0, minh = 0, maxw = 0, maxh = 0;
double sc;
flags = FLAG_XY;
sc = ed->scale;
if (sc == 0.0) sc = _edje_scale;
// if (flags & FLAG_X)
{
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)
minw = ep->swallow_params.min.w;
@ -287,7 +290,7 @@ _edje_part_recalc_single(Edje *ed,
maxw = desc->max.w;
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;
}
}
@ -300,7 +303,7 @@ _edje_part_recalc_single(Edje *ed,
maxw = desc->max.w;
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 (ep->swallow_params.max.w < maxw)
@ -315,7 +318,7 @@ _edje_part_recalc_single(Edje *ed,
// if (flags & FLAG_Y)
{
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)
minh = ep->swallow_params.min.h;
@ -326,7 +329,7 @@ _edje_part_recalc_single(Edje *ed,
maxh = desc->max.h;
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;
}
}
@ -339,7 +342,7 @@ _edje_part_recalc_single(Edje *ed,
maxh = desc->max.h;
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 (ep->swallow_params.max.h < maxh)
@ -647,7 +650,7 @@ _edje_part_recalc_single(Edje *ed,
}
if (ep->part->scale)
evas_object_scale_set(ep->object, _edje_scale);
evas_object_scale_set(ep->object, sc);
if (stl)
{
@ -786,7 +789,7 @@ _edje_part_recalc_single(Edje *ed,
}
}
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);
else evas_object_text_font_source_set(ep->object, NULL);

View File

@ -684,6 +684,7 @@ struct _Edje
int block;
int load_error;
int freeze;
double scale;
struct {
void (*func) (void *data, Evas_Object *obj, const char *part);

View File

@ -147,11 +147,15 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
char *buf;
int c1 = -1, c2 = -1, loop = 0, extra;
size_t orig_len;
double sc;
sc = ed->scale;
if (sc == 0.0) sc = _edje_scale;
*free_text = 0;
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_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 sw, sh;
int inlined_font = 0, free_text = 0;
double sc;
sc = ed->scale;
if (sc == 0.0) sc = _edje_scale;
text = chosen_desc->text.text;
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);
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_text_set(ep->object, text);
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);
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);
part_get_geometry(ep, &tw, &th);
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);
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);
part_get_geometry(ep, &tw, &th);
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);
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_text_set(ep->object, text);
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);
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);
part_get_geometry(ep, &tw, &th);
if ((size > 0) && (th == 0)) break;
@ -499,7 +505,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
{
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);
part_get_geometry(ep, &tw, &th);
@ -524,7 +530,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
{
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);
part_get_geometry(ep, &tw, &th);
@ -538,7 +544,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
{
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);
part_get_geometry(ep, &tw, &th);
} 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);
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_text_set(ep->object, text);
part_get_geometry(ep, &tw, &th);

View File

@ -163,6 +163,28 @@ edje_scale_get(void)
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 */
/** Get Edje object data
* @param obj A valid Evas_Object handle