From: discomfitor Date: Sat, 3 Dec 2011 22:51:12 +0000 (+0000) Subject: MIN/MAX macros -> elm_priv.h X-Git-Tag: REL_F_I9500_20120323_1~17^2~1185 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5fa7a393cbfa3dbe6a74442b7562d392a45caa54;p=framework%2Fuifw%2Felementary.git MIN/MAX macros -> elm_priv.h +elm_win_center +elm_win_screen_constrain_get/set git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@65859 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index a437aab..6d2cedb 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -4546,6 +4546,22 @@ extern "C" { */ EAPI Eina_Bool elm_win_focus_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); /** + * Constrain the maximum width and height of a window to the width and height of its screen + * + * When @p constrain is true, @p obj will never resize larger than the screen. + * @param obj The window object + * @param constrain EINA_TRUE to restrict the window's maximum size, EINA_FALSE to disable restriction + */ + EAPI void elm_win_screen_constrain_set(Evas_Object *obj, Eina_Bool constrain) EINA_ARG_NONNULL(1); + /** + * Retrieve the constraints on the maximum width and height of a window relative to the width and height of its screen + * + * When this function returns true, @p obj will never resize larger than the screen. + * @param obj The window object + * @return EINA_TRUE to restrict the window's maximum size, EINA_FALSE to disable restriction + */ + EAPI Eina_Bool elm_win_screen_constrain_get(Evas_Object *obj) EINA_ARG_NONNULL(1); + /** * Get screen geometry details for the screen that a window is on * @param obj The window to query * @param x where to return the horizontal offset value. May be NULL. diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h index 65d2ec2..f7a874e 100644 --- a/src/lib/elm_priv.h +++ b/src/lib/elm_priv.h @@ -95,6 +95,11 @@ extern const char *_elm_engines[]; #define ELM_ACCESS_MODE_OFF 0 #define ELM_ACCESS_MODE_ON 1 +#undef MIN +#define MIN(x, y) (((x) < (y)) ? (x) : (y)) +#undef MAX +#define MAX(x, y) (((x) > (y)) ? (x) : (y)) + struct _Elm_Config { int config_version; diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c index 8713dfe..6eedc60 100644 --- a/src/lib/elm_win.c +++ b/src/lib/elm_win.c @@ -25,6 +25,7 @@ struct _Elm_Win int shot_counter; } shot; Eina_Bool autodel : 1; + Eina_Bool constrain : 1; int *autodel_clear, rot; int show_count; struct { @@ -640,6 +641,13 @@ _elm_win_obj_callback_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, v evas_object_geometry_get(obj, NULL, NULL, &w, &h); if (w < 1) w = 1; if (h < 1) h = 1; + if (win->constrain) + { + int sw, sh; + ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh); + w = MIN(w, sw); + h = MIN(h, sh); + } evas_object_image_size_set(win->img_obj, w, h); } } @@ -673,6 +681,13 @@ _elm_win_resize_job(void *data) win->deferred_resize_job = NULL; ecore_evas_request_geometry_get(win->ee, NULL, NULL, &w, &h); + if (win->constrain) + { + int sw, sh; + ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh); + w = MIN(w, sw); + h = MIN(h, sh); + } evas_object_resize(win->win_obj, w, h); if (win->frame_obj) { @@ -1755,6 +1770,23 @@ elm_win_raise(Evas_Object *obj) } EAPI void +elm_win_center(Evas_Object *obj, Eina_Bool h, Eina_Bool v) +{ + Elm_Win *win; + int win_w, win_h, screen_w, screen_h, nx, ny; + ELM_CHECK_WIDTYPE(obj, widtype); + win = elm_widget_data_get(obj); + if (!win) return; + ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &screen_w, &screen_h); + evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h); + if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2); + else nx = win->screen.x; + if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2); + else ny = win->screen.y; + evas_object_move(obj, nx, ny); +} + +EAPI void elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless) { Elm_Win *win; @@ -2186,6 +2218,26 @@ elm_win_focus_get(const Evas_Object *obj) } EAPI void +elm_win_screen_constrain_set(Evas_Object *obj, Eina_Bool constrain) +{ + Elm_Win *win; + ELM_CHECK_WIDTYPE(obj, widtype); + win = elm_widget_data_get(obj); + if (!win) return; + win->constrain = !!constrain; +} + +EAPI Eina_Bool +elm_win_screen_constrain_get(Evas_Object *obj) +{ + Elm_Win *win; + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + win = elm_widget_data_get(obj); + if (!win) return EINA_FALSE; + return win->constrain; +} + +EAPI void elm_win_screen_size_get(const Evas_Object *obj, int *x, int *y, int *w, int *h) { Elm_Win *win;