B
    ä^•\Œ~ ã               @   sJ  d Z ddlZddlZddlZdd„ Zedkr2eƒ  dZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZd
ZdZdZdZejjdkZejZdZG dd„ dƒZG dd„ dƒZ G dd„ de ƒZ!G dd„ dƒZ"G dd„ dƒZ#G dd„ dƒZ$G dd„ dƒZ%G d d!„ d!ƒZ&G d"d#„ d#ƒZ'G d$d%„ d%ƒZ(G d&d'„ d'ƒZ)e(ƒ Z*d(d)„ Z+d…d+d,„Z,d†d-d,„Z,d‡d.d/„Z-d0d1„ Z.d2d3„ Z/d4d5„ Z0dˆd7d8„Z1d9d8„ Z1d:d8„ Z1d;d8„ Z1d<d8„ Z1d=d>„ Z2d?d>„ Z2d@d>„ Z2dAdB„ Z3d‰dDdE„Z4dŠdGdH„Z5dIdJ„ Z6dKdJ„ Z6d‹dMdN„Z7dŒdPdQ„Z8dRdS„ Z9ddUdV„Z:dŽdXdY„Z;dZd[„ Z<dd\d]„Z=d^d_„ Z>dd`da„Z?dbdc„ Z@d‘ddd]„Z=d’deda„Z?d“dfdg„ZAd”dhdH„Z5did>„ Z2djd>„ Z2dkd>„ Z2dldB„ Z3d•dmdE„Z4dndJ„ Z6dodJ„ Z6d–dpdN„Z7d—dqdQ„Z8drdS„ Z9d˜dsdV„Z:d™dtdY„Z;dšdudv„ZBdwd,„ Z,dxdH„ Z5dydJ„ Z6dzdN„ Z7d{dE„ Z4d|d8„ Z1d}d>„ Z2d~dB„ Z3ddQ„ Z8d€dS„ Z9ddV„ Z:d‚dY„ Z;dƒd]„ Z=d„da„ Z?dS )›aÐ  
A (very) simple UI lib built on top of OpenCV drawing primitives.
Version: 2.7

Use of cvui revolves around calling cvui.init() to initialize the lib,
rendering cvui components to a np.ndarray (that you handle yourself) and
finally showing that np.ndarray on the screen using cvui.imshow(), which
is cvui's version of cv2.imshow(). Alternatively you can use cv2.imshow()
to show things, but in such case you must call cvui.update() yourself
before calling cv.imshow().

E.g.:

	import numpy as np
	import cv2
	import cvui

	WINDOW_NAME = 'CVUI Hello World!'

	frame = np.zeros((200, 500, 3), np.uint8)
	cvui.init(WINDOW_NAME)

	while (True):
		# Fill the frame with a nice color
		frame[:] = (49, 52, 49)

		cvui.text(frame, x, y, 'Hello world!')
		cvui.imshow(WINDOW_NAME, frame)

		if cv2.waitKey(20) == 27:
			break

Read the full documentation at https://dovyski.github.io/cvui/

Copyright (c) 2018 Fernando Bevilacqua <dovyski@gmail.com>
Licensed under the MIT license.
é    Nc               C   s   dS )Nr   © r   r   r   ú-C:\software\vidtrack\examples\bb-tool\cvui.pyÚmain+   s    r   Ú__main__z2.7é   é   é   é   é   é   é   é   é   é    éÿÿÿÿc               @   s   e Zd Zddd„Zdd„ ZdS )ÚPointr   c             C   s   || _ || _d S )N)ÚxÚy)ÚselfÚtheXÚtheYr   r   r   Ú__init__S   s    zPoint.__init__c             C   s
   |  | ¡S )N)Úcontains)r   ÚtheRectr   r   r   ÚinsideW   s    zPoint.insideN)r   r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   R   s   
r   c               @   s&   e Zd Zd	dd„Zdd„ Zdd„ ZdS )
ÚRectr   c             C   s   || _ || _|| _|| _d S )N)r   r   ÚwidthÚheight)r   r   r   ÚtheWidthÚ	theHeightr   r   r   r   \   s    zRect.__init__c             C   s<   |j | j ko:|j | j | j ko:|j| jko:|j| j| j kS )N)r   r   r   r    )r   ZthePointr   r   r   r   b   s    zRect.containsc             C   s   | j | j S )N)r   r    )r   r   r   r   Úareae   s    z	Rect.areaN)r   r   r   r   )r   r   r   r   r   r#   r   r   r   r   r   [   s   
r   c               @   s   e Zd Zddd„ZdS )ÚSizer   c             C   s   d| _ d| _|| _|| _d S )Nr   )r   r   r   r    )r   r!   r"   r   r   r   r   k   s    zSize.__init__N)r   r   )r   r   r   r   r   r   r   r   r$   j   s   r$   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚBlockc             C   s6   d | _ tƒ | _tƒ | _tƒ | _d| _t| _|  	¡  d S )Nr   )
Úwherer   ÚrectÚfillr   ÚanchorÚpaddingÚROWÚtypeÚreset)r   r   r   r   r   s   s    zBlock.__init__c             C   sR   d| j _d| j _d| j _d| j _| j | _d| j_d| j_d| j_d| j_d| _d S )Nr   )r'   r   r   r   r    r(   r)   r*   )r   r   r   r   r-   }   s    zBlock.resetN)r   r   r   r   r-   r   r   r   r   r%   r   s   
r%   c               @   s   e Zd Zdd„ ZdS )ÚLabelc             C   s   d| _ d| _d| _d| _d S )NFÚ )ÚhasShortcutÚshortcutÚtextBeforeShortcutÚtextAfterShortcut)r   r   r   r   r   “   s    zLabel.__init__N)r   r   r   r   r   r   r   r   r.   ’   s   r.   c               @   s   e Zd Zdd„ Zdd„ ZdS )ÚMouseButtonc             C   s   d| _ d| _d| _d S )NF)ÚjustReleasedÚjustPressedÚpressed)r   r   r   r   r   ›   s    zMouseButton.__init__c             C   s   d| _ d| _d| _d S )NF)r6   r5   r7   )r   r   r   r   r-       s    zMouseButton.resetN)r   r   r   r   r-   r   r   r   r   r4   š   s   r4   c               @   s   e Zd Zdd„ ZdS )ÚMousec             C   s0   t tƒ ttƒ ttƒ i| _tƒ | _tddƒ| _d S )Nr   )ÚLEFT_BUTTONr4   ÚMIDDLE_BUTTONÚRIGHT_BUTTONÚbuttonsÚ	anyButtonr   Úposition)r   r   r   r   r   §   s
    zMouse.__init__N)r   r   r   r   r   r   r   r   r8   ¦   s   r8   c               @   s   e Zd Zdd„ ZdS )ÚContextc             C   s   d| _ tƒ | _d S )Nr/   )Ú
windowNamer8   Úmouse)r   r   r   r   r   ²   s    zContext.__init__N)r   r   r   r   r   r   r   r   r?   ±   s   r?   c               @   s   e Zd Zd	dd„ZdS )
ÚTrackbarParamsç        ç      9@ç      ð?r   ú%.0Lfc             C   s(   || _ || _|| _|| _|| _|| _d S )N)ÚminÚmaxÚstepÚsegmentsÚoptionsÚlabelFormat)r   ÚtheMinÚtheMaxÚtheStepÚtheSegmentsÚtheLabelFormatÚ
theOptionsr   r   r   r   ¸   s    zTrackbarParams.__init__N)rC   rD   rE   r   rF   r   )r   r   r   r   r   r   r   r   rB   ·   s   rB   c               @   s@  e Zd Zdd„ Zdd„ ZdOdd„Zdd	„ Zd
d„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdPdd„Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ Zd:d;„ Zd<d=„ Z d>d?„ Z!d@dA„ Z"dBdC„ Z#dDdE„ Z$dFdG„ Z%dHdI„ Z&dJdK„ Z'dLdM„ Z(dNS )QÚInternalc             C   s`   d| _ d| _i | _g | _d| _d| _tƒ | _dd„ tdƒD ƒ| _	d| _
d| _tƒ | _| | j_d S )Nr/   r   c             S   s   g | ]
}t ƒ ‘qS r   )r%   )Ú.0Úir   r   r   ú
<listcomp>Ë   s    z%Internal.__init__.<locals>.<listcomp>éd   é   )ÚdefaultContextÚcurrentContextÚcontextsÚbufferÚlastKeyPressedÚdelayWaitKeyr%   ÚscreenÚrangeÚstackÚ
stackCountÚtrackbarMarginXÚRenderÚ_renderÚ	_internal)r   r   r   r   r   Ã   s    zInternal.__init__c             C   s>   d}|t ks|tkr|j}n|tkr,|j}n|tkr:|j}|S )NF)ÚCLICKÚUPr5   ÚDOWNr6   ÚIS_DOWNr7   )r   Ú	theButtonÚtheQueryÚaRetr   r   r   ÚisMouseButtonÒ   s    zInternal.isMouseButtonr/   c             C   s   |   |¡jjS )ag  
		Return the last position of the mouse.

		\param theWindowName name of the window whose mouse cursor will be used. If nothing is informed (default), the function will return the position of the mouse cursor for the default window (the one informed in `cvui::init()`).
		eturn a point containing the position of the mouse cursor in the speficied window.
		)Ú
