davemds pushed a commit to branch master. http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=130f1db451c01270554b2ac02fc4b0f7e6d49beb
commit 130f1db451c01270554b2ac02fc4b0f7e6d49beb Author: Dave Andreoli <d...@gurumeditation.it> Date: Mon Aug 3 16:09:16 2015 +0200 New 1.15 API: Object.focus_move_policy, with test. --- doc/elementary/object.rst | 6 +++ efl/elementary/object.pxi | 20 +++++++++ efl/elementary/object.py | 1 + efl/elementary/object_cdef.pxi | 3 ++ examples/elementary/test.py | 1 + examples/elementary/test_focus.py | 94 ++++++++++++++++++++++++++++++++++++++- 6 files changed, 123 insertions(+), 2 deletions(-) diff --git a/doc/elementary/object.rst b/doc/elementary/object.rst index 8ebeff6..14756ce 100644 --- a/doc/elementary/object.rst +++ b/doc/elementary/object.rst @@ -105,6 +105,12 @@ Focus move policy .. versionadded:: 1.10 +.. data:: ELM_FOCUS_MOVE_POLICY_KEY_ONLY + + Focus is set on key input like Left, Right, Up, Down, Tab, or Shift+Tab + + .. versionadded:: 1.15 + .. _Elm_Focus_Autoscroll_Mode: diff --git a/efl/elementary/object.pxi b/efl/elementary/object.pxi index f03f775..7d3c5e4 100644 --- a/efl/elementary/object.pxi +++ b/efl/elementary/object.pxi @@ -924,6 +924,26 @@ cdef class Object(SmartObject): def tree_focus_allow_get(self): return bool(elm_object_tree_focus_allow_get(self.obj)) + property focus_move_policy: + """The focus movement policy for the object. + + :type: :ref:`Elm_Focus_Move_Policy` + + .. versionadded:: 1.15 + + """ + def __get__(self): + return elm_object_focus_move_policy_get(self.obj) + + def __set__(self, Elm_Focus_Move_Policy policy): + elm_object_focus_move_policy_set(self.obj, policy) + + def focus_move_policy_get(self): + return elm_object_focus_move_policy_get(self.obj) + def focus_move_policy_set(self, Elm_Focus_Move_Policy policy): + elm_object_focus_move_policy_set(self.obj, policy) + + # # Mirroring # ========= diff --git a/efl/elementary/object.py b/efl/elementary/object.py index d0fc55d..1345a87 100644 --- a/efl/elementary/object.py +++ b/efl/elementary/object.py @@ -7,6 +7,7 @@ from . import ELM_FOCUS_LEFT from . import ELM_FOCUS_MOVE_POLICY_CLICK from . import ELM_FOCUS_MOVE_POLICY_IN +from . import ELM_FOCUS_MOVE_POLICY_KEY_ONLY from . import ELM_FOCUS_AUTOSCROLL_MODE_SHOW from . import ELM_FOCUS_AUTOSCROLL_MODE_NONE diff --git a/efl/elementary/object_cdef.pxi b/efl/elementary/object_cdef.pxi index 8558f45..8e986d7 100644 --- a/efl/elementary/object_cdef.pxi +++ b/efl/elementary/object_cdef.pxi @@ -35,6 +35,7 @@ cdef extern from "Elementary.h": cpdef enum Elm_Focus_Move_Policy: ELM_FOCUS_MOVE_POLICY_CLICK ELM_FOCUS_MOVE_POLICY_IN + ELM_FOCUS_MOVE_POLICY_KEY_ONLY ctypedef enum Elm_Focus_Move_Policy: pass @@ -156,6 +157,8 @@ cdef extern from "Elementary.h": Eina_Bool elm_object_focus_highlight_style_set(Evas_Object *obj, const char *style) const char * elm_object_focus_highlight_style_get(const Evas_Object *obj) Elm_Object_Item * elm_object_focused_item_get(const Evas_Object *obj) + void elm_object_focus_move_policy_set(Evas_Object *obj, Elm_Focus_Move_Policy policy) + Elm_Focus_Move_Policy elm_object_focus_move_policy_get(Evas_Object *obj) # Object - Mirroring (elm_mirroring.h) Eina_Bool elm_object_mirrored_get(const Evas_Object *obj) diff --git a/examples/elementary/test.py b/examples/elementary/test.py index 0878178..6e421a7 100755 --- a/examples/elementary/test.py +++ b/examples/elementary/test.py @@ -143,6 +143,7 @@ items = [ ("Focus 3", "test_focus", "focus3_clicked"), ("Focus 4", "test_focus", "focus4_clicked"), ("Focus Custom", "test_focus", "focus5_clicked"), + ("Focus Move Policy", "test_focus", "focus6_clicked"), ]), ("Geographic", [ ("Map", "test_map", "map_clicked"), diff --git a/examples/elementary/test_focus.py b/examples/elementary/test_focus.py index 70d1616..63be861 100644 --- a/examples/elementary/test_focus.py +++ b/examples/elementary/test_focus.py @@ -22,9 +22,12 @@ from efl.elementary.check import Check from efl.elementary.entry import Entry from efl.elementary.table import Table from efl.elementary.toolbar import Toolbar, ELM_TOOLBAR_SHRINK_MENU -from efl.elementary.object import ELM_FOCUS_DOWN, ELM_FOCUS_UP +from efl.elementary.object import ELM_FOCUS_DOWN, ELM_FOCUS_UP, \ + ELM_FOCUS_MOVE_POLICY_CLICK, ELM_FOCUS_MOVE_POLICY_IN, \ + ELM_FOCUS_MOVE_POLICY_KEY_ONLY from efl.elementary.configuration import Configuration from efl.elementary.theme import theme_overlay_add +from efl.elementary.radio import Radio script_path = os.path.dirname(os.path.abspath(__file__)) @@ -553,6 +556,91 @@ def focus5_clicked(obj, item=None): win.show() +# Focus Move Policy +def _move_policy_changed_cb(radio, bt3, text): + bt3.text = "Test Button " + text + bt3.focus_move_policy = radio.state_value + +def focus6_clicked(obj, item=None): + win = StandardWindow("focus6", "Focus Move Policy", + autodel=True, size=(320, 320)) + win.focus_highlight_enabled = True + win.focus_highlight_animate = True + + bx = Box(win, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) + win.resize_object_add(bx) + bx.show() + + # first frame + fr = Frame(bx, text="Focusable Buttons", size_hint_fill=FILL_BOTH) + bx.pack_end(fr) + fr.show() + + frbx = Box(fr, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) + fr.content = frbx + frbx.show() + + bt1 = Button(frbx, text="Button 1", size_hint_fill=FILL_HORIZ) + frbx.pack_end(bt1) + bt1.show() + + bt2 = Button(frbx, text="Button 2", size_hint_fill=FILL_HORIZ) + frbx.pack_end(bt2) + bt2.show() + + bt3 = Button(frbx, text="Test Button (MOUSE CLICK or KEY)", + size_hint_fill=FILL_HORIZ) + frbx.pack_end(bt3) + bt3.show() + + bt4 = Button(frbx, text="Button 4", size_hint_fill=FILL_HORIZ) + frbx.pack_end(bt4) + bt4.show() + + + # second frame + fr = Frame(bx, text="Focus Options for a TEST button", + size_hint_fill=FILL_BOTH) + bx.pack_end(fr) + fr.show() + + frbx = Box(fr, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH) + fr.content = frbx + frbx.show() + + lbl = Label(frbx, text="This focus option will be applied only for the TEST button. <br/>The focus policies of other buttons will remain in MOUSE CLICK status.", + size_hint_expand=EXPAND_HORIZ) + frbx.pack_end(lbl) + lbl.show() + + rdg = Radio(frbx, state_value=ELM_FOCUS_MOVE_POLICY_CLICK, + text="Focus Move Pollicy Mouse Click", + size_hint_align=(0.0,0.5)) + frbx.pack_end(rdg) + rdg.show() + rdg.callback_changed_add(_move_policy_changed_cb, bt3, "(MOUSE CLICK or KEY)") + + rd = Radio(frbx, state_value=ELM_FOCUS_MOVE_POLICY_IN, + text="Focus Move Policy Mouse In", + size_hint_align=(0.0,0.5)) + frbx.pack_end(rd) + rd.group_add(rdg) + rd.show() + rd.callback_changed_add(_move_policy_changed_cb, bt3, "(MOUSE IN or KEY))") + + rd = Radio(frbx, state_value=ELM_FOCUS_MOVE_POLICY_KEY_ONLY, + text="Focus Move Pollicy Key Only", + size_hint_align=(0.0,0.5)) + frbx.pack_end(rd) + rd.group_add(rdg) + rd.show() + rd.callback_changed_add(_move_policy_changed_cb, bt3, "(KEY ONLY)") + + # show the win + bt1.focus = True + win.show() + + if __name__ == "__main__": win = StandardWindow("test", "python-elementary test application", size=(320,520)) @@ -576,7 +664,9 @@ if __name__ == "__main__": ("Focus 2", focus2_clicked), ("Focus 3", focus3_clicked), ("Focus 4", focus4_clicked), - ("Focus Custom", focus5_clicked)] + ("Focus Custom", focus5_clicked), + ("Focus Move Policy", focus6_clicked), + ] li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) box0.pack_end(li) --