davemds pushed a commit to branch master. http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=9809eb2739b64b11f0072a353308106dd5a4ece2
commit 9809eb2739b64b11f0072a353308106dd5a4ece2 Author: Dave Andreoli <d...@gurumeditation.it> Date: Sat Jan 23 13:46:43 2016 +0100 New 1.17 API: ELM_GEN[GRID/LIST]_ITEM_SCROLLTO_BOTTOM The grid enum was a bit messed, it was using the list enums, fixed and leave the old one in place for compatibility --- doc/elementary/gengrid.rst | 6 ++ doc/elementary/genlist.rst | 6 ++ efl/elementary/gengrid.py | 8 ++ efl/elementary/gengrid_cdef.pxi | 10 +++ efl/elementary/gengrid_item.pxi | 10 ++- efl/elementary/genlist.py | 1 + efl/elementary/genlist_cdef.pxi | 1 + efl/elementary/genlist_item.pxi | 10 ++- examples/elementary/test_gengrid.py | 139 ++++++++++++++++++++-------------- examples/elementary/test_genlist_1.py | 69 +++++++++-------- 10 files changed, 163 insertions(+), 97 deletions(-) diff --git a/doc/elementary/gengrid.rst b/doc/elementary/gengrid.rst index 9527361..c279329 100644 --- a/doc/elementary/gengrid.rst +++ b/doc/elementary/gengrid.rst @@ -266,6 +266,12 @@ Items' scroll to types Scroll to the middle of viewport +.. data:: ELM_GENGRID_ITEM_SCROLLTO_BOTTOM + + Scroll to the bottom of viewport + + .. versionadded:: 1.17 + .. _Elm_Gengrid_Object_Multi_Select_Mode: diff --git a/doc/elementary/genlist.rst b/doc/elementary/genlist.rst index 1d1b482..2218045 100644 --- a/doc/elementary/genlist.rst +++ b/doc/elementary/genlist.rst @@ -415,6 +415,12 @@ Genlist items' scroll-to types Scroll to the middle of viewport +.. data:: ELM_GENLIST_ITEM_SCROLLTO_BOTTTOM + + Scroll to the bottom of viewport + + .. versionadded:: 1.17 + Inheritance diagram =================== diff --git a/efl/elementary/gengrid.py b/efl/elementary/gengrid.py index 81e57a9..24f33ba 100644 --- a/efl/elementary/gengrid.py +++ b/efl/elementary/gengrid.py @@ -1,9 +1,17 @@ from . import Gengrid, GengridItem, GengridItemClass +# deprecated from . import ELM_GENLIST_ITEM_SCROLLTO_NONE from . import ELM_GENLIST_ITEM_SCROLLTO_IN from . import ELM_GENLIST_ITEM_SCROLLTO_TOP from . import ELM_GENLIST_ITEM_SCROLLTO_MIDDLE +# + +from . import ELM_GENGRID_ITEM_SCROLLTO_NONE +from . import ELM_GENGRID_ITEM_SCROLLTO_IN +from . import ELM_GENGRID_ITEM_SCROLLTO_TOP +from . import ELM_GENGRID_ITEM_SCROLLTO_MIDDLE +from . import ELM_GENGRID_ITEM_SCROLLTO_BOTTOM from . import ELM_OBJECT_SELECT_MODE_DEFAULT from . import ELM_OBJECT_SELECT_MODE_ALWAYS diff --git a/efl/elementary/gengrid_cdef.pxi b/efl/elementary/gengrid_cdef.pxi index 922a783..779aa6c 100644 --- a/efl/elementary/gengrid_cdef.pxi +++ b/efl/elementary/gengrid_cdef.pxi @@ -2,6 +2,7 @@ cdef extern from "Elementary.h": ctypedef cEo Elm_Gengrid + # deprecated cpdef enum Elm_Genlist_Item_Scrollto_Type: ELM_GENLIST_ITEM_SCROLLTO_NONE ELM_GENLIST_ITEM_SCROLLTO_IN @@ -10,6 +11,15 @@ cdef extern from "Elementary.h": ctypedef enum Elm_Genlist_Item_Scrollto_Type: pass + cpdef enum Elm_Gengrid_Item_Scrollto_Type: + ELM_GENGRID_ITEM_SCROLLTO_NONE + ELM_GENGRID_ITEM_SCROLLTO_IN + ELM_GENGRID_ITEM_SCROLLTO_TOP + ELM_GENGRID_ITEM_SCROLLTO_MIDDLE + ELM_GENGRID_ITEM_SCROLLTO_BOTTOM + ctypedef enum Elm_Gengrid_Item_Scrollto_Type: + pass + cpdef enum Elm_Object_Select_Mode: ELM_OBJECT_SELECT_MODE_DEFAULT ELM_OBJECT_SELECT_MODE_ALWAYS diff --git a/efl/elementary/gengrid_item.pxi b/efl/elementary/gengrid_item.pxi index 54f4bd2..ce4b8f4 100644 --- a/efl/elementary/gengrid_item.pxi +++ b/efl/elementary/gengrid_item.pxi @@ -261,26 +261,28 @@ cdef class GengridItem(ObjectItem): def selected_get(self): return bool(elm_gengrid_item_selected_get(self.item)) - def show(self, scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN): + def show(self, scrollto_type=ELM_GENGRID_ITEM_SCROLLTO_IN): """This causes gengrid to **redraw** its viewport's contents to the region containing the given ``item``, if it is not fully visible. .. seealso:: :py:func:`bring_in()` - :param type: Where to position the item in the viewport. + :param scrollto_type: Where to position the item in the viewport. + :type scrollto_type: :ref:`Elm_Gengrid_Item_Scrollto_Type` """ elm_gengrid_item_show(self.item, scrollto_type) - def bring_in(self, scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN): + def bring_in(self, scrollto_type=ELM_GENGRID_ITEM_SCROLLTO_IN): """This causes gengrid to jump to the item and show it (by scrolling), if it is not fully visible. This will use animation to do so and take a period of time to complete. .. seealso:: :py:func:`show()` - :param type: Where to position the item in the viewport. + :param scrollto_type: Where to position the item in the viewport. + :type scrollto_type: :ref:`Elm_Gengrid_Item_Scrollto_Type` """ elm_gengrid_item_bring_in(self.item, scrollto_type) diff --git a/efl/elementary/genlist.py b/efl/elementary/genlist.py index c7b538d..94a8d57 100644 --- a/efl/elementary/genlist.py +++ b/efl/elementary/genlist.py @@ -14,6 +14,7 @@ from . import ELM_GENLIST_ITEM_SCROLLTO_NONE from . import ELM_GENLIST_ITEM_SCROLLTO_IN from . import ELM_GENLIST_ITEM_SCROLLTO_TOP from . import ELM_GENLIST_ITEM_SCROLLTO_MIDDLE +from . import ELM_GENLIST_ITEM_SCROLLTO_BOTTOM from . import ELM_LIST_COMPRESS from . import ELM_LIST_SCROLL diff --git a/efl/elementary/genlist_cdef.pxi b/efl/elementary/genlist_cdef.pxi index 89779d3..0476ffb 100644 --- a/efl/elementary/genlist_cdef.pxi +++ b/efl/elementary/genlist_cdef.pxi @@ -21,6 +21,7 @@ cdef extern from "Elementary.h": ELM_GENLIST_ITEM_SCROLLTO_IN ELM_GENLIST_ITEM_SCROLLTO_TOP ELM_GENLIST_ITEM_SCROLLTO_MIDDLE + ELM_GENLIST_ITEM_SCROLLTO_BOTTOM ctypedef enum Elm_Genlist_Item_Scrollto_Type: pass diff --git a/efl/elementary/genlist_item.pxi b/efl/elementary/genlist_item.pxi index c5eb23f..409b52d 100644 --- a/efl/elementary/genlist_item.pxi +++ b/efl/elementary/genlist_item.pxi @@ -330,23 +330,25 @@ cdef class GenlistItem(ObjectItem): cdef bint ret = elm_genlist_item_selected_get(self.item) return ret - def show(self, scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN): + def show(self, scrollto_type=ELM_GENLIST_ITEM_SCROLLTO_IN): """This causes genlist to jump to the item and show it (by jumping to that position), if it is not fully visible. - :type: :ref:`Elm_Genlist_Item_Scrollto_Type` + :param scrollto_type: Where to position the item in the viewport. + :type scrollto_type: :ref:`Elm_Genlist_Item_Scrollto_Type` .. seealso:: :py:func:`bring_in()` """ elm_genlist_item_show(self.item, scrollto_type) - def bring_in(self, scrollto_type = ELM_GENLIST_ITEM_SCROLLTO_IN): + def bring_in(self, scrollto_type=ELM_GENLIST_ITEM_SCROLLTO_IN): """This causes genlist to jump to the item and show it (by animatedly scrolling), if it is not fully visible. This may use animation and take a some time to do so. - :type: :ref:`Elm_Genlist_Item_Scrollto_Type` + :param scrollto_type: Where to position the item in the viewport. + :type scrollto_type: :ref:`Elm_Genlist_Item_Scrollto_Type` .. seealso:: :py:func:`show()` diff --git a/examples/elementary/test_gengrid.py b/examples/elementary/test_gengrid.py index 4b2ee6d..12eada2 100644 --- a/examples/elementary/test_gengrid.py +++ b/examples/elementary/test_gengrid.py @@ -6,19 +6,10 @@ import os from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, EXPAND_BOTH, FILL_BOTH, \ EXPAND_HORIZ, FILL_HORIZ, EVAS_ASPECT_CONTROL_BOTH -from efl import elementary -from efl.elementary.window import StandardWindow -from efl.elementary.background import Background -from efl.elementary.button import Button -from efl.elementary.check import Check -from efl.elementary.entry import Entry -from efl.elementary.image import Image -from efl.elementary.label import Label -from efl.elementary.general import ELM_GLOB_MATCH_NOCASE -from efl.elementary.gengrid import Gengrid, GengridItemClass -from efl.elementary.slider import Slider -from efl.elementary.table import Table -from efl.elementary.scroller import Scrollable +from efl import elementary as elm +from efl.elementary import StandardWindow, Button, Check, Entry, Image, \ + Label, Gengrid, GengridItemClass, Slider, Radio, Table, Scrollable, \ + ELM_GLOB_MATCH_NOCASE script_path = os.path.dirname(os.path.abspath(__file__)) @@ -69,7 +60,7 @@ def gengrid_clicked(obj): win = StandardWindow("gengrid", "Gengrid", autodel=True, size=(480, 600)) if obj is None: - win.callback_delete_request_add(lambda o: elementary.exit()) + win.callback_delete_request_add(lambda o: elm.exit()) tb = Table(win, homogeneous=False, size_hint_weight=EXPAND_BOTH) win.resize_object_add(tb) @@ -248,38 +239,6 @@ def gengrid_clicked(obj): tb.pack(bt, 5, 2, 1, 1) bt.show() - # show first/last - def show_clicked(bt, gg, first): - ggi = gg.first_item if first else gg.last_item - if ggi: - ggi.show() - - bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show first") - bt.callback_clicked_add(show_clicked, gg, True) - tb.pack(bt, 2, 3, 1, 1) - bt.show() - - bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show last") - bt.callback_clicked_add(show_clicked, gg, False) - tb.pack(bt, 3, 3, 1, 1) - bt.show() - - # bring-in first/last - def bring_in_clicked(bt, gg, first): - ggi = gg.first_item if first else gg.last_item - if ggi: - ggi.bring_in() - - bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn first") - bt.callback_clicked_add(bring_in_clicked, gg, True) - tb.pack(bt, 4, 3, 1, 1) - bt.show() - - bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn last") - bt.callback_clicked_add(bring_in_clicked, gg, False) - tb.pack(bt, 5, 3, 1, 1) - bt.show() - # append def append_clicked(bt, gg, n): global item_count @@ -290,22 +249,22 @@ def gengrid_clicked(obj): bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 1") bt.callback_clicked_add(append_clicked, gg, 1) - tb.pack(bt, 2, 4, 1, 1) + tb.pack(bt, 2, 3, 1, 1) bt.show() bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 100") bt.callback_clicked_add(append_clicked, gg, 100) - tb.pack(bt, 3, 4, 1, 1) + tb.pack(bt, 3, 3, 1, 1) bt.show() bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 1000") bt.callback_clicked_add(append_clicked, gg, 1000) - tb.pack(bt, 4, 4, 1, 1) + tb.pack(bt, 4, 3, 1, 1) bt.show() bt = Button(win, size_hint_align=FILL_HORIZ, text="Append 10000 :)") bt.callback_clicked_add(append_clicked, gg, 10000) - tb.pack(bt, 5, 4, 1, 1) + tb.pack(bt, 5, 3, 1, 1) bt.show() # prepend @@ -316,7 +275,7 @@ def gengrid_clicked(obj): bt = Button(win, size_hint_align=FILL_HORIZ, text="Prepend") bt.callback_clicked_add(prepend_clicked, gg) - tb.pack(bt, 2, 5, 1, 1) + tb.pack(bt, 2, 4, 1, 1) bt.show() # insert_before @@ -331,7 +290,7 @@ def gengrid_clicked(obj): bt = Button(win, size_hint_align=FILL_HORIZ, text="Ins before") bt.callback_clicked_add(ins_before_clicked, gg) - tb.pack(bt, 3, 5, 1, 1) + tb.pack(bt, 3, 4, 1, 1) bt.show() # insert_after @@ -346,7 +305,75 @@ def gengrid_clicked(obj): bt = Button(win, size_hint_align=FILL_HORIZ, text="Ins after") bt.callback_clicked_add(ins_after_clicked, gg) - tb.pack(bt, 4, 5, 1, 1) + tb.pack(bt, 4, 4, 1, 1) + bt.show() + + # scroll_to methods + rdg = rd = Radio(win, text='SCROLL_IN', + state_value=elm.ELM_GENGRID_ITEM_SCROLLTO_IN) + tb.pack(rd, 2, 5, 1, 1) + rd.show() + + rd = Radio(win, text='SCROLL_TOP', + state_value=elm.ELM_GENGRID_ITEM_SCROLLTO_TOP) + rd.group_add(rdg) + tb.pack(rd, 3, 5, 1, 1) + rd.show() + + rd = Radio(win, text='SCROLL_MIDDLE', + state_value=elm.ELM_GENGRID_ITEM_SCROLLTO_MIDDLE) + rd.group_add(rdg) + tb.pack(rd, 4, 5, 1, 1) + rd.show() + + rd = Radio(win, text='SCROLL_BOTTOM', + state_value=elm.ELM_GENGRID_ITEM_SCROLLTO_BOTTOM) + rd.group_add(rdg) + tb.pack(rd, 5, 5, 1, 1) + rd.show() + + rdg.value = elm.ELM_GENGRID_ITEM_SCROLLTO_IN + + # show first/last + def show_clicked(bt, gg, rdg, what): + ggi = getattr(gg, what) + if ggi: + ggi.show(rdg.value) + + bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show first") + bt.callback_clicked_add(show_clicked, gg, rdg, "first_item") + tb.pack(bt, 2, 6, 1, 1) + bt.show() + + bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show last") + bt.callback_clicked_add(show_clicked, gg, rdg, "last_item") + tb.pack(bt, 3, 6, 1, 1) + bt.show() + + bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="Show selected") + bt.callback_clicked_add(show_clicked, gg, rdg, "selected_item") + tb.pack(bt, 2, 7, 2, 1) + bt.show() + + # bring-in first/last/selected + def bring_in_clicked(bt, gg, rdg, what): + ggi = getattr(gg, what) + if ggi: + ggi.bring_in(rdg.value) + + bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn first") + bt.callback_clicked_add(bring_in_clicked, gg, rdg, "first_item") + tb.pack(bt, 4, 6, 1, 1) + bt.show() + + bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn last") + bt.callback_clicked_add(bring_in_clicked, gg, rdg, "last_item") + tb.pack(bt, 5, 6, 1, 1) + bt.show() + + bt = Button(win, size_hint_align=(EVAS_HINT_FILL, 0), text="BringIn selected") + bt.callback_clicked_add(bring_in_clicked, gg, rdg, "selected_item") + tb.pack(bt, 4, 7, 2, 1) bt.show() # search_by_text_item_get @@ -362,14 +389,14 @@ def gengrid_clicked(obj): gg.selected_item.selected = False lb = Label(win, text="Search:") - tb.pack(lb, 2, 6, 1, 1) + tb.pack(lb, 0, 6, 2, 1) lb.show() en = Entry(win, single_line=True, scrollable=True, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ) en.part_text_set("guide", "Type the search query") en.callback_activated_add(search_cb, gg) - tb.pack(en, 3, 6, 3, 1) + tb.pack(en, 0, 7, 2, 1) en.show() en.focus = True @@ -383,4 +410,4 @@ if __name__ == "__main__": gengrid_clicked(None) - elementary.run() + elm.run() diff --git a/examples/elementary/test_genlist_1.py b/examples/elementary/test_genlist_1.py index 5d9f479..ff67832 100644 --- a/examples/elementary/test_genlist_1.py +++ b/examples/elementary/test_genlist_1.py @@ -5,7 +5,7 @@ from efl.evas import Rectangle, EXPAND_BOTH, FILL_BOTH, EVAS_CALLBACK_MOUSE_DOWN from efl import elementary as elm -from efl.elementary import StandardWindow, Box, Label, Button, Icon, \ +from efl.elementary import StandardWindow, Box, Label, Button, Radio, Icon, \ Genlist, GenlistItemClass, ELM_LIST_COMPRESS @@ -123,53 +123,58 @@ def test_genlist_1(parent): if i == 50: it_50 = item elif i == 1500: it_1500 = item - # item 50 buttons + # scroll_to methods hbox = Box(win, horizontal=True) box.pack_end(hbox) hbox.show() - bt = Button(win, text="Show 50 (IN)") - bt.callback_clicked_add(lambda bt: it_50.show(elm.ELM_GENLIST_ITEM_SCROLLTO_IN)) - hbox.pack_end(bt) - bt.show() + rdg = rd = Radio(win, text='SCROLL_IN', + state_value=elm.ELM_GENLIST_ITEM_SCROLLTO_IN) + hbox.pack_end(rd) + rd.show() - bt = Button(win, text="Show 50 (TOP)") - bt.callback_clicked_add(lambda bt: it_50.show(elm.ELM_GENLIST_ITEM_SCROLLTO_TOP)) - hbox.pack_end(bt) - bt.show() + rd = Radio(win, text='SCROLL_TOP', + state_value=elm.ELM_GENLIST_ITEM_SCROLLTO_TOP) + rd.group_add(rdg) + hbox.pack_end(rd) + rd.show() - bt = Button(win, text="Show 50 (MID)") - bt.callback_clicked_add(lambda bt: it_50.show(elm.ELM_GENLIST_ITEM_SCROLLTO_MIDDLE)) - hbox.pack_end(bt) - bt.show() + rd = Radio(win, text='SCROLL_MIDDLE', + state_value=elm.ELM_GENLIST_ITEM_SCROLLTO_MIDDLE) + rd.group_add(rdg) + hbox.pack_end(rd) + rd.show() - bt = Button(win, text="Bring 50 (IN)") - bt.callback_clicked_add(lambda bt: it_50.bring_in(elm.ELM_GENLIST_ITEM_SCROLLTO_IN)) - hbox.pack_end(bt) - bt.show() + rd = Radio(win, text='SCROLL_BOTTOM', + state_value=elm.ELM_GENLIST_ITEM_SCROLLTO_BOTTOM) + rd.group_add(rdg) + hbox.pack_end(rd) + rd.show() - bt = Button(win, text="Bring 50 (TOP)") - bt.callback_clicked_add(lambda bt: it_50.bring_in(elm.ELM_GENLIST_ITEM_SCROLLTO_TOP)) + rdg.value = elm.ELM_GENLIST_ITEM_SCROLLTO_IN + + # item 50/1500 buttons + hbox = Box(win, horizontal=True) + box.pack_end(hbox) + hbox.show() + + bt = Button(win, text="Show 50") + bt.callback_clicked_add(lambda bt: it_50.show(rdg.value)) hbox.pack_end(bt) bt.show() - bt = Button(win, text="Bring 50 (MID)") - bt.callback_clicked_add(lambda bt: it_50.bring_in(elm.ELM_GENLIST_ITEM_SCROLLTO_MIDDLE)) + bt = Button(win, text="BringIn 50") + bt.callback_clicked_add(lambda bt: it_50.bring_in(rdg.value)) hbox.pack_end(bt) bt.show() - # item 1500 buttons - hbox = Box(win, horizontal=True) - box.pack_end(hbox) - hbox.show() - - bt = Button(win, text="Show 1500 (IN)") - bt.callback_clicked_add(lambda bt: it_1500.show()) + bt = Button(win, text="Show 1500") + bt.callback_clicked_add(lambda bt: it_1500.show(rdg.value)) hbox.pack_end(bt) bt.show() - bt = Button(win, text="Bring 1500 (IN)") - bt.callback_clicked_add(lambda bt: it_1500.bring_in()) + bt = Button(win, text="BringIn 1500") + bt.callback_clicked_add(lambda bt: it_1500.bring_in(rdg.value)) hbox.pack_end(bt) bt.show() @@ -177,8 +182,6 @@ def test_genlist_1(parent): win.show() - - if __name__ == "__main__": elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED) test_genlist_1(None) --