getContextrA   r>   )r   ÚtheWindowNamer   r   r   ÚmouseWÞ   s    zInternal.mouseWc             C   s   |   d|¡S )at  
		Query the mouse for events, e.g. "is any button down now?". Available queries are:

		* `cvui::DOWN`: any mouse button was pressed. `cvui::mouse()` returns `true` for a single frame only.
		* `cvui::UP`: any mouse button was released.  `cvui::mouse()` returns `true` for a single frame only.
		* `cvui::CLICK`: any mouse button was clicked (went down then up, no matter the amount of frames in between). `cvui::mouse()` returns `true` for a single frame only.
		* `cvui::IS_DOWN`: any mouse button is currently pressed. `cvui::mouse()` returns `true` for as long as the button is down/pressed.

		It is easier to think of this function as the answer to a questions. For instance, asking if any mouse button went down:

		```
		if (cvui::mouse(cvui::DOWN)) {
		  // Any mouse button just went down.
		}
		```

		The window whose mouse will be queried depends on the context. If `cvui::mouse(query)` is being called after
		`cvui::context()`, the window informed in the context will be queried. If no context is available, the default
		window (informed in `cvui::init()`) will be used.

		Parameters
		----------
		theQuery: int
			Integer describing the intended mouse query. Available queries are `cvui::DOWN`, `cvui::UP`, `cvui::CLICK`, and `cvui::IS_DOWN`.

		\sa mouse(const cv::String&)
		\sa mouse(const cv::String&, int)
		\sa mouse(const cv::String&, int, int)
		\sa mouse(int, int)
		r/   )ÚmouseWQ)r   rl   r   r   r   ÚmouseQç   s    zInternal.mouseQc             C   s   |   |¡jj}|  ||¡}|S )a  
		 Query the mouse for events in a particular window. This function behave exactly like `cvui::mouse(int theQuery)`
		 with the difference that queries are targeted at a particular window.

		 \param theWindowName name of the window that will be queried.
		 \param theQuery an integer describing the intended mouse query. Available queries are `cvui::DOWN`, `cvui::UP`, `cvui::CLICK`, and `cvui::IS_DOWN`.

		 \sa mouse(const cv::String&)
		 \sa mouse(const cv::String&, int, int)
		 \sa mouse(int, int)
		 \sa mouse(int)
		)ro   rA   r=   rn   )r   rp   rl   ÚaButtonrm   r   r   r   rr     s    zInternal.mouseWQc             C   s   |   d||¡S )af  
		 Query the mouse for events in a particular button. This function behave exactly like `cvui::mouse(int theQuery)`,
		 with the difference that queries are targeted at a particular mouse button instead.

		 \param theButton an integer describing the mouse button to be queried. Possible values are `cvui::LEFT_BUTTON`, `cvui::MIDDLE_BUTTON` and `cvui::LEFT_BUTTON`.
		 \param theQuery an integer describing the intended mouse query. Available queries are `cvui::DOWN`, `cvui::UP`, `cvui::CLICK`, and `cvui::IS_DOWN`.

		 \sa mouse(const cv::String&)
		 \sa mouse(const cv::String&, int, int)
		 \sa mouse(int)
		r/   )ÚmouseWBQ)r   rk   rl   r   r   r   ÚmouseBQ  s    zInternal.mouseBQc             C   sF   |t kr$|tkr$|tkr$t dd¡ |  |¡jj| }|  ||¡}|S )aŠ  
		 Query the mouse for events in a particular button in a particular window. This function behave exactly
		 like `cvui::mouse(int theButton, int theQuery)`, with the difference that queries are targeted at
		 a particular mouse button in a particular window instead.

		 \param theWindowName name of the window that will be queried.
		 \param theButton an integer describing the mouse button to be queried. Possible values are `cvui::LEFT_BUTTON`, `cvui::MIDDLE_BUTTON` and `cvui::LEFT_BUTTON`.
		 \param theQuery an integer describing the intended mouse query. Available queries are `cvui::DOWN`, `cvui::UP`, `cvui::CLICK`, and `cvui::IS_DOWN`.
		r   z[Invalid mouse button. Are you using one of the available: cvui.{RIGHT,MIDDLE,LEFT}_BUTTON ?)	r;   r:   r9   Z_Internal__internalÚerrorro   rA   r<   rn   )r   rp   rk   rl   rt   rm   r   r   r   ru   (  s
    
zInternal.mouseWBQc             C   s   || _ || _|| _d| _d S )Nr   )rY   rZ   r^   r]   )r   rp   ÚtheDelayWaitKeyr   r   r   Úinit:  s    zInternal.initc             C   s   ||@ dkS )Nr   r   )r   Z	theBitsetÚtheValuer   r   r   Ú	bitsetHas@  s    zInternal.bitsetHasc             C   s&   t d|d|ƒ t d¡ t d¡ d S )Nz[CVUI] Fatal error (code z): i † r   )ÚprintÚcv2ÚwaitKeyÚsysÚexit)r   ZtheIdZ
theMessager   r   r   rw   C  s    
zInternal.errorc             C   sZ   t |ƒdkr| j| S t | jƒdkr0| j| j S t | jƒdkrJ| j| j S |  dd¡ d S )Nr   r
   z;Unable to read context. Did you forget to call cvui.init()?)Úlenr[   rZ   rY   rw   )r   rp   r   r   r   ro   H  s    
zInternal.getContextc             C   sš   |j tkrL|j|j }|j j|7  _|j j|7  _t|j|jjƒ|j_nJ|j t	kr–|j|j }|j j
|7  _
|j j|7  _t|j|jjƒ|j_d S )N)r,   r+   r   r*   r)   r   r(   rH   r    ÚCOLUMNr   )r   ÚtheBlockZtheSizeÚaValuer   r   r   ÚupdateLayoutFlowZ  s    

zInternal.updateLayoutFlowc             C   s
   | j dkS )Nr   )rb   )r   r   r   r   ÚblockStackEmptyi  s    zInternal.blockStackEmptyc             C   s"   | j dk r|  dd¡ | j| j  S )Nr   r   zrYou are using a function that should be enclosed by begin*() and end*(), but you probably forgot to call begin*().)rb   rw   ra   )r   r   r   r   ÚtopBlockl  s    
zInternal.topBlockc             C   s   |  j d7  _ | j| j  S )Nr   )rb   ra   )r   r   r   r   Ú	pushBlockr  s    zInternal.pushBlockc             C   s4   | j dk r|  dd¡ | j }|  j d8  _ | j| S )Nr   r   zYMismatch in the number of begin*()/end*() calls. You are calling one more than the other.)rb   rw   ra   )r   ZaIndexr   r   r   ÚpopBlockv  s
    
zInternal.popBlockc             C   s®   d}d}d}t ƒ }d|_d|_d|_d|_xr|t|ƒk rœ|| }|dkrv|t|ƒd k rvd|_||d  |_|d7 }n|jdkrŠ||7 }n||7 }|d7 }q,W ||_||_|S )Nr   r/   Fú&r   T)r.   r0   r1   r2   r3   r   )r   ÚtheLabelrU   ZaBeforeZaAfterÚaLabelÚcr   r   r   ÚcreateLabel€  s*    


zInternal.createLabelc             C   sn   t  |t j|d¡\}}	t|d |d ƒ}
t|||
j ƒ}| j |||||¡ |rj|
 jd7  _|  ||
¡ d S )Nr   r   )	r}   ÚgetTextSizeÚFONT_HERSHEY_SIMPLEXr$   r   r    re   Útextr…   )r   rƒ   r   r   ÚtheTextÚtheFontScaleÚtheColorÚtheUpdateLayoutÚ	aSizeInfoÚ	aBaselineÚ	aTextSizeÚaPosr   r   r   r‘   œ  s    zInternal.textc       
   	   C   s¨   t |d |ddƒ}|  |||dddd¡r8|d  |8  < ||d  }| j |||¡ |  ||j|j |dddd¡r‚|d  |7  < td|j |jƒ}	|  ||	¡ |d S )Né   é0   ú-Fr   ú+é,   )	r   ÚbuttonWHre   Úcounterr   r   r$   r    r…   )
r   rƒ   r   r   rz   rO   Ú	theFormatÚaContentAreaÚaTextÚaSizer   r   r   r    ©  s    zInternal.counterc             C   sô   |   ¡ j}t||ddƒ}t |tjdd¡\}	}
tdd|	d |	d ƒ}t|||j|j d |jƒ}| |j	¡}|r˜| j
 |t|¡ |jjr¨|d  |d< n| j
 |t|¡ | j
 |||||¡ |d rÒ| j
 ||¡ t|j|jƒ}|  ||¡ |d S )Né   gš™™™™™Ù?r   r   r   )ro   rA   r   r}   r   r   r   r    r   r>   re   ÚcheckboxÚOVERr=   r5   ÚOUTÚcheckboxLabelÚcheckboxCheckr$   r…   )r   rƒ   r   r   r‹   ÚtheStater”   ÚaMouseÚaRectr–   r—   r˜   ZaHitAreaÚaMouseIsOverr¤   r   r   r   r¦   »  s"    
zInternal.checkboxc             C   s$   |dkrdn|}|dk rdn|}|S )Ng      ð?g        r   )r   rz   r   r   r   Úclamp01Ö  s    zInternal.clamp01c             C   sP   |   |jt¡rL|jdkrLt|d |j ƒ|j }t|ƒ}|j|j|  |d< d S )Ng        r   )r{   rK   ÚTRACKBAR_DISCRETErI   ÚfloatrG   Úround)r   Ú	theParamsrz   Úkr   r   r   Ú)trackbarForceValuesAsMultiplesOfSmallStepÛ  s    z2Internal.trackbarForceValuesAsMultiplesOfSmallStepc             C   sH   t ||j| j  ƒ|jd| j   }|  |¡}|j||j|j   }|S )Nr   )r±   r   rc   r   r¯   rG   rH   )r   r³   ÚtheBoundingZ	thePixelXÚaRatior„   r   r   r   ÚtrackbarXPixelToValueá  s    $
zInternal.trackbarXPixelToValuec             C   sL   t ||j ƒ|j|j  }|  |¡}|j| j ||jd| j    }t|ƒS )Nr   )r±   rG   rH   r¯   r   rc   r   Úint)r   r³   r¶   rz   r·   ZaPixelsXr   r   r   ÚtrackbarValueToXPixelç  s    
 zInternal.trackbarValueToXPixelc             C   sN   |   ¡ j}t}t||||ƒ |j¡}|r:|jjr6t}nt	}|rJ|jj
rJt}|S )N)ro   rA   r¨   r   r   r>   r=   r7   ri   r§   r5   rg   )r   r   r   r!   r"   r¬   rm   r®   r   r   r   Úiareaí  s    
zInternal.iareac             C   sÔ   t  |t jdd¡\}}	tdd|d |d ƒ}
t||||ƒ}|  |||j|j¡}| j ||||¡ | j 	|||||
¡ |rŽt
||ƒ}|  ||¡ d}| jdkrÈ|  |¡}|jrÈ|j ¡ t| jƒ ¡ krÈd}|tkpÒ|S )Ngš™™™™™Ù?r   r   Fr   T)r}   r   r   r   r»   r   r    re   ÚbuttonÚbuttonLabelr$   r…   r]   rŽ   r0   r1   ÚlowerÚchrrg   )r   rƒ   r   r   r!   r"   r‹   r•   r–   r—   r˜   r­   ÚaStatusr¤   ZaWasShortcutPressedrŒ   r   r   r   rŸ     s    


zInternal.buttonWHc          	   C   sN   t  |t jdd¡\}}tdd|d |d ƒ}|  ||||jd |jd |d¡S )Ngš™™™™™Ù?r   r   é   é   T)r}   r   r   r   rŸ   r   r    )r   rƒ   r   r   r‹   r–   r—   r˜   r   r   r   r¼   !  s    zInternal.buttonc             C   s¨   |j d }|j d }	t|||	|ƒ}
|  |||
j|
j¡}|tkrP| j ||
|¡ n2|tkrj| j ||
|¡ n|t	kr‚| j ||
|¡ |r t
|
j|
jƒ}|  ||¡ |tkS )Nr   r   )Úshaper   r»   r   r    r¨   re   Úimager§   ri   r$   r…   rg   )r   rƒ   r   r   ÚtheIdleÚtheOverÚtheDownr•   Z	aIdleRowsZ	aIdleColsr­   rÀ   r¤   r   r   r   ÚbuttonI)  s    

   zInternal.buttonIc       	      C   sL   |j d }|j d }t||||ƒ}| j |||¡ t||ƒ}|  ||¡ d S )Nr   r   )rÃ   r   re   rÄ   r$   r…   )	r   rƒ   r   r   ÚtheImageZ
