
    kjR3                         d dl Z d dlZ e j                    dk    r
dej        d<   dej        d<   d dlmZ d dlmZmZ d dl	m
Z
 d d	lmZ  G d
 de
          Z G d dej        j                  ZdS )    NDarwinFshadow_windowdebug_gl)Path)AnyUnion)
BaseWindow)Keysc                       e Zd ZdZdZeZddddZdef fdZ	d	e
d
dfdZed
eeef         fd            Zej        d	eeef         d
dfd            Zed
eeef         fd            Zej        d	eeef         d
dfd            Zed
e
fd            Zej        d	e
d
dfd            Zed
e
fd            Zej        d	e
d
dfd            Zed
e
fd            Zej        d	e
d
dfd            Zed
efd            Zej        d	ed
dfd            Zed
e
f fd            Zej        d	e
d
dfd            Zd> fdZd>dZded
dfdZded
dfd Zd	e
d
dfd!Zd"ed#ed
e
fd$Zd%ed
dfd&Zd"ed#ed
dfd'Z d(ed)ed*ed+ed
df
d,Z!d(ed)ed*ed+ed-ed#ed
dfd.Z"d(ed)ed/eded
df
d0Z#d(ed)ed/eded
df
d1Z$d(ed)ed2e%d3e%d
df
d4Z&d5ed6ed
df fd7Z'd>d8Z(d>d9Z)d>d:Z*d(ed)ed;e+e,eef                  d
dfd<Z-d>d=Z. xZ/S )?Windowz&
    Window based on Pyglet 1.4.x
    pyglet         )r      r   kwargsc                     t                      j        d	i | t          j                            | j        d         | j        d         dddddddd| j        dk    rdnd| j                  }| j        rKt          j        	                                }|
                                }|j        |j        c| _        | _        t          | j        | j        | j        | j        | j        | j        | j        |t+          j                    dk    	  	        | _        | j        | _        | j                            | j                   | j                            | j                   | j                            | j                   | j                            | j                   | j                            | j                   | j                            | j                    | j                            | j!                   | j                            | j"                   | j                            | j#                   | j                            | j$                   | j                            | j%                   | j                            | j&                   | j                            | j'                   | (                                 | j        )                                \  | _*        | _+        | ,                                 d S )
