U
    Pe                     @   s8   d Z dZddlmZ ddlmZmZ G dd deZdS )a  
Anchor Layout
=============

.. only:: html

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

.. only:: latex

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

The :class:`AnchorLayout` aligns its children to a border (top, bottom,
left, right) or center.


To draw a button in the lower-right corner::

    layout = AnchorLayout(
        anchor_x='right', anchor_y='bottom')
    btn = Button(text='Hello World')
    layout.add_widget(btn)

)AnchorLayout    )Layout)OptionPropertyVariableListPropertyc                       sP   e Zd ZdZeddddgZedddZedddZ fddZ	d	d
 Z
  ZS )r   zLAnchor layout class. See the module documentation for more information.
    r   center)leftr   right)options)topr   bottomc                    sh   t t| jf | | j}| j}|d| |d| |d| |d| |d| |d| |d| d S )Nchildrenparentpaddinganchor_xanchor_ysizepos)superr   __init__fbindZ_trigger_layout)selfkwargsr   update	__class__ 9/tmp/pip-unpacked-wheel-xzebddm3/kivy/uix/anchorlayout.pyr   C   s    





zAnchorLayout.__init__c                 G   s  | j \}}| j}| j}| j}| j}| j\}}	}
}| jD ]^}|| }}|j\}}|j\}}|j	\}}|j
\}}|d k	r||| |
  }|d k	r||k r|}n|d k	r||kr|}|d k	r|||	 |  }|d k	r||k r|}n|d k	r||kr|}|dkr|| }n4|dkr"|| ||
  }n|||
 | | d  }|dkrN|| }n4|dkrj|| ||	  }n|||	 | | d  }||f|_ ||f|_q6d S )Nr   r      r   r
   )r   widthheightr   r   r   r   r   Z	size_hintZsize_hint_minZsize_hint_max)r   largs_xZ_yr   r   r   r   Zpad_leftZpad_topZ	pad_rightZ
pad_bottomcxyZcwchZshwZshhZshw_minZshh_minZshw_maxZshh_maxr   r   r   	do_layoutO   sH    












zAnchorLayout.do_layout)__name__
__module____qualname____doc__r   r   r   r   r   r   r&   __classcell__r   r   r   r   r   "   s   		r   N)r*   __all__Zkivy.uix.layoutr   Zkivy.propertiesr   r   r   r   r   r   r   <module>   s   