aImageRowsZ
aImageColsr­   r¤   r   r   r   rÄ   =  s    


zInternal.imagec             C   s    |   ¡ j}t|||dƒ}| |j¡}	|d }
| j ||	r<tnt||d |¡ |j	j
rˆ|	rˆ|  |||jj¡|d< |  |jt¡rˆ|  ||¡ |  ||¡ |d |
kS )Né-   r   )ro   rA   r   r   r>   re   Útrackbarr§   r¨   r=   r7   r¸   r   r{   rK   r°   rµ   r…   )r   rƒ   r   r   r!   rz   r³   r¬   r¢   r®   r„   r   r   r   rË   J  s    
 zInternal.trackbarc       
      C   sT   t |||dƒ}t |||j |||j ƒ}| j ||||¡ t||ƒ}	|  ||	¡ d S )Né   )r   r    re   Úwindowr$   r…   )
r   rƒ   r   r   r!   r"   ÚtheTitleZ	aTitleBarZaContentr¤   r   r   r   rÍ   ^  s
    
zInternal.windowc             C   sœ   t ||ƒ}t||||ƒ}	|	jdk r.|j|	j n|j|	_|	jdk rL|j|	j n|j|	_t|	jƒ|	_t|	jƒ|	_| j ||	||¡ t	|	j|	jƒ}
|  
||
¡ d S )Nr   )r   r   r   r   r    r   Úabsre   r'   r$   r…   )r   rƒ   r   r   r!   r"   ÚtheBorderColorÚtheFillingColorZaAnchorr­   r¤   r   r   r   r'   h  s    
zInternal.rectc          	   C   s€   t ||||ƒ}t|ƒ}	|	dkrD|  |¡\}
}| j ||||
||¡ n"|  ||||	dkrZdndddd¡ t||ƒ}|  ||¡ d S )Nr   r   zNo data.zInsufficient data points.gš™™™™™Ù?iÎÎÎ F)r   r   Ú
findMinMaxre   Ú	sparkliner‘   r$   r…   )r   rƒ   Ú	theValuesr   r   r!   r"   r”   r­   ZaHowManyValuesÚaMinÚaMaxr¤   r   r   r   rÓ   w  s    "
zInternal.sparklinec             C   s8   |d? d@ }|d? d@ }|d? d@ }|d@ }||||fS )Né   éÿ   r   r   r   )r   r”   ÚaAlphaZaRedZaGreenZaBluer   r   r   ÚhexToScalar…  s
    zInternal.hexToScalarc             C   s   t |trtntƒS )N)Ú
isinstanceÚ_IS_PY2Ú
basestringÚstr)r   ZtheObjr   r   r   ÚisString  s    zInternal.isStringc       	      C   sf   |   ¡ }||_||j_||j_||j_||j_|j|_d|j_d|j_||j_||j_||_	||_
d S )Nr   )rˆ   r&   r'   r   r   r   r    r(   r)   r*   r,   )	r   ÚtheTypeÚtheWherer   r   r!   r"   Ú
thePaddingÚaBlockr   r   r   Úbegin  s    zInternal.beginc             C   s„   |   ¡ }|j|kr|  dd¡ |  ¡ dkr€|  ¡ }tƒ }|jjdk rL|jjn|jj|_|jj	dk rj|jj	n|jj	|_	|  
||¡ d S )Nr	   z‘Calling wrong type of end*(). E.g. endColumn() instead of endRow(). Check if your begin*() calls are matched with their appropriate end*() calls.Fr   )r‰   r,   rw   r†   r‡   r$   r'   r   r(   r    r…   )r   rà   rã   ZaTopr¤   r   r   r   Úend¤  s    
	zInternal.endc             C   s>   |d }|d }x$|D ]}||k r&|}||kr|}qW ||fS )Nr   r   )r   rÔ   rÕ   rÖ   r„   r   r   r   rÒ   ¿  s    
zInternal.findMinMaxN)r/   )r/   ))r   r   r   r   rn   rq   rs   rr   rv   ru   ry   r{   rw   ro   r…   r†   r‡   rˆ   r‰   rŽ   r‘   r    r¦   r¯   rµ   r¸   rº   r»   rŸ   r¼   rÈ   rÄ   rË   rÍ   r'   rÓ   rÚ   rß   rä   rå   rÒ   r   r   r   r   rS   Â   sL   
	!


rS   c               @   s¶   e Zd ZdZdefdd„Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ ZdS )+rd   Nr   c             C   sL   t |jƒt |jƒf}t |j|j ƒt |j|j ƒf}t ||||||¡ d S )N)r¹   r   r   r   r    r}   Ú	rectangle)r   rá   ÚtheShaper”   ZtheThicknessZtheLineTypeZaStartPointZ	aEndPointr   r   r   ræ   Ð  s     zRender.rectanglec          
   C   s>   t |jƒt |jƒf}t |j||tj|| j |¡dtj	¡ d S )Nr   )
r¹   r   r   r}   ÚputTextr&   r   rf   rÚ   ÚLINE_AA)r   rƒ   r’   ÚthePosr“   r”   Ú	aPositionr   r   r   r‘   Ö  s    zRender.textc          
   C   s´   |   |j|dt¡ |   |j|d¡ t |tjdd¡\}}tdd|d |d ƒ}t|j|j	d  |j	d  |j
|jd  |jd  ƒ}t |j|t|jƒt|j
ƒftjdddt¡ d S )N)é)   rì   rì   )éE   rí   rí   gš™™™™™Ù?r   r   r   )éÎ   rî   rî   )ræ   r&   ÚCVUI_FILLEDr}   r   r   r   r   r   r   r   r    rè   r¹   ÚCVUI_ANTIALISED)r   rƒ   rç   rz   r–   r—   r˜   r™   r   r   r   r    Ú  s    6zRender.counterc             C   s¾   |   |j|d¡ | jd7  _| jd7  _| jd8  _| jd8  _|   |j|d¡ | jd7  _| jd7  _| jd8  _| jd8  _|   |j||tkr¦dn|tkr²dndt¡ d S )N)rì   rì   rì   r   r   )éJ   rñ   rñ   )éB   rò   rò   )éR   ró   ró   )é2   rô   rô   )	ræ   r&   r   r   r   r    r¨   r§   rï   )r   rƒ   r«   rç   r‹   r   r   r   r¼   ä  s    zRender.buttonc             C   s.   ||j |j|j|j …|j|j|j …f< d S )N)r&   r   r    r   r   )r   rƒ   r   rÉ   r   r   r   rÄ   ö  s    zRender.imagec          
   C   s€   |t krdnd}tƒ }|dkrzt|jƒt|jƒf}t |j||tj||dt	¡ t 
|tj|d¡\}	}
tdd|	d |	d ƒ}|jS )Ngö(\ÂõØ?gš™™™™™Ù?r/   r   r   )ri   r   r¹   r   r   r}   rè   r&   r   rð   r   r   )r   rƒ   r«   r”   r’   ÚthePositionÚ
aFontScaler˜   rë   r–   r—   r   r   r   rè   ù  s    zRender.putTextc       	   
   C   sz   d}t  |t j|d¡\}}tdd|d |d ƒ}t|j|jd  |jƒ}t  |j	|t
|jƒt
|jƒft j|ddt¡ |jS )Ng333333Ó?r   r   r   )rî   rî   rî   )r}   r   r   r   r   r   r   r   rè   r&   r¹   rð   )	r   rƒ   rõ   r’   rö   r–   r—   r˜   ZaPositionDecenteredr   r   r   ÚputTextCentered  s    ,zRender.putTextCenteredc             C   s  t |j|jd  |jd  |j|jd  |jd  ƒ}d}| j |¡}|jdkrd|  |||||¡ n°|  ||||j	|¡}	|j|	 }
| j|	7  _d}||j
7 }|  |||||¡}	|
|	 }| j|	7  _|  ||||j|¡ t |jt|
ƒt|jd ƒft|ƒt|jd ƒf|dt¡ d S )Nr   )rî   rî   rî   Fr/   r   r   )r   r   r   r   r    rf   rŽ   r0   rè   r2   r1   r3   r}   Úliner&   r¹   rð   )r   rƒ   r«   r   r‹   ÚtheTextSizer™   ÚaColorrŒ   ÚaWidthZaStartZ	aShortcutZaEndr   r   r   r½     s    6


zRender.buttonLabelc             C   s0  t |j|j|jd  ƒ}d}| j |||¡}	d}
d}t |	|
 |j| ƒ}t |	|
 |j| | ƒ}t|j|j|j|j |j|j ƒ}|tkrŽdnd}|  ||dd¡ | jd7  _| jd7  _| j	d8  _	| jd8  _|  ||d	|¡ | j 
|jt¡d
k}|r,t |	|jd ƒ}|j| }|  |||¡ d S )Nr   r   r   r	   iRRR iBBB i!!! r   iQQQ Fé   )r   r   r   r    rf   rº   r   r§   r'   r   r{   rK   ÚTRACKBAR_HIDE_VALUE_LABELrL   r÷   )r   rƒ   r«   rç   rz   r³   ÚtheWorkingAreaÚaBarTopLeftÚ
aBarHeightÚaPixelXZaIndicatorWidthZaIndicatorHeightÚaPoint1ÚaPoint2r­   Z
aFillColorZ
aShowLabelÚaTextPosr£   r   r   r   ÚtrackbarHandle(  s(    "
zRender.trackbarHandlec             C   s¤   d}t |j|j|jd  ƒ}t|j|j|j|ƒ}	|tkr<dnd}
|  ||	|
d¡ t 	|j
t|	jd ƒt|	j| d ƒft|	j|	j d ƒt|	j| d ƒfd¡ d S )Nr   r   iNNN i>>> i))) r   )rX   rX   rX   )r   r   r   r    r   r   r§   r'   r}   rø   r&   r¹   )r   rƒ   r«   rç   rz   r³   rþ   r   rÿ   r­   ÚaBorderColorr   r   r   ÚtrackbarPathE  s    zRender.trackbarPathc             C   s®   t |j|j|jd  ƒ}d}| j |jt¡}	|	r6|jn|j	|j
 d }
