U
    Pe	                     @   s   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d	 Zd
d Zdd ZG dd deZdd Zdd ZdS )z
Monitor module
==============

The Monitor module is a toolbar that shows the activity of your current
application :

* FPS
* Graph of input events

Usage
-----

For normal module usage, please see the :mod:`~kivy.modules` documentation.

)startstop    )Label)	RectangleColor)Clock)partialc                 G   s,   dt   | j_| jj| j_| jj| j_d S )NzFPS: %f)r   Zget_fpslabeltextZtexture	rectangleZtexture_sizesize)ctxlargs r   8/tmp/pip-unpacked-wheel-xzebddm3/kivy/modules/monitor.py
update_fps   s    r   c                 G   s~   |j dd  tg |_ datdt}t|j D ]J\}}d|j | | d f|j| _| jd |d  | jd f|j| _	q.d S )N   r   g      ?            )
stats_statsinputmax	_maxinput	enumeratestatsrr   widthheightpos)winr   r   mixr   r   r   update_stats#   s    
r%   c              	   G   sJ   | j j8 d| jd f|j_| jdf|j_d| jd f|j_W 5 Q R X d S )Nr   r      r   )canvasafterr   overlayr    r   r   r   )r!   r   r   r   r   r   _update_monitor_canvas-   s    
r*   c                   @   s   e Zd Zdd ZdS )
StatsInputc                 C   s    t t|7 a t tkrtt a|S N)r   lenr   float)selfeventsr   r   r   process5   s    zStatsInput.processN)__name__
__module____qualname__r1   r   r   r   r   r+   4   s   r+   c              	   C   s.  ddl m} t |d< tdd|_d|_g |_g |_| jj	 t
dddd|_td| jd f| jdfd	|_t
ddd|_td
| jd fd|_t
dddd|_tdD ]<}|jd |jt| jd |d  | jd fdd	 qW 5 Q R X | jtt| |d ttt|d ttt| |d d S )Nr   )kivy_postproc_modulesZfpszFPS: 0.0)r   r   g      ?r   )r    r   r&   r   )r    @   r   r   )r   r   )r   g?)Zkivy.input.postprocr5   r+   r   r
   Z
inputstatsr   r   r'   r(   r   colorr   r   r   r)   r   rangeappendbindr   r*   r   Zschedule_intervalr   r%   )r!   r   r5   r#   r   r   r   r   =   s0    

r   c                 C   s   | j |j d S r,   )r'   remover
   )r!   r   r   r   r   r   W   s    r   N)__doc____all__Zkivy.uix.labelr   Zkivy.graphicsr   r   Z
kivy.clockr   	functoolsr   r   r   r   r%   r*   objectr+   r   r   r   r   r   r   <module>   s   
	