U
    Pe
                     @   st   d Z dZddlmZ ddlmZmZ ddlmZ ddl	m
Z
 dadad	ad
d Zdd Zdd Zdd Zdd ZdS )a]  
Touchring
=========

Shows rings around every touch on the surface / screen. You can use this module
to check that you don't have any calibration issues with touches.

Configuration
-------------

:Parameters:
    `image`: str, defaults to '<kivy>/data/images/ring.png'
        Filename of the image to use.
    `scale`: float, defaults to 1.
        Scale of the image.
    `alpha`: float, defaults to 1.
        Opacity of the image.

Example
-------

In your configuration (`~/.kivy/config.ini`), you can add something like
this::

    [modules]
    touchring = image=mypointer.png,scale=.3,alpha=.7

)startstop    )Image)Color	Rectangle)kivy_data_dir)joinN      ?gffffff?c              	   C   s   |j }| jjf tdddt|d< tj\}}t|jtj	d t
  |jtjd t
  f|t
 |t
 ftjd|d< W 5 Q R X |ddsd|d< ||  d S )	N   tr.color       @)possizetexturetr.recttr.grabFT)udcanvasafterr   pointer_alphapointer_imager   r   xwidthpointer_scaleyheightr   getZgrab)wintouchr   iwZih r    :/tmp/pip-unpacked-wheel-xzebddm3/kivy/modules/touchring.py_touch_down*   s    

r"   c                 C   sN   |j }|ddst| | |jtjd t  |jtjd t  f|d _	d S )Nr   Fr   )
r   r   r"   r   r   r   r   r   r   r   r   r   r   r    r    r!   _touch_move;   s    
r$   c                 C   sX   |j | krT|j}| jj|d  | jj|d  |ddkrT||  d|d< d S )Nr   r   r   TF)Zgrab_currentr   r   r   remover   Zungrabr#   r    r    r!   	_touch_upD   s    

r&   c                 C   sN   |j dd}t|j ddat|j ddat|a| jtt	t
d d S )Nimagez%atlas://data/images/defaulttheme/ringZscaler	   alphaZon_touch_downZon_touch_moveZon_touch_up)configr   floatr   r   r   r   bindr"   r$   r&   )r   ctxZ
pointer_fnr    r    r!   r   O   s    r   c                 C   s   | j tttd d S )Nr)   )Zunbindr"   r$   r&   )r   r-   r    r    r!   r   ^   s    r   )__doc____all__Zkivy.core.imager   Zkivy.graphicsr   r   Zkivyr   os.pathr   r   r   r   r"   r$   r&   r   r   r    r    r    r!   <module>   s   	