|j
}x\||j	kr¨t| j |||¡ƒ}|t|jƒf}|t|jd ƒf}t |j|||¡ ||
7 }qNW d S )Nr   )éQ   r  r  rÌ   r   )r   r   r   r    rf   r{   rK   r°   rI   rH   rG   r¹   rº   r}   rø   r&   )r   rƒ   r«   rç   rz   r³   rþ   rÿ   rú   Z	aDiscreteZ
aFixedStepr„   r  r  r  r   r   r   ÚtrackbarStepsO  s    zRender.trackbarStepsc             C   s’   d}t |j|j|jd  ƒ}t| j |||¡ƒ}	|	t|jƒf}
|	t|jd ƒf}t |j	|
||¡ |rŽ|j
| }t |	|jd ƒ}|  |||¡ d S )N)r  r  r  r   r   rü   )r   r   r   r    r¹   rf   rº   r}   rø   r&   rL   r÷   )r   rƒ   rç   r³   rz   rþ   ZtheShowLabelrú   rÿ   r  r  r  r£   r  r   r   r   ÚtrackbarSegmentLabel_  s    
zRender.trackbarSegmentLabelc             C   s²   |j dk rdn|j }t|j|j ƒ| }| j |jt¡dk}	|  ||||j||	¡ | j |jt	¡dk}
|j}x*||jkr–|  ||||||
¡ ||7 }qnW |  ||||j||	¡ d S )Nr   F)
rJ   r±   rH   rG   rf   r{   rK   ÚTRACKBAR_HIDE_MIN_MAX_LABELSr
  ÚTRACKBAR_HIDE_SEGMENT_LABELS)r   rƒ   r«   rç   rz   r³   rþ   Ú	aSegmentsZaSegmentLengthZaHasMinMaxLabelsZaHasSegmentLabelsr„   r   r   r   ÚtrackbarSegmentsn  s    zRender.trackbarSegmentsc       	      C   s¶   t |j| jj |j|jd| jj  |jƒ}|  ||||||¡ | j |j	t
¡}| j |j	t¡dk}|r‚|dkr‚|  ||||||¡ |dkrž|  ||||||¡ |  ||||||¡ d S )Nr   F)r   r   rf   rc   r   r   r    r  r{   rK   ÚTRACKBAR_HIDE_LABELSÚTRACKBAR_HIDE_STEP_SCALEr	  r  r  )	r   rƒ   r«   rç   rz   r³   ZaWorkingAreaZaHideAllLabelsZ
aShowStepsr   r   r   rË   ‚  s    *zRender.trackbarc             C   s²   |   |j||tkrdnd¡ | jd7  _| jd7  _| jd8  _| jd8  _|   |j|d¡ | jd7  _| jd7  _| jd8  _| jd8  _|   |j|dt¡ d S )N)éc   r  r  )é€   r  r  r   r   )é   r  r  )rì   rì   rì   )ræ   r&   r¨   r   r   r   r    rï   )r   rƒ   r«   rç   r   r   r   r¦   ’  s    zRender.checkboxc             C   sL   t |j|j d |j|j |jd  |jd  d ƒ}|  |||d|¡ d S )Nr   r   r   gš™™™™™Ù?)r   r   r   r   r    r‘   )r   rƒ   r   r‹   rù   r”   r™   r   r   r   r©   ¤  s    6zRender.checkboxLabelc             C   sN   | j d7  _ | jd7  _| jd8  _| jd8  _|  |j|dt¡ d S )Nr   r   )rØ   é¿   éu   )r   r   r   r    ræ   r&   rï   )r   rƒ   rç   r   r   r   rª   ¨  s
    zRender.checkboxCheckc       	   
   C   s^  d}d}|j  ¡ }|  |j |d¡ | jd7  _| jd7  _| jd8  _| jd8  _|  |j |dt¡ t|jd |jd ƒ}t	 
|j |t|jƒt|jƒft	jd	d
dt¡ |  |j |d¡ | jd7  _| jd7  _| jd8  _| jd8  _|  ||dt¡ |rHt ||j ¡ |  ||dt¡ t	 |||j d| d|j ¡ n|  |j |dt¡ d S )NFg333333Ó?)rñ   rñ   rñ   r   r   )é!   r  r  r
   é   gš™™™™™Ù?)rî   rî   rî   )é1   r  r  g      ð?g        )r&   Úcopyræ   r   r   r   r    rï   r   r}   rè   r¹   r   rð   ÚnpÚcopytoÚaddWeighted)	r   rƒ   ZtheTitleBarZ
theContentrÎ   ZaTransparecyrÙ   ZaOverlayr™   r   r   r   rÍ   ¯  s,    
,zRender.windowc             C   sP   | j  |¡}| j  |¡}|d dk}|r<|  |j||tt¡ |  |j||¡ d S )Nr   rØ   )rf   rÚ   ræ   r&   rï   rð   )r   rƒ   rê   rÐ   rÑ   r  ÚaFillingColorZaHasFillingr   r   r   r'   Ó  s    zRender.rectc             C   s  t |ƒ}d}|| }	t|jƒ| }
|j}xÖ||d krþ|}|| | |	 |jd   |j |j d }t||ƒ}||
 }||d  | |	 |jd   |j |j d }t||ƒ}t |j	t
|jƒt
|jƒft
|jƒt
|jƒf| j |¡¡ ||
7 }|d7 }q*W d S )Nr   r   r
   r   )r   r±   r   r   r    r   r   r}   rø   r&   r¹   rf   rÚ   )r   rƒ   rÔ   r   rM   rN   r”   r¤   rU   ZaScaleZaGapZaPosXr   r   r  r  r   r   r   rÓ   ß  s    ,
0
:zRender.sparkline)r   r   r   rf   rð   ræ   r‘   r    r¼   rÄ   rè   r÷   r½   r  r  r	  r
  r  rË   r¦   r©   rª   rÍ   r'   rÓ   r   r   r   r   rd   Í  s*   


$rd   c       
      C   sÜ   t ttg}tjtjtjg}tjtjtj	g}x˜t
