From 46508d81164013fbeebf1f92cb95ff63e2d92484 Mon Sep 17 00:00:00 2001 From: Jaehwan Kim Date: Fri, 19 Sep 2014 13:45:03 +0900 Subject: [PATCH] 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. --- legacy/elementary/src/lib/elm_app.h | 27 ++++++++++++++++++++++++++ legacy/elementary/src/lib/elm_macros.h | 1 + legacy/elementary/src/lib/elm_main.c | 15 ++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/legacy/elementary/src/lib/elm_app.h b/legacy/elementary/src/lib/elm_app.h index f08fd1b409..df2a37c963 100644 --- a/legacy/elementary/src/lib/elm_app.h +++ b/legacy/elementary/src/lib/elm_app.h @@ -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); + /** * @} */ diff --git a/legacy/elementary/src/lib/elm_macros.h b/legacy/elementary/src/lib/elm_macros.h index c25e95639f..05403aef07 100644 --- a/legacy/elementary/src/lib/elm_macros.h +++ b/legacy/elementary/src/lib/elm_macros.h @@ -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)))) diff --git a/legacy/elementary/src/lib/elm_main.c b/legacy/elementary/src/lib/elm_main.c index 19779946b2..9fabd43574 100644 --- a/legacy/elementary/src/lib/elm_main.c +++ b/legacy/elementary/src/lib/elm_main.c @@ -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;