summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2015-08-03 16:09:16 +0200
committerDave Andreoli <dave@gurumeditation.it>2015-08-03 16:09:16 +0200
commit130f1db451c01270554b2ac02fc4b0f7e6d49beb (patch)
treee5d1810beff303b3f961b78a07a01db3515e24f6
parent97dadf30da441d91ba46389c9f8b711ad611aca6 (diff)
New 1.15 API: Object.focus_move_policy, with test.
-rw-r--r--doc/elementary/object.rst6
-rw-r--r--efl/elementary/object.pxi20
-rw-r--r--efl/elementary/object.py1
-rw-r--r--efl/elementary/object_cdef.pxi3
-rwxr-xr-xexamples/elementary/test.py1
-rw-r--r--examples/elementary/test_focus.py94
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
105 105
106 .. versionadded:: 1.10 106 .. versionadded:: 1.10
107 107
108.. data:: ELM_FOCUS_MOVE_POLICY_KEY_ONLY
109
110 Focus is set on key input like Left, Right, Up, Down, Tab, or Shift+Tab
111
112 .. versionadded:: 1.15
113
108 114
109.. _Elm_Focus_Autoscroll_Mode: 115.. _Elm_Focus_Autoscroll_Mode:
110 116
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):
924 def tree_focus_allow_get(self): 924 def tree_focus_allow_get(self):
925 return bool(elm_object_tree_focus_allow_get(self.obj)) 925 return bool(elm_object_tree_focus_allow_get(self.obj))
926 926
927 property focus_move_policy:
928 """The focus movement policy for the object.
929
930 :type: :ref:`Elm_Focus_Move_Policy`
931
932 .. versionadded:: 1.15
933
934 """
935 def __get__(self):
936 return elm_object_focus_move_policy_get(self.obj)
937
938 def __set__(self, Elm_Focus_Move_Policy policy):
939 elm_object_focus_move_policy_set(self.obj, policy)
940
941 def focus_move_policy_get(self):
942 return elm_object_focus_move_policy_get(self.obj)
943 def focus_move_policy_set(self, Elm_Focus_Move_Policy policy):
944 elm_object_focus_move_policy_set(self.obj, policy)
945
946
927 # 947 #
928 # Mirroring 948 # Mirroring
929 # ========= 949 # =========
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
7 7
8from . import ELM_FOCUS_MOVE_POLICY_CLICK 8from . import ELM_FOCUS_MOVE_POLICY_CLICK
9from . import ELM_FOCUS_MOVE_POLICY_IN 9from . import ELM_FOCUS_MOVE_POLICY_IN
10from . import ELM_FOCUS_MOVE_POLICY_KEY_ONLY
10 11
11from . import ELM_FOCUS_AUTOSCROLL_MODE_SHOW 12from . import ELM_FOCUS_AUTOSCROLL_MODE_SHOW
12from . import ELM_FOCUS_AUTOSCROLL_MODE_NONE 13from . 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":
35 cpdef enum Elm_Focus_Move_Policy: 35 cpdef enum Elm_Focus_Move_Policy:
36 ELM_FOCUS_MOVE_POLICY_CLICK 36 ELM_FOCUS_MOVE_POLICY_CLICK
37 ELM_FOCUS_MOVE_POLICY_IN 37 ELM_FOCUS_MOVE_POLICY_IN
38 ELM_FOCUS_MOVE_POLICY_KEY_ONLY
38 ctypedef enum Elm_Focus_Move_Policy: 39 ctypedef enum Elm_Focus_Move_Policy:
39 pass 40 pass
40 41
@@ -156,6 +157,8 @@ cdef extern from "Elementary.h":
156 Eina_Bool elm_object_focus_highlight_style_set(Evas_Object *obj, const char *style) 157 Eina_Bool elm_object_focus_highlight_style_set(Evas_Object *obj, const char *style)
157 const char * elm_object_focus_highlight_style_get(const Evas_Object *obj) 158 const char * elm_object_focus_highlight_style_get(const Evas_Object *obj)
158 Elm_Object_Item * elm_object_focused_item_get(const Evas_Object *obj) 159 Elm_Object_Item * elm_object_focused_item_get(const Evas_Object *obj)
160 void elm_object_focus_move_policy_set(Evas_Object *obj, Elm_Focus_Move_Policy policy)
161 Elm_Focus_Move_Policy elm_object_focus_move_policy_get(Evas_Object *obj)
159 162
160 # Object - Mirroring (elm_mirroring.h) 163 # Object - Mirroring (elm_mirroring.h)
161 Eina_Bool elm_object_mirrored_get(const Evas_Object *obj) 164 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 = [
143 ("Focus 3", "test_focus", "focus3_clicked"), 143 ("Focus 3", "test_focus", "focus3_clicked"),
144 ("Focus 4", "test_focus", "focus4_clicked"), 144 ("Focus 4", "test_focus", "focus4_clicked"),
145 ("Focus Custom", "test_focus", "focus5_clicked"), 145 ("Focus Custom", "test_focus", "focus5_clicked"),
146 ("Focus Move Policy", "test_focus", "focus6_clicked"),
146 ]), 147 ]),
147 ("Geographic", [ 148 ("Geographic", [
148 ("Map", "test_map", "map_clicked"), 149 ("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
22from efl.elementary.entry import Entry 22from efl.elementary.entry import Entry
23from efl.elementary.table import Table 23from efl.elementary.table import Table
24from efl.elementary.toolbar import Toolbar, ELM_TOOLBAR_SHRINK_MENU 24from efl.elementary.toolbar import Toolbar, ELM_TOOLBAR_SHRINK_MENU
25from efl.elementary.object import ELM_FOCUS_DOWN, ELM_FOCUS_UP 25from efl.elementary.object import ELM_FOCUS_DOWN, ELM_FOCUS_UP, \
26 ELM_FOCUS_MOVE_POLICY_CLICK, ELM_FOCUS_MOVE_POLICY_IN, \
27 ELM_FOCUS_MOVE_POLICY_KEY_ONLY
26from efl.elementary.configuration import Configuration 28from efl.elementary.configuration import Configuration
27from efl.elementary.theme import theme_overlay_add 29from efl.elementary.theme import theme_overlay_add
30from efl.elementary.radio import Radio
28 31
29 32
30script_path = os.path.dirname(os.path.abspath(__file__)) 33script_path = os.path.dirname(os.path.abspath(__file__))
@@ -553,6 +556,91 @@ def focus5_clicked(obj, item=None):
553 win.show() 556 win.show()
554 557
555 558
559# Focus Move Policy
560def _move_policy_changed_cb(radio, bt3, text):
561 bt3.text = "Test Button " + text
562 bt3.focus_move_policy = radio.state_value
563
564def focus6_clicked(obj, item=None):
565 win = StandardWindow("focus6", "Focus Move Policy",
566 autodel=True, size=(320, 320))
567 win.focus_highlight_enabled = True
568 win.focus_highlight_animate = True
569
570 bx = Box(win, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
571 win.resize_object_add(bx)
572 bx.show()
573
574 # first frame
575 fr = Frame(bx, text="Focusable Buttons", size_hint_fill=FILL_BOTH)
576 bx.pack_end(fr)
577 fr.show()
578
579 frbx = Box(fr, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
580 fr.content = frbx
581 frbx.show()
582
583 bt1 = Button(frbx, text="Button 1", size_hint_fill=FILL_HORIZ)
584 frbx.pack_end(bt1)
585 bt1.show()
586
587 bt2 = Button(frbx, text="Button 2", size_hint_fill=FILL_HORIZ)
588 frbx.pack_end(bt2)
589 bt2.show()
590
591 bt3 = Button(frbx, text="Test Button (MOUSE CLICK or KEY)",
592 size_hint_fill=FILL_HORIZ)
593 frbx.pack_end(bt3)
594 bt3.show()
595
596 bt4 = Button(frbx, text="Button 4", size_hint_fill=FILL_HORIZ)
597 frbx.pack_end(bt4)
598 bt4.show()
599
600
601 # second frame
602 fr = Frame(bx, text="Focus Options for a TEST button",
603 size_hint_fill=FILL_BOTH)
604 bx.pack_end(fr)
605 fr.show()
606
607 frbx = Box(fr, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
608 fr.content = frbx
609 frbx.show()
610
611 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.",
612 size_hint_expand=EXPAND_HORIZ)
613 frbx.pack_end(lbl)
614 lbl.show()
615
616 rdg = Radio(frbx, state_value=ELM_FOCUS_MOVE_POLICY_CLICK,
617 text="Focus Move Pollicy Mouse Click",
618 size_hint_align=(0.0,0.5))
619 frbx.pack_end(rdg)
620 rdg.show()
621 rdg.callback_changed_add(_move_policy_changed_cb, bt3, "(MOUSE CLICK or KEY)")
622
623 rd = Radio(frbx, state_value=ELM_FOCUS_MOVE_POLICY_IN,
624 text="Focus Move Policy Mouse In",
625 size_hint_align=(0.0,0.5))
626 frbx.pack_end(rd)
627 rd.group_add(rdg)
628 rd.show()
629 rd.callback_changed_add(_move_policy_changed_cb, bt3, "(MOUSE IN or KEY))")
630
631 rd = Radio(frbx, state_value=ELM_FOCUS_MOVE_POLICY_KEY_ONLY,
632 text="Focus Move Pollicy Key Only",
633 size_hint_align=(0.0,0.5))
634 frbx.pack_end(rd)
635 rd.group_add(rdg)
636 rd.show()
637 rd.callback_changed_add(_move_policy_changed_cb, bt3, "(KEY ONLY)")
638
639 # show the win
640 bt1.focus = True
641 win.show()
642
643
556if __name__ == "__main__": 644if __name__ == "__main__":
557 win = StandardWindow("test", "python-elementary test application", 645 win = StandardWindow("test", "python-elementary test application",
558 size=(320,520)) 646 size=(320,520))
@@ -576,7 +664,9 @@ if __name__ == "__main__":
576 ("Focus 2", focus2_clicked), 664 ("Focus 2", focus2_clicked),
577 ("Focus 3", focus3_clicked), 665 ("Focus 3", focus3_clicked),
578 ("Focus 4", focus4_clicked), 666 ("Focus 4", focus4_clicked),
579 ("Focus Custom", focus5_clicked)] 667 ("Focus Custom", focus5_clicked),
668 ("Focus Move Policy", focus6_clicked),
669 ]
580 670
581 li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH) 671 li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
582 box0.pack_end(li) 672 box0.pack_end(li)