t td ƒD ]†}|| }	| || kr„d|jj_d|jj_d|jj|	 _d|jj|	 _q:| || kr:d|jj_d|jj_d|jj|	 _d|jj|	 _q:W ||jj_||jj_d S )Nr   TF)r9   r:   r;   r}   ÚEVENT_LBUTTONDOWNÚEVENT_MBUTTONDOWNÚEVENT_RBUTTONDOWNÚEVENT_LBUTTONUPÚEVENT_MBUTTONUPÚEVENT_RBUTTONUPr`   rA   r=   r6   r7   r<   r5   r>   r   r   )
ZtheEventr   r   ZtheFlagsZ
theContextZaButtonsZaEventsDownZ	aEventsUprU   ZaBtnr   r   r   Ú_handleMouse÷  s"    





r$  Tc             C   s   t dƒ dS )a1  
	Initializes cvui. You must provide the name of the window where
	components will be added. It is also possible to tell cvui to handle
	OpenCV's event queue automatically (by informing a value greater than zero
	in the `theDelayWaitKey` parameter of the function). In that case, cvui will
	automatically call `cv2.waitKey()` within `cvui.update()`, so you don't
	have to worry about it. The value passed to `theDelayWaitKey` will be
	used as the delay for `cv2.waitKey()`.

	Parameters
	----------
	theWindowName: str
		name of the window where the components will be added.
	theDelayWaitKey: int
		delay value passed to `cv2.waitKey()`. If a negative value is informed (default is `-1`), cvui will not automatically call `cv2.waitKey()` within `cvui.update()`, which will disable keyboard shortcuts for all components. If you want to enable keyboard shortcut for components (e.g. using & in a button label), you must specify a positive value for this param.
	theCreateNamedWindow: bool
		if an OpenCV window named `theWindowName` should be created during the initialization. Windows are created using `cv2.namedWindow()`. If this parameter is `False`, ensure you call `cv2.namedWindow(WINDOW_NAME)` *before* initializing cvui, otherwise it will not be able to track UI interactions.

	See Also
	----------
	watch()
	context()
	z5This is wrapper function to help code autocompletion.N)r|   )rp   rx   ÚtheCreateNamedWindowr   r   r   ry     s    ry   c             C   s   t dƒ dS )aö  
	Initialize cvui using a list of names of windows where components will be added.
	It is also possible to tell cvui to handle OpenCV's event queue automatically
	(by informing a value greater than zero in the `theDelayWaitKey` parameter of the function).
	In that case, cvui will automatically call `cv2.waitKey()` within `cvui.update()`,
	so you don't have to worry about it. The value passed to `theDelayWaitKey` will be
	used as the delay for `cv2.waitKey()`.

	Parameters
	----------
	theWindowNames: str
		array containing the name of the windows where components will be added. Those windows will be automatically if `theCreateNamedWindows` is `True`.
	theHowManyWindows: int
		how many window names exist in the `theWindowNames` array.
	theDelayWaitKey: int
		delay value passed to `cv2.waitKey()`. If a negative value is informed (default is `-1`), cvui will not automatically call `cv2.waitKey()` within `cvui.update()`, which will disable keyboard shortcuts for all components. If you want to enable keyboard shortcut for components (e.g. using & in a button label), you must specify a positive value for this param.
	theCreateNamedWindows: bool
		if OpenCV windows named according to `theWindowNames` should be created during the initialization. Windows are created using `cv2.namedWindow()`. If this parameter is `False`, ensure you call `cv2.namedWindow(WINDOW_NAME)` for all windows *before* initializing cvui, otherwise it will not be able to track UI interactions.

	See Also
	----------
	watch()
	context()
	z5This is wrapper function to help code autocompletion.N)r|   )ZtheWindowNamesZtheHowManyWindowsrx   ZtheCreateNamedWindowsr   r   r   ry   (  s    c             C   sŒ   |rt  | ¡ tƒ }| |_d|jj_d|jj_|jj 	¡  |jj
t  	¡  |jj
t  	¡  |jj
t  	¡  |tj| < t  | ttj|  ¡ dS )aÇ  
	Track UI interactions of a particular window. This function must be invoked
	for any window that will receive cvui components. cvui automatically calls `cvui.watch()`
	for any window informed in `cvui.init()`, so generally you don't have to watch them
	yourself. If you initialized cvui and told it *not* to create windows automatically,
	you need to call `cvui.watch()` on those windows yourself. `cvui.watch()` can
	automatically create a window before watching it, if it does not exist.

	Parameters
	----------
	theWindowName: str
		name of the window whose UI interactions will be tracked.
	theCreateNamedWindow: bool
		if an OpenCV window named `theWindowName` should be created before it is watched. Windows are created using `cv2.namedWindow()`. If this parameter is `False`, ensure you have called `cv2.namedWindow(WINDOW_NAME)` to create the window, otherwise cvui will not be able to track its UI interactions.

	See Also
	----------
	init()
	context()
	r   N)r}   ÚnamedWindowr?   r@   rA   r>   r   r   r=   r-   r<   r;   r:   r9   Ú
__internalr[   ÚsetMouseCallbackr$  )rp   r%  ZaContexr   r   r   ÚwatchC  s    



r)  c             C   s
   | t _dS )aŸ  
	Inform cvui that all subsequent component calls belong to a window in particular.
	When using cvui with multiple OpenCV windows, you must call cvui component calls
	between `cvui.contex(NAME)` and `cvui.update(NAME)`, where `NAME` is the name of
	the window. That way, cvui knows which window you are using (`NAME` in this case),
	so it can track mouse events, for instance.

	E.g.

	```
	# Code for window 'window1'.
	cvui.context('window1')
	cvui.text(frame, ...)
	cvui.button(frame, ...)
	cvui.update('window1')


	# somewhere else, code for 'window2'
	cvui.context('window2')
	cvui.printf(frame, ...)
	cvui.printf(frame, ...)
	cvui.update('window2')

	# Show everything in a window
	cv2.imshow(frame)
	```

	Pay attention to the pair `cvui.context(NAME)` and `cvui.update(NAME)`, which
	encloses the component calls for that window. You need such pair for each window
	of your application.

	After calling `cvui.update()`, you can show the result in a window using `cv2.imshow()`.
	If you want to save some typing, you can use `cvui.imshow()`, which calls `cvui.update()`
	for you and then shows the frame in a window.

	E.g.:

	```
	# Code for window 'window1'.
	cvui.context('window1')
	cvui.text(frame, ...)
	cvui.button(frame, ...)
	cvui.imshow('window1')

	# somewhere else, code for 'window2'
	cvui.context('window2')
	cvui.printf(frame, ...)
	cvui.printf(frame, ...)
	cvui.imshow('window2')
	```

	In that case, you don't have to bother calling `cvui.update()` yourself, since
	`cvui.imshow()` will do it for you.

	Parameters
	----------
	theWindowName: str
		name of the window that will receive components from all subsequent cvui calls.

	See Also
	----------
	init()
	watch()
	N)r'  rZ   )rp   r   r   r   Úcontexth  s    Ar*  c             C   s   t | ƒ t | |¡ dS )aÃ  
	Display an image in the specified window and update the internal structures of cvui.
	This function can be used as a replacement for `cv2.imshow()`. If you want to use
	`cv2.imshow() instead of `cvui.imshow()`, you must ensure you call `cvui.update()`
	*after* all component calls and *before* `cv2.imshow()`, so cvui can update its
	internal structures.

	In general, it is easier to call `cvui.imshow()` alone instead of calling
	`cvui.update()' immediately followed by `cv2.imshow()`.

	Parameters
	----------
	theWindowName: str
		name of the window that will be shown.
	theFrame: np.ndarray
		image, i.e. `np.ndarray`, to be shown in the window.

	See Also
	----------
	update()
	context()
	watch()
	N)Úupdater}   Úimshow)rp   ZtheFramer   r   r   r,  «  s    r,  c               C   s   t jS )zÀ
	Return the last key that was pressed. This function will only
	work if a value greater than zero was passed to `cvui.init()`
	as the delay waitkey parameter.

	See Also
	----------
	init()
	)r'  r]   r   r   r   r   r]   Æ  s    
r]   r/   c             C   s   t dƒ dS )a‰  
	Return the last position of the mouse.

	Parameters
	----------
	theWindowName: str
		name of the window whose mouse cursor will be used. If nothing is informed (default), the function will return the position of the mouse cursor for the default window (the one informed in `cvui.init()`).

	Returns
	----------
	a point containing the position of the mouse cursor in the speficied window.
	z5This is wrapper function to help code autocompletion.N)r|   )rp   r   r   r   rA   Ò  s    rA   c             C   s   t dƒ dS )a#  
	Query the mouse for events, e.g. 'is any button down now?'. Available queries are:

	* `cvui.DOWN`: any mouse button was pressed. `cvui.mouse()` returns `True` for a single frame only.
	* `cvui.UP`: any mouse button was released.  `cvui.mouse()` returns `True` for a single frame only.
	* `cvui.CLICK`: any mouse button was clicked (went down then up, no matter the amount of frames in between). `cvui.mouse()` returns `True` for a single frame only.
	* `cvui.IS_DOWN`: any mouse button is currently pressed. `cvui.mouse()` returns `True` for as long as the button is down/pressed.

	It is easier to think of this function as the answer to a questions. For instance, asking if any mouse button went down:

	```
	if cvui.mouse(cvui.DOWN):
	# Any mouse button just went down.

	```

	The window whose mouse will be queried depends on the context. If `cvui.mouse(query)` is being called after
	`cvui.context()`, the window informed in the context will be queried. If no context is available, the default
	window (informed in `cvui.init()`) will be used.

	Parameters
	----------
	theQuery: int
		an integer describing the intended mouse query. Available queries are `cvui.DOWN`, `cvui.UP`, `cvui.CLICK`, and `cvui.IS_DOWN`.

	See Also
	----------
	mouse(str)
	mouse(str, int)
	mouse(str, int, int)
	mouse(int, int)
	z5This is wrapper function to help code autocompletion.N)r|   )rl   r   r   r   rA   á  s    !c             C   s   t dƒ dS )aù  
	Query the mouse for events in a particular window. This function behave exactly like `cvui.mouse(int theQuery)`
	with the difference that queries are targeted at a particular window.

	Parameters
	----------
	theWindowName: str
		name of the window that will be queried.
	theQuery: int
		an integer describing the intended mouse query. Available queries are `cvui.DOWN`, `cvui.UP`, `cvui.CLICK`, and `cvui.IS_DOWN`.

	See Also
	----------
	mouse(str)
	mouse(str, int, int)
	mouse(int, int)
	mouse(int)
	z5This is wrapper function to help code autocompletion.N)r|   )rp   rl   r   r   r   rA     s    c             C   s   t dƒ dS )aU  
	Query the mouse for events in a particular button. This function behave exactly like `cvui.mouse(int theQuery)`,
	with the difference that queries are targeted at a particular mouse button instead.

	Parameters
	----------
	theButton: int
		an integer describing the mouse button to be queried. Possible values are `cvui.LEFT_BUTTON`, `cvui.MIDDLE_BUTTON` and `cvui.LEFT_BUTTON`.
	theQuery: int
		an integer describing the intended mouse query. Available queries are `cvui.DOWN`, `cvui.UP`, `cvui.CLICK`, and `cvui.IS_DOWN`.

	See Also
	----------
	mouse(str)
	mouse(str, int, int)
	mouse(int)
	z5This is wrapper function to help code autocompletion.N)r|   )rk   rl   r   r   r   rA     s    c             C   s   t dƒ dS )a  
	Query the mouse for events in a particular button in a particular window. This function behave exactly
	like `cvui.mouse(int theButton, int theQuery)`, with the difference that queries are targeted at
	a particular mouse button in a particular window instead.

	Parameters
	----------
	theWindowName: str
		name of the window that will be queried.
	theButton: int
		an integer describing the mouse button to be queried. Possible values are `cvui.LEFT_BUTTON`, `cvui.MIDDLE_BUTTON` and `cvui.LEFT_BUTTON`.
	theQuery: int
		an integer describing the intended mouse query. Available queries are `cvui.DOWN`, `cvui.UP`, `cvui.CLICK`, and `cvui.IS_DOWN`.
	z5This is wrapper function to help code autocompletion.N)r|   )rp   rk   rl   r   r   r   rA   -  s    c             C   s   t dƒ dS )aÉ  
	Display a button. The size of the button will be automatically adjusted to
	properly house the label content.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theLabel: str
		text displayed inside the button.

	Returns
	----------
	`true` everytime the user clicks the button.
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r‹   r   r   r   r¼   >  s    r¼   c             C   s   t dƒ dS )a$  
	Display a button. The button size will be defined by the width and height parameters,
	no matter the content of the label.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theWidth: int
		width of the button.
	theHeight: int
		height of the button.
	theLabel: str
		text displayed inside the button.

	Returns
	----------
	`true` everytime the user clicks the button.
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r!   r"   r‹   r   r   r   r¼   T  s    c             C   s   t dƒ dS )aÂ  
	Display a button whose graphics are images (np.ndarray). The button accepts three images to describe its states,
	which are idle (no mouse interaction), over (mouse is over the button) and down (mouse clicked the button).
	The button size will be defined by the width and height of the images.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theIdle: np.ndarray
		an image that will be rendered when the button is not interacting with the mouse cursor.
	theOver: np.ndarray
		an image that will be rendered when the mouse cursor is over the button.
	theDown: np.ndarray
		an image that will be rendered when the mouse cursor clicked the button (or is clicking).

	Returns
	----------
	`true` everytime the user clicks the button.

	See Also
	----------
	button()
	image()
	iarea()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   rÅ   rÆ   rÇ   r   r   r   r¼   n  s    c             C   s   t dƒ dS )at  
	Display an image (np.ndarray).

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the provded image should be rendered.
	theX: int
		position X where the image should be placed.
	theY: int
		position Y where the image should be placed.
	theImage: np.ndarray
		image to be rendered in the specified destination.

	See Also
	----------
	button()
	iarea()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   rÉ   r   r   r   rÄ     s    rÄ   éÎÎÎ c             C   s   t dƒ dS )a  
	Display a checkbox. You can use the state parameter to monitor if the
	checkbox is checked or not.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theLabel: str
		text displayed besides the clickable checkbox square.
	theState: [bool]
		array or list of booleans whose first position, i.e. theState[0], will be used to store the current state of the checkbox: `True` means the checkbox is checked.
	theColor: uint
		color of the label in the format `0xRRGGBB`, e.g. `0xff0000` for red.

	Returns
	----------
	a boolean value that indicates the current state of the checkbox, `true` if it is checked.
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r‹   r«   r”   r   r   r   r¦   ¥  s    r¦   çš™™™™™Ù?c             C   s   t dƒ dS )aÀ  
	Display a piece of text.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theText: str
		the text content.
	theFontScale: float
		size of the text.
	theColor: uint
		color of the text in the format `0xRRGGBB`, e.g. `0xff0000` for red.

	See Also
	----------
	printf()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r’   r“   r”   r   r   r   r‘   ¿  s    r‘   c             C   s   t dƒ dS )aá  
	Display a piece of text that can be formated using `C stdio's printf()` style. For instance
	if you want to display text mixed with numbers, you can use:

	```
	printf(frame, 10, 15, 0.4, 0xff0000, 'Text: %d and %f', 7, 3.1415)
	```

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theFontScale: float
		size of the text.
	theColor: uint
		color of the text in the format `0xRRGGBB`, e.g. `0xff0000` for red.
	theFmt: str
		formating string as it would be supplied for `stdio's printf()`, e.g. `'Text: %d and %f', 7, 3.1415`.

	See Also
	----------
	text()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r“   r”   ÚtheFmtr   r   r   ÚprintfØ  s    r0  c             C   s   t dƒ dS )aª  
	Display a piece of text that can be formated using `C stdio's printf()` style. For instance
	if you want to display text mixed with numbers, you can use:

	```
	printf(frame, 10, 15, 0.4, 0xff0000, 'Text: %d and %f', 7, 3.1415)
	```

	The size and color of the text will be based on cvui's default values.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theFmt: str
		formating string as it would be supplied for `stdio's printf()`, e.g. `'Text: %d and %f', 7, 3.1415`.

	See Also
	----------
	text()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r/  r   r   r   r0  ö  s    ú%dc             C   s   t dƒ dS )az  
	Display a counter for integer values that the user can increase/descrease
	by clicking the up and down arrows.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theValue: [number]
		array or list of numbers whose first position, i.e. theValue[0], will be used to store the current value of the counter.
	theStep: number
		amount that should be increased/decreased when the user interacts with the counter buttons
	theFormat: str
		how the value of the counter should be presented, as it was printed by `stdio's printf()`. E.g. `'%d'` means the value will be displayed as an integer, `'%0d'` integer with one leading zero, etc.

	Returns
	----------
	number that corresponds to the current value of the counter.
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   rz   rO   r¡   r   r   r   r      s    r    ú%.1Lfc             C   s   t dƒ dS )a¹
  
	Display a trackbar for numeric values that the user can increase/decrease
	by clicking and/or dragging the marker right or left. This component can use
	different types of data as its value, so it is imperative provide the right
	label format, e.g. '%d' for ints, otherwise you might end up with weird errors.

	Example:

	```
	# using float
	trackbar(where, x, y, width, &floatValue, 0.0, 50.0)

	# using float
	trackbar(where, x, y, width, &floatValue, 0.0f, 50.0f)

	# using char
	trackbar(where, x, y, width, &charValue, (char)1, (char)10)
	```

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theWidth: int
		width of the trackbar.
	theValue: [number]
		array or list of numbers whose first position, i.e. theValue[0], will be used to store the current value of the trackbar. It will be modified when the user interacts with the trackbar. Any numeric type can be used, e.g. int, float, long double, etc.
	theMin: number
		minimum value allowed for the trackbar.
	theMax: number
		maximum value allowed for the trackbar.
	theSegments: int
		number of segments the trackbar will have (default is 1). Segments can be seen as groups of numbers in the scale of the trackbar. For example, 1 segment means a single groups of values (no extra labels along the scale), 2 segments mean the trackbar values will be divided in two groups and a label will be placed at the middle of the scale.
	theLabelFormat: str
		formating string that will be used to render the labels. If you are using a trackbar with integers values, for instance, you can use `%d` to render labels.
	theOptions: uint
		options to customize the behavior/appearance of the trackbar, expressed as a bitset. Available options are defined as `cvui.TRACKBAR_` constants and they can be combined using the bitwise `|` operand. Available options are: `TRACKBAR_HIDE_SEGMENT_LABELS` (do not render segment labels, but do render min/max labels), `TRACKBAR_HIDE_STEP_SCALE` (do not render the small lines indicating values in the scale), `TRACKBAR_DISCRETE` (changes of the trackbar value are multiples of theDiscreteStep param), `TRACKBAR_HIDE_MIN_MAX_LABELS` (do not render min/max labels), `TRACKBAR_HIDE_VALUE_LABEL` (do not render the current value of the trackbar below the moving marker), `TRACKBAR_HIDE_LABELS` (do not render labels at all).
	theDiscreteStep: number
		amount that the trackbar marker will increase/decrease when the marker is dragged right/left (if option TRACKBAR_DISCRETE is ON)

	Returns
	----------
	`true` when the value of the trackbar changed.

	See Also
	----------
	counter()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r!   rz   rM   rN   rP   rQ   rR   ÚtheDiscreteStepr   r   r   rË   ,  s    5rË   c             C   s   t dƒ dS )aÁ  
	Display a window (a block with a title and a body).

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theWidth: int
		width of the window.
	theHeight: int
		height of the window.
	theTitle: str
		text displayed as the title of the window.

	See Also
	----------
	rect()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r!   r"   rÎ   r   r   r   rÍ   c  s    rÍ   ì      ~ c             C   s   t dƒ dS )an  
	Display a filled rectangle.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theWidth: int
		width of the rectangle.
	theHeight: int
		height of the rectangle.
	theBorderColor: uint
		color of rectangle's border in the format `0xRRGGBB`, e.g. `0xff0000` for red.
	theFillingColor: uint
		color of rectangle's filling in the format `0xAARRGGBB`, e.g. `0x00ff0000` for red, `0xff000000` for transparent filling.

	See Also
	----------
	image()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r!   r"   rÐ   rÑ   r   r   r   r'   |  s    r'   é ÿ  c             C   s   t dƒ dS )aB  
	Display the values of a vector as a sparkline.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the component should be rendered.
	theValues: number[]
		array or list containing the numeric values to be used in the sparkline.
	theX: int
		position X where the component should be placed.
	theY: int
		position Y where the component should be placed.
	theWidth: int
		width of the sparkline.
	theHeight: int
		height of the sparkline.
	theColor: uint
		color of sparkline in the format `0xRRGGBB`, e.g. `0xff0000` for red.

	See Also
	----------
	trackbar()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   rÔ   r   r   r!   r"   r”   r   r   r   rÓ   —  s    rÓ   c             C   s   t  | |||¡S )ap  
	Create an interaction area that reports activity with the mouse cursor.
	The tracked interactions are returned by the function and they are:

	`OUT` when the cursor is not over the iarea.
	`OVER` when the cursor is over the iarea.
	`DOWN` when the cursor is pressed over the iarea, but not released yet.
	`CLICK` when the cursor clicked (pressed and released) within the iarea.

	This function creates no visual output on the screen. It is intended to
	be used as an auxiliary tool to create interactions.

	Parameters
	----------
	theX: int
		position X where the interactive area should be placed.
	theY: int
		position Y where the interactive area should be placed.
	theWidth: int
		width of the interactive area.
	theHeight: int
		height of the interactive area.

	Returns
	----------
	integer value representing the current state of interaction with the mouse cursor. It can be `OUT` (cursor is not over the area), `OVER` (cursor is over the area), `DOWN` (cursor is pressed over the area, but not released yet) and `CLICK` (cursor clicked, i.e. pressed and released, within the area).

	See Also
	----------
	button()
	image()
	)r'  r»   )r   r   r!   r"   r   r   r   r»   ²  s    !r»   c             C   s   t dƒ dS )aå  
	Start a new row.

	One of the most annoying tasks when building UI is to calculate
	where each component should be placed on the screen. cvui has
	a set of methods that abstract the process of positioning
	components, so you don't have to think about assigning a
	X and Y coordinate. Instead you just add components and cvui
	will place them as you go.

	You use `beginRow()` to start a group of elements. After `beginRow()`
	has been called, all subsequent component calls don't have to specify
	the frame where the component should be rendered nor its position.
	The position of the component will be automatically calculated by cvui
	based on the components within the group. All components are placed
	side by side, from left to right.

	E.g.

	```
	beginRow(frame, x, y, width, height)
	text('test')
	button('btn')
	endRow()
	```

	Rows and columns can be nested, so you can create columns/rows within
	columns/rows as much as you want. It's important to notice that any
	component within `beginRow()` and `endRow()` *do not* specify the position
	where the component is rendered, which is also True for `beginRow()`.
	As a consequence, **be sure you are calling `beginRow(width, height)`
	when the call is nested instead of `beginRow(x, y, width, height)`**,
	otherwise cvui will throw an error.

	E.g.

	```
	beginRow(frame, x, y, width, height)
	text('test')
	button('btn')

	beginColumn()      # no frame nor x,y parameters here!
	text('column1')
	text('column2')
	endColumn()
	endRow()
	```

	Don't forget to call `endRow()` to finish the row, otherwise cvui will throw an error.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the components within this block should be rendered.
	theX: int
		position X where the row should be placed.
	theY: int
		position Y where the row should be placed.
	theWidth: int
		width of the row. If a negative value is specified, the width of the row will be automatically calculated based on the content of the block.
	theHeight: int
		height of the row. If a negative value is specified, the height of the row will be automatically calculated based on the content of the block.
	thePadding: int
		space, in pixels, among the components of the block.

	See Also
	----------
	beginColumn()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r!   r"   râ   r   r   r   ÚbeginRowÕ  s    Hr6  c               C   s   t  t¡ dS )zº
	End a row. You must call this function only if you have previously called
	its counter part, the `beginRow()` function.

	See Also
	----------
	beginRow()
	beginColumn()
	endColumn()
	N)r'  rå   r+   r   r   r   r   ÚendRow  s    r7  c             C   s   t dƒ dS )a1	  
	Start a new column.

	One of the most annoying tasks when building UI is to calculate
	where each component should be placed on the screen. cvui has
	a set of methods that abstract the process of positioning
	components, so you don't have to think about assigning a
	X and Y coordinate. Instead you just add components and cvui
	will place them as you go.

	You use `beginColumn()` to start a group of elements. After `beginColumn()`
	has been called, all subsequent component calls don't have to specify
	the frame where the component should be rendered nor its position.
	The position of the component will be automatically calculated by cvui
	based on the components within the group. All components are placed
	below each other, from the top of the screen towards the bottom.

	E.g.

	```
	beginColumn(frame, x, y, width, height)
	text('test')
	button('btn')
	endColumn()
	```

	Rows and columns can be nested, so you can create columns/rows within
	columns/rows as much as you want. It's important to notice that any
	component within `beginColumn()` and `endColumn()` *do not* specify the position
	where the component is rendered, which is also True for `beginColumn()`.
	As a consequence, **be sure you are calling `beginColumn(width, height)`
	when the call is nested instead of `beginColumn(x, y, width, height)`**,
	otherwise cvui will throw an error.

	E.g.

	```
	beginColumn(frame, x, y, width, height)
	text('test')
	button('btn')

	beginRow()      # no frame nor x,y parameters here!
	text('column1')
	text('column2')
	endRow()
	endColumn()
	```

	Don't forget to call `endColumn()` to finish the column, otherwise cvui will throw an error.

	Parameters
	----------
	theWhere: np.ndarray
		image/frame where the components within this block should be rendered.
	theX: int
		position X where the row should be placed.
	theY: int
		position Y where the row should be placed.
	theWidth: int
		width of the column. If a negative value is specified, the width of the column will be automatically calculated based on the content of the block.
	theHeight: int
		height of the column. If a negative value is specified, the height of the column will be automatically calculated based on the content of the block.
	thePadding: int
		space, in pixels, among the components of the block.

	See Also
	----------
	beginRow()
	endColumn()
	endRow()
	z5This is wrapper function to help code autocompletion.N)r|   )rá   r   r   r!   r"   râ   r   r   r   ÚbeginColumn,  s    Hr8  c               C   s   t  t¡ dS )zµ
	End a column. You must call this function only if you have previously called
	its counter part, i.e. `beginColumn()`.

	See Also
	----------
	beginColumn()
	beginRow()
	endRow()
	N)r'  rå   r‚   r   r   r   r   Ú	endColumnv  s    r9  c             C   s   t dƒ dS )a1  
	Start a row. This function behaves in the same way as `beginRow(frame, x, y, width, height)`,
	however it is suposed to be used within `begin*()/end*()` blocks since they require components
	not to inform frame nor x,y coordinates.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theWidth: int
		width of the row. If a negative value is specified, the width of the row will be automatically calculated based on the content of the block.
	theHeight: int
		height of the row. If a negative value is specified, the height of the row will be automatically calculated based on the content of the block.
	thePadding: int
		space, in pixels, among the components of the block.

	See Also
	----------
	beginColumn()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r!   r"   râ   r   r   r   r6  ƒ  s    c             C   s   t dƒ dS )aC  
	Start a column. This function behaves in the same way as `beginColumn(frame, x, y, width, height)`,
	however it is suposed to be used within `begin*()/end*()` blocks since they require components
	not to inform frame nor x,y coordinates.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theWidth: int
		width of the column. If a negative value is specified, the width of the column will be automatically calculated based on the content of the block.
	theHeight: int
		height of the column. If a negative value is specified, the height of the column will be automatically calculated based on the content of the block.
	thePadding: int
		space, in pixels, among the components of the block.

	See Also
	----------
	beginColumn()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r!   r"   râ   r   r   r   r8  œ  s    c             C   s"   t  ¡ }t| | ƒ}t  ||¡ dS )a4  
	Add an arbitrary amount of space between components within a `begin*()` and `end*()` block.
	The function is aware of context, so if it is used within a `beginColumn()` and
	`endColumn()` block, the space will be vertical. If it is used within a `beginRow()`
	and `endRow()` block, space will be horizontal.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theValue: int
		the amount of space to be added.

	See Also
	----------
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	N)r'  r‡   r$   r…   )rz   rã   r¤   r   r   r   Úspaceµ  s    
r:  c             C   s   t dƒ dS )a¶  
	Display a piece of text within a `begin*()` and `end*()` block.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theText: str
		text content.
	theFontScale: float
		size of the text.
	theColor: uint
		color of the text in the format `0xRRGGBB`, e.g. `0xff0000` for red.

	See Also
	----------
	printf()
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r’   r“   r”   r   r   r   r‘   Ï  s    c             C   s   t dƒ dS )ai  
	Display a button within a `begin*()` and `end*()` block.
	The button size will be defined by the width and height parameters,
	no matter the content of the label.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theWidth: int
		width of the button.
	theHeight: int
		height of the button.
	theLabel: str
		text displayed inside the button. You can set shortcuts by pre-pending them with '&'

	Returns
	----------
	`true` everytime the user clicks the button.

	See Also
	----------
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r!   r"   r‹   r   r   r   r¼   è  s    c             C   s   t dƒ dS )a  
	Display a button within a `begin*()` and `end*()` block. The size of the button will be
	automatically adjusted to properly house the label content.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theLabel: str
		text displayed inside the button. You can set shortcuts by pre-pending them with '&'

	Returns
	----------
	`true` everytime the user clicks the button.

	See Also
	----------
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r‹   r   r   r   r¼     s    c             C   s   t dƒ dS )aŽ  
	Display a button whose graphics are images (np.ndarray).

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	The button accepts three images to describe its states,
	which are idle (no mouse interaction), over (mouse is over the button) and down (mouse clicked the button).
	The button size will be defined by the width and height of the images.

	Parameters
	----------
	theIdle: np.ndarray
		image that will be rendered when the button is not interacting with the mouse cursor.
	theOver: np.ndarray
		image that will be rendered when the mouse cursor is over the button.
	theDown: np.ndarray
		image that will be rendered when the mouse cursor clicked the button (or is clicking).

	Returns
	----------
	`true` everytime the user clicks the button.

	See Also
	----------
	button()
	image()
	iarea()
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )rÅ   rÆ   rÇ   r   r   r   r¼     s    !c             C   s   t dƒ dS )aq  
	Display an image (np.ndarray) within a `begin*()` and `end*()` block

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theImage: np.ndarray
		image to be rendered in the specified destination.

	See Also
	----------
	button()
	iarea()
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )rÉ   r   r   r   rÄ   B  s    c             C   s   t dƒ dS )a  
	Display a checkbox within a `begin*()` and `end*()` block. You can use the state parameter
	to monitor if the checkbox is checked or not.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theLabel: str
		text displayed besides the clickable checkbox square.
	theState: [bool]
		array or list of booleans whose first position, i.e. theState[0], will be used to store the current state of the checkbox: `True` means the checkbox is checked.
	theColor: uint
		color of the label in the format `0xRRGGBB`, e.g. `0xff0000` for red.

	Returns
	----------
	a boolean value that indicates the current state of the checkbox, `true` if it is checked.

	See Also
	----------
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r‹   r«   r”   r   r   r   r¦   X  s    c             C   s   t dƒ dS )aÕ  
	Display a piece of text within a `begin*()` and `end*()` block.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	The text can be formated using `C stdio's printf()` style. For instance if you want to display text mixed
	with numbers, you can use:

	```
	printf(0.4, 0xff0000, 'Text: %d and %f', 7, 3.1415)
	```

	Parameters
	----------
	theFontScale: float
		size of the text.
	theColor: uint
		color of the text in the format `0xRRGGBB`, e.g. `0xff0000` for red.
	theFmt: str
		formating string as it would be supplied for `C stdio's printf()`, e.g. `'Text: %d and %f', 7, 3.1415`.

	See Also
	----------
	text()
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r“   r”   r/  r   r   r   r0  u  s    c             C   s   t dƒ dS )a~  
	Display a piece of text that can be formated using `C stdio's printf()` style.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	For instance if you want to display text mixed with numbers, you can use:

	```
	printf(frame, 10, 15, 0.4, 0xff0000, 'Text: %d and %f', 7, 3.1415)
	```

	The size and color of the text will be based on cvui's default values.

	Parameters
	----------
	theFmt: str
		formating string as it would be supplied for `stdio's printf()`, e.g. `'Text: %d and %f', 7, 3.1415`.

	See Also
	----------
	text()
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r/  r   r   r   r0  •  s    c             C   s   t dƒ dS )aq  
	Display a counter for integer values that the user can increase/descrease
	by clicking the up and down arrows.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theValue: [number]
		array or list of numbers whose first position, i.e. theValue[0], will be used to store the current value of the counter.
	theStep: number
		amount that should be increased/decreased when the user interacts with the counter buttons.
	theFormat: str
		how the value of the counter should be presented, as it was printed by `C stdio's printf()`. E.g. `'%d'` means the value will be displayed as an integer, `'%0d'` integer with one leading zero, etc.

	Returns
	----------
	number that corresponds to the current value of the counter.

	See Also
	----------
	printf()
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )rz   rO   r¡   r   r   r   r    ²  s    c             C   s   t dƒ dS )a`  
	Display a trackbar for numeric values that the user can increase/decrease
	by clicking and/or dragging the marker right or left.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	This component uses templates so it is imperative that you make it very explicit
	the type of `theValue`, `theMin`, `theMax` and `theStep`, otherwise you might end up with
	weird compilation errors.

	Example:

	```
	# using float
	trackbar(width, &floatValue, 0.0, 50.0)

	# using float
	trackbar(width, &floatValue, 0.0f, 50.0f)

	# using char
	trackbar(width, &charValue, (char)1, (char)10)
	```

	Parameters
	----------
	theWidth: int
		the width of the trackbar.
	theValue: [number]
		array or list of numbers whose first position, i.e. theValue[0], will be used to store the current value of the trackbar. It will be modified when the user interacts with the trackbar. Any numeric type can be used, e.g. int, float, long double, etc.
	theMin: number
		minimum value allowed for the trackbar.
	theMax: number
		maximum value allowed for the trackbar.
	theSegments: int
		number of segments the trackbar will have (default is 1). Segments can be seen as groups of numbers in the scale of the trackbar. For example, 1 segment means a single groups of values (no extra labels along the scale), 2 segments mean the trackbar values will be divided in two groups and a label will be placed at the middle of the scale.
	theLabelFormat: str
		formating string that will be used to render the labels, e.g. `%.2Lf`. No matter the type of the `theValue` param, internally trackbar stores it as a `long float`, so the formating string will *always* receive a `long float` value to format. If you are using a trackbar with integers values, for instance, you can supress decimals using a formating string as `%.0Lf` to format your labels.
	theOptions: uint
		options to customize the behavior/appearance of the trackbar, expressed as a bitset. Available options are defined as `TRACKBAR_` constants and they can be combined using the bitwise `|` operand. Available options are: `TRACKBAR_HIDE_SEGMENT_LABELS` (do not render segment labels, but do render min/max labels), `TRACKBAR_HIDE_STEP_SCALE` (do not render the small lines indicating values in the scale), `TRACKBAR_DISCRETE` (changes of the trackbar value are multiples of informed step param), `TRACKBAR_HIDE_MIN_MAX_LABELS` (do not render min/max labels), `TRACKBAR_HIDE_VALUE_LABEL` (do not render the current value of the trackbar below the moving marker), `TRACKBAR_HIDE_LABELS` (do not render labels at all).
	theDiscreteStep: number
		amount that the trackbar marker will increase/decrease when the marker is dragged right/left (if option TRACKBAR_DISCRETE is ON)

	Returns
	----------
	`true` when the value of the trackbar changed.

	See Also
	----------
	counter()
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r!   rz   rM   rN   rP   rQ   rR   r3  r   r   r   rË   Ð  s    7c             C   s   t dƒ dS )a»  
	Display a window (a block with a title and a body) within a `begin*()` and `end*()` block.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theWidth: int
		width of the window.
	theHeight: int
		height of the window.
	theTitle: str
		text displayed as the title of the window.

	See Also
	----------
	rect()
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r!   r"   rÎ   r   r   r   rÍ   		  s    c             C   s   t dƒ dS )ab  
	Display a rectangle within a `begin*()` and `end*()` block.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theWidth: int
		width of the rectangle.
	theHeight: int
		height of the rectangle.
	theBorderColor: uint
		color of rectangle's border in the format `0xRRGGBB`, e.g. `0xff0000` for red.
	theFillingColor: uint
		color of rectangle's filling in the format `0xAARRGGBB`, e.g. `0x00ff0000` for red, `0xff000000` for transparent filling.

	See Also
	----------
	window()
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )r!   r"   rÐ   rÑ   r   r   r   r'   "	  s    c             C   s   t dƒ dS )a-  
	Display the values of a vector as a sparkline within a `begin*()` and `end*()` block.

	IMPORTANT: this function can only be used within a `begin*()/end*()` block, otherwise it does nothing.

	Parameters
	----------
	theValues: number[]
		array or list of numeric values that will be rendered as a sparkline.
	theWidth: int
		width of the sparkline.
	theHeight: int
		height of the sparkline.
	theColor: uint
		color of sparkline in the format `0xRRGGBB`, e.g. `0xff0000` for red.

	See Also
	----------
	beginColumn()
	beginRow()
	endRow()
	endColumn()
	z5This is wrapper function to help code autocompletion.N)r|   )rÔ   r!   r"   r”   r   r   r   rÓ   =	  s    c             C   s   t  | ¡}d|jj_d|jj_x2tttd ƒD ] }d|jj	| _d|jj	| _q.W t j
 ¡  t jdkrtt t j¡t _t  ¡ dkrŒt  dd¡ dS )a†  
	Update the library internal things. You need to call this function **AFTER** you are done adding/manipulating
	UI elements in order for them to react to mouse interactions.

	Parameters
	----------
	theWindowName: str
		name of the window whose components are being updated. If no window name is provided, cvui uses the default window.

	See Also
	----------
	init()
	watch()
	context()
	Fr   r   r   z½Calling update() before finishing all begin*()/end*() calls. Did you forget to call a begin*() or an end*()? Check if every begin*() has an appropriate end*() call before you call update().N)r'  ro   rA   r=   r5   r6   r`   r9   r;   r<   r_   r-   r^   r}   r~   r]   r†   rw   )rp   ZaContextrU   r   r   r   r+  W	  s    




