forked from enlightenment/efl
elm_ui_focus_layer: add configurable behaviour
the layer can now be configured if it should be automatically enabled at visibility and if the focus should cycle in the layer or not.
This commit is contained in:
parent
383dd5de15
commit
94afff21da
|
@ -2,6 +2,8 @@
|
|||
# include "elementary_config.h"
|
||||
#endif
|
||||
|
||||
#define EFL_UI_FOCUS_LAYER_PROTECTED
|
||||
|
||||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
#include "efl_ui_focus_layer.eo.h"
|
||||
|
@ -10,8 +12,9 @@
|
|||
|
||||
typedef struct {
|
||||
Efl_Ui_Focus_Manager *registered_manager;
|
||||
Eina_Bool registered;
|
||||
Efl_Ui_Focus_Manager *manager;
|
||||
Eina_Bool cycle;
|
||||
Eina_Bool enable_on_visible;
|
||||
} Efl_Ui_Focus_Layer_Data;
|
||||
|
||||
EOLIAN static Efl_Ui_Focus_Manager*
|
||||
|
@ -25,18 +28,9 @@ _efl_ui_focus_layer_efl_gfx_visible_set(Eo *obj, Efl_Ui_Focus_Layer_Data *pd, Ei
|
|||
{
|
||||
efl_gfx_visible_set(efl_super(obj, MY_CLASS), v);
|
||||
|
||||
if (v && !pd->registered)
|
||||
if (pd->enable_on_visible)
|
||||
{
|
||||
pd->registered_manager = elm_widget_top_get(obj);
|
||||
|
||||
efl_ui_focus_manager_redirect_set(pd->registered_manager, obj);
|
||||
efl_ui_focus_manager_focus_set(pd->manager, obj);
|
||||
pd->registered = EINA_TRUE;
|
||||
}
|
||||
else if (!v && pd->registered)
|
||||
{
|
||||
efl_ui_focus_manager_redirect_set(pd->registered_manager, NULL);
|
||||
pd->registered = EINA_FALSE;
|
||||
efl_ui_focus_layer_enable_set(obj, v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +42,10 @@ _efl_ui_focus_layer_efl_ui_focus_manager_move(Eo *obj, Efl_Ui_Focus_Layer_Data *
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
//ret is NULL here, if we do not want to cycle return NULL, which will result in obj beeing unset
|
||||
if (!pd->cycle)
|
||||
return NULL;
|
||||
|
||||
if ((direction == EFL_UI_FOCUS_DIRECTION_PREV) || (direction == EFL_UI_FOCUS_DIRECTION_NEXT))
|
||||
efl_ui_focus_manager_focus_set(pd->manager, obj);
|
||||
|
||||
|
@ -55,18 +53,14 @@ _efl_ui_focus_layer_efl_ui_focus_manager_move(Eo *obj, Efl_Ui_Focus_Layer_Data *
|
|||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_focus_layer_efl_object_destructor(Eo *obj, Efl_Ui_Focus_Layer_Data *pd)
|
||||
_efl_ui_focus_layer_efl_object_destructor(Eo *obj, Efl_Ui_Focus_Layer_Data *pd EINA_UNUSED)
|
||||
{
|
||||
if (pd->registered)
|
||||
{
|
||||
efl_ui_focus_manager_redirect_set(pd->registered_manager, NULL);
|
||||
pd->registered = EINA_FALSE;
|
||||
}
|
||||
efl_ui_focus_layer_enable_set(obj, EINA_FALSE);
|
||||
efl_destructor(efl_super(obj, MY_CLASS));
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Ui_Focus_Manager*
|
||||
_efl_ui_focus_layer_efl_ui_focus_user_manager_get(Eo *obj, Efl_Ui_Focus_Layer_Data *pd)
|
||||
_efl_ui_focus_layer_efl_ui_focus_user_manager_get(Eo *obj, Efl_Ui_Focus_Layer_Data *pd EINA_UNUSED)
|
||||
{
|
||||
return elm_widget_top_get(obj);
|
||||
}
|
||||
|
@ -84,7 +78,49 @@ _efl_ui_focus_layer_efl_object_constructor(Eo *obj, Efl_Ui_Focus_Layer_Data *pd)
|
|||
|
||||
efl_composite_attach(obj, pd->manager);
|
||||
|
||||
pd->enable_on_visible = EINA_TRUE;
|
||||
pd->cycle = EINA_TRUE;
|
||||
|
||||
return efl_constructor(efl_super(obj, MY_CLASS));
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_focus_layer_enable_set(Eo *obj, Efl_Ui_Focus_Layer_Data *pd, Eina_Bool v)
|
||||
{
|
||||
if (v)
|
||||
{
|
||||
pd->registered_manager = elm_widget_top_get(obj);
|
||||
|
||||
efl_ui_focus_manager_redirect_set(pd->registered_manager, obj);
|
||||
efl_ui_focus_manager_focus_set(pd->manager, obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (efl_ui_focus_manager_redirect_get(pd->registered_manager) == obj)
|
||||
efl_ui_focus_manager_redirect_set(pd->registered_manager, NULL);
|
||||
pd->registered_manager = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_ui_focus_layer_enable_get(Eo *obj, Efl_Ui_Focus_Layer_Data *pd)
|
||||
{
|
||||
if (!pd->registered_manager) return EINA_FALSE;
|
||||
return (efl_ui_focus_manager_redirect_get(pd->registered_manager) == obj);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_focus_layer_behaviour_set(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Layer_Data *pd, Eina_Bool enable_on_visible, Eina_Bool cycle)
|
||||
{
|
||||
pd->enable_on_visible = enable_on_visible;
|
||||
pd->cycle = cycle;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_focus_layer_behaviour_get(Eo *obj EINA_UNUSED, Efl_Ui_Focus_Layer_Data *pd, Eina_Bool *enable_on_visible, Eina_Bool *cycle)
|
||||
{
|
||||
*cycle = pd->cycle;
|
||||
*enable_on_visible = pd->enable_on_visible;
|
||||
}
|
||||
|
||||
#include "efl_ui_focus_layer.eo.c"
|
||||
|
|
|
@ -5,6 +5,20 @@ mixin Efl.Ui.Focus.Layer (Efl.Interface, Elm.Widget, Efl.Gfx, Efl.Ui.Focus.Manag
|
|||
|
||||
Once the object is hidden or destructed the focus will go back to the mainwindow, where it has been before.
|
||||
]]
|
||||
methods {
|
||||
@property enable @protected {
|
||||
values {
|
||||
v : bool; [[$true to set enable the layer $false to disable it]]
|
||||
}
|
||||
}
|
||||
@property behaviour @protected {
|
||||
[[Constructor for setting the behaviour of the layer]]
|
||||
values {
|
||||
enable_on_visible : bool; [[$true means layer will set itself once the inheriting widget gets visible, $false means the layer does not get enabled automatically]]
|
||||
cycle : bool; [[If $true the focus will cycle in the layer, if $false]]
|
||||
}
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Elm.Widget.focus_manager_create;
|
||||
Elm.Widget.focus_state_apply;
|
||||
|
|
Loading…
Reference in New Issue