forked from enlightenment/efl
win: Implement aspect control with Efl.Gfx.Size.Hint
This changes the API from a double to int, int. Still not sure which API variant is the best (int,int or double).
This commit is contained in:
parent
f88750c7ba
commit
cfa739fbf6
|
@ -208,7 +208,8 @@ struct _Efl_Ui_Win_Data
|
|||
|
||||
void *trap_data;
|
||||
|
||||
double aspect;
|
||||
double aspect; /* defined as w/h or 0 */
|
||||
int aspect_w, aspect_h; /* used for the get API */
|
||||
int size_base_w, size_base_h;
|
||||
int size_step_w, size_step_h;
|
||||
int norender;
|
||||
|
@ -4766,8 +4767,8 @@ _efl_ui_win_modal_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
|
|||
return EFL_UI_WIN_MODAL_NONE;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_win_aspect_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, double aspect)
|
||||
static void
|
||||
_win_aspect_set(Efl_Ui_Win_Data *sd, double aspect)
|
||||
{
|
||||
sd->aspect = aspect;
|
||||
TRAP(sd, aspect_set, aspect);
|
||||
|
@ -4776,12 +4777,31 @@ _efl_ui_win_aspect_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, double aspect)
|
|||
#endif
|
||||
}
|
||||
|
||||
EOLIAN static double
|
||||
_efl_ui_win_aspect_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
|
||||
static double
|
||||
_win_aspect_get(Efl_Ui_Win_Data *sd)
|
||||
{
|
||||
return sd->aspect;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_win_efl_gfx_size_hint_aspect_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd,
|
||||
Efl_Gfx_Size_Hint_Aspect mode EINA_UNUSED, int w, int h)
|
||||
{
|
||||
pd->aspect_w = w;
|
||||
pd->aspect_h = h;
|
||||
if (h) _win_aspect_set(pd, (double) w / (double) h);
|
||||
else _win_aspect_set(pd, 0.0);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_win_efl_gfx_size_hint_aspect_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd,
|
||||
Efl_Gfx_Size_Hint_Aspect *mode, int *w, int *h)
|
||||
{
|
||||
if (mode) *mode = EFL_GFX_SIZE_HINT_ASPECT_NONE;
|
||||
if (w) *w = pd->aspect_w;
|
||||
if (h) *h = pd->aspect_h;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_win_efl_gfx_size_hint_base_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, int w, int h)
|
||||
{
|
||||
|
@ -6489,4 +6509,21 @@ end:
|
|||
return sd->main_menu;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_win_aspect_set(Eo *obj, double aspect)
|
||||
{
|
||||
if (aspect > DBL_EPSILON)
|
||||
efl_gfx_size_hint_aspect_set(obj, EFL_GFX_SIZE_HINT_ASPECT_NONE, 1000 * aspect, 1000);
|
||||
else
|
||||
efl_gfx_size_hint_aspect_set(obj, EFL_GFX_SIZE_HINT_ASPECT_NONE, 0, 0);
|
||||
}
|
||||
|
||||
EAPI double
|
||||
elm_win_aspect_get(const Eo *obj)
|
||||
{
|
||||
ELM_WIN_CHECK(obj) 0.0;
|
||||
ELM_WIN_DATA_GET_OR_RETURN(obj, sd, 0.0);
|
||||
return _win_aspect_get(sd);
|
||||
}
|
||||
|
||||
#include "efl_ui_win.eo.c"
|
||||
|
|
|
@ -647,18 +647,6 @@ class Efl.Ui.Win (Elm.Widget, Elm.Interface.Atspi.Window,
|
|||
$false otherwise.]]
|
||||
}
|
||||
}
|
||||
@property aspect {
|
||||
set {
|
||||
[[Set the aspect ratio of a window.]]
|
||||
}
|
||||
get {
|
||||
[[Get the aspect ratio of a window.]]
|
||||
}
|
||||
values {
|
||||
aspect: double; [[If 0, the window has no aspect limits,
|
||||
otherwise it is width divided by height.]]
|
||||
}
|
||||
}
|
||||
socket_listen {
|
||||
[[Create a socket to provide the service for Plug widget.]]
|
||||
return: bool;
|
||||
|
@ -806,6 +794,8 @@ class Efl.Ui.Win (Elm.Widget, Elm.Interface.Atspi.Window,
|
|||
Efl.Gfx.Size.Hint.base.get;
|
||||
Efl.Gfx.Size.Hint.step.set;
|
||||
Efl.Gfx.Size.Hint.step.get;
|
||||
Efl.Gfx.Size.Hint.aspect.set;
|
||||
Efl.Gfx.Size.Hint.aspect.get;
|
||||
Efl.Text.text.set;
|
||||
Efl.Text.text.get;
|
||||
}
|
||||
|
|
|
@ -1071,3 +1071,19 @@ EAPI void elm_win_keyboard_mode_set(Elm_Win *obj, Elm_Win_Keyboard_Mode mode);
|
|||
* @ingroup Elm_Win
|
||||
*/
|
||||
EAPI Elm_Win_Keyboard_Mode elm_win_keyboard_mode_get(const Elm_Win *obj);
|
||||
|
||||
/**
|
||||
* @brief Set the aspect ratio of a window.
|
||||
*
|
||||
* @param[in] aspect If 0, the window has no aspect limits, otherwise it is
|
||||
* width divided by height.
|
||||
*/
|
||||
EAPI void elm_win_aspect_set(Elm_Win *obj, double aspect);
|
||||
|
||||
/**
|
||||
* @brief Get the aspect ratio of a window.
|
||||
*
|
||||
* @return If 0, the window has no aspect limits, otherwise it is width divided
|
||||
* by height.
|
||||
*/
|
||||
EAPI double elm_win_aspect_get(const Elm_Win *obj);
|
||||
|
|
Loading…
Reference in New Issue