diff --git a/src/lib/efl/interfaces/efl_gfx_size_hint.eo b/src/lib/efl/interfaces/efl_gfx_size_hint.eo index 6e86fbc887..fb53e83aa0 100644 --- a/src/lib/efl/interfaces/efl_gfx_size_hint.eo +++ b/src/lib/efl/interfaces/efl_gfx_size_hint.eo @@ -1,4 +1,7 @@ -interface Efl.Gfx.Size.Hint { +import efl_gfx_types; + +interface Efl.Gfx.Size.Hint +{ methods { @property base { set { @@ -38,5 +41,44 @@ interface Efl.Gfx.Size.Hint { h: int; [[The stepping height (0 disables).]] } } + @property aspect { + [[Defines the aspect ratio to respect when scaling this object. + + The aspect ratio is defined as the width / height ratio of the + object. Depending on the object and its container, this hint may + or may not be fully respected. + + If any of the given aspect ratio terms are 0, the object's container + will ignore the aspect and scale this object to occupy the whole + available area, for any given policy. + ]] + /* + @image html any-policy.png + @image rtf any-policy.png + @image latex any-policy.eps + + @image html aspect-control-none-neither.png + @image rtf aspect-control-none-neither.png + @image latex aspect-control-none-neither.eps + + @image html aspect-control-both.png + @image rtf aspect-control-both.png + @image latex aspect-control-both.eps + + @image html aspect-control-horizontal.png + @image rtf aspect-control-horizontal.png + @image latex aspect-control-horizontal.eps + */ + values { + mode: Efl.Gfx.Size.Hint.Aspect; [[Mode of interpretation.]] + w: int; + h: int; + + /* FIXME: do we want min/max like Edje instead?? + min: double; [[Default: 0.0 (no preference).]] + max: double @optional; [[Default: 0.0, may be ignored.]] + */ + } + } } } diff --git a/src/lib/efl/interfaces/efl_gfx_types.eot b/src/lib/efl/interfaces/efl_gfx_types.eot index 86b860b3cd..9821784c3d 100644 --- a/src/lib/efl/interfaces/efl_gfx_types.eot +++ b/src/lib/efl/interfaces/efl_gfx_types.eot @@ -174,3 +174,22 @@ struct Efl.Gfx.Event.Render_Post updated_area: list ; [[A list of rectangles that were updated in the canvas.]] } + +enum Efl.Gfx.Size.Hint.Aspect +{ + [[Aspect types/policies for scaling size hints. + + See also $Efl.Gfx.Size.Hint.aspect. + ]] + + none = 0, [[No preference on either direction of the container + for aspect ratio control.]] + neither = 1, [[Same effect as disabling aspect ratio preference]] + horizontal = 2, [[Use all horizontal container space to place an object, + using the given aspect.]] + vertical = 3, [[Use all vertical container space to place an object, using + the given aspect.]] + both = 4 [[Use all horizontal and vertical container spaces to place an + object (never growing it out of those bounds), using the given + aspect.]] +} diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index f793264a50..5e6a17bc4d 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -355,6 +355,14 @@ typedef Efl_Event_Flags Evas_Event_Flags; #define EVAS_EVENT_FLAG_ON_HOLD EFL_EVENT_FLAGS_ON_HOLD #define EVAS_EVENT_FLAG_ON_SCROLL EFL_EVENT_FLAGS_ON_SCROLL +typedef Efl_Gfx_Size_Hint_Aspect Evas_Aspect_Control; /**< Aspect types/policies for scaling size hints, used for evas_object_size_hint_aspect_set */ + +#define EVAS_ASPECT_CONTROL_NONE EFL_GFX_SIZE_HINT_ASPECT_NONE +#define EVAS_ASPECT_CONTROL_NEITHER EFL_GFX_SIZE_HINT_ASPECT_NEITHER +#define EVAS_ASPECT_CONTROL_HORIZONTAL EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL +#define EVAS_ASPECT_CONTROL_VERTICAL EFL_GFX_SIZE_HINT_ASPECT_VERTICAL +#define EVAS_ASPECT_CONTROL_BOTH EFL_GFX_SIZE_HINT_ASPECT_BOTH + struct _Evas_Engine_Info /** Generic engine information. Generic info is useless */ { int magic; /**< Magic number */ diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index f4d19984da..dc65965437 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -857,6 +857,50 @@ EAPI void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h); */ EAPI Eina_Bool evas_object_visible_get(const Evas_Object *obj); +/** + * @brief Sets the hints for an object's aspect ratio. + * + * This is not a size enforcement in any way, it's just a hint that should be + * used whenever appropriate. + * + * If any of the given aspect ratio terms are 0, the object's container will + * ignore the aspect and scale @c obj to occupy the whole available area, for + * any given policy. + * + * @note Smart objects(such as elementary) can have their own size hint policy. + * So calling this API may or may not affect the size of smart objects. + * + * @param[in] aspect The policy/type of aspect ratio to apply to @c obj. + * @param[in] w Integer to use as aspect width ratio term. + * @param[in] h Integer to use as aspect height ratio term. + * + * @ingroup Evas_Object + */ +EAPI void evas_object_size_hint_aspect_set(Evas_Object *obj, Evas_Aspect_Control aspect, Evas_Coord w, Evas_Coord h); + +/** + * @brief Retrieves the hints for an object's aspect ratio. + * + * The different aspect ratio policies are documented in the + * #Evas_Aspect_Control type. A container respecting these size hints would + * resize its children accordingly to those policies. + * + * For any policy, if any of the given aspect ratio terms are 0, the object's + * container should ignore the aspect and scale @c obj to occupy the whole + * available area. If they are both positive integers, that proportion will be + * respected, under each scaling policy. + * + * @note Use @c null pointers on the hint components you're not interested in: + * they'll be ignored by the function. + * + * @param[out] aspect The policy/type of aspect ratio to apply to @c obj. + * @param[out] w Integer to use as aspect width ratio term. + * @param[out] h Integer to use as aspect height ratio term. + * + * @ingroup Evas_Object + */ +EAPI void evas_object_size_hint_aspect_get(const Evas_Object *obj, Evas_Aspect_Control *aspect, Evas_Coord *w, Evas_Coord *h); + /** * * Sets the layer of its canvas that the given object will be part of. diff --git a/src/lib/evas/canvas/evas_object.eo b/src/lib/evas/canvas/evas_object.eo index 2bc9d569ae..cda5c357f7 100644 --- a/src/lib/evas/canvas/evas_object.eo +++ b/src/lib/evas/canvas/evas_object.eo @@ -1,7 +1,7 @@ import evas_types; abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx, Efl.Gfx.Stack, - Efl.Animator, Efl.Input.Interface) + Efl.Animator, Efl.Input.Interface, Efl.Gfx.Size.Hint) { legacy_prefix: evas_object; eo_prefix: evas_obj; @@ -304,74 +304,6 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx, Efl.Gfx.Stack, map: const(Evas.Map)*; [[The map.]] } } - @property size_hint_aspect { - set { - [[Sets the hints for an object's aspect ratio. - - This is not a size enforcement in any way, it's just a hint - that should be used whenever appropriate. - - If any of the given aspect ratio terms are 0, the object's - container will ignore the aspect and scale $obj to occupy - the whole available area, for any given policy. - - Note: Smart objects(such as elementary) can have their own - size hint policy. So calling this API may or may not affect - the size of smart objects. - ]] - } - get { - [[Retrieves the hints for an object's aspect ratio. - - The different aspect ratio policies are documented in the - #Evas_Aspect_Control type. A container respecting these size - hints would resize its children accordingly to those policies. - - For any policy, if any of the given aspect ratio terms are 0, - the object's container should ignore the aspect and scale $obj - to occupy the whole available area. If they are both positive - integers, that proportion will be respected, under each - scaling policy. - - Note: Use $null pointers on the hint components you're not - interested in: they'll be ignored by the function. - ]] - /* FIXME-doc - These images illustrate some of the #Evas_Aspect_Control policies: - - @image html any-policy.png - @image rtf any-policy.png - @image latex any-policy.eps - - @image html aspect-control-none-neither.png - @image rtf aspect-control-none-neither.png - @image latex aspect-control-none-neither.eps - - @image html aspect-control-both.png - @image rtf aspect-control-both.png - @image latex aspect-control-both.eps - - @image html aspect-control-horizontal.png - @image rtf aspect-control-horizontal.png - @image latex aspect-control-horizontal.eps - - This is not a size enforcement in any way, it's just a hint that - should be used whenever appropriate. - --- - Example: - @dontinclude evas-aspect-hints.c - @skip if (strcmp(ev->key, "c") == 0) - @until } - - See the full @ref Example_Evas_Aspect_Hints "example". - */ - } - values { - aspect: Evas.Aspect_Control; [[The policy/type of aspect ratio to apply to $obj.]] - w: Evas.Coord; [[Integer to use as aspect width ratio term.]] - h: Evas.Coord; [[Integer to use as aspect height ratio term.]] - } - } @property clip { set { [[Clip one object to another. @@ -1246,6 +1178,8 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx, Efl.Gfx.Stack, Efl.Gfx.Stack.stack_above; Efl.Gfx.Stack.raise; Efl.Gfx.Stack.lower; + Efl.Gfx.Size.Hint.aspect.set; + Efl.Gfx.Size.Hint.aspect.get; } events { /* FIXME: remove events from Efl.Input.Interface */ diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index 7e2950a893..bef3774d4c 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -1185,7 +1185,7 @@ _evas_object_size_hint_request_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, } EOLIAN static void -_evas_object_size_hint_aspect_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Evas_Aspect_Control *aspect, Evas_Coord *w, Evas_Coord *h) +_evas_object_efl_gfx_size_hint_aspect_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Efl_Gfx_Size_Hint_Aspect *aspect, Evas_Coord *w, Evas_Coord *h) { if ((!obj->size_hints) || obj->delete_me) { @@ -1200,7 +1200,7 @@ _evas_object_size_hint_aspect_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_ } EOLIAN static void -_evas_object_size_hint_aspect_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Aspect_Control aspect, Evas_Coord w, Evas_Coord h) +_evas_object_efl_gfx_size_hint_aspect_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Efl_Gfx_Size_Hint_Aspect aspect, Evas_Coord w, Evas_Coord h) { if (obj->delete_me) return; @@ -2131,5 +2131,19 @@ _evas_object_legacy_ctor(Eo *eo_obj, Evas_Object_Protected_Data *obj) obj->legacy = EINA_TRUE; } +/* legacy */ + +EAPI void +evas_object_size_hint_aspect_set(Evas_Object *obj, Evas_Aspect_Control aspect, Evas_Coord w, Evas_Coord h) +{ + efl_gfx_size_hint_aspect_set(obj, aspect, w, h); +} + +EAPI void +evas_object_size_hint_aspect_get(const Evas_Object *obj, Evas_Aspect_Control *aspect, Evas_Coord *w, Evas_Coord *h) +{ + efl_gfx_size_hint_aspect_get(obj, aspect, w, h); +} + #include "canvas/evas_object.eo.c" diff --git a/src/lib/evas/canvas/evas_types.eot b/src/lib/evas/canvas/evas_types.eot index fcfcc83b44..b89d876889 100644 --- a/src/lib/evas/canvas/evas_types.eot +++ b/src/lib/evas/canvas/evas_types.eot @@ -6,19 +6,6 @@ struct Evas.Native_Surface; [[A generic datatype for engine specific native surf type Evas.Modifier_Mask: ullong; [[An Evas modifier mask type]] type Evas.Coord: int; [[A type for coordinates]] -enum Evas.Aspect_Control { - [[Aspect types/policies for scaling size hints, used for - evas_object_size_hint_aspect_set()]] - none = 0, [[Preference on scaling unset]] - neither = 1, [[Same effect as unset preference on scaling]] - horizontal = 2, [[Use all horizontal container space to place an object, - using the given aspect]] - vertical = 3, [[Use all vertical container space to place an object, using - the given aspect]] - both = 4 [[Use all horizontal and vertical container spaces to place an - object (never growing it out of those bounds), using the given - aspect]] -} enum Evas.Render_Op { [[How the object should be rendered to output.]]