r+  c              G   sÔ   t  | d ¡r^| d }t| ƒdkr*| d nd}t| ƒdkrB| d nd}t  ||¡ t||ƒ nr| d }| d }t| ƒdkr‚| d nd}t| ƒdkrš| d nd}t  |d |¡ x td|ƒD ]}t|| |ƒ qºW d S )Nr   r   r   r   r   Tr	   )r'  rß   r   ry   r)  r`   )ÚtheArgsÚaWindowNameZaDelayWaitKeyZaCreateNamedWindowZaWindowNamesZaHowManyWindowsZaCreateNamedWindowsrU   r   r   r   ry   z	  s    c           	   G   sÚ   t | d tjƒrp| d }| d }| d }| d }t| ƒdkrD| d nd}t| ƒdkr\| d nd	}|tj_tj}nPt ¡ }|jj	}|jj
}| d }t| ƒdkr¤| d nd}t| ƒdkr¼| d nd	}t ||||||d
¡ d S )Nr   r   r   r   r
   r	   gš™™™™™Ù?r   iÎÎÎ T)rÛ   r  Úndarrayr   r'  r_   r&   r‡   r)   r   r   r‘   )r;  ÚaWhereÚaXÚaYr£   rö   rú   rã   r   r   r   r‘   	  s     c           	   G   sÒ   t | d tjƒrD| d }| d }| d }|tj_tj}| dd … }nt ¡ }|jj}|jj	}| }t 
