Network Sharing
Introduction
Network sharing mean the possibility to share widget over the network. They are many side to attack this problem :
- save a widget, and restore in another pymt instance
- real-time shared control
We are focusing on the first point : found a way to serialize widget, and saving his state. With that, you can do things like:
- save/restore application UI state
- exchange widget with other network pymt instance (usefull when more than 1 table is connected on the same application)
- designer can use it for live edition
XML Serialization
We got a sort of XML syntax about UI creation. Work for basic things but not for a real serialization. With serialization, you must be able to :
- create a widget without passing his __init__()
- having custom action for some properties (like OpenGL texture properties)
- control restore or save action
Many method are available for subclass ::
- __serialize_start__() : called when serialization on the object start. if False, object will be not serialized
- __serialize_classname__() : may return the real classname to use
- __serialize_member__(member) : ask the value of a member, if None, the member will be skipped
- __serialize_end__() : end of serialization
- __unserialize_start__() : unserialization start
- __unserialize_end__() : end of unserialization
Snippet with a MT Label serialization :
<?xml version="1.0" ?>
<MTLabel classid="675532108">
<prop name="_event_stack">
<tuple/>
</prop>
<prop name="_event_types">
<list>
<str value="on_update"/>
<str value="on_draw"/>
<str value="on_mouse_press"/>
<str value="on_mouse_drag"/>
<str value="on_mouse_release"/>
<str value="on_touch_up"/>
<str value="on_touch_move"/>
<str value="on_touch_down"/>
<str value="on_animation_complete"/>
<str value="on_animation_reset"/>
<str value="on_animation_start"/>
<str value="on_resize"/>
<str value="on_parent_resize"/>
<str value="on_move"/>
</list>
</prop>
<prop name="_height">
<int value="100"/>
</prop>
<prop name="_label">
<str value="hello"/>
</prop>
<prop name="_visible">
<bool value="True"/>
</prop>
<prop name="_width">
<int value="100"/>
</prop>
<prop name="_x">
<int value="0"/>
</prop>
<prop name="_y">
<int value="0"/>
</prop>
<prop name="a_properties">
<dict/>
</prop>
<prop name="animations">
<list/>
</prop>
<prop name="autoheight">
<bool value="False"/>
</prop>
<prop name="children">
<list/>
</prop>
<prop name="cls">
<str value=""/>
</prop>
<prop name="draw_children">
<bool value="True"/>
</prop>
<prop name="label_obj">
<Label classid="720476788">
<prop name="_label">
<str value="hello"/>
</prop>
<prop name="_pos">
<tuple>
<int value="0"/>
<int value="0"/>
</tuple>
</prop>
<prop name="_size">
<tuple>
<int value="33"/>
<int value="17"/>
</tuple>
</prop>
<prop name="color">
<tuple>
<int value="1"/>
<int value="1"/>
<int value="1"/>
<int value="1"/>
</tuple>
</prop>
<prop name="options">
<dict>
<entry key="autoheight">
<bool value="False"/>
</entry>
<entry key="font_size">
<int value="12"/>
</entry>
<entry key="bold">
<bool value="False"/>
</entry>
<entry key="color">
<tuple>
<int value="1"/>
<int value="1"/>
<int value="1"/>
<int value="1"/>
</tuple>
</entry>
<entry key="height">
<None/>
</entry>
<entry key="width">
<None/>
</entry>
<entry key="multiline">
<bool value="False"/>
</entry>
<entry key="italic">
<bool value="False"/>
</entry>
<entry key="anchor_x">
<str value="left"/>
</entry>
<entry key="anchor_y">
<str value="bottom"/>
</entry>
<entry key="font_name">
<str value="Liberation Sans,Bitstream Vera Sans,Free Sans,Arial, Sans"/>
</entry>
</dict>
</prop>
</Label>
</prop>
<prop name="shared_attributes">
<tuple>
<str value="font_name"/>
<str value="font_size"/>
<str value="bold"/>
<str value="anchor_x"/>
<str value="anchor_y"/>
<str value="multiline"/>
</tuple>
</prop>
<prop name="style">
<dict>
<entry key="border-radius">
<int value="0"/>
</entry>
<entry key="font-size">
<int value="10"/>
</entry>
<entry key="color">
<list>
<float value="1.0"/>
<float value="1.0"/>
<float value="1.0"/>
<float value="1.0"/>
</list>
</entry>
<entry key="draw-alpha-background">
<bool value="False"/>
</entry>
<entry key="draw-border">
<bool value="False"/>
</entry>
<entry key="text-shadow-color">
<list>
<float value="0.0862745098039"/>
<float value="0.0862745098039"/>
<float value="0.0862745098039"/>
<float value="0.247058823529"/>
</list>
</entry>
<entry key="font-name">
<unicode value=""/>
</entry>
<entry key="alpha-background">
<list>
<float value="1.0"/>
<float value="1.0"/>
<float value="0.5"/>
<float value="0.5"/>
</list>
</entry>
<entry key="draw-text-shadow">
<bool value="False"/>
</entry>
<entry key="bg-color">
<list>
<float value="0.235294117647"/>
<float value="0.235294117647"/>
<float value="0.235294117647"/>
<float value="0.588235294118"/>
</list>
</entry>
<entry key="border-width">
<float value="1.5"/>
</entry>
<entry key="text-shadow-position">
<list>
<int value="-1"/>
<int value="1"/>
</list>
</entry>
<entry key="border-radius-precision">
<float value="1.0"/>
</entry>
<entry key="font-color">
<list>
<float value="1.0"/>
<float value="1.0"/>
<float value="1.0"/>
<float value="1.0"/>
</list>
</entry>
<entry key="color-down">
<list>
<float value="0.588235294118"/>
<float value="0.588235294118"/>
<float value="0.588235294118"/>
<float value="0.588235294118"/>
</list>
</entry>
<entry key="font-weight">
<unicode value="normal"/>
</entry>
</dict>
</prop>
<prop name="visible_events">
<list>
<str value="on_update"/>
<str value="on_draw"/>
<str value="on_mouse_press"/>
<str value="on_mouse_drag"/>
<str value="on_mouse_release"/>
<str value="on_touch_up"/>
<str value="on_touch_move"/>
<str value="on_touch_down"/>
<str value="on_animation_complete"/>
<str value="on_animation_reset"/>
<str value="on_animation_start"/>
</list>
</prop>
</MTLabel>
<MTLabel classid="675532108">
<prop name="_event_stack">
<tuple/>
</prop>
<prop name="_event_types">
<list>
<str value="on_update"/>
<str value="on_draw"/>
<str value="on_mouse_press"/>
<str value="on_mouse_drag"/>
<str value="on_mouse_release"/>
<str value="on_touch_up"/>
<str value="on_touch_move"/>
<str value="on_touch_down"/>
<str value="on_animation_complete"/>
<str value="on_animation_reset"/>
<str value="on_animation_start"/>
<str value="on_resize"/>
<str value="on_parent_resize"/>
<str value="on_move"/>
</list>
</prop>
<prop name="_height">
<int value="100"/>
</prop>
<prop name="_label">
<str value="hello"/>
</prop>
<prop name="_visible">
<bool value="True"/>
</prop>
<prop name="_width">
<int value="100"/>
</prop>
<prop name="_x">
<int value="0"/>
</prop>
<prop name="_y">
<int value="0"/>
</prop>
<prop name="a_properties">
<dict/>
</prop>
<prop name="animations">
<list/>
</prop>
<prop name="autoheight">
<bool value="False"/>
</prop>
<prop name="children">
<list/>
</prop>
<prop name="cls">
<str value=""/>
</prop>
<prop name="draw_children">
<bool value="True"/>
</prop>
<prop name="label_obj">
<Label classid="720476788">
<prop name="_label">
<str value="hello"/>
</prop>
<prop name="_pos">
<tuple>
<int value="0"/>
<int value="0"/>
</tuple>
</prop>
<prop name="_size">
<tuple>
<int value="33"/>
<int value="17"/>
</tuple>
</prop>
<prop name="color">
<tuple>
<int value="1"/>
<int value="1"/>
<int value="1"/>
<int value="1"/>
</tuple>
</prop>
<prop name="options">
<dict>
<entry key="autoheight">
<bool value="False"/>
</entry>
<entry key="font_size">
<int value="12"/>
</entry>
<entry key="bold">
<bool value="False"/>
</entry>
<entry key="color">
<tuple>
<int value="1"/>
<int value="1"/>
<int value="1"/>
<int value="1"/>
</tuple>
</entry>
<entry key="height">
<None/>
</entry>
<entry key="width">
<None/>
</entry>
<entry key="multiline">
<bool value="False"/>
</entry>
<entry key="italic">
<bool value="False"/>
</entry>
<entry key="anchor_x">
<str value="left"/>
</entry>
<entry key="anchor_y">
<str value="bottom"/>
</entry>
<entry key="font_name">
<str value="Liberation Sans,Bitstream Vera Sans,Free Sans,Arial, Sans"/>
</entry>
</dict>
</prop>
</Label>
</prop>
<prop name="shared_attributes">
<tuple>
<str value="font_name"/>
<str value="font_size"/>
<str value="bold"/>
<str value="anchor_x"/>
<str value="anchor_y"/>
<str value="multiline"/>
</tuple>
</prop>
<prop name="style">
<dict>
<entry key="border-radius">
<int value="0"/>
</entry>
<entry key="font-size">
<int value="10"/>
</entry>
<entry key="color">
<list>
<float value="1.0"/>
<float value="1.0"/>
<float value="1.0"/>
<float value="1.0"/>
</list>
</entry>
<entry key="draw-alpha-background">
<bool value="False"/>
</entry>
<entry key="draw-border">
<bool value="False"/>
</entry>
<entry key="text-shadow-color">
<list>
<float value="0.0862745098039"/>
<float value="0.0862745098039"/>
<float value="0.0862745098039"/>
<float value="0.247058823529"/>
</list>
</entry>
<entry key="font-name">
<unicode value=""/>
</entry>
<entry key="alpha-background">
<list>
<float value="1.0"/>
<float value="1.0"/>
<float value="0.5"/>
<float value="0.5"/>
</list>
</entry>
<entry key="draw-text-shadow">
<bool value="False"/>
</entry>
<entry key="bg-color">
<list>
<float value="0.235294117647"/>
<float value="0.235294117647"/>
<float value="0.235294117647"/>
<float value="0.588235294118"/>
</list>
</entry>
<entry key="border-width">
<float value="1.5"/>
</entry>
<entry key="text-shadow-position">
<list>
<int value="-1"/>
<int value="1"/>
</list>
</entry>
<entry key="border-radius-precision">
<float value="1.0"/>
</entry>
<entry key="font-color">
<list>
<float value="1.0"/>
<float value="1.0"/>
<float value="1.0"/>
<float value="1.0"/>
</list>
</entry>
<entry key="color-down">
<list>
<float value="0.588235294118"/>
<float value="0.588235294118"/>
<float value="0.588235294118"/>
<float value="0.588235294118"/>
</list>
</entry>
<entry key="font-weight">
<unicode value="normal"/>
</entry>
</dict>
</prop>
<prop name="visible_events">
<list>
<str value="on_update"/>
<str value="on_draw"/>
<str value="on_mouse_press"/>
<str value="on_mouse_drag"/>
<str value="on_mouse_release"/>
<str value="on_touch_up"/>
<str value="on_touch_move"/>
<str value="on_touch_down"/>
<str value="on_animation_complete"/>
<str value="on_animation_reset"/>
<str value="on_animation_start"/>
</list>
</prop>
</MTLabel>
