New 1.12 API: elm_panel_scrollable_set/get/content_size_set
Also improved the test for panel and added a new test for scrollable panel.
This commit is contained in:
parent
d3f98802b0
commit
3be938511f
|
@ -8,3 +8,6 @@ cdef extern from "Elementary.h":
|
|||
void elm_panel_hidden_set(Evas_Object *obj, Eina_Bool hidden)
|
||||
Eina_Bool elm_panel_hidden_get(const Evas_Object *obj)
|
||||
void elm_panel_toggle(Evas_Object *obj)
|
||||
void elm_panel_scrollable_set(Evas_Object *obj, Eina_Bool scrollable)
|
||||
Eina_Bool elm_panel_scrollable_get(const Evas_Object *obj)
|
||||
void elm_panel_scrollable_content_size_set(Evas_Object *obj, double ratio)
|
||||
|
|
|
@ -131,6 +131,38 @@ cdef class Panel(LayoutClass):
|
|||
def hidden_get(self):
|
||||
return elm_panel_hidden_get(self.obj)
|
||||
|
||||
property scrollable:
|
||||
""" The scrollability of the panel.
|
||||
|
||||
:type: bool
|
||||
|
||||
.. versionadded:: 1.12
|
||||
|
||||
"""
|
||||
def __set__(self, bint scrollable):
|
||||
elm_panel_scrollable_set(self.obj, scrollable)
|
||||
def __get__(self):
|
||||
return bool(elm_panel_scrollable_get(self.obj))
|
||||
|
||||
def scrollable_set(self, bint scrollable):
|
||||
elm_panel_scrollable_set(self.obj, scrollable)
|
||||
def scrollable_get(self):
|
||||
return bool(elm_panel_scrollable_get(self.obj))
|
||||
|
||||
property scrollable_content_size:
|
||||
""" The size of the scrollable panel.
|
||||
|
||||
:type: double
|
||||
|
||||
..versionadded:: 1.12
|
||||
|
||||
"""
|
||||
def __set__(self, double ratio):
|
||||
elm_panel_scrollable_content_size_set(self.obj, ratio)
|
||||
|
||||
def scrollable_content_size_set(self, double ratio):
|
||||
elm_panel_scrollable_content_size_set(self.obj, ratio)
|
||||
|
||||
def toggle(self):
|
||||
"""Toggle the hidden state of the panel from code."""
|
||||
elm_panel_toggle(self.obj)
|
||||
|
|
|
@ -99,6 +99,7 @@ items = [
|
|||
]),
|
||||
("Dividers", [
|
||||
("Panel", "test_panel", "panel_clicked"),
|
||||
("Panel Scrollable", "test_panel_scroll", "panel_scroll_clicked"),
|
||||
("Panes", "test_panes", "panes_clicked"),
|
||||
]),
|
||||
# ("Drag & Drop", [
|
||||
|
|
|
@ -1,20 +1,30 @@
|
|||
#!/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.elementary.window import StandardWindow
|
||||
from efl.elementary.box import Box
|
||||
from efl.elementary.button import Button
|
||||
from efl.elementary.panel import Panel, ELM_PANEL_ORIENT_LEFT
|
||||
from efl.elementary.icon import Icon
|
||||
from efl.elementary.list import List
|
||||
from efl.elementary.panel import Panel, ELM_PANEL_ORIENT_LEFT, \
|
||||
ELM_PANEL_ORIENT_TOP, ELM_PANEL_ORIENT_RIGHT, ELM_PANEL_ORIENT_BOTTOM
|
||||
from efl.elementary.photo import Photo
|
||||
from efl.elementary.table import Table
|
||||
from efl.elementary.toolbar import Toolbar, ELM_TOOLBAR_SHRINK_NONE
|
||||
|
||||
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
|
||||
EXPAND_VERT = 0.0, EVAS_HINT_EXPAND
|
||||
EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
|
||||
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
|
||||
FILL_VERT_ALIGN_LEFT = 0.0, EVAS_HINT_FILL
|
||||
|
||||
script_path = os.path.dirname(os.path.abspath(__file__))
|
||||
img_file = os.path.join(script_path, "images", "plant_01.jpg")
|
||||
|
||||
def panel_clicked(obj):
|
||||
win = StandardWindow("panel", "Panel test", autodel=True, size=(300, 300))
|
||||
win = StandardWindow("panel", "Panel test", autodel=True, size=(320, 400))
|
||||
if obj is None:
|
||||
win.callback_delete_request_add(lambda o: elementary.exit())
|
||||
|
||||
|
@ -22,15 +32,65 @@ def panel_clicked(obj):
|
|||
win.resize_object_add(bx)
|
||||
bx.show()
|
||||
|
||||
bt = Button(win, text="HIDE ME :)", size_hint_weight=EXPAND_BOTH,
|
||||
size_hint_align=FILL_BOTH)
|
||||
# top panel (toolbar content)
|
||||
panel1 = Panel(bx, orient=ELM_PANEL_ORIENT_TOP,
|
||||
size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
|
||||
bx.pack_end(panel1)
|
||||
panel1.show()
|
||||
|
||||
toolbar = Toolbar(panel1, homogeneous=False,
|
||||
shrink_mode=ELM_TOOLBAR_SHRINK_NONE)
|
||||
toolbar.item_append("home", "Hello Toolbar")
|
||||
panel1.content = toolbar
|
||||
toolbar.show()
|
||||
|
||||
# table + bg image
|
||||
table = Table(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
|
||||
bx.pack_end(table)
|
||||
table.show()
|
||||
|
||||
photo = Photo(table, fill_inside=True, style="shadow", file=img_file,
|
||||
size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
|
||||
table.pack(photo, 0, 0, 4, 5)
|
||||
photo.show()
|
||||
|
||||
# left panel (list content)
|
||||
panel2 = Panel(table, orient=ELM_PANEL_ORIENT_LEFT,
|
||||
size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
|
||||
table.pack(panel2, 0, 0, 2, 4)
|
||||
panel2.show()
|
||||
|
||||
li = List(panel2, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
|
||||
for i in range(1, 50):
|
||||
ic = Icon(win, standard="home")
|
||||
li.item_append("Item #%d" % i, ic)
|
||||
panel2.content = li
|
||||
li.show()
|
||||
|
||||
# right panel (button content)
|
||||
panel3 = Panel(table, orient=ELM_PANEL_ORIENT_RIGHT, hidden=True,
|
||||
size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
|
||||
table.pack(panel3, 2, 0, 2, 4);
|
||||
panel3.show()
|
||||
|
||||
bt = Button(panel3, text="HIDE ME :)", size_hint_weight=EXPAND_BOTH,
|
||||
size_hint_align=FILL_BOTH)
|
||||
bt.callback_clicked_add(lambda b: panel3.toggle())
|
||||
panel3.content = bt
|
||||
bt.show()
|
||||
|
||||
panel = Panel(win, orient=ELM_PANEL_ORIENT_LEFT, content=bt,
|
||||
size_hint_weight=EXPAND_VERT, size_hint_align=FILL_VERT_ALIGN_LEFT)
|
||||
# bottom panel (toolbar content)
|
||||
panel4 = Panel(table, orient=ELM_PANEL_ORIENT_BOTTOM, hidden=True,
|
||||
size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
|
||||
table.pack(panel4, 0, 4, 4, 1)
|
||||
panel4.show()
|
||||
|
||||
bx.pack_end(panel)
|
||||
panel.show()
|
||||
toolbar = Toolbar(panel4, homogeneous=False,
|
||||
shrink_mode=ELM_TOOLBAR_SHRINK_NONE,
|
||||
size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
|
||||
toolbar.item_append("home", "Hello Toolbar")
|
||||
panel4.content = toolbar
|
||||
toolbar.show()
|
||||
|
||||
win.show()
|
||||
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
|
||||
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL
|
||||
from efl import elementary
|
||||
from efl.elementary.window import StandardWindow
|
||||
from efl.elementary.box import Box
|
||||
from efl.elementary.button import Button
|
||||
from efl.elementary.list import List
|
||||
from efl.elementary.panel import Panel, ELM_PANEL_ORIENT_LEFT
|
||||
from efl.elementary.table import Table
|
||||
|
||||
EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
|
||||
EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
|
||||
FILL_BOTH = EVAS_HINT_FILL, EVAS_HINT_FILL
|
||||
|
||||
|
||||
def panel_scroll_clicked(obj):
|
||||
win = StandardWindow("panel", "Panel test", autodel=True, size=(320, 400))
|
||||
if obj is None:
|
||||
win.callback_delete_request_add(lambda o: elementary.exit())
|
||||
|
||||
# bor for button and table
|
||||
box = Box(win, size_hint_weight=EXPAND_BOTH)
|
||||
win.resize_object_add(box)
|
||||
box.show()
|
||||
|
||||
# toggle button
|
||||
button = Button(box, text="Toggle",
|
||||
size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
|
||||
button.show()
|
||||
box.pack_end(button)
|
||||
|
||||
# table for panel and center content
|
||||
table = Table(win,
|
||||
size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
|
||||
table.show()
|
||||
box.pack_end(table)
|
||||
|
||||
# center content
|
||||
li = List(table, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
|
||||
for i in range(1, 50):
|
||||
li.item_append("center list item #%.02d" % i)
|
||||
table.pack(li, 0, 0, 1, 1)
|
||||
li.show()
|
||||
|
||||
# panel
|
||||
panel = Panel(table, orient=ELM_PANEL_ORIENT_LEFT, hidden=True,
|
||||
scrollable=True, scrollable_content_size = 0.75,
|
||||
size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
|
||||
panel.show()
|
||||
table.pack(panel, 0, 0, 1, 1)
|
||||
|
||||
li = List(panel, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
|
||||
for i in range(1, 7):
|
||||
li.item_append("panel item #%d" % i)
|
||||
panel.content = li
|
||||
li.show()
|
||||
|
||||
button.callback_clicked_add(lambda b: panel.toggle())
|
||||
win.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
elementary.init()
|
||||
|
||||
panel_scroll_clicked(None)
|
||||
|
||||
elementary.run()
|
||||
elementary.shutdown()
|
||||
|
Loading…
Reference in New Issue