Nr   r   T      )major_versionminor_versionforward_compatiblered_size
green_size	blue_size
alpha_sizestencil_size
depth_sizedouble_buffersample_bufferssamplesr   )	widthheightcaption	resizablevisiblevsync
fullscreenconfig
file_drops )-super__init__r   glConfig
gl_versionr!   r(   canvasget_displayget_default_screenr"   r#   _width_heightPygletWrapper_title
_resizable_visible_vsync_fullscreenplatformsystem_window_cursorcursoreventon_key_presson_key_releaseon_mouse_motionon_mouse_drag	on_resizeon_closeon_mouse_presson_mouse_releaseon_mouse_scrollon_texton_showon_hideon_file_dropinit_mgl_contextget_framebuffer_size_buffer_width_buffer_heightset_default_viewport)selfr   r)   displayscreen	__class__s        `/home/agentuser/manim-venv/lib/python3.11/site-packages/moderngl_window/context/pyglet/window.pyr-   zWindow.__init__#   s   ""6"""!!/!,/!,# $q 0 011aL " 
 
 ? 	Dm//11G//11F(.fm%DK$+<KoM+' ( 1 1X =

 

 

 l4,---4.///4/0004-...4>***4=)))4.///401114/0004<(((4<(((4<(((4,---26,2S2S2U2U/D/!!#####    valuereturnNc                 :    | j                             |           d S N)r>   set_fullscreenrT   rZ   s     rX   _set_fullscreenzWindow._set_fullscreenZ   s    ##E*****rY   c                     | j         | j        fS )ztuple[int, int]: current window size.

        This property also support assignment::

            # Resize the window to 1000 x 1000
            window.size = 1000, 1000
        )r4   r5   rT   s    rX   sizezWindow.size]   s     {DL((rY   c                 T    | j                             |d         |d                    d S Nr   r   )r>   set_sizer_   s     rX   rc   zWindow.sizeh   s(    eAha11111rY   c                 4    | j                                         S )ztuple[int, int]: The current window position.

        This property can also be set to move the window::

            # Move window to 100, 100
            window.position = 100, 100
        )r>   get_locationrb   s    rX   positionzWindow.positionl   s     |((***rY   c                 T    | j                             |d         |d                    d S re   )r>   set_locationr_   s     rX   ri   zWindow.positionw   s(    !!%(E!H55555rY   c                     | j         S )zbool: Is the window visible?

        This property can also be set::

            # Hide or show the window
            window.visible = False
        )r9   rb   s    rX   r&   zWindow.visible{   s     }rY   c                 H    || _         | j                            |           d S r]   )r9   r>   set_visibler_   s     rX   r&   zWindow.visible   s%      '''''rY   c                     | j         S )zbool: Should the mouse cursor be visible inside the window?

        This property can also be assigned to::

            # Disable cursor
            window.cursor = False
        )r?   rb   s    rX   r@   zWindow.cursor   s     |rY   c                 H    | j                             |           || _        d S r]   )r>   set_mouse_visibler?   r_   s     rX   r@   zWindow.cursor   s#    &&u---rY   c                     | j         S )u  bool: If mouse exclusivity is enabled.

        When you enable mouse-exclusive mode, the mouse cursor is no longer
        available. It is not merely hidden – no amount of mouse movement
        will make it leave your application. This is for example useful
        when you don't want the mouse leaving the screen when rotating
        a 3d scene.

        This property can also be set::

            window.mouse_exclusivity = True
        )_mouse_exclusivityrb   s    rX   mouse_exclusivityzWindow.mouse_exclusivity   s     &&rY   c                 H    | j                             |           || _        d S r]   )r>   set_exclusive_mousers   r_   s     rX   rt   zWindow.mouse_exclusivity   s&    ((///"'rY   c                     | j         S )zlstr: Window title.

        This property can also be set::

            window.title = "New Title"
        )r7   rb   s    rX   titlezWindow.title   s     {rY   c                 H    | j                             |           || _        d S r]   )r>   set_captionr7   r_   s     rX   rx   zWindow.title   s#      '''rY   c                 B    | j         j        pt                      j        S )z"Check pyglet's internal exit state)r>   has_exitr,   
is_closingrT   rW   s    rX   r}   zWindow.is_closing   s     |$:(::rY   c                     || _         d S r]   )_closer_   s     rX   r}   zWindow.is_closing   s    rY   c                     d| _         | j                                         t                                                       dS )z Close the pyglet window directlyTN)r}   r>   closer,   r~   s    rX   r   zWindow.close   s3    rY   c                     | j                                          | xj        dz  c_        | j                                          dS )z5Swap buffers, increment frame counter and pull eventsr   N)r>   flip_framesdispatch_eventsrb   s    rX   swap_bufferszWindow.swap_buffers   s@    $$&&&&&rY   modsc                 x    |dz  dk    | j         _        |dz  dk    | j         _        |dz  dk    | j         _        dS )zUpdate key modifier statesr   r   r   N)
_modifiersshiftctrlalt)rT   r   s     rX   _handle_modifierszWindow._handle_modifiers   s>     $qA#ax1}"Qh!mrY   	icon_pathc                 x    t           j                            |          }| j                            |           d S r]   )r   imageloadr>   set_icon)rT   r   icons      rX   	_set_iconzWindow._set_icon   s3    |  ++d#####rY   c                 :    | j                             |           d S r]   )r>   	set_vsyncr_   s     rX   
_set_vsynczWindow._set_vsync   s    u%%%%%rY   symbol	modifiersc                 8   | j         || j         k    r|                                  | j        || j        k    r| j         | _        d| j        |<   |                     |           |                     || j        j        | j	                   t          j        j        S )zPyglet specific key press callback.

        Forwards and translates the events to the standard methods.

        Args:
            symbol: The symbol of the pressed key
            modifiers: Modifier state (shift, ctrl etc.)
        NT)	_exit_keyr   _fs_keyr(   _key_pressed_mapr   _key_event_funckeysACTION_PRESSr   r   rA   EVENT_HANDLEDrT   r   r   s      rX   rB   zWindow.on_key_press   s     >%&DN*B*BJJLLL<#$,(>(>"&/1DO(,f%y)))VTY%;T_MMM|))rY   textc                 0    |                      |           dS )zPyglet specific text input callback

        Forwards and translates the events to the standard methods.

        Args:
            text (str): The unicode character entered
        N)_unicode_char_entered_func)rT   r   s     rX   rK   zWindow.on_text   s     	''-----rY   c                     d| j         |<   |                     |           |                     || j        j        | j                   dS )zPyglet specific key release callback.

        Forwards and translates the events to standard methods.

        Args:
            symbol: The symbol of the pressed key
            modifiers: Modifier state (shift, ctrl etc.)
        FN)r   r   r   r   ACTION_RELEASEr   r   s      rX   rC   zWindow.on_key_release   sJ     ).f%y)))VTY%=tOOOOOrY   xydxdyc                 H    |                      || j        |z
  ||            dS )a  Pyglet specific mouse motion callback.

        Forwards and translates the event to the standard methods.

        Args:
            x: x position of the mouse
            y: y position of the mouse
            dx: delta x position
            dy: delta y position of the mouse
        N)_mouse_position_event_funcr5   )rT   r   r   r   r   s        rX   rD   zWindow.on_mouse_motion  s-     	''4<!+;R"EEEEErY   buttonsc                 r    |                      |           |                     || j        |z
  ||            dS )zPyglet specific mouse drag event.

        When a mouse button is pressed this is the only way
        to capture mouse position events
        N)r   _mouse_drag_event_funcr5   )rT   r   r   r   r   r   r   s          rX   rE   zWindow.on_mouse_drag  sA     	y)))##At|a'7bSAAAAArY   buttonc                     |                      |           | j                            |d          }|dk    r7|                     |d           |                     || j        |z
  |           dS dS )zHandle mouse press events and forward to standard methods

        Args:
            x: x position of the mouse when pressed
            y: y position of the mouse when pressed
            button: The pressed button
            mods: Modifiers
        TN)r   _mouse_button_mapget!_handle_mouse_button_state_change_mouse_press_event_funcr5   rT   r   r   r   r   s        rX   rH   zWindow.on_mouse_press&  s     	t$$$'++FB77R<<2264@@@((q      <rY   c                     | j                             |d          }|dk    r7|                     |d           |                     || j        |z
  |           dS dS )a  Handle mouse release events and forward to standard methods

        Args:
            x: x position when mouse button was released
            y: y position when mouse button was released
            button: The button pressed
            mods: Modifiers
        r   FN)r   r   r   _mouse_release_event_funcr5   r   s        rX   rI   zWindow.on_mouse_release9  st     '++FB77R<<2265AAA**q      <rY   x_offsety_offsetc                 \    |                      d           |                     ||           dS )zHandle mouse wheel.

        Args:
            x_offset (float): X scroll offset
            y_offset (float): Y scroll offset
        r   N)r   mouse_scroll_event_func)rT   r   r   r   r   s        rX   rJ   zWindow.on_mouse_scrollK  s4     	q!!!$$Xx88888rY   r"   r#   c                     ||c| _         | _        | j                                        \  | _        | _        |                                  t                                          | j        | j                   dS )zPyglet specific callback for window resize events forwarding to standard methods

        Args:
            width: New window width
            height: New window height
        N)	r4   r5   r>   rP   rQ   rR   rS   r,   resize)rT   r"   r#   rW   s      rX   rF   zWindow.on_resizeU  si     %*6!T\26,2S2S2U2U/D/!!###t)4+>?????rY   c                 .    |                                   dS )z%Pyglet specific window close callbackN)_close_funcrb   s    rX   rG   zWindow.on_closeb  s    rY   c                 >    d| _         |                     d           dS )z=Called when window first appear or restored from hidden stateTFNr9   _iconify_funcrb   s    rX   rL   zWindow.on_showf  s#    5!!!!!rY   c                 >    d| _         |                     d           dS )zCalled when window is minimizedFTNr   rb   s    rX   rM   zWindow.on_hidek  s#    4     rY   pathsc                 j    |                      ||d          \  }}|                     |||           dS )zCalled when files dropped onto the window

        Args:
            x (int): X location in window where file was dropped
            y (int): Y location in window where file was dropped
            paths (list): List of file paths dropped
        T)	y_flippedN)convert_window_coordinates_files_dropped_event_func)rT   r   r   r   s       rX   rN   zWindow.on_file_dropp  s@     00A0FFA&&q!U33333rY   c                     dS )zDestroy the pyglet windowNr+   rb   s    rX   destroyzWindow.destroy~      rY   r[   N)0__name__
__module____qualname____doc__namer
   r   r   r   r-   boolr`   propertytupleintrc   setterri   r&   r@   rt   strrx   r}   r   r   r   r   r   r   rB   rK   rC   rD   rE   rH   rI   floatrJ   rF   rG   rL   rM   listr   rN   r   __classcell__)rW   s   @rX   r   r      s9        
 DD  5$ 5$ 5$ 5$ 5$ 5$ 5$n+T +d + + + + )eCHo ) ) ) X) 
