diff options
author | Marcel Hollerbach <marcel-hollerbach@t-online.de> | 2016-02-19 22:55:04 +0100 |
---|---|---|
committer | Marcel Hollerbach <marcel-hollerbach@t-online.de> | 2016-02-19 22:55:04 +0100 |
commit | 0ed61a27dc30e887485c33bcfe37efab454de9e2 (patch) | |
tree | 2b6b079339fcf367356715b0143391e20e7d82a7 | |
parent | 017e7bd48411f483ba0b03eee6159606d2db2bbf (diff) | |
download | elementary-devs/bu5hm4n/focus_overhaul.tar.gz |
lets make button a focusable widgetdevs/bu5hm4n/focus_overhaul
-rw-r--r-- | src/lib/Makefile.am | 4 | ||||
-rw-r--r-- | src/lib/elm_button.c | 2 | ||||
-rw-r--r-- | src/lib/elm_button.eo | 2 | ||||
-rw-r--r-- | src/lib/elm_focusable.eo | 24 | ||||
-rw-r--r-- | src/lib/elm_focuswidget.c | 73 | ||||
-rw-r--r-- | src/lib/elm_focuswidget.eo | 7 |
6 files changed, 106 insertions, 6 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index cc5f5a8bd..1729e88b1 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -506,6 +506,7 @@ elm_helper.c \ els_box.c \ els_cursor.c \ els_tooltip.c \ +elm_focuswidget.c \ elu_ews_wm.c libelementary_la_CFLAGS = @ELEMENTARY_CFLAGS@ @@ -638,7 +639,8 @@ elm_toolbar_item.eo \ elm_diskselector_item.eo \ elm_popup_item.eo \ elm_focus_manager.eo \ -elm_focusable.eo +elm_focusable.eo \ +elm_focuswidget.eo elm_eolian_type_files = \ elm_general.eot diff --git a/src/lib/elm_button.c b/src/lib/elm_button.c index 43fb45b71..a3c2598e0 100644 --- a/src/lib/elm_button.c +++ b/src/lib/elm_button.c @@ -10,6 +10,8 @@ #include "elm_widget_button.h" #include "elm_widget_layout.h" +#include "elm_focuswidget.eo.h" + #define MY_CLASS ELM_BUTTON_CLASS #define MY_CLASS_NAME "Elm_Button" diff --git a/src/lib/elm_button.eo b/src/lib/elm_button.eo index f1b1164e3..5d27e99a4 100644 --- a/src/lib/elm_button.eo +++ b/src/lib/elm_button.eo @@ -1,4 +1,4 @@ -class Elm.Button (Elm.Layout, Evas.Clickable_Interface, +class Elm.Button (Elm.Focuswidget, Evas.Clickable_Interface, Elm.Interface_Atspi_Widget_Action) { eo_prefix: elm_obj_button; diff --git a/src/lib/elm_focusable.eo b/src/lib/elm_focusable.eo index d868c6f7a..4d8a831fa 100644 --- a/src/lib/elm_focusable.eo +++ b/src/lib/elm_focusable.eo @@ -2,13 +2,29 @@ interface Elm.Focusable { [[Implemented by objects which may be focusable]] legacy_prefix: null; methods { - focusable { + @property focusable { [[returns true if this object is focusable]] - return : bool; + values { + focusable : bool; + } + set { + + } + get { + + } } - focus { + @property focus { [[returnds if this object is currently focused]] - return : bool; + values { + focus : bool; + } + set { + + } + get { + + } } } events { diff --git a/src/lib/elm_focuswidget.c b/src/lib/elm_focuswidget.c new file mode 100644 index 000000000..0cfc8adc4 --- /dev/null +++ b/src/lib/elm_focuswidget.c @@ -0,0 +1,73 @@ +#include <Elementary.h> +#include "elm_priv.h" + +#include "elm_focuswidget.eo.h" +#include "elm_focusable.eo.h" +#include "elm_focus_manager.eo.h" +#include "elm_layout.eo.h" +typedef struct { + Eina_Bool focusable; + Eina_Bool focus; +} Elm_Focuswidget_Data; + + +EOLIAN static void +_elm_focuswidget_elm_focusable_focus_set(Eo *obj, Elm_Focuswidget_Data *pd, Eina_Bool focus) +{ + if (!pd->focusable) return; + + pd->focus = focus; + + eo_do(obj, eo_event_callback_call(pd->focus ? ELM_FOCUSABLE_EVENT_FOCUS_ON : ELM_FOCUSABLE_EVENT_FOCUS_OFF, NULL)); +} + + +EOLIAN static Eina_Bool +_elm_focuswidget_elm_focusable_focus_get(Eo *obj, Elm_Focuswidget_Data *pd) +{ + return pd->focus; +} + + +EOLIAN static void +_elm_focuswidget_elm_focusable_focusable_set(Eo *obj, Elm_Focuswidget_Data *pd, Eina_Bool focusable) +{ + pd->focusable = focusable; + + if (!focusable) + eo_do(obj, elm_focusable_focus_set(EINA_FALSE)); +} + + +EOLIAN static Eina_Bool +_elm_focuswidget_elm_focusable_focusable_get(Eo *obj, Elm_Focuswidget_Data *pd) +{ + return pd->focusable; +} + +EOLIAN static Eo* +_elm_focuswidget_eo_base_finalize(Eo *obj, Elm_Focuswidget_Data *pd) +{ + Eo *eo; + Eo *nextParent; + eo_do_super(obj, ELM_FOCUSWIDGET_CLASS, eo = eo_finalize()); + + eo_do(obj, nextParent = eo_parent_get()); + + do { + if (eo_isa(nextParent, ELM_FOCUS_MANAGER_INTERFACE)) + { + eo_do(nextParent, elm_focus_manager_register_simple(obj)); + break; + } + eo_do(nextParent, nextParent = eo_parent_get()); + } while (nextParent); + + if (!nextParent) + printf("Failed to find the highest focus manager\n"); + + return eo; +} + + +#include "elm_focuswidget.eo.c"
\ No newline at end of file diff --git a/src/lib/elm_focuswidget.eo b/src/lib/elm_focuswidget.eo new file mode 100644 index 000000000..63f36f898 --- /dev/null +++ b/src/lib/elm_focuswidget.eo @@ -0,0 +1,7 @@ +class Elm.Focuswidget (Elm.Layout, Elm.Focusable) { + implements { + Elm.Focusable.focus; + Elm.Focusable.focusable; + Eo.Base.finalize; + } +}
\ No newline at end of file |