|d ¡rŒd}d}|d }|dd … }	n$|d }|d }|d }|dd … }	||	 }
t ||||
||d¡ d S )Nr   r   r   r   gš™™™™™Ù?iÎÎÎ T)rÛ   r  r=  r'  r_   r&   r‡   r)   r   r   rß   r‘   )r;  r>  r?  r@  rã   ÚaArgsrö   rú   ZaFmtZaFmtArgsr£   r   r   r   r0  ¦	  s,    c        	      G   s   t | d tjƒrp| d }| d }| d }| d }t| ƒdkrD| d nd}t| ƒdkr\| d nd}|tj_tj}nPt ¡ }|jj	}|jj
}| d }t| ƒdkr¤| d nd}t| ƒdkr¼| d nd}|sìt |d tƒd	koÞt |tƒ}|rèd
nd}t ||||||¡S )Nr   r   r   r   r
   r	   r   r/   Tz%dz%.1f)rÛ   r  r=  r   r'  r_   r&   r‡   r)   r   r   r¹   r    )	r;  r>  r?  r@  r„   ZaStepZaFormatrã   ZaIsIntr   r   r   r    È	  s&    c              G   s´   t | d tjƒr`| d }| d }| d }| d }| d }t| ƒdkrL| d nd}|tj_tj}n@t ¡ }|jj	}|jj
}| d }| d }t| ƒdkrœ| d nd}t ||||||¡S )	Nr   r   r   r   r	   r   r
   iÎÎÎ )rÛ   r  r=  r   r'  r_   r&   r‡   r)   r   r   r¦   )r;  r>  r?  r@  rŒ   ZaStaterú   rã   r   r   r   r¦   ã	  s     c              G   sØ   t | ƒdkr2| d }| d }| d }t |||¡S t | ƒdkr†t | d ¡rh| d }| d }t ||¡S | d }| d }t ||¡S nNt | ƒdkr²t| d tƒr²| d }t |¡S t | ƒdkrÆ| d nd}t 	|¡S d S )Nr   r   r   r   r/   )
