From 0ed61d0b6c9ccbc3add59fb70b7c24e9bb587e9e Mon Sep 17 00:00:00 2001 From: Kai Huuhko Date: Sun, 14 Apr 2013 20:37:20 +0000 Subject: [PATCH] Elementary: Add a simple test for floating objects. --- examples/elementary/test.py | 4 ++ examples/elementary/test_floating.py | 65 ++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 examples/elementary/test_floating.py diff --git a/examples/elementary/test.py b/examples/elementary/test.py index d6890f3..39619f6 100755 --- a/examples/elementary/test.py +++ b/examples/elementary/test.py @@ -42,6 +42,7 @@ from test_fileselector import fileselector_clicked, fileselector_button_clicked, fileselector_entry_clicked from test_flip import flip_clicked, flip_interactive_clicked from test_flipselector import flipselector_clicked +from test_floating import floating_clicked from test_frame import frame_clicked from test_gengrid import gengrid_clicked from test_genlist import genlist_clicked, genlist2_clicked, genlist3_clicked, genlist4_clicked, genlist5_clicked @@ -162,6 +163,9 @@ items = [ ("Genlist Sorted", genlist4_clicked), ("Genlist Iteration", genlist5_clicked), ("Gengrid", gengrid_clicked), + ]), + ("Miscellaneous", [ + ("Floating Objects", floating_clicked), ]), ("Naviframe", [ ("Naviframe", naviframe_clicked), diff --git a/examples/elementary/test_floating.py b/examples/elementary/test_floating.py new file mode 100644 index 0000000..3def0ea --- /dev/null +++ b/examples/elementary/test_floating.py @@ -0,0 +1,65 @@ +from math import sin + +from efl import elementary +from efl.elementary.window import StandardWindow +from efl.elementary.genlist import Genlist, GenlistItem, GenlistItemClass, \ + ELM_GENLIST_ITEM_NONE +from efl.elementary.icon import Icon +from efl.ecore import Animator, loop_time_get +from efl.evas import EVAS_ASPECT_CONTROL_VERTICAL, EVAS_HINT_EXPAND, \ + EVAS_HINT_FILL + +class ItemClass(GenlistItemClass): + def text_get(self, obj, part, *args, **kwargs): + return "Item #{0}".format(args[0]) + + def content_get(self, obj, part, *args, **kwargs): + ic = Icon(obj) + ic.file = "images/logo_small.png" + ic.size_hint_aspect = EVAS_ASPECT_CONTROL_VERTICAL, 1, 1 + return ic + +def gl_sel_cb(obj, event_info, *args): + print("sel item data [{0}] on genlist obj [{1}], item [{2}]".format(data, obj, event_info)) + +def anim(*args, **kwargs): + gl = args[0] + y = 0 + x = (sin(loop_time_get()) * 500) + gl.move(x, y) + + return True + +def del_cb(obj, *args, **kwargs): + ani = args[0] + ani.delete() + +def floating_clicked(obj): + win = StandardWindow("floating", "Floating") + win.autodel = True + + gl = Genlist(win) + gl.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + gl.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL + gl.move(800, 0) + gl.size = 480, 800 + gl.show() + + for i in range(20): + GenlistItem(ItemClass(), None, ELM_GENLIST_ITEM_NONE, gl_sel_cb, i).append_to(gl) + + win.size = 480, 800 + win.show() + + ani = Animator(anim, gl) + win.callback_delete_request_add(del_cb, ani) + if obj is None: + win.callback_delete_request_add(lambda o: elementary.exit()) + +if __name__ == "__main__": + elementary.init() + + floating_clicked(None) + + elementary.run() + elementary.shutdown()