scale: set the base scale of the application.

The scale is used for the application to be scaled.
If the application isn't made on the basis of scale 1.0,
the application layout will be scaled inappositely. So if the
application set the base scale, it is applied when the application is scaled.
This commit is contained in:
Jaehwan Kim 2014-09-19 13:45:03 +09:00
parent 1ea72cda55
commit 46508d8116
3 changed files with 43 additions and 0 deletions

View File

@ -265,6 +265,33 @@ EAPI const char *elm_app_data_dir_get(void);
*/
EAPI const char *elm_app_locale_dir_get(void);
/**
* Set the base scale of the application.
*
* @param base_scale The scale that the application is made on the basis of.
*
* @note The scale is used for the application to be scaled.
* If the application isn't made on the basis of scale 1.0,
* the application layout will be scaled inappositely. So if the application set
* the base scale, it is applied when the application is scaled.
*
* @note You should call this function @b before using ELM_SCALE_SIZE macro.
*
* @ingroup App
* @since 1.12
*/
EAPI void elm_app_base_scale_set(double base_scale);
/**
* Get the base scale of the application.
*
* @return The base scale which the application sets.
*
* @ingroup App
* @since 1.12
*/
EAPI double elm_app_base_scale_get(void);
/**
* @}
*/

View File

@ -1,6 +1,7 @@
/* handy macros */
#define ELM_RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy)))
#define ELM_PI 3.14159265358979323846
#define ELM_SCALE_SIZE(x) x / elm_app_base_scale_get() * elm_config_scale_get()
// checks if the point(xx, yy) stays out of the rectangle(x, y, w, h) area.
#define ELM_RECTS_POINT_OUT(x, y, w, h, xx, yy) (((xx) < (x)) || ((yy) < (y)) || ((xx) > ((x) + (w))) || ((yy) > ((y) + (h))))

View File

@ -127,6 +127,7 @@ static const char *app_bin_dir = NULL;
static const char *app_lib_dir = NULL;
static const char *app_data_dir = NULL;
static const char *app_locale_dir = NULL;
static double app_base_scale = 1.0;
static Eina_Prefix *app_pfx = NULL;
@ -457,6 +458,20 @@ elm_app_locale_dir_get(void)
return app_locale_dir;
}
EAPI void
elm_app_base_scale_set(double base_scale)
{
if (base_scale <= 0.0) return;
app_base_scale = base_scale;
}
EAPI double
elm_app_base_scale_get(void)
{
if (app_base_scale) return app_base_scale;
return 1.0;
}
static Eina_Bool _elm_need_e_dbus = EINA_FALSE;
static void *e_dbus_handle = NULL;