r   r'  ru   rß   rr   rv   rÛ   r¹   rs   rq   )r;  r<  rt   ZaQueryr   r   r   rA   ú	  s$    
c           	   G   s  t | d tjƒrXt | d tjƒdkrX| d }| d }| d }|tj_tj}| dd … }nt ¡ }|jj}|jj	}| }t
|ƒdkr˜|d }t ||||¡S t
|ƒdkrt |d tƒrâ|d }|d }|d }t ||||||d¡S |d }	|d }
|d }t ||||	|
|d¡S ntdƒ d S )Nr   r   Fr   r   TzProblem?)rÛ   r  r=  r'  r_   r&   r‡   r)   r   r   r   r¼   r¹   rŸ   rÈ   r|   )r;  r>  r?  r@  rã   rA  rŒ   rû   ÚaHeightZaIdleZaOverZaDownr   r   r   r¼   
  s2    $c              G   s„   t | d tjƒrXt| ƒdkrX| d }| d }| d }| d }|tj_t tj|||¡ n(| d }t ¡ }t ||j	j
|j	j|¡ d S )Nr   r   r   r   )rÛ   r  r=  r   r'  r_   r&   rÄ   r‡   r)   r   r   )r;  r>  r?  r@  ZaImagerã   r   r   r   rÄ   >
  s    c              G   s‚  t | d tjƒr¸| d }| d }| d }| d }| d }| d }| d }t| ƒdkr\| d	 nd}t| ƒd
krt| d nd}	t| ƒdkrŒ| d
 nd}
t| ƒdkr¤| d nd}|tj_tj}n t ¡ }|jj	}|jj
}| d }| d }| d }| d }t| ƒdkr| d nd}t| ƒdkr | d nd}	t| ƒd	kr:| d nd}
t| ƒdkrT| d	 nd}t|||||	|
ƒ}t ||||||¡}|S )Nr   r   r   r   r	   r
   r   r   r   é	   z%.1Lfé
   rü   )rÛ   r  r=  r   r'  r_   r&   r‡   r)   r   r   rB   rË   )r;  r>  r?  r@  rû   r„   rÕ   rÖ   r  ZaLabelFormatZaOptionsZaDiscreteSteprã   ZaParamsZaResultr   r   r   rË   O
  s8    c              G   s    t | d tjƒr`| d }| d }| d }| d }| d }| d }|tj_t tj|||||¡ n<| d }| d }| d }t ¡ }t ||jj	|jj
|||¡ d S )Nr   r   r   r   r	   r
   )rÛ   r  r=  r'  r_   r&   rÍ   r‡   r)   r   r   )r;  r>  r?  r@  rû   rB  ZaTitlerã   r   r   r   rÍ   u
  s    c        	   	   G   sÊ   t | d tjƒrh| d }| d }| d }| d }| d }| d }t| ƒdkrT| d nd	}|tj_tj}nHt ¡ }|jj	}|jj
}| d }| d }| d }t| ƒdkr¬| d nd	}t |||||||¡ d S )
Nr   r   r   r   r	   r
   r   r   l      ~ )rÛ   r  r=  r   r'  r_   r&   r‡   r)   r   r   r'   )	r;  r>  r?  r@  rû   rB  r  r  rã   r   r   r   r'   Š
  s$    c        	   	   G   sÊ   t | d tjƒrh| d }| d }| d }| d }| d }| d }t| ƒdkrT| d nd	}|tj_tj}nHt ¡ }| d }|jj	}|jj
}| d }| d }t| ƒdkr¬| d nd	}t |||||||¡ d S )
Nr   r   r   r   r	   r
   r   r   i ÿ  )rÛ   r  r=  r   r'  r_   r&   r‡   r)   r   r   rÓ   )	r;  r>  ZaValuesr?  r@  rû   rB  rú   rã   r   r   r   rÓ   £
  s$    c           	   G   s  t | ƒrt| d tjƒr| d }| d }| d }t | ƒdkrD| d nd}t | ƒdkr\| d nd}t | ƒdkrt| d nd}t t||||||¡ npt | ƒdkr¤| d nd}t | ƒdkr¼| d nd}t | ƒdkrÔ| d nd}t ¡ }t t|j|j	j
|j	j|||¡ d S )	Nr   r   r   r	   r   r   r
   r   )r   rÛ   r  r=  r'  rä   r+   r‡   r&   r)   r   r   )r;  r>  r?  r@  rû   rB  ÚaPaddingrã   r   r   r   r6  ¼
  s    c           	   G   s  t | ƒdkr”t| d tjƒr”| d }| d }| d }t | ƒdkrH| d nd}t | ƒdkr`| d nd}t | ƒdkrx| d nd}t t||||||¡ npt | ƒdkr¨| d nd}t | ƒdkrÀ| d nd}t | ƒdkrØ| d nd}t ¡ }t t|j|j	j
|j	j|||¡ d S )	Nr   r   r   r	   r   r   r
   r   )r   rÛ   r  r=  r'  rä   r‚   r‡   r&   r)   r   r   )r;  r>  r?  r@  rû   rB  rE  rã   r   r   r   r8  Ð
  s    )r   T)r   T)T)r/   )r-  )r.  r-  )r   r1  )r   r2  r   r   )r4  )r5  )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r
   )r.  r-  )r-  )r   r1  )r   r2  r   r   )r4  )r5  )r/   )CÚ__doc__r}   Únumpyr  r   r   r   ÚVERSIONr+   r‚   ri   rg   r§   r¨   rh   rj   r9   r:   r;   r  r  r°   r  rý   r  Úversion_infoÚmajorrÜ   ré   rð   rï   r   r   r$   r%   r.   r4   r8   r?   rB   rS   rd   r'  r$  ry   r)  r*  r,  r]   rA   r¼   rÄ   r¦   r‘   r0  r    rË   rÍ   r'   rÓ   r»   r6  r7  r8  r9  r:  r+  r   r   r   r   Ú<module>%   sÔ   	       *


%C
#!



7

#
J
J



#
 

9


#"(&