[2%S/ 2d 2 2 2 [2 +%S/ + + + X+ _6eCHo 6$ 6 6 6 _6     X ^(T (d ( ( ( ^(     X ]D T    ] '4 ' ' ' X' (t ( ( ( ( ( s    X \3 4    \ ;D ; ; ; ; ; X;           ' ' ' ',c ,d , , , ,$4 $D $ $ $ $& & & & & &*3 *3 *4 * * * **.C .D . . . .PS PS PT P P P PF F F# F3 F4 F F F F Bs Bs B B Bs BWZ B_c B B B B  S      &# # s # $    $9 9 9 9 9SW 9 9 9 9@s @C @D @ @ @ @ @ @   " " " "
! ! ! !
4c 4c 4$uS$Y7G2H 4T 4 4 4 4       rY   r   c                   .    e Zd ZdZdededdfdZddZdS )	r6   z?Block out some window methods so pyglet don't trigger GL errorsr"   r#   r[   Nc                     dS )zbBlock out the resize method.
        For some reason pyglet calls this triggering errors.
        Nr+   )rT   r"   r#   s      rX   rF   zPygletWrapper.on_resize  s	     	rY   c                     dS )z4Block out the default draw method to avoid GL errorsNr+   rb   s    rX   on_drawzPygletWrapper.on_draw  r   rY   r   )r   r   r   r   r   rF   r   r+   rY   rX   r6   r6     sW        IIs C D         rY   r6   )r<   r   r=   optionspathlibr   typingr   r   moderngl_window.context.baser	   #moderngl_window.context.pyglet.keysr
   r   windowr6   r+   rY   rX   <module>r      s      8?  &+FN?#"z                3 3 3 3 3 3 4 4 4 4 4 4n n n n nZ n n nb    FM(     rY   