
    lj                        d dl mZ d dlmZmZ d dlZd dlmZ	 d dl
mZ d dlmZmZ ddlmZmZ erd	d
lmZ dgZ G d de	          ZdS )    )annotations)TYPE_CHECKINGAnyN)Window)Timer)Monitorget_monitors   )__version__config   )OpenGLRendererr   c                       e Zd ZdZdZdZdZdZej	        fd% fdZ
d& fdZd' fdZd( fdZd) fdZd* fdZd+d"Zd, fd$Z xZS )-r   FT)   r   rendererr   window_sizestr | tuple[int, ...]kwargsr   returnNonec                *   t                      }t          j        }|t          |t	          |          dz
                     }d}t          |t                    r%t	          |          dk    rt          |          |}n|dk    rF|j        }	t          j	        s|	dz  }	t          |	t          j        z  t          j        z            }
|	|
f}nrt	          |                    d                    dk    r=t          t          t          |                    d                              \  }	}
|	|
f}nt          |          t                                          |           dt"           | _        || _        || _        t+          j        |            t/                      | _        t+          j        | j        | | j        	          | _        | j                                         |                                  |                     ||          }|| _        d S )
Nr   zwindow_size must be specified either as 'default', a string of the form 'width,height', or a tuple of 2 ints of the form (width, height).r
   default,)sizezManim Community )window)ctxwndtimer)r	   r   window_monitorminlen
isinstancetuple
ValueErrorwidth
fullscreenintframe_heightframe_widthsplitmapsuper__init__r   titler   r   mglwactivate_contextr   r   WindowConfigr   startswap_buffersfind_initial_positionposition)selfr   r   r   monitors	mon_indexmonitor!invalid_window_size_error_messager   window_widthwindow_heightinitial_position	__class__s               `/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/renderer/opengl_renderer_window.pyr-   zWindow.__init__   s     >>)	3y#h--!*;<<=P 	*
 k5)) 	@;1$$ !BCCCDDI%% #=L$ #"  v22f6HH M !-0DD""3''((A--,1#c;;L;LS;Q;Q2R2R,S,S)\= -0DD>???d###555
	 T****WW
'DH$djQQQ
55dGDD(    xr'   ydxdyc                    t                                          ||||           | j                            ||          }| j                            ||d          }| j        j                            ||           d S NT)relative)r,   on_mouse_motionr   pixel_coords_to_space_coordsscene)r6   rA   rB   rC   rD   pointd_pointr>   s          r?   rH   zWindow.on_mouse_motionO   su    1b"---::1a@@-<<Rd<SS++E7;;;;;r@   x_offsetfloaty_offsetc                    t                                          ||||           | j                            ||          }| j                            ||d          }| j        j                            ||           d S rF   )r,   on_mouse_scrollr   rI   rJ   )r6   rA   rB   rM   rO   rK   offsetr>   s          r?   rQ   zWindow.on_mouse_scrollU   s    1h999::1a@@;; < 
 

 	++E6:::::r@   symbol	modifiersboolc                    | j         j                            |           t                                          ||          }| j         j                            ||           |S N)r   pressed_keysaddr,   on_key_pressrJ   )r6   rS   rT   event_handledr>   s       r?   rZ   zWindow.on_key_press_   sV    "&&v...#gg2269EE((;;;r@   c                    || j         j        v r| j         j                            |           t                                          ||           | j         j                            ||           d S rW   )r   rX   remover,   on_key_releaserJ   )r6   rS   rT   r>   s      r?   r^   zWindow.on_key_releasee   sg    T]///M&--f555vy111**69=====r@   buttonsc                   t                                          ||||||           | j                            ||          }| j                            ||d          }| j        j                            ||||           d S rF   )r,   on_mouse_dragr   rI   rJ   )
r6   rA   rB   rC   rD   r_   rT   rK   rL   r>   s
            r?   ra   zWindow.on_mouse_dragk   s     	aBGY???::1a@@-<<Rd<SS))%'9MMMMMr@   r   tuple[int, int]r9   r   c                   t           j        }|\  }}t          |          dk    rt          d          |dv rd|d         z   }nY|dv r|d         dz   }nI|dk    rd}n@d	|v r<t	          t          t          |                    d	                              \  }}||fS dddd
d
d}|j        |z
  }	|j	        |z
  }
|j
        ||d                  |	z  d
z  z   |j         ||d                  |
z  d
z  z   fS )Nr   zhwindow_position must specify both Y and X positions (Y/X -> UR). Also accepts LEFT/RIGHT/ORIGIN/UP/DOWN.)LEFTRIGHTOr   )UPDOWNORIGINOOr   r
   )LUrf   RD)r   window_positionr!   r$   r#   r+   r'   r*   r%   heightrA   rB   )r6   r   r9   custom_positionr;   r<   pos_ypos_x	char_to_n
width_diffheight_diffs              r?   r4   zWindow.find_initial_positions   s@    !0&*#m1$$z   ///!OA$66OO..-a036OO((%OOO## S/*?*?*D*D!E!EFFLE55>! !!!!<<	!-,6
">M9 I	/!"45
BaGGYJ?1#56DII
 	
r@   buttonc                    t                                          ||||           | j                            ||          }dddd}| j        j                            |||         |           d S )Nrd   MOUSEre   )r   r
      )r,   on_mouse_pressr   rI   rJ   )r6   rA   rB   rw   rT   rK   mouse_button_mapr>   s          r?   r{   zWindow.on_mouse_press   sy    q!VY777::1a@@
 

 	**52B62JIVVVVVr@   )r   r   r   r   r   r   r   r   )
rA   r'   rB   r'   rC   r'   rD   r'   r   r   )
rA   r'   rB   r'   rM   rN   rO   rN   r   r   )rS   r'   rT   r'   r   rU   )rS   r'   rT   r'   r   r   )rA   r'   rB   r'   rC   r'   rD   r'   r_   r'   rT   r'   r   r   )r   rb   r9   r   r   rb   )
rA   r'   rB   r'   rw   r'   rT   r'   r   r   )__name__
__module____qualname__r&   	resizable
gl_versionvsynccursorr   r   r-   rH   rQ   rZ   r^   ra   r4   r{   __classcell__)r>   s   @r?   r   r      s=       JIJEF
 .4-?3) 3) 3) 3) 3) 3) 3)l< < < < < <; ; ; ; ; ;     > > > > > >N N N N N N
 
 
 
@W W W W W W W W W Wr@   )
__future__r   typingr   r   moderngl_windowr/   %moderngl_window.context.pyglet.windowr   PygletWindowmoderngl_window.timers.clockr   
screeninfor   r	    r   r   opengl_rendererr   __all__ r@   r?   <module>r      s    " " " " " " % % % % % % % %     H H H H H H . . . . . . , , , , , , , , " " " " " " " " 0//////*IW IW IW IW IW\ IW IW IW IW IWr@   