davemds pushed a commit to branch python-efl-1.8.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=e45f41b936dc586127503661a3ad1fb7d6f90cf1

commit e45f41b936dc586127503661a3ad1fb7d6f90cf1
Author: davemds <d...@gurumeditation.it>
Date:   Mon Dec 16 20:51:26 2013 +0100

    Python-EFL: 5 new tests about Focus.
    
    Also add some missed values to Elm_Object_Focus_Direction enum.
---
 efl/elementary/enums.pxd                  |   4 +
 efl/elementary/object.pyx                 |  27 ++
 examples/elementary/test.py               |   7 +
 examples/elementary/test_focus.py         | 596 ++++++++++++++++++++++++++++++
 examples/elementary/test_focus_custom.edc | 389 +++++++++++++++++++
 examples/elementary/test_focus_custom.edj | Bin 0 -> 33585 bytes
 6 files changed, 1023 insertions(+)

diff --git a/efl/elementary/enums.pxd b/efl/elementary/enums.pxd
index 9db9ac9..415207f 100644
--- a/efl/elementary/enums.pxd
+++ b/efl/elementary/enums.pxd
@@ -145,6 +145,10 @@ cdef extern from "Elementary.h":
     ctypedef enum Elm_Focus_Direction:
         ELM_FOCUS_PREVIOUS
         ELM_FOCUS_NEXT
+        ELM_FOCUS_UP
+        ELM_FOCUS_DOWN
+        ELM_FOCUS_RIGHT
+        ELM_FOCUS_LEFT
 
     ctypedef enum Elm_Genlist_Item_Type:
         ELM_GENLIST_ITEM_NONE
diff --git a/efl/elementary/object.pyx b/efl/elementary/object.pyx
index 363da9a..cc62e05 100644
--- a/efl/elementary/object.pyx
+++ b/efl/elementary/object.pyx
@@ -78,6 +78,29 @@ Focus direction
 
     Focus next
 
+.. data:: ELM_FOCUS_UP
+
+    Focus up
+
+    .. versionadded:: 1.8.1
+
+.. data:: ELM_FOCUS_DOWN
+
+    Focus down
+
+    .. versionadded:: 1.8.1
+
+.. data:: ELM_FOCUS_RIGHT
+
+    Focus right
+
+    .. versionadded:: 1.8.1
+
+.. data:: ELM_FOCUS_LEFT
+
+    Focus left
+
+    .. versionadded:: 1.8.1
 
 .. _Elm_Input_Event_Type:
 
@@ -221,6 +244,10 @@ cimport enums
 
 ELM_FOCUS_PREVIOUS = enums.ELM_FOCUS_PREVIOUS
 ELM_FOCUS_NEXT = enums.ELM_FOCUS_NEXT
+ELM_FOCUS_UP = enums.ELM_FOCUS_UP
+ELM_FOCUS_DOWN = enums.ELM_FOCUS_DOWN
+ELM_FOCUS_RIGHT = enums.ELM_FOCUS_RIGHT
+ELM_FOCUS_LEFT = enums.ELM_FOCUS_LEFT
 
 EVAS_CALLBACK_KEY_DOWN = evasenums.EVAS_CALLBACK_KEY_DOWN
 EVAS_CALLBACK_KEY_UP = evasenums.EVAS_CALLBACK_KEY_UP
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index 54bb4c5..3146930 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -114,6 +114,13 @@ items = [
             ("Entry Anchor", "test_entry", "entry_anchor_clicked"),
             ("MultiButtonEntry", "test_multibuttonentry", 
"multibuttonentry_clicked"),
         ]),
+         ("Focus", [
+            ("Focus", "test_focus", "focus_clicked"),
+            ("Focus 2", "test_focus", "focus2_clicked"),
+            ("Focus 3", "test_focus", "focus3_clicked"),
+            ("Focus 4", "test_focus", "focus4_clicked"),
+            ("Focus Custom", "test_focus", "focus5_clicked"),
+        ]),
          ("Geographic", [
             ("Map", "test_map", "map_clicked"),
         ]),
