U
    Pe                     @   sp   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dlmZ ddlmZ d	d
 Zdd Zdd ZdS )a  
Cursor
======

Shows a cursor following mouse motion events, useful on systems with no
visible native mouse cursor.

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

:Parameters:
    `texture`: str, defaults to
        'data/images/cursor.png' Image used to represent the cursor if
        displayed
    `size`: tuple, defaults to (40, 40)
        Apparent size of the mouse cursor, if displayed, (None,None) value
        will keep its real size.
    `offset`: tuple, defaults to (None, None)
        Offset of the texture image. The default value will align the
        top-left corner of the image to the mouse pos.

Example
-------

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

    [modules]
    cursor = texture=mypointer.png,size=20x20,offset=20x20

.. versionadded:: 1.10.0
)startstop    )Image)Color	Rectangle)kivy_data_dir)string_types)join)partialc              	   G   sx   t |dr|j}n8|jj* tdddddd t| |d |_}W 5 Q R X |d |d  |d |d  |d  f|_d S )N_cursor   Zrgba)mode)texturesizer   )hasattrr   Zcanvasafterr   r   pos)r   r   offsetwinr   argsc r   7/tmp/pip-unpacked-wheel-xzebddm3/kivy/modules/cursor.py_mouse_move,   s    

r   c                 C   s   t |jdttddj}|jd}t|trHdd |dD }n
|sR|j	}|jdd	}t|tr~d
d |dD }| j
tt|||d d S )Nr   Zimagesz
cursor.pngr   c                 S   s   g | ]}t |qS r   int.0xr   r   r   
<listcomp>=   s     zstart.<locals>.<listcomp>r   r   )r   r   c                 S   s   g | ]}t |qS r   r   r   r   r   r   r   C   s     Z	mouse_pos)r   configgetr	   r   r   
isinstancer   splitr   bindr
   r   )r   ctxZcursor_textureZcursor_sizeZcursor_offsetr   r   r   r   7   s&    

   r   c                 C   s   | j td d S )Nr    )Zunbindr   )r   r&   r   r   r   r   J   s    r   N)__doc____all__Zkivy.core.imager   Zkivy.graphicsr   r   Zkivyr   Zkivy.compatr   os.pathr	   	functoolsr
   r   r   r   r   r   r   r   <module>   s   !