U
    Pe]                     @   s(   d Z dZddlmZ G dd deZdS )a;  
Float Layout
============

:class:`FloatLayout` honors the :attr:`~kivy.uix.widget.Widget.pos_hint`
and the :attr:`~kivy.uix.widget.Widget.size_hint` properties of its children.

.. only:: html

    .. image:: images/floatlayout.gif
        :align: right

.. only:: latex

    .. image:: images/floatlayout.png
        :align: right

For example, a FloatLayout with a size of (300, 300) is created::

    layout = FloatLayout(size=(300, 300))

By default, all widgets have their size_hint=(1, 1), so this button will adopt
the same size as the layout::

    button = Button(text='Hello world')
    layout.add_widget(button)

To create a button 50% of the width and 25% of the height of the layout and
positioned at (20, 20), you can do::

    button = Button(
        text='Hello world',
        size_hint=(.5, .25),
        pos=(20, 20))

If you want to create a button that will always be the size of layout minus
20% on each side::

    button = Button(text='Hello world', size_hint=(.6, .6),
                    pos_hint={'x':.2, 'y':.2})

.. note::

    This layout can be used for an application. Most of the time, you will
    use the size of Window.

.. warning::

    If you are not using pos_hint, you must handle the positioning of the
    children: if the float layout is moving, you must handle moving the
    children too.

)FloatLayout    )Layoutc                       s@   e Zd ZdZ fddZdd Z fddZ fdd	Z  ZS )
r   zGFloat layout class. See module documentation for more information.
    c                    sT   t t| jf | | j}| j}|d| |d| |d| |d| |d| d S )Nchildrenpospos_hint	size_hintsize)superr   __init__fbind_trigger_layout)selfkwargsr   update	__class__ 8/tmp/pip-unpacked-wheel-xzebddm3/kivy/uix/floatlayout.pyr
   @   s    



zFloatLayout.__init__c                 O   st  | d| j\}}| d| j\}}| jD ]B}|j\}}	|j\}
}|j\}}|d k	r|	d k	r|| }|	| }|
d k	r||
k r|
}n|d k	r||kr|}|d k	r||k r|}n|d k	r||kr|}||f|_n|d k	r|| }|
d k	r||
k r|
}n|d k	r||kr|}||_nJ|	d k	r`|	| }|d k	rB||k rB|}n|d k	rZ||krZ|}||_|j	
 D ] \}}|dkr|||  |_n|dkr|||  |_n|dkr||d |  ||d |  f|_n|dkr|||  |_nz|dkr
|||  |_n`|d	kr8||d |  ||d |  f|_n2|d
krR|||  |_n|dkrj|||  |_qjq*d S )Nr   r   xrightr      ytopcentercenter_xcenter_y)getr   r   r   r   Zsize_hint_minZsize_hint_maxwidthheightr   itemsr   r   r   r   r   r   r   )r   largsr   whr   r   cZshwZshhZshw_minZshh_minZshw_maxZshh_maxZc_wZc_hkeyvaluer   r   r   	do_layoutJ   sb    







$


$

zFloatLayout.do_layoutc                    s*   |j | j| jd tt| j|f||S N)r   r   )bindr   r	   r   
add_widgetr   Zwidgetargsr   r   r   r   r)      s
    zFloatLayout.add_widgetc                    s*   |j | j| jd tt| j|f||S r'   )Zunbindr   r	   r   remove_widgetr*   r   r   r   r,      s
    zFloatLayout.remove_widget)	__name__
__module____qualname____doc__r
   r&   r)   r,   __classcell__r   r   r   r   r   <   s
   
<r   N)r0   __all__Zkivy.uix.layoutr   r   r   r   r   r   <module>   s   6