diff --git a/examples/elementary/test_focus.py 
b/examples/elementary/test_focus.py
new file mode 100644
index 0000000..d187e3b
--- /dev/null
+++ b/examples/elementary/test_focus.py
@@ -0,0 +1,596 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+import os
+
+from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
+from efl import elementary
+from efl import edje
+from efl.elementary.window import StandardWindow
+from efl.elementary.box import Box
+from efl.elementary.bubble import Bubble
+from efl.elementary.button import Button
+from efl.elementary.label import Label
+from efl.elementary.layout import Layout
+from efl.elementary.list import List
+from efl.elementary.frame import Frame
+from efl.elementary.separator import Separator
+from efl.elementary.scroller import Scroller
+from efl.elementary.spinner import Spinner
+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.configuration import Configuration
+from efl.elementary.theme import theme_overlay_add
+
+EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
+EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
+FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
+FILL_HORIZ = EVAS_HINT_FILL, 0.5
+
+script_path = os.path.dirname(os.path.abspath(__file__))
+edj_file = os.path.join(script_path, "test.edj")
+conf = Configuration()
+
+# Focus
+def _tb_sel(tb, item):
+    print(item)
+    print(item.text)
+
+def focus_clicked(obj, item=None):
+    win = StandardWindow("focus", "Focus", autodel=True, size=(800,600))
+    
+    win.focus_highlight_enabled = True
+
+    tbx = Box(win, size_hint_weight=EXPAND_BOTH)
+    win.resize_object_add(tbx)
+    tbx.show()
+
+    ### Toolbar
+    tbar = Toolbar(win, shrink_mode=ELM_TOOLBAR_SHRINK_MENU,
+                   size_hint_align=(EVAS_HINT_FILL,0.0))
+
+    tb_it = tbar.item_append("document-print", "Hello", _tb_sel)
+    tb_it.disabled = True
+    tb_it = tbar.item_append("folder-new", "World", _tb_sel)
+    tb_it = tbar.item_append("object-rotate-right", "H", _tb_sel)
+    tb_it = tbar.item_append("mail-send", "Comes", _tb_sel)
+    tb_it = tbar.item_append("clock", "Elementary", _tb_sel)
+
+    tb_it = tbar.item_append("refresh", "Menu", _tb_sel)
+    tb_it.menu = True
+    tbar.menu_parent = win
+    menu = tb_it.menu
+
+    menu.item_add(None, "Shrink", "edit-cut", _tb_sel)
+    menu_it = menu.item_add(None, "Mode", "edit-copy", _tb_sel)
+    menu.item_add(menu_it, "is set to", "edit-paste", _tb_sel)
+    menu.item_add(menu_it, "or to", "edit-paste", _tb_sel)
+    menu.item_add(None, "Menu", "edit-delete", _tb_sel)
+
+    tbx.pack_end(tbar)
+    tbar.show()
+
+
+    mainbx = Box(win, horizontal=True, size_hint_weight=EXPAND_BOTH)
+    tbx.pack_end(mainbx)
+    mainbx.show()
+
+    ## First Col
+    bx = Box(win, size_hint_weight=EXPAND_BOTH)
+    mainbx.pack_end(bx)
+    bx.show()
+
+    lb = Label(win, text="<b>Use Tab or Shift+Tab<br/>or Arrow keys</b>",
+                    size_hint_align=FILL_BOTH)
+    bx.pack_end(lb)
+    lb.show()
+
+    tg = Check(win, style="toggle")
+    tg.part_text_set("on", "Yes")
+    tg.part_text_set("off", "No")
+    bx.pack_end(tg)
+    tg.show()
+    
+    en = Entry(win, scrollable=True, single_line=True, text="This is a single 
line",
+                    size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    bx.pack_end(en)
+    en.show()
+
+    #
+    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
+    bx.pack_end(bx2)
+    bx2.show()
+
+    for i in range(2):
+        bt = Button(win, text="Box", size_hint_align=FILL_BOTH, disabled=(i % 
2))
+        bx2.pack_end(bt)
+        bt.show()
+
+    sc = Scroller(win, bounce=(True,True), content_min_limit=(1,1),
+                  size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+    bx2.pack_end(sc)
+    sc.show()
+
+    bt = Button(win, text="Scroller", size_hint_align=FILL_BOTH)
+    sc.content = bt
+    bt.show()
+
+    #
+    bt = Button(win, text="Box", size_hint_align=FILL_BOTH)
+    bx.pack_end(bt)
+    bt.show()
+
+    #
+    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
+    bx.pack_end(bx2)
+    bx2.show()
+    
+    for i in range(2):
+        bx3 = Box(win, size_hint_align=FILL_BOTH)
+        bx2.pack_end(bx3)
+        bx3.show()
+
+        for j in range(3):
+            bt = Button(win, text="Box", size_hint_align=FILL_BOTH)
+            bx3.pack_end(bt)
+            bt.show()
+    
+
+    sc = Scroller(win, bounce=(False, True), content_min_limit=(1,0),
+                  size_hint_align=FILL_BOTH, size_hint_weight=EXPAND_BOTH)
+    sc.content_min_limit=(1,1)
+    bx2.pack_end(sc)
+    sc.show()
+
+    bx3 = Box(win, size_hint_align=FILL_BOTH)
+    sc.content = bx3
+    bx3.show()
+
+    for i in range(5):
+        bt = Button(win, text="BX Scroller", size_hint_align=FILL_BOTH)
+        bx3.pack_end(bt)
+        bt.show()
+
+
+    ## Second Col
+    ly = Layout(win, size_hint_weight=EXPAND_BOTH)
+    ly.file = edj_file, "twolines"
+    mainbx.pack_end(ly)
+    ly.show()
+
+    bx2 = Box(win, horizontal=True, size_hint_align=FILL_BOTH)
+    ly.part_content_set("element1", bx2)
+    bx2.show()
+
+    for i in range(3):
+        bt = Button(win, text="Layout", size_hint_align=FILL_BOTH)
+        bx2.pack_end(bt)
+        bt.show()
+        bx2.focus_custom_chain_prepend(bt)
+
+    bx2 = Box(win, size_hint_align=FILL_BOTH)
+    ly.part_content_set("element2", bx2)
+    bx2.show()
+
+    bt = Button(win, text="Disable", size_hint_align=FILL_BOTH)
+    bt.callback_clicked_add(lambda b: b.disabled_set(True))
+    bx2.pack_end(bt)
+    bt.show()
+    bx2.focus_custom_chain_prepend(bt)
+
+    bt2 = Button(win, text="Enable", size_hint_align=FILL_BOTH)
+    bt2.callback_clicked_add(lambda b, b1: b1.disabled_set(False), bt)
+    bx2.pack_end(bt2)
+    bt2.show()
+    bx2.focus_custom_chain_append(bt2)
+
+    ## Third Col
+    bx = Box(win, size_hint_weight=EXPAND_BOTH)
+    mainbx.pack_end(bx)
+    bx.show()
+
+    fr = Frame(win, text="Frame", )
+    bx.pack_end(fr)
+    fr.show()
+
+    tb = Table(win, size_hint_weight=EXPAND_BOTH)
+    fr.content = tb
+    tb.show()
+
+    for j in range(1):
+        for i in range(2):
+            bt = Button(win, text="Table", size_hint_align=FILL_BOTH, 
size_hint_weight=EXPAND_BOTH)
+            tb.pack(bt, i, j, 1, 1)
+            bt.show()
+
+    #
+    fr = Bubble(win, text="Bubble", size_hint_align=FILL_BOTH, 
size_hint_weight=EXPAND_BOTH)
+    bx.pack_end(fr)
+    fr.show()
+
+    tb = Table(win,  size_hint_weight=EXPAND_BOTH)
+    fr.content = tb
+    tb.show()
+
+    for j in range(2):
+        for i in range(1):
+            bt = Button(win, text="Table", size_hint_align=FILL_BOTH, 
size_hint_weight=EXPAND_BOTH)
+            tb.pack(bt, i, j, 1, 1)
+            bt.show()
+
+
+    win.show()
+
+
+# Focus 2
+def _focus_obj(bt, newfocus):
+    print newfocus
+    newfocus.focus = True
+
+def _focus_layout_part(bt, layout):
+    newfocus = layout.edje.part_object_get("sky")
+    print newfocus
+    newfocus.focus = True
+    
+
+def focus2_clicked(obj, item=None):
+    win = StandardWindow("focus2", "Focus 2", autodel=True, size=(400, 400))
+
+    win.focus_highlight_enabled = True
+
+    bx = Box(win, size_hint_weight=EXPAND_BOTH)
+    win.resize_object_add(bx)
+    bx.show()
+
+    PARENT = bx
+
+    en = Entry(PARENT, scrollable=True, single_line=True,
+               text="Entry that should get focus",
+               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    bx.pack_end(en)
+    en.show()
+    
+    bt = Button(PARENT, text="Give focus to entry")
+    bt.callback_clicked_add(_focus_obj, en)
+    bx.pack_end(bt)
+    bt.show()
+   
+    ly = Layout(PARENT, size_hint_weight=EXPAND_BOTH)
+    ly.file = edj_file, "layout"
+    bx.pack_end(ly)
+    ly.show()
+
+    bt1 = bt = Button(ly, text="Button 1")
+    ly.part_content_set("element1", bt)
+
+    en1 = Entry(ly, scrollable=True, single_line=True,
+                text="Scrolled Entry that should get focus",
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ )
+    ly.part_content_set("element2", en1)
+
+    bt = Button(ly, text="Button 2")
+    ly.part_content_set("element3", bt)
+
+
+    bt = Button(PARENT, text="Give focus to layout",
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    bt.callback_clicked_add(_focus_obj, ly)
+    bx.pack_end(bt)
+    bt.show()
+
+    bt = Button(PARENT, text="Give focus to layout part",
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    bt.callback_clicked_add(_focus_layout_part, ly)
+    bx.pack_end(bt)
+    bt.show()
+
+    bt = Button(PARENT, text="Give focus to layout 'Button 1'",
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    bt.callback_clicked_add(_focus_obj, bt1)
+    bx.pack_end(bt)
+    bt.show()
+
+    bt = Button(PARENT, text="Give focus to layout 'Entry'",
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    bt.callback_clicked_add(_focus_obj, en1)
+    bx.pack_end(bt)
+    bt.show()
+
+    bt.focus_next_object_set(en, ELM_FOCUS_DOWN)
+    en.focus_next_object_set(bt, ELM_FOCUS_UP)
+    win.show()
+
+
+# Focus 3
+focused = None
+def _focused_cb(obj):
+    global focused
+    print obj
+    focused = obj
+
+def _unfocused_cb(obj):
+    global focused
+    print obj
+    focused = None
+
+def _add_cb(bt, win, bx):
+    en = Entry(win, scrollable=True, single_line=True, text="An entry",
+               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    en.callback_focused_add(_focused_cb)
+    en.callback_unfocused_add(_unfocused_cb)
+    bx.pack_start(en)
+    en.show()
+
+def _del_cb(bt, bx):
+    if focused:
+        focused.delete()
+
+def _hide_cb(bt):
+    if focused:
+        focused.hide()
+
+def focus3_clicked(obj, item=None):
+    win = StandardWindow("focus3", "Focus 3", autodel=True, size=(320, 480))
+
+    win.focus_highlight_enabled = True
+
+    bx = Box(win, size_hint_weight=EXPAND_BOTH)
+    win.resize_object_add(bx)
+    bx.show()
+
+    en = Entry(win, scrollable=True, single_line=True, text="An entry",
+               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    en.callback_focused_add(_focused_cb)
+    en.callback_unfocused_add(_unfocused_cb)
+    bx.pack_end(en)
+    en.show()
+
+    bt = Button(win, text="Add", focus_allow=False,
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    bt.callback_clicked_add(_add_cb, win, bx)
+    bx.pack_end(bt)
+    bt.show()
+
+    bt = Button(win, text="Del", focus_allow=False,
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    bt.callback_clicked_add(_del_cb, bx)
+    bx.pack_end(bt)
+    bt.show()
+
+    bt = Button(win, text="hide", focus_allow=False,
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
+    bt.callback_clicked_add(_hide_cb)
+    bx.pack_end(bt)
+    bt.show()
+
+    win.show()
+
+
+# Focus 4
+def _highlight_enabled_cb(chk, win):
+    conf.focus_highlight_enabled = chk.state
+
+def _highlight_animate_cb(chk, win):
+    conf.focus_highlight_animate = chk.state
+
+def _win_highlight_enabled_cb(chk, win):
+    win.focus_highlight_enabled = chk.state
+
+def _win_highlight_animate_cb(chk, win):
+    win.focus_highlight_animate = chk.state
+
+def _custom_chain_cb(chk, bx):
+    print chk.state
+    if chk.state is True:
+        i = 0
+        custom_chain = []
+        for child in bx.children:
+            print child
+            if i == 0:
+                c = child   
+                custom_chain.append(child)
+                bx.focus_custom_chain_set(custom_chain)
+            elif i == 1:
+                bx.focus_custom_chain_prepend(child, c)
+            elif i == 2:
+                bx.focus_custom_chain_append(child, c)
+                c = child
+            elif i == 3:
+                bx.focus_custom_chain_prepend(child, c);
+            i += 1
+        
+    else:
+        bx.focus_custom_chain_unset()
+
+def focus4_clicked(obj, item=None):
+    win = StandardWindow("focus4", "Focus 4", autodel=True, size=(320, 320))
+
+    win.focus_highlight_enabled = True
+    win.focus_highlight_animate = True
+
+    fr = Frame(win, style="pad_large",
+              size_hint_weight=EXPAND_BOTH);
+    win.resize_object_add(fr)
+    fr.show()
+
+    # First Example - Using Focus Highlight
+    bx = Box(fr)
+    fr.content = bx
+    bx.show()
+
+    tg = Check(bx, text="Focus Highlight Enabled (Config)", state=True,
+               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+    tg.callback_changed_add(_highlight_enabled_cb, win)
+
+    bx.pack_end(tg)
+    tg.show()
+
+    tg = Check(bx, text="Focus Highlight Animate (Config)", state=True,
+               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+    tg.callback_changed_add(_highlight_animate_cb, win)
+    bx.pack_end(tg)
+    tg.show()
+
+    tg = Check(bx, text="Focus Highlight Enabled (Win)", state=True,
+               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+    tg.callback_changed_add(_win_highlight_enabled_cb, win)
+    bx.pack_end(tg)
+    tg.show()
+
+    tg = Check(bx, text="Focus Highlight Animate (Win)", state=True,
+               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+    tg.callback_changed_add(_win_highlight_animate_cb, win)
+    bx.pack_end(tg)
+    tg.show()
+
+    sp = Separator(win, horizontal=True,
+                   size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+    bx.pack_end(sp)
+    sp.show()
+
+    # Second Example - Using Custom Chain
+    lb = Label(bx, text="Custom Chain: Please use tab key to check",
+               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+    bx.pack_end(lb)
+    lb.show()
+
+    bx2 = Box(bx, horizontal=True,
+              size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+    bx.pack_end(bx2)
+    bx2.show()
+
+    bt1 = Button(bx2, text="Button 1",
+                 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+    bx2.pack_end(bt1)
+    bt1.show()
+    
+    bt2 = Button(bx2, text="Button 2",
+                 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+    bx2.pack_end(bt2)
+    bt2.show()
+    
+    bt3 = Button(bx2, text="Button 3",
+                 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+    bx2.pack_end(bt3)
+    bt3.show()
+    
+    bt4 = Button(bx2, text="Button 4",
+                 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+    bx2.pack_end(bt4)
+    bt4.show()
+
+    bx2.focus_custom_chain = [bt2, bt1, bt4, bt3]
+   
+    tg = Check(bx, text="Custom Chain", state=False, 
+               size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+    tg.callback_changed_add(_custom_chain_cb, bx)
+    bx.pack_end(tg)
+    tg.show()
+   
+
+    win.show()
+
+
+# Focus 5 (custom)
+def _glow_effect_on_cb(btn, win, chk):
+    if chk.state:
+        win.focus_highlight_style = "glow_effect"
+
+def _glow_effect_off_cb(btn, win, chk):
+    if chk.state:
+        win.focus_highlight_style = "glow"
+
+def focus5_clicked(obj, item=None):
+
+    theme_overlay_add(os.path.join(script_path, "test_focus_custom.edj"))
+
+    win = StandardWindow("focus5", "Focus Custom", autodel=True, size=(320, 
320))
+    win.focus_highlight_enabled = True
+    win.focus_highlight_animate = True
+    win.focus_highlight_style = "glow"
+
+    fr = Frame(win, style="pad_large",
+              size_hint_weight=EXPAND_BOTH);
+    win.resize_object_add(fr)
+    fr.show()
+
+    bx = Box(fr)
+    fr.content = bx
+    bx.show()
+
+    chk = Check(bx, text='Enable glow effect on "Glow" Button', state=True,
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+    bx.pack_end(chk)
+    chk.show()
+
+    spinner = Spinner(bx, size_hint_weight=EXPAND_HORIZ, 
size_hint_align=FILL_BOTH)
+    bx.pack_end(spinner)
+    spinner.show()
+
+    bt = Button(bx, text="Glow Button",
+                size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+    bt.callback_focused_add(_glow_effect_on_cb, win, chk)
+    bt.callback_unfocused_add(_glow_effect_off_cb, win, chk)
+    bx.pack_end(bt)
+    bt.show()
+
+    sp = Separator(bx, horizontal=True,
+                   size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
+    bx.pack_end(sp)
+    sp.show()
+
+    bx2 = Box(bx, horizontal=True,
+              size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+    bx.pack_end(bx2)
+    bx2.show()
+
+    for i in range (1, 5):
+        bt = Button(bx2, text="Button %d" % i,
+                    size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+        bx2.pack_end(bt)
+        bt.show()
+
+    win.show()
+
+
+if __name__ == "__main__":
+    elementary.init()
+    win = StandardWindow("test", "python-elementary test application",
+        size=(320,520))
+    win.callback_delete_request_add(lambda o: elementary.exit())
+
+    box0 = Box(win, size_hint_weight=EXPAND_BOTH)
+    win.resize_object_add(box0)
+    box0.show()
+
+    lb = Label(win)
+    lb.text_set("Please select a test from the list below<br>"
+                 "by clicking the test button to show the<br>"
+                 "test window.")
+    lb.show()
+
+    fr = Frame(win, text="Information", content=lb)
+    box0.pack_end(fr)
+    fr.show()
+
+    items = [("Focus", focus_clicked),
+             ("Focus 2", focus2_clicked),
+             ("Focus 3", focus3_clicked),
+             ("Focus 4", focus4_clicked),
+             ("Focus Custom", focus5_clicked)]
+
+    li = List(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+    box0.pack_end(li)
+    li.show()
+
+    for item in items:
+        li.item_append(item[0], callback=item[1])
+
+    li.go()
+
+    win.show()
+    elementary.run()
+    elementary.shutdown()
diff --git a/examples/elementary/test_focus_custom.edc 
b/examples/elementary/test_focus_custom.edc
new file mode 100644
index 0000000..caa4d9c
--- /dev/null
+++ b/examples/elementary/test_focus_custom.edc
@@ -0,0 +1,389 @@
+//  c1 - c4
+//  |base|
+//  |    |
+//  c3 - c2
+#define OUTER_BASE_PARTS(w, h)               \
+   part { name: "base"; type: SPACER;        \
+      description {                          \
+         state: "default" 0.0; } }           \
+   part { name: "c1"; type: SPACER;          \
+      description { state: "default" 0.0;    \
+         rel1.to: "base";                    \
+         rel2.to: "base";                    \
+         rel2.relative: 0 0;                 \
+         align: 1 1;                         \
+         min: w h;                           \
+         max: w h; } }                       \
+   part { name: "c3"; type: SPACER;          \
+      description { state: "default" 0.0;    \
+         rel1.to: "base";                    \
+         rel2.to: "base";                    \
+         rel1.relative: 0 1;                 \
+         rel2.relative: 0 1;                 \
+         align: 1 0;                         \
+         min: w h;                           \
+         max: w h; } }                       \
+   part { name: "c4"; type: SPACER;          \
+      description { state: "default" 0.0;    \
+         rel1.to: "base";                    \
+         rel2.to: "base";                    \
+         rel1.relative: 1 0;                 \
+         rel2.relative: 1 0;                 \
+         min: w h;                           \
+         max: w h; } }                       \
+   part { name: "c2"; type: SPACER;          \
+      mouse_events: 0;                       \
+      description { state: "default" 0.0;    \
+         rel1.to: "base";                    \
+         rel1.relative: 1 1;                 \
+         rel2.to: "base";                    \
+         rel2.relative: 1 1;                 \
+         align: 0 0;                         \
+         min: w h;                           \
+         max: w h; } }
+
+collections {
+   group { name: "elm/focus_highlight/top/glow";
+      images {
+         image: "border6.png" COMP;
+      }
+      data.item: "animate" "on";
+
+      script {
+         public src_x, src_y, src_w, src_h;
+         public diffx, diffy, diffw, diffh;
+         public anim_highlight(val, Float:pos) {
+            new x, y, w, h, dx, dy, dw, dh;
+
+            dx = round(float_mul(float(get_int(diffx)), pos));
+            x = get_int(src_x) + dx;
+            dy = round(float_mul(float(get_int(diffy)), pos));
+            y = get_int(src_y) + dy;
+            dw = round(float_mul(float(get_int(diffw)), pos));
+            w = get_int(src_w) + dw;
+            dh = round(float_mul(float(get_int(diffh)), pos));
+            h = get_int(src_h) + dh;
+
+            update_offset(x, y, w, h);
+
+            if(pos >= 1.0) {
+               emit("elm,action,focus,anim,end", "");
+               set_state(PART:"highlight", "default", 0.0);
+            }
+         }
+         public update_offset(x, y, w, h) {
+            set_state_val(PART:"base", STATE_REL1_OFFSET, x, y);
+            set_state_val(PART:"base", STATE_REL2_OFFSET, x + w, y + h);
+         }
+         public message(Msg_Type:type, id, ...) {
+            if((type == MSG_INT_SET) && (id == 1)) {
+               new x1, y1, w1, h1, x2, y2, w2, h2;
+
+               x1 = getarg(2);
+               y1 = getarg(3);
+               w1 = getarg(4);
+               h1 = getarg(5);
+               x2 = getarg(6);
+               y2 = getarg(7);
+               w2 = getarg(8);
+               h2 = getarg(9);
+
+               set_int(src_x, x1);
+               set_int(src_y, y1);
+               set_int(src_w, w1);
+               set_int(src_h, h1);
+               set_int(diffx, x2 - x1);
+               set_int(diffy, y2 - y1);
+               set_int(diffw, w2 - w1);
+               set_int(diffh, h2 - h1);
+
+               custom_state(PART:"base", "default", 0.0);
+               set_state_val(PART:"base", STATE_REL1, 0.0, 0.0);
+               set_state_val(PART:"base", STATE_REL2, 0.0, 0.0);
+               update_offset(x1, y1, w1, h1);
+               set_state(PART:"base", "custom", 0.0);
+               anim(0.2, "anim_highlight", 0);
+            }
+         }
+      } //script ends
+      parts {
+         OUTER_BASE_PARTS(12, 12);
+         part { name: "highlight"; type: IMAGE;
+            mouse_events: 0;
+            description { state: "default" 0.0;
+               image.normal: "border6.png";
+               image.border: 20 20 20 20;
+               rel1.to: "c1";
+               rel2.to: "c2";
+            }
+            description { state: "visible" 0.0;
+               inherit: "default" 0.0;
+              }
+            description { state: "invisible" 0.0;
+               inherit: "default" 0.0;
+               visible: 0;
+            }
+         }
+      } //parts ends
+      programs {
+         program { name: "show";
+            signal: "elm,action,focus,show";
+            source: "elm";
+            action: ACTION_STOP;
+            target: "hide";
+            target: "hide_start";
+            target: "hide_end";
+            after: "show_start";
+         }
+         program { name: "show_start";
+            action: STATE_SET "visible" 0.0;
+            transition: SIN 0.2;
+            target: "highlight";
+            after: "show_end";
+         }
+         program { name: "show_end";
+            action: SIGNAL_EMIT "elm,action,focus,show,end" "";
+         }
+         program { name: "hide";
+            signal: "elm,action,focus,hide";
+            source: "elm";
+            action: ACTION_STOP;
+            target: "show";
+            target: "show_start";
+            target: "show_end";
+            after: "hide_start";
+         }
+         program { name: "hide_start";
+            action: STATE_SET "invisible" 0.0;
+            transition: SIN 0.2;
+            target: "highlight";
+            after: "hide_end";
+         }
+         program { name: "hide_end";
+            action: SIGNAL_EMIT "elm,action,focus,hide,end" "";
+         }
+      } //programs ends
+   } //group ends
+
+   group { name: "elm/focus_highlight/top/glow_effect";
+      inherit: "elm/focus_highlight/top/glow";
+      images {
+         image: "border.png" COMP;
+         image: "border2.png" COMP;
+         image: "border3.png" COMP;
+         image: "border4.png" COMP;
+         image: "border5.png" COMP;
+         image: "border6.png" COMP;
+      }
+      data.item: "animate" "on";
+
+      script {
+         public src_x, src_y, src_w, src_h;
+         public diffx, diffy, diffw, diffh;
+         public anim_highlight(val, Float:pos) {
+            new x, y, w, h, dx, dy, dw, dh, Float:p;
+            p = 1.0 - ((1.0 - pos) * (1.0 - pos) * (1.0 - pos));
+
+            dx = round(float_mul(float(get_int(diffx)), p));
+            x = get_int(src_x) + dx;
+            dy = round(float_mul(float(get_int(diffy)), p));
+            y = get_int(src_y) + dy;
+            dw = round(float_mul(float(get_int(diffw)), p));
+            w = get_int(src_w) + dw;
+            dh = round(float_mul(float(get_int(diffh)), p));
+            h = get_int(src_h) + dh;
+
+            update_offset(x, y, w, h);
+
+            if(pos >= 1.0) {
+               emit("elm,action,focus,anim,end", "");
+               set_state(PART:"highlight", "default", 0.0);
+               emit("dim", "");
+            }
+         }
+         public update_offset(x, y, w, h) {
+            set_state_val(PART:"base", STATE_REL1_OFFSET, x, y);
+            set_state_val(PART:"base", STATE_REL2_OFFSET, x + w, y + h);
+         }
+         public message(Msg_Type:type, id, ...) {
+            if((type == MSG_INT_SET) && (id == 1)) {
+               new x1, y1, w1, h1, x2, y2, w2, h2;
+
+               x1 = getarg(2);
+               y1 = getarg(3);
+               w1 = getarg(4);
+               h1 = getarg(5);
+               x2 = getarg(6);
+               y2 = getarg(7);
+               w2 = getarg(8);
+               h2 = getarg(9);
+
+               set_int(src_x, x1);
+               set_int(src_y, y1);
+               set_int(src_w, w1);
+               set_int(src_h, h1);
+               set_int(diffx, x2 - x1);
+               set_int(diffy, y2 - y1);
+               set_int(diffw, w2 - w1);
+               set_int(diffh, h2 - h1);
+
+               custom_state(PART:"base", "default", 0.0);
+               set_state_val(PART:"base", STATE_REL1, 0.0, 0.0);
+               set_state_val(PART:"base", STATE_REL2, 0.0, 0.0);
+               update_offset(x1, y1, w1, h1);
+               set_state(PART:"base", "custom", 0.0);
+               anim(0.2, "anim_highlight", 0);
+            }
+         }
+      } //script ends
+      parts {
+         part { name: "highlight"; type: IMAGE;
+            mouse_events: 0;
+            description { state: "default" 0.0;
+               image.normal: "border6.png";
+               image.border: 16 16 16 16;
+               rel1.to: "c1";
+               rel2.to: "c2";
+               visible: 1;
+            }
+            description { state: "visible" 0.0;
+               inherit: "default" 0.0;
+            }
+            description { state: "visible" 0.1;
+               inherit: "visible" 0.0;
+               image.normal: "border2.png";
+               image.border: 18 18 18 18;
+            }
+            description { state: "visible" 0.2;
+               inherit: "visible" 0.0;
+               image.normal: "border3.png";
+               image.border: 19 19 19 19;
+            }
+            description { state: "visible" 0.3;
+               inherit: "visible" 0.0;
+               image.normal: "border4.png";
+               image.border: 20 20 20 20;
+            }
+            description { state: "visible" 0.4;
+               inherit: "visible" 0.0;
+               image.normal: "border5.png";
+               image.border: 21 21 21 21;
+            }
+            description { state: "visible" 0.5;
+               inherit: "visible" 0.0;
+               image.normal: "border6.png";
+               image.border: 25 25 25 25;
+            }
+            description { state: "invisible" 0.0;
+               inherit: "default" 0.0;
+               visible: 0;
+            }
+         }
+      }//parts ends
+      programs {
+         program { name: "show";
+            signal: "elm,action,focus,show";
+            source: "elm";
+            action: ACTION_STOP;
+            target: "hide";
+            target: "hide_start";
+            target: "hide_end";
+            after: "show_start";
+         }
+         program { name: "show_start";
+            action: SIGNAL_EMIT "dim" "";
+            after: "show_end";
+         }
+         program { name: "dim_start";
+            signal: "dim";
+            in: 2 0.4;
+            source: "";
+            action: STATE_SET "visible" 0.4;
+            transition: SINUSOIDAL 0.2;
+            target: "highlight";
+            after: "dim1";
+         }
+         program { name: "dim1";
+            action: STATE_SET "visible" 0.3;
+            transition: SINUSOIDAL 0.2;
+            target: "highlight";
+            after: "dim2";
+         }
+         program { name: "dim2";
+            action: STATE_SET "visible" 0.2;
+            transition: SINUSOIDAL 0.2;
+            target: "highlight";
+            after: "dim3";
+         }
+         program { name: "dim3";
+            action: STATE_SET "visible" 0.1;
+            transition: SINUSOIDAL 0.2;
+            target: "highlight";
+            after: "dim_end";
+         }
+         program { name: "dim_end";
+            action: SIGNAL_EMIT "glow" "";
+         }
+         program { name: "glow_start";
+            signal: "glow";
+            source: "";
+            in: 1 0.4;
+            action: STATE_SET "visible" 0.0;
+            transition: SINUSOIDAL 0.2;
+            target: "highlight";
+            after: "glow1";
+         }
+         program { name: "glow1";
+            action: STATE_SET "visible" 0.1;
+            transition: SINUSOIDAL 0.2;
+            target: "highlight";
+            after: "glow2";
+         }
+         program { name: "glow2";
+            action: STATE_SET "visible" 0.2;
+            transition: SINUSOIDAL 0.2;
+            target: "highlight";
+            after: "glow3";
+         }
+         program { name: "glow3";
+            action: STATE_SET "visible" 0.3;
+            transition: SINUSOIDAL 0.2;
+            target: "highlight";
+            after: "glow4";
+         }
+         program { name: "glow4";
+            action: STATE_SET "visible" 0.4;
+            transition: SINUSOIDAL 0.2;
+            target: "highlight";
+            after: "glow5";
+         }
+         program { name: "glow5";
+            action: STATE_SET "visible" 0.5;
+            transition: SINUSOIDAL 0.2;
+            target: "highlight";
+            after: "glow1";
+         }
+         program { name: "show_end";
+            action: SIGNAL_EMIT "elm,action,focus,show,end" "";
+         }
+         program { name: "hide";
+            signal: "elm,action,focus,hide";
+            source: "elm";
+            action: ACTION_STOP;
+            target: "show";
+            target: "show_start";
+            target: "show_end";
+            after: "hide_start";
+         }
+         program { name: "hide_start";
+            action: STATE_SET "invisible" 0.0;
+            transition: LIN 0.2;
+            target: "highlight";
+            after: "hide_end";
+         }
+         program { name: "hide_end";
+            action: SIGNAL_EMIT "elm,action,focus,hide,end" "";
+         }
+      } //programs ends
+   } //group ends
+}
diff --git a/examples/elementary/test_focus_custom.edj 
b/examples/elementary/test_focus_custom.edj
new file mode 100644
index 0000000..d910903
Binary files /dev/null and b/examples/elementary/test_focus_custom.edj differ

-- 


Reply via email to