edje: Add dpi feature.

Summary:
This dpi is used to get the scale for each collection.
If each collection has a described dpi, it calculates a proper scale
based on the dpi and dpi which is described in the collection.

@feature

Test Plan:
If add dpi to collection of edc, the edje will save the value as the dpi of the collection.
For example, if the dpi of your device is 100, you just set dpi: 100 in the collection of edc.
If the edj is loaded in another device(dpi is 200), it will scaled 2 times.
It is possible that the described dpi of application and theme are different.
In that case, application and theme have a different scale.
It makes the edj that made in different environment works in one device.

Reviewers: seoz, zmike, JackDanielZ, Hermet, woohyun, cedric, raster

Reviewed By: raster

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D1190
This commit is contained in:
Jaehwan Kim 2014-07-24 14:50:25 +09:00 committed by Carsten Haitzler (Rasterman)
parent 0c3487cd3d
commit 7e5d2606cc
8 changed files with 53 additions and 12 deletions

View File

@ -364,6 +364,7 @@ main(int argc, char **argv)
* does not load nicely as a NULL or 0 value
* and needs a special fallback initialization
*/
edje_file->base_scale = FROM_INT(1);
source_edd();
source_fetch();

View File

@ -201,6 +201,7 @@ static void st_color_class_color2(void);
static void st_color_class_color3(void);
static void ob_collections(void);
static void st_collections_base_scale(void);
static void ob_collections_group(void);
static void st_collections_group_name(void);
@ -516,6 +517,7 @@ New_Statement_Handler statement_handlers[] =
IMAGE_SET_STATEMENTS("collections")
{"collections.font", st_fonts_font}, /* dup */
FONT_STYLE_CC_STATEMENTS("collections.")
{"collections.base_scale", st_collections_base_scale},
{"collections.sounds.sample.name", st_collections_group_sound_sample_name},
{"collections.sounds.sample.source", st_collections_group_sound_sample_source},
@ -2463,6 +2465,37 @@ ob_collections(void)
}
}
/**
@page edcref
@block
base_scale
@context
collections {
..
base_scale: 1.2;
..
}
@description
The base_scale is the standard scale value of the collection.
The default base_scale is 1.0. It means the collection is made in the environment
which is same with a desktop(The monitor has 96 dpi).
If you make a collection in another environment(ex: 115 dpi), you have to
set the base_scale(ex: 1.2). Then it will be shown same size in the desktop.
@endblock
*/
static void
st_collections_base_scale(void)
{
check_min_arg_count(1);
edje_file->base_scale = FROM_DOUBLE(parse_float_range(0, 0.0, 999999999.0));
if (edje_file->base_scale == ZERO)
{
ERR("The base_scale is 0.0. The value should be bigger than 0.0.");
exit(-1);
}
}
/**
@edcsubsection{collections_sounds,Sounds}
*/

View File

@ -300,6 +300,11 @@ _edje_file_open(const Eina_File *f, const char *coll, int *error_ret, Edje_Part_
WRN("`%s` may use feature from a newer edje and could not show up as expected.",
eina_file_filename_get(f));
}
if (edf->base_scale <= ZERO)
{
edf->base_scale = FROM_INT(1);
WRN("The base_scale can not be a 0.0. It is changed the default value(1.0)");
}
edf->path = eina_stringshare_add(eina_file_filename_get(f));
edf->references = 1;

View File

@ -1437,8 +1437,8 @@ _edje_textblock_recalc_apply(Edje *ed, Edje_Real_Part *ep,
{
/* FIXME: this is just an hack. */
FLOAT_T sc;
sc = ed->scale;
if (sc == ZERO) sc = _edje_scale;
sc = DIV(ed->scale, ed->file->base_scale);
if (sc == ZERO) sc = DIV(_edje_scale, ed->file->base_scale);
if (chosen_desc->text.fit_x || chosen_desc->text.fit_y)
{
_edje_part_recalc_single_textblock(sc, ed, ep, chosen_desc, params,
@ -2267,8 +2267,8 @@ _edje_part_recalc_single(Edje *ed,
int minw = 0, minh = 0, maxw = 0, maxh = 0;
FLOAT_T sc;
sc = ed->scale;
if (sc == ZERO) sc = _edje_scale;
sc = DIV(ed->scale, ed->file->base_scale);
if (sc == ZERO) sc = DIV(_edje_scale, ed->file->base_scale);
_edje_part_recalc_single_min_max(sc, ed, ep, desc, &minw, &minh, &maxw, &maxh);
if (minw < mmw) minw = mmw;
if (minh < mmh) minh = mmh;
@ -2651,8 +2651,8 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj
{
FLOAT_T sc;
sc = ed->scale;
if (sc == 0.0) sc = _edje_scale;
sc = DIV(ed->scale, ed->file->base_scale);
if (sc == ZERO) sc = DIV(_edje_scale, ed->file->base_scale);
eo_do(ep->object,
evas_obj_image_fill_set(p3->type.common.fill.x, p3->type.common.fill.y,
p3->type.common.fill.w, p3->type.common.fill.h),

View File

@ -427,6 +427,7 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "version", version, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "minor", minor, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "feature_ver", feature_ver, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "base_scale", base_scale, EDJE_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "external_dir", external_dir, _edje_edd_edje_external_directory);
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "image_dir", image_dir, _edje_edd_edje_image_directory);
EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "sound_dir", sound_dir, _edje_edd_edje_sound_directory);

View File

@ -2118,8 +2118,8 @@ _edje_part_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
d2 = d * d;
d = (r2->y + (r2->h / 2)) - cy;
d2 += d * d;
sc = en->ed->scale;
if (sc == ZERO) sc = _edje_scale;
sc = DIV(en->ed->scale, en->ed->file->base_scale);
if (sc == ZERO) sc = DIV(_edje_scale, en->ed->file->base_scale);
d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number!
d = d * d;
if (d1 < d2)

View File

@ -478,6 +478,7 @@ struct _Edje_File
int version;
int minor;
int feature_ver;
FLOAT_T base_scale;
Eina_Hash *data;
Eina_Hash *fonts;

View File

@ -85,8 +85,8 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
{
FLOAT_T sc;
sc = ed->scale;
if (sc == ZERO) sc = _edje_scale;
sc = DIV(ed->scale, ed->file->base_scale);
if (sc == ZERO) sc = DIV(_edje_scale, ed->file->base_scale);
*free_text = 0;
if (sw <= 1) return "";
@ -179,8 +179,8 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
if ((ep->type != EDJE_RP_TYPE_TEXT) ||
(!ep->typedata.text)) return;
sc = ed->scale;
if (sc == 0.0) sc = _edje_scale;
sc = DIV(ed->scale, ed->file->base_scale);
if (sc == ZERO) sc = DIV(_edje_scale, ed->file->base_scale);
text = edje_string_get(&chosen_desc->text.text);
font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
filter = chosen_desc->text.filter.str;