
    ^j                   V   d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
mZmZ ddlZddlZddlZddlmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZmZ e	rddlZddlmZmZm Z  ddl!m"Z"m#Z#m$Z$ ddl%m&Z&  e'ed          oej(        Z) G d de*          Z+ G d de+          Z, G d de+          Z- G d de+          Z. G d de+          Z/ G d d          Z0 G d de0          Z1 G d de0          Z2dTd$Z3dUd&Z4 G d' d(e5          Z6 G d) d*ee6+          Ze7                    d,           e7                    d-           e7                    d.           e7                    d/           e7                    d0           e7                    d1           e7                    d2           e7                    d3           e7                    d4           e7                    d5           e7                    d6           e7                    d7           e7                    d8           e7                    d9           e7                    d:           e7                    d;           e7                    d<           e7                    d=           e7                    d>           e7                    d?           e7                    d@           e7                    dA           e7                    dB           e7                    dC           e7                    dD           e7                    dE           e7                    dF           e7                    dG            G dH dI          Z8e)rRddl9Z9eZdJe_:        dJe_;         e9j<        ee9j=        K          D ]%\  Z>Z?e?j;        @                    d*dJ          e?_;        &n<ejA        dL         rddMlBmCZ n(ejD        dNk    rddOlEmFZ nejD        dPv rddQlGmHZ nddRlImJZ e)s!ejK        e:         e_L         ejM                     dSZNdS )Va  Windowing and user-interface events.

This module allows applications to create and display windows with an
OpenGL context.  Windows can be created with a variety of border styles
or set fullscreen.

You can register event handlers for keyboard, mouse and window events.
For games and kiosks you can also restrict the input to your windows,
for example disabling users from switching away from the application
with certain key combinations or capturing and hiding the mouse.

Getting started
---------------

Call the Window constructor to create a new window::

    from pyglet.window import Window
    win = Window(width=960, height=540)

Attach your own event handlers::

    @win.event
    def on_key_press(symbol, modifiers):
        # ... handle this event ...

Place drawing code for the window within the `Window.on_draw` event handler::

    @win.event
    def on_draw():
        # ... drawing code ...

Call `pyglet.app.run` to enter the main event loop (by default, this
returns when all open windows are closed)::

    from pyglet import app
    app.run()

Creating a game window
----------------------

Use :py:meth:`~pyglet.window.Window.set_exclusive_mouse` to hide the mouse
cursor and receive relative mouse movement events.  Specify ``fullscreen=True``
as a keyword argument to the :py:class:`~pyglet.window.Window` constructor to
render to the entire screen rather than opening a window::

    win = Window(fullscreen=True)
    win.set_exclusive_mouse()

Working with multiple screens
-----------------------------

By default, fullscreen windows are opened on the primary display (typically
set by the user in their operating system settings).  You can retrieve a list
of attached screens and select one manually if you prefer.  This is useful for
opening a fullscreen window on each screen::

    display = pyglet.display.get_display()
    screens = display.get_screens()
    windows = []
    for screen in screens:
        windows.append(window.Window(fullscreen=True, screen=screen))

Specifying a screen has no effect if the window is not fullscreen.

Specifying the OpenGL context properties
----------------------------------------

Each window has its own context which is created when the window is created.
You can specify the properties of the context before it is created
by creating a "template" configuration::

    from pyglet import gl
    # Create template config
    config = gl.Config()
    config.stencil_size = 8
    config.aux_buffers = 4
    # Create a window using this config
    win = window.Window(config=config)

To determine if a given configuration is supported, query the screen (see
above, "Working with multiple screens")::

    configs = screen.get_matching_configs(config)
    if not configs:
        # ... config is not supported
    else:
        win = window.Window(config=configs[0])

    )annotationsN)abstractmethoddeque)TYPE_CHECKINGAnyCallableSequence)gl)EVENT_HANDLE_STATEEventDispatcher)shader)Mat4)eventkey)DisplayScreen
ScreenMode)DisplayConfigConfigContextLabelis_pyglet_doc_runc                      e Zd ZdZdS )WindowExceptionz1The root exception for all window-related errors.N__name__
__module____qualname____doc__     Q/home/agentuser/manim-venv/lib/python3.11/site-packages/pyglet/window/__init__.pyr   r   s   s        ;;;;r#   r   c                      e Zd ZdZdS )NoSuchDisplayExceptionz?An exception indicating the requested display is not available.Nr   r"   r#   r$   r&   r&   w   s        IIIIr#   r&   c                      e Zd ZdZdS )NoSuchConfigExceptionzEAn exception indicating the requested configuration is not available.Nr   r"   r#   r$   r(   r(   {   s        OOOOr#   r(   c                      e Zd ZdZdS )NoSuchScreenModeExceptionzIAn exception indicating the requested screen resolution could not be met.Nr   r"   r#   r$   r*   r*      s        SSSSr#   r*   c                      e Zd ZdZdS )MouseCursorExceptionz7The root exception for all mouse cursor-related errors.Nr   r"   r#   r$   r,   r,      s        AAAAr#   r,   c                  8    e Zd ZU dZdZded<   dZded<   ddZdS )MouseCursorzAn abstract mouse cursor.Tboolgl_drawableFhw_drawablexintyreturnNonec                    dS )a  Abstract render method.

        The cursor should be drawn with the "hot" spot at the given
        coordinates.  The projection is set to the pyglet default (i.e.,
        orthographic in window-space), however no other aspects of the
        state can be assumed.

        Args:
            x:
                X coordinate of the mouse pointer's hot spot.
            y:
                Y coordinate of the mouse pointer's hot spot.

        Nr"   selfr2   r4   s      r$   drawzMouseCursor.draw         r#   Nr2   r3   r4   r3   r5   r6   )r   r   r    r!   r0   __annotations__r1   r:   r"   r#   r$   r.   r.      sT         ## KK     r#   r.   c                  0    e Zd ZU dZdZded<   dZded<   dS )DefaultMouseCursorz5The default mouse cursor set by the operating system.Fr/   r0   Tr1   N)r   r   r    r!   r0   r=   r1   r"   r#   r$   r?   r?      s:         ??KKr#   r?   c                  (    e Zd ZdZ	 	 dddZddZdS )ImageMouseCursora  A user-defined mouse cursor created from an image.

    Use this class to create your own mouse cursors and assign them
    to windows. Cursors can be drawn by OpenGL, or optionally passed
    to the OS to render natively. There are no restrictions on cursors
    drawn by OpenGL, but natively rendered cursors may have some
    platform limitations (such as color depth, or size). In general,
    reasonably sized cursors will render correctly
    r   Fimagepyglet.image.AbstractImagehot_xr3   hot_yaccelerationr/   r5   r6   c                    |                                 | _        || _        || _        d| _        | | _        || _        dS )a  Create a mouse cursor from an image.

        Args:
            image:
                Image to use for the mouse cursor.  It must have a valid ``texture`` attribute.
            hot_x:
                X coordinate of the "hot" spot in the image relative to the image's anchor.
                May be clamped to the maximum image width if acceleration is enabled.
            hot_y:
                Y coordinate of the "hot" spot in the image, relative to the image's anchor.
                May be clamped to the maximum image height if acceleration is enabled.
            acceleration:
                If ``True``, draw the cursor natively instead of using OpenGL.
                The image may be downsampled or color reduced to fit the platform limitations.
              ?N)get_texturetexturerD   rE   scalingr0   r1   )r9   rB   rD   rE   rF   s        r$   __init__zImageMouseCursor.__init__   sE    " ((**

++'r#   r2   r4   c                H   t          j        t           j                   t          j        t           j        t           j                   | j                            || j        z
  | j	        z  || j
        z
  | j	        z  d           t          j        t           j                   d S )Nr   )r   glEnableGL_BLENDglBlendFuncGL_SRC_ALPHAGL_ONE_MINUS_SRC_ALPHArJ   blitrD   rK   rE   	glDisabler8   s      r$   r:   zImageMouseCursor.draw   sx    
BK   
r(ABBB1tz>T\9A
Ndl;Z\]^^^
R[!!!!!r#   N)r   r   F)
rB   rC   rD   r3   rE   r3   rF   r/   r5   r6   r<   )r   r   r    r!   rL   r:   r"   r#   r$   rA   rA      sU          XY&+( ( ( ( (2" " " " " "r#   rA   datar   r5   r	   c                     d fd}|S )a  Decorator for platform event handlers.

    Apply giving the platform-specific data needed by the window to associate
    the method with an event.  See platform-specific subclasses of this
    decorator for examples.

    The following attributes are set on the function, which is returned
    otherwise unchanged:

    _platform_event
        True
    _platform_event_data
        List of data applied to the function (permitting multiple decorators
        on the same method).
    fr	   r5   c                x    d| _         t          | d          sg | _        | j                                       | S )NT_platform_event_data)_platform_eventhasattrrY   append)rW   rU   s    r$   _event_wrapperz-_PlatformEventHandler.<locals>._event_wrapper   sB     q011 	(%'A"	%%d+++r#   rW   r	   r5   r	   r"   )rU   r]   s   ` r$   _PlatformEventHandlerr_      s)    "      r#   rW   c                    d| _         | S )NT)_view)rW   s    r$   _ViewEventHandlerrb      s    AGHr#   c                  $     e Zd ZdZd fdZ xZS )_WindowMetaclasszESets the _platform_event_names class variable on the window subclass.clstype[_WindowMetaclass]namestrbasestupledctdictr5   r6   c                d   t                      | _        |D ]1}t          |d          r| j                            |j                   2|                                D ]/\  }}t          |d          r| j                            |           0t                                          |||           d S )N_platform_event_namesrZ   )setrn   r[   updateitemsaddsuperrL   )re   rg   ri   rk   basefunc	__class__s         r$   rL   z_WindowMetaclass.__init__   s    $'EE! 	M 	MDt455 M)001KLLL))++ 	4 	4JD$t.// 4)--d333uc*****r#   )
re   rf   rg   rh   ri   rj   rk   rl   r5   r6   )r   r   r    r!   rL   __classcell__rv   s   @r$   rd   rd      sC        OO+ + + + + + + + + +r#   rd   c                  
    e Zd ZU dZ e            Zded<   dZded<   dZded	<   d
Z	ded<   dZ
ded<   dZded<   dZded<   dZdZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   d Zded!<   d"Zded#<   d$Zded%<   d&Zded'<   d(Zded)<   d*Zded+<   d,Zded-<   d.Zded/<   d0Zded1<   d2Zded3<   d4Zded5<   d6Z d7ed8<   d9Z!d7ed:<   d;Z"d<ed=<   dZ#d>ed?<   dZ$d>ed@<   dZ%dAedB<   d6Z&d7edC<   eZ'dAedD<   d6Z(d7edE<   d6Z)d7edF<   d6Z*d7edG<   d6Z+d7edH<   dZ,dIedJ<   dZ-dKedL<   dZ.dMedN<   e/j0        1                                Z2dOedP<   e/j0        1                                Z3dOedQ<   dRZ4dSedT<   dZ5dUedV<   dZ6dUedW<   dZ7dUedX<   dZ8dUedY<   d6Z9d7edZ<   d6Z:d7ed[<    e;            Z<d\ed]<   d^Z=d<ed_<   d^Z>d<ed`<   d9Z?d7eda<   d6Z@d7edb<   d6ZAd7edc<   dZBd9ZCd7edd<   d6ZDd7ede<   dfZEd<edg<   dhZFd<edi<   d<edj<   d<edk<   dlZGdmZHdddd6ed6d9d9d6dddddfddZIddZJddZKddZLeMdd            ZNeMdd            ZOeMdd            ZPeQdd            ZRddZSd fdZTeMdd            ZUddZVddZWeMdd            ZXddZYeMdd            ZZddZ[ddZ\ddZ]ddZ^ddZ_ddZ`ddZaeMdd            ZbeMdd            ZcddZdddZeddZfddZgddZhddZieMdd            Zj	 	 d d!dZkd"dZlddZmddZnddZoeMd#d            Zpd$d%dZqd&dZrd$d%dZsd'd(dZtd'd)dZud Zvd$d*dÄZwd$d*dĄZxd+dǄZyeMddȄ            Zze{ddɄ            Z|e{d,dʄ            Z}e{dd˄            Z~e{d,d̄            Ze{d,d̈́            Ze{d,d΄            Ze{d-dЄ            Ze{d.d҄            Ze{d/dԄ            Ze{d0dք            Ze{d1dׄ            Zej        d2dل            Ze{d1dڄ            Zej        d3d܄            Ze{dd݄            Ze{d1dބ            Ze{dd߄            Zej        d4d            Ze{dd            Ze{d5d            Zej        d6d            Ze{d5d            Zej        d6d            Ze{d7d            Zej        d8d            Zerd9dZd9dZdd9dZd9dZd9dZd9dZd9dZd:dZd9dZddZe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Zhdd	Zid9d
ZdAdZdBdZdBdZ xZS  xZS (C  
BaseWindowa{  Platform-independent application window.

    A window is a "heavyweight" object occupying operating system resources.
    The "client" or "content" area of a window is filled entirely with
    an OpenGL viewport.  Applications have no access to operating system
    widgets or controls; all rendering must be done via OpenGL.

    Windows may appear as floating regions or can be set to fill an entire
    screen (fullscreen).  When floating, windows may appear borderless or
    decorated with a platform-specific frame (including, for example, the
    title bar, minimize and close buttons, resize handles, and so on).

    While it is possible to set the location of a window, it is recommended
    that applications allow the platform to place it according to local
    conventions.  This will ensure it is not obscured by other windows,
    and appears on an appropriate screen for the user.

    To render into a window, you must first call its :py:meth:`.switch_to`
    method to make it the active OpenGL context. If you use only one
    window in your application, you can skip this step as it will always
    be the active context.
    zset[_PlatformEventHandler]rn   Nr6   WINDOW_STYLE_DEFAULTdialogrh   WINDOW_STYLE_DIALOGtoolWINDOW_STYLE_TOOL
borderlessWINDOW_STYLE_BORDERLESStransparentWINDOW_STYLE_TRANSPARENToverlayWINDOW_STYLE_OVERLAY	crosshairCURSOR_CROSSHAIRhandCURSOR_HANDhelpCURSOR_HELPno	CURSOR_NOsizeCURSOR_SIZEsize_upCURSOR_SIZE_UPsize_up_rightCURSOR_SIZE_UP_RIGHT
size_rightCURSOR_SIZE_RIGHTsize_down_rightCURSOR_SIZE_DOWN_RIGHT	size_downCURSOR_SIZE_DOWNsize_down_leftCURSOR_SIZE_DOWN_LEFT	size_leftCURSOR_SIZE_LEFTsize_up_leftCURSOR_SIZE_UP_LEFTsize_up_downCURSOR_SIZE_UP_DOWNsize_left_rightCURSOR_SIZE_LEFT_RIGHTtextCURSOR_TEXTwaitCURSOR_WAIT
wait_arrowCURSOR_WAIT_ARROWFr/   has_exitTinvalid`   r3   _dpi
int | None_width_height
str | None_caption
_resizable_style_fullscreen_visible_vsync_file_dropsScreen | None_screenzDisplayConfig | None_configContext | None_contextr   _projection_matrix_view_matrix)r   r   r   r   tuple[int, int, int, int]	_viewportztuple[int, int] | None_windowed_size_windowed_location_minimum_size_maximum_size_keyboard_exclusive_shadowzMouseCursor | ImageMouseCursor_mouse_cursorr   _mouse_x_mouse_y_mouse_visible_mouse_exclusive_mouse_in_window_enable_event_queue_allow_dispatch_eventi   _default_widthi  _default_height_requested_width_requested_heighta  #version 150 core
        in vec4 position;

        uniform WindowBlock
        {
            mat4 projection;
            mat4 view;
        } window;

        void main()
        {
            gl_Position = window.projection * window.view * position;
        }
    z#version 150 core
        out vec4 color;

        void main()
        {
            color = vec4(1.0, 0.0, 0.0, 1.0);
        }
    widthheightcaption	resizablestyle
fullscreenvisiblevsync
file_dropsdisplayDisplay | NonescreenconfigConfig | NonecontextmodeScreenMode | Noner5   c           	        t          j        |            t                      | _        |
st          j                                        }
|s|
                                }|sd}d}|dv rd}d}t          j	        dddd||          t          j	        dd	dd||          dfD ])}	 |
                    |          } n# t          $ r Y &w xY w|sd
}t          |          n|dv rd|_        d|_        |                                s|
                    |          }|s|                    t          j                  }|| _        | j        j        | _        t)          | j        d          r| j        j        | _        n|| _        | j        j        | _        |rB||| j        | j        f| _        |                     |||          \  }}| j        s	||f| _        n|| j        }|| j        }|| _        || _        || _        || _        || _         || _!        || _"        t          j#        d         t          j#        d         | _$        n|| _$        |	| _%        |ptL          j'        d         | _(        ddlm)} |j*        +                    |            | ,                                 | -                                 | .                                 |r+| /                    d           | 0                                 dS dS )a
  Create a window.

        All parameters are optional, and reasonable defaults are assumed
        where they are not specified.

        The ``display``, ``screen``, ``config`` and ``context`` parameters form
        a hierarchy of control: there is no need to specify more than
        one of these.  For example, if you specify ``screen`` the ``display``
        will be inferred, and a default ``config`` and ``context`` will be
        created.

        ``config`` is a special case; it can be a template created by the
        user specifying the attributes desired, or it can be a complete
        ``config`` as returned from :py:meth:`~pyglet.display.Screen.get_matching_configs` or similar.

        The context will be active as soon as the window is created, as if
        :py:meth:`~pyglet.window.Window.switch_to` was just called.

        Args:
            width:
                Width of the window, in pixels.  Defaults to 960, or the screen width if ``fullscreen`` is True.
            height:
                Height of the window, in pixels.  Defaults to 540, or the screen height if ``fullscreen`` is True.
            caption:
                Initial caption (title) of the window.  Defaults to ``sys.argv[0]``.
            resizable:
                If True, the window will be resizable.  Defaults to False.
            style:
                One of the ``WINDOW_STYLE_*`` constants specifying the border style of the window.
            fullscreen:
                If True, the window will cover the entire screen rather than floating.  Defaults to False.
            visible:
                Determines if the window is visible immediately after
                creation.  Defaults to True.  Set this to False if you
                would like to change attributes of the window before
                having it appear to the user.
            vsync:
                If True, buffer flips are synchronised to the primary screen's
                vertical retrace, eliminating flicker.
            file_drops:
                If True, the Window will accept files being dropped into it and call the ``on_file_drop`` event.
            display:
                The display device to use.  Useful only under X11.
            screen:
                The screen to use, if in fullscreen.
            config:
                Either a template from which to create a complete config, or a complete config.
            context:
                The context to attach to this window.  The context must not already be attached to another window.
            mode:
                The screen will be switched to this mode if `fullscreen` is
                True.  If None, an appropriate mode is selected to accommodate ``width`` and ``height``.

        NF)r   r      T      )double_buffer
depth_sizemajor_versionminor_version
alpha_sizetransparent_framebuffer   z No standard config is available.r   r   r   app)1r   rL   r   _event_queuepygletr   get_displayget_default_screenr   r   get_best_configr(   r   r   is_completecreate_contextcurrent_contextr   r   r   r[   r   r   _displayr   r   r   _set_fullscreen_moder   r   r   r   r   r   r   optionsr   r   sysargvr   r   windowsrr   _create	switch_to_create_projectionset_visibleactivate)r9   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   transparent_fbtemplate_configmsgr   s                       r$   rL   zBaseWindow.__init__  sZ   J 	 &&&!GG 	3n0022G 	2//11F 	6J"N222
!% 	1\]%/Y Y Y	1\]%/Y Y Y$  #33ODDFE,   D 18+C0001 222$%!15.!!## 	4++F33F 	@++B,>??G  }+ 4<** 	"<.DLL!DL, 
	.}&*&94;O&O# 55dE6JJME6& 4&+Vm#}+~- %!'#%>'". .1DKKDK%.38A;!!! 	T"""MMOOOOO	 	s   $B;;
CCc                   t          j        t          j        | j        d          t          j        | j        d                    | _        | j        j        d                                         | _        ddg| 	                                R | _
        |                                 \  }}t                      | _        t          j        d|d|dd          | _        d S )NvertexfragmentWindowBlockr        )r   ShaderProgramShader_default_vertex_source_default_fragment_source_default_programuniform_blocks
create_ubouboget_framebuffer_sizer   get_sizer   vieworthogonal_projection
projectionr9   r   r   s      r$   r  zBaseWindow._create_projectionY  s     & 4M$5x@@M$7DD!F !F (7FQQSSA; 9 9 ; ;;;vFF	4Qq&%QUVVr#   c                @    	 |                                   d S #  Y d S xY wN)closer9   s    r$   __del__zBaseWindow.__del__f  s(    	JJLLLLL	DDs    c                @    | j         j         d| j         d| j         dS )Nz=(width=z	, height=))rv   r   r   r   r  s    r$   __repr__zBaseWindow.__repr__o  s*    .)VV4:VVVVVVr#   c                    d S r  r"   r  s    r$   r   zBaseWindow._creater  s    r#   changesSequence[str]c                    dS )aD  Recreate the window with current attributes.

        Args:
            changes:
                Sequence of attribute names that were changed since the last
                ``_create`` or ``_recreate``.  For example, ``['fullscreen']``
                is given if the window is to be toggled to or from fullscreen.
        Nr"   )r9   r%  s     r$   	_recreatezBaseWindow._recreatev  r;   r#   c                    dS )ab  Attempt to restore keyboard focus to the window.

        Depending on the window manager or operating system, this may not
        be successful.  For example, on Windows XP an application is not
        allowed to "steal" focus from another application.  Instead, the
        window's taskbar icon will flash, indicating it requires attention.
        Nr"   r  s    r$   r  zBaseWindow.activate  r;   r#   c                 \    t          j        t           j        t           j        z             dS )zClear the window.

        This is a convenience method for clearing the color and depth
        buffer.  The window must be the active context (see
        :py:meth:`.switch_to`).
        N)r   glClearGL_COLOR_BUFFER_BITGL_DEPTH_BUFFER_BITr"   r#   r$   clearzBaseWindow.clear  s%     	
2)B,BBCCCCCr#   c                   ddl m} | j        sdS |j                            |            | j                                         d| _        d| _        |j        r|j                            d|            t                      | _
        dS )a|  Close the window.

        After closing the window, the GL context will be invalid.  The
        window instance cannot be reused once closed. To reuse windows,
        see :py:meth:`.set_visible` instead.

        The :py:meth:`pyglet.app.EventLoop.on_window_close` event is
        dispatched by the :py:attr:`pyglet.app.event_loop` when this method
        is called.
        r   r   Non_window_close)r   r   r   r   removedestroyr   
event_loopdispatch_eventr   r   r9   r   s     r$   r  zBaseWindow.close  s     	} 	F4   > 	CN))*;TBBB!GGr#   argsr   c                    | j         r| j        r t                      j        |  d S | j                            |           d S r  )r   r   rs   r4  r   r\   )r9   r6  rv   s     r$   r4  zBaseWindow.dispatch_event  sO    ' 	+4+E 	+"EGG"D))))$$T*****r#   c                    dS )aY  Poll the operating system event queue for new events and call attached event handlers.

        This method is provided for legacy applications targeting pyglet 1.0,
        and advanced applications that must integrate their event loop
        into another framework.

        Typical applications should use :py:func:`pyglet.app.run`.
        Nr"   r  s    r$   dispatch_eventszBaseWindow.dispatch_events  r;   r#   dtfloatc                    |                                   |                     d           |                     d|           |                                  dS )a  Redraw the Window contents.

        This method will first call the :py:meth:`~pyglet.window.Window.`switch_to`
        method to make the GL context current. It then dispatches the
        :py:meth:`~pyglet.window.Window.on_draw` and
        :py:meth:`~pyglet.window.Window.on_refresh`
        events. Finally, it calls the :py:meth:`~pyglet.window.Window.flip`
        method to swap the front and back OpenGL buffers.
        on_draw
on_refreshN)r  r4  flipr9   r:  s     r$   r:   zBaseWindow.draw  sO     	I&&&L"---		r#   c                    | j         j        r5| j        r0| j        r+| j                             | j        | j                   dS dS dS dS )aW  Draw the custom mouse cursor.

        If the current mouse cursor has ``drawable`` set, this method
        is called before the buffers are flipped to render it.

        There is little need to override this method; instead, subclass
        :py:class:`MouseCursor` and provide your own
        :py:meth:`~MouseCursor.draw` method.
        N)r   r0   r   r   r:   r   r   r  s    r$   draw_mouse_cursorzBaseWindow.draw_mouse_cursor  sp     ) 	Bd.A 	BdF[ 	B##DM4=AAAAA	B 	B 	B 	B 	B 	Br#   c                    dS )a  Swap the OpenGL front and back buffers.

        Call this method on a double-buffered window to update the
        visible display with the back buffer. Windows are
        double-buffered by default unless you turn this feature off.

        The contents of the back buffer are undefined after this operation.

        The default :py:attr:`~pyglet.app.event_loop` automatically
        calls this method after the window's
        :py:meth:`~pyglet.window.Window.on_draw` event.
        Nr"   r  s    r$   r?  zBaseWindow.flip  r;   r#   tuple[int, int]c                *    |                                  S )a5  Return the size in actual pixels of the Window framebuffer.

        When using HiDPI screens, the size of the Window's framebuffer
        can be higher than that of the Window size requested. If you
        are performing operations that require knowing the actual number
        of pixels in the window, this method should be used instead of
        :py:func:`Window.get_size()`. For example, setting the Window
        projection or setting the glViewport size.

        Returns:
            The width and height of the Window's framebuffer, in pixels.
        r  r  s    r$   r  zBaseWindow.get_framebuffer_size  s     }}r#   c                    dS )zReturn the current position of the window.

        Returns:
             The distances of the left and top edges from their respective edges on the virtual desktop, in pixels.
        Nr"   r  s    r$   get_locationzBaseWindow.get_location  r;   r#   c                    | j         S )a*  Return the framebuffer/window size ratio.

        Some platforms and/or window systems support subpixel scaling,
        making the framebuffer size larger than the window size.
        Retina screens on OS X and Gnome on Linux are some examples.

        On a Retina systems the returned ratio would usually be 2.0 as a
        window of size 500 x 500 would have a framebuffer of 1000 x 1000.
        Fractional values between 1.0 and 2.0, as well as values above
        2.0 may also be encountered.

        :deprecated: Use `Window.scale`.
        scaler  s    r$   get_pixel_ratiozBaseWindow.get_pixel_ratio  s     zr#   c                    | j         | j        fS )zReturn the current size of the window.

        This does not include the windows' border or title bar.

        Returns:
            The width and height of the window, in pixels.
        )r   r   r  s    r$   r  zBaseWindow.get_size  s     {DL((r#   c                    | j         | j        fS )zReturn the size of the window without any scaling taken into effect.

        This does not include the windows' border or title bar.

        Returns:
            The width and height of the window, in pixels.
        )r   r   r  s    r$   get_requested_sizezBaseWindow.get_requested_size  s     $d&<<<r#   rg   r.   c                    t           )a  Obtain a system mouse cursor.

        Use :py:meth:`~pyglet.window.Window.set_mouse_cursor` to make the cursor returned by this method
        active.  The names accepted by this method are the ``CURSOR_*``
        constants defined on this class.
        NotImplementedError)r9   rg   s     r$   get_system_mouse_cursorz"BaseWindow.get_system_mouse_cursor&  s
     "!r#   c                    t           )zAccess the system clipboard and attempt to retrieve text.

        Returns:
             A string from the clipboard. String will be empty if no text found.
        rQ  r  s    r$   get_clipboard_textzBaseWindow.get_clipboard_text/  s
     "!r#   c                    t           )zAccess the system clipboard and set a text string as the clipboard data.

        This will clear the existing clipboard.
        rQ  r9   r   s     r$   set_clipboard_textzBaseWindow.set_clipboard_text7  s
    
 "!r#   statec                    t           )a  Set whether the operating system will ignore mouse input from this window.

        Behavior may differ across operating systems. This is typically used in window overlays with
        transparent frame buffers.

        Args:
            state:
                ``True`` will allow mouse input to pass through the window to anything behind it. Otherwise, ``False``
                allows the window to accept focus again.

        .. versionadded:: 2.1.8
        rQ  )r9   rY  s     r$   set_mouse_passthroughz BaseWindow.set_mouse_passthrough>  s
     "!r#   c                    dS )zMinimize the window.Nr"   r  s    r$   minimizezBaseWindow.minimizeM  r;   r#   c                    dS )zMaximize the window.

        The behaviour of this method is somewhat dependent on the user's
        display setup.  On a multi-monitor system, the window may maximize
        to either a single screen or the entire virtual desktop.
        Nr"   r  s    r$   maximizezBaseWindow.maximizeQ  r;   r#   c                d    d| _         ddlm} |j        j        r|                                  dS dS )zDefault on_close handler.Tr   r   N)r   r   r   r3  
is_runningr  r5  s     r$   on_closezBaseWindow.on_closeZ  sC    >$ 	JJLLLLL	 	r#   symbol	modifiersr   c                    |t           j        k    rA|t           j        t           j        z  t           j        z   z  s|                     d           dS dS dS )zDefault on_key_press handler.rb  N)r   ESCAPEMOD_NUMLOCKMOD_CAPSLOCKMOD_SCROLLLOCKr4  r9   rc  rd  s      r$   on_key_presszBaseWindow.on_key_pressa  sf    SZs7:7G8H7:7I8J 6K *K 
+++++  r#   c           	     |   |                                  }t          j        ddt          |d         d          t          |d         d                     |                                 \  }}t          j        dt          |d          dt          |d          dd          | _        |                     d||           d S )Nr      r  r  	on_resize)	r  r   
glViewportmaxr  r   r  r  r4  )r9   r   r   framebuffer_sizewhs         r$   _on_internal_resizezBaseWindow._on_internal_resizeh  s    4466
aC 0 3Q77=Ma=PRS9T9TUUU}}14QAq		1c!QiiQVX\]]KA.....r#   rK  dpic           	        |                                  }t          j        ddt          |d         d          t          |d         d                     |                                 \  }}t          j        dt          |d          dt          |d          dd          | _        |                                 | j	        _
        |                     d||           d S )Nr   rm  r  r  on_scale)r  r   ro  rp  r  r   r  r  _get_mouse_scaler   rK   r4  )r9   rK  ru  rq  rr  rs  s         r$   _on_internal_scalezBaseWindow._on_internal_scaleo  s    4466
aC 0 3Q77=Ma=PRS9T9TUUU}}14QAq		1c!QiiQVX\]]%)%:%:%<%<"Js33333r#   c                    dS )am  A default resize event handler.

        This default handler updates the GL viewport to cover the entire
        window. The bottom-left corner is (0, 0) and the top-right
        corner is the width and height of the window's framebuffer.
        In addition, the projection matrix is set to an orthogonal
        projection based on the same dimensions.
        Nr"   r  s      r$   rn  zBaseWindow.on_resizew  r;   r#   c                    dS )zA default scale event handler.

        This default handler is called if the screen or system's DPI changes
        during runtime.
        Nr"   r9   rK  ru  s      r$   rw  zBaseWindow.on_scale  r;   r#   c                    dS )zSet the window's caption.

        The caption appears in the titlebar of the window, if it has one,
        and in the taskbar on Windows and many X11 window managers.
        Nr"   )r9   r   s     r$   set_captionzBaseWindow.set_caption  r;   r#   c                d   || j         k    r'|	|| j        u r||| j        k    r||| j        k    rdS | j         s2|                                 | _        |                                 | _        |r||j        | j        u sJ || _        || _         | j         r%| 	                    |||          \  | _        | _        n?| j
                                         | j        \  | _        | _        ||| _        ||| _        |                     dg           | j         s| j        r | j        | j          dS dS dS )a  Toggle to or from fullscreen.

        After toggling fullscreen, the GL context should have retained its
        state and objects, however the buffers will need to be cleared and
        redrawn.

        If ``width`` and ``height`` are specified and ``fullscreen`` is True, the
        screen may be switched to a different resolution that most closely
        matches the given size.  If the resolution doesn't match exactly,
        a higher resolution is selected and the window will be centered
        within a black border covering the rest of the screen.

        Args:
            fullscreen:
                True if the window should be made fullscreen, False if it
                should be windowed.
            screen:
                If not None and fullscreen is True, the window is moved to the
                given screen.  The screen must belong to the same display as
                the window.
            mode:
                The screen will be switched to the given mode.  The mode must
                have been obtained by enumerating :py:meth:`~pyglet.display.Screen.get_modes`.  If
                None, an appropriate mode will be selected from the given
                ``width`` and ``height``.
            width: int
                Optional width of the window.  If unspecified, defaults to the
                previous window size when windowed, or the screen size if
                fullscreen.

                .. versionadded:: 1.2
            height:
                Optional height of the window.  If unspecified, defaults to
                the previous window size when windowed, or the screen size if
                fullscreen.

                .. versionadded:: 1.2
        Nr   )r   r   r   r   r  r   rH  r   r   r   r   restore_moder(  set_location)r9   r   r   r   r   r   s         r$   set_fullscreenzBaseWindow.set_fullscreen  sm   P $***6T\#9#9%4;"6"66T\#9#9F 	:"&--//D&*&7&7&9&9D# 	"&,>T\1111!DL% 		&(,(A(A$v(V(V%DKK$$&&&(,(;%DK #!%~&&& 	8D$; 	8Dt67777	8 	8 	8 	8r#   r   c                   |7| j                             |           || j         j        }|| j         j        }n||q|d}|d}| j                             ||          }|| j                             |           nI| j                                         rd| d| }t          |          n| j         j        }| j         j        }||fS )Nr   zNo mode matching r2   )r   set_moder   r   get_closest_mode	get_modesr*   )r9   r   r   r   r  s        r$   r   zBaseWindow._set_fullscreen_mode  s    K  &&&})~+&"4}~;//v>>D$$T****&&(( 5:%::&::/4445
 K%E['Ff}r#   c                R    |dk     s|dk     rd}t          |          ||f| _        dS )aa  Set the minimum size of the window.

        Once set, the user will not be able to resize the window smaller
        than the given dimensions.  There is no way to remove the
        minimum size constraint on a window (but you could set it to 0,0).

        The behaviour is undefined if the minimum size is set larger than
        the current size of the window.

        The window size does not include the border or title bar.

        Args:
            width:
                Minimum width of the window, in pixels.
            height:
                Minimum height of the window, in pixels.

        rm  z+Width and height must be positive integers.N)
ValueErrorr   r9   r   r   r  s       r$   set_minimum_sizezBaseWindow.set_minimum_size  s8    & 199

?CS//!"F]r#   c                R    |dk     s|dk     rd}t          |          ||f| _        dS )as  Set the maximum size of the window.

        Once set, the user will not be able to resize the window larger
        than the given dimensions.  There is no way to remove the
        maximum size constraint on a window (but you could set it to a large
        value).

        The behaviour is undefined if the maximum size is set smaller than
        the current size of the window.

        The window size does not include the border or title bar.

        Args:
            width:
                Maximum width of the window, in pixels.
            height:
                Maximum height of the window, in pixels.

        rm  z*Width and height must be positive integersN)r  r   r  s       r$   set_maximum_sizezBaseWindow.set_maximum_size
  s8    ( 199

>CS//!"F]r#   c                    | j         rd}t          |          |dk     s|dk     rd}t          |          ||c| _        | _        ||c| _        | _        dS )zResize the window.

        The behaviour is undefined if the window is not resizable, or if
        it is currently fullscreen.

        The window size does not include the border or title bar.
        z%Cannot set size of fullscreen window.rm  z*width and height must be positive integersN)r   r   r  r   r   r   r   r  s       r$   set_sizezBaseWindow.set_size$  sl      	'9C!#&&&199

>CS//!$)6!T\8=v5t555r#   r2   r4   c                    dS )a/  Set the position of the window.

        Args:
            x:
                Distance of the left edge of the window from the left edge of the virtual desktop, in pixels.
            y:
                Distance of the top edge of the window from the top edge of the virtual desktop, in pixels.
        Nr"   r8   s      r$   r  zBaseWindow.set_location6  r;   r#   c                    || _         dS )zShow or hide the window.Nr   r9   r   s     r$   r  zBaseWindow.set_visibleA  s    r#   c                    || _         dS )a  Enable or disable vertical sync control.

        When enabled, this option ensures flips from the back to the front
        buffer are performed only during the vertical retrace period of the
        primary display.  This can prevent "tearing" or flickering when
        the buffer is updated in the middle of a video scan.

        Note that LCD monitors have an analogous time in which they are not
        reading from the video buffer; while it does not correspond to
        a vertical retrace it has the same effect.

        Also note that with multi-monitor systems the secondary monitor
        cannot be synchronised to, so tearing and flicker cannot be avoided
        when the window is positioned outside of the primary display.
        Nr   )r9   r   s     r$   	set_vsynczBaseWindow.set_vsyncE  s      r#   c                <    || _         |                                  dS )zShow or hide the mouse cursor.

        The mouse cursor will only be hidden while it is positioned within
        this window.  Mouse events will still be processed as usual.
        N)r   set_mouse_platform_visibler  s     r$   set_mouse_visiblezBaseWindow.set_mouse_visibleW  s$     &'')))))r#   platform_visiblebool | Nonec                    t           )a.  Set the platform-drawn mouse cursor visibility.

        This is called automatically after changing the mouse cursor or exclusive mode.

        Applications should not normally need to call this method.

        :see: :py:meth:`~pyglet.window.Window.set_mouse_visible` instead.

        Args:
            platform_visible:
                If ``None``, sets platform visibility to the required visibility
                for the current exclusive mode and cursor type.  Otherwise,
                a bool value will override and force a visibility.

        rQ  )r9   r  s     r$   r  z%BaseWindow.set_mouse_platform_visible`  s
      "!r#   cursorMouseCursor | Nonec                    |t                      }|| _        |                                 | j        _        |                                  dS )a	  Change the appearance of the mouse cursor.

        The appearance of the mouse cursor is only changed while it is
        within this window.

        Args:
            cursor:
                The cursor to set, or ``None`` to restore the default cursor.

        N)r?   r   rx  rK   r  )r9   r  s     r$   set_mouse_cursorzBaseWindow.set_mouse_cursorr  sK     >'))F#%)%:%:%<%<"'')))))r#   c                    | j         S )zSThe mouse scale factoring in the DPI.

        On Mac, this is always 1.0.
        rJ  r  s    r$   rx  zBaseWindow._get_mouse_scale  s    
 zr#   	exclusivec                    || _         dS )a  Hide the mouse cursor and direct all mouse events to this window.

        When enabled, this feature prevents the mouse leaving the window.  It
        is useful for certain styles of games that require complete control of
        the mouse.  The position of the mouse as reported in subsequent events
        is meaningless when exclusive mouse is enabled; you should only use
        the relative motion parameters ``dx`` and ``dy``.
        N)r   r9   r  s     r$   set_exclusive_mousezBaseWindow.set_exclusive_mouse  s     !*r#   c                    || _         dS )ad  Prevent the user from switching away from this window using keyboard accelerators.

        When enabled, this feature disables certain operating-system specific
        key combinations such as Alt+Tab (Command+Tab on OS X).  This can be
        useful in certain kiosk applications, it should be avoided in general
        applications or games.
        N)r   r  s     r$   set_exclusive_keyboardz!BaseWindow.set_exclusive_keyboard  s     $-   r#   imagesrC   c                    dS )a*  Set the window icon.

        If multiple images are provided, one with an appropriate size
        will be selected (if the correct size is not provided, the image
        will be scaled).

        Useful sizes to provide are 16x16, 32x32, 64x64 (Mac only) and
        128x128 (Mac only).
        Nr"   )r9   r  s     r$   set_iconzBaseWindow.set_icon  r;   r#   c                    dS )a  Make this window the current OpenGL rendering context.

        Only one OpenGL context can be active at a time. This method
        sets the current window context as the active one.

        In most cases, you should use this method instead of directly
        calling :py:meth:`~pyglet.gl.Context.set_current`. The latter
        will not perform platform-specific state management tasks for
        you.
        Nr"   r  s    r$   r  zBaseWindow.switch_to  r;   r#   c                    | j         S )z&The window caption (title). Read-only.)r   r  s    r$   r   zBaseWindow.caption       }r#   c                    | j         S )z+True if the window is resizable. Read-only.)r   r  s    r$   
resizeablezBaseWindow.resizeable  s     r#   c                    | j         S )zEThe window style; one of the ``WINDOW_STYLE_*`` constants. Read-only.)r   r  s    r$   r   zBaseWindow.style       {r#   c                    | j         S )z6True if the window is currently fullscreen. Read-only.)r   r  s    r$   r   zBaseWindow.fullscreen  s     r#   c                    | j         S )z3True if the window is currently visible. Read-only.r  r  s    r$   r   zBaseWindow.visible  r  r#   c                    | j         S )zRTrue if buffer flips are synchronised to the screen's vertical retrace. Read-only.r  r  s    r$   r   zBaseWindow.vsync  r  r#   r   c                    | j         S )z/The display this window belongs to.  Read-only.)r   r  s    r$   r   zBaseWindow.display  r  r#   r   c                    | j         S )z4The screen this window is fullscreen in.  Read-only.)r   r  s    r$   r   zBaseWindow.screen       |r#   r   c                    | j         S )z>A GL config describing the context of this window.  Read-only.)r   r  s    r$   r   zBaseWindow.config  r  r#   r   c                    | j         S )z7The OpenGL context attached to this window.  Read-only.)r   r  s    r$   r   zBaseWindow.context  r  r#   c                6    |                                  d         S )z0The width of the window, in pixels.  Read-write.r   rF  r  s    r$   r   zBaseWindow.width       }}q!!r#   	new_widthc                <    |                      || j                   d S r  )r  r   )r9   r  s     r$   r   zBaseWindow.width  s    i-----r#   c                6    |                                  d         S )z1The height of the window, in pixels.  Read-write.rm  rF  r  s    r$   r   zBaseWindow.height  r  r#   
new_heightc                <    |                      | j        |           d S r  )r  r   )r9   r  s     r$   r   zBaseWindow.height  s    dj*-----r#   c                D    t           j        j        dk    r
| j        dz  S dS )zFThe scale of the window factoring in DPI.

        Read only.
        realr   rH   )r   r   dpi_scalingr   r  s    r$   rK  zBaseWindow.scale  s%     >%//9r>!sr#   c                    | j         S )z6DPI values of the Window.

        Read only.
        )r   r  s    r$   ru  zBaseWindow.dpi  s     yr#   c                *    |                                  S )z#The size of the window. Read-Write.rF  r  s    r$   r   zBaseWindow.size  s     }}r#   new_sizeSequence[int, int]c                     | j         |  d S r  )r  )r9   r  s     r$   r   zBaseWindow.size  s    x    r#   c                :    |                                  \  }}||z  S )z*The aspect ratio of the window. Read-Only.rF  )r9   rr  rs  s      r$   aspect_ratiozBaseWindow.aspect_ratio  s     }}11ur#   c                    | j         S )a  The OpenGL window projection matrix. Read-write.

        This matrix is used to transform vertices when using any of the built-in
        drawable classes. `view` is done first, then `projection`.

        The default projection matrix is orthographic (2D),
        but a custom :py:class:`~pyglet.math.Mat4` instance
        can be set. Alternatively, you can supply a flat
        tuple of 16 values.

        (2D), but can be changed to any 4x4 matrix desired.
        :see: :py:class:`~pyglet.math.Mat4`.
        )r   r  s    r$   r  zBaseWindow.projection  s     &&r#   matrixc                j    | j         5 }||j        d d <   d d d            n# 1 swxY w Y   || _        d S r  )r  r  r   r9   r  window_blocks      r$   r  zBaseWindow.projection0  s     X 	0)/L#AAA&	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 #)   !%%c                    | j         S )a  The OpenGL window view matrix. Read-write.

        This matrix is used to transform vertices when using any of the built-in
        drawable classes. `view` is done first, then `projection`.

        The default view is an identity matrix, but a custom
        :py:class:`~pyglet.math.Mat4` instance can be set.
        Alternatively, you can supply a flat tuple of 16 values.
        )r   r  s    r$   r  zBaseWindow.view8  s       r#   c                j    | j         5 }||j        d d <   d d d            n# 1 swxY w Y   || _        d S r  )r  r  r   r  s      r$   r  zBaseWindow.viewE  s     X 	*#)Laaa 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* #r  c                    | j         S )z_The Window viewport.

        The Window viewport, expressed as (x, y, width, height).
        )r   r  s    r$   viewportzBaseWindow.viewportM  s     ~r#   valuesc           	         || _         | j        }|\  }}}}t          j                            t          ||z            t          ||z            t          ||z            t          ||z                       d S r  )r   rK  r   r   ro  r3   )r9   r  prr2   r4   rr  rs  s          r$   r  zBaseWindow.viewportU  sg    Z
1a	SR[[#a"f++s1r6{{CBKKPPPPPr#   c                    dS )a  The window was activated.

            This event can be triggered by clicking on the title bar, bringing
            it to the foreground; or by some platform-specific method.

            When a window is "active" it has the keyboard focus.

            :event:
            Nr"   r  s    r$   on_activatezBaseWindow.on_activate_  r;   r#   c                    dS )a  The user attempted to close the window.

            This event can be triggered by clicking on the "X" control box in
            the window title bar, or by some other platform-dependent manner.

            The default handler sets `has_exit` to ``True``.  In pyglet 1.1, if
            `pyglet.app.event_loop` is being used, `close` is also called,
            closing the window immediately.

            :event:
            Nr"   r  s    r$   rb  zBaseWindow.on_closej  r;   r#   c                    dS )a  The window's GL context was lost.

            When the context is lost no more GL methods can be called until it
            is recreated.  This is a rare event, triggered perhaps by the user
            switching to an incompatible video mode.  When it occurs, an
            application will need to reload all objects (display lists, texture
            objects, shaders) as well as restore the GL state.

            :event:
            Nr"   r  s    r$   on_context_lostzBaseWindow.on_context_lostw  r;   r#   c                    dS )a#  The state of the window's GL context was lost.

            pyglet may sometimes need to recreate the window's GL context if
            the window is moved to another video device, or between fullscreen
            or windowed mode.  In this case it will try to share the objects
            (display lists, texture objects, shaders) between the old and new
            contexts.  If this is possible, only the current state of the GL
            context is lost, and the application should simply restore state.

            :event:
            Nr"   r  s    r$   on_context_state_lostz BaseWindow.on_context_state_lost  r;   r#   c                    dS )zThe window was deactivated.

            This event can be triggered by clicking on another application
            window.  When a window is deactivated it no longer has the
            keyboard focus.

            :event:
            Nr"   r  s    r$   on_deactivatezBaseWindow.on_deactivate  r;   r#   c                    dS )ar  The window contents should be redrawn.

            The `EventLoop` will dispatch this event when the `draw`
            method has been called. The window will already have the
            GL context, so there is no need to call `switch_to`. The window's
            `flip` method will be called immediately after this event,
            so your event handler should not.

            You should make no assumptions about the window contents when
            this event is triggered; a resize or expose event may have
            invalidated the framebuffer since the last time it was drawn.

            :event:
            Nr"   r  s    r$   r=  zBaseWindow.on_draw  r;   r#   c                    dS )a/  A portion of the window needs to be redrawn.

            This event is triggered when the window first appears, and any time
            the contents of the window is invalidated due to another window
            obscuring it.

            There is no way to determine which portion of the window needs
            redrawing.  Note that the use of this method is becoming
            increasingly uncommon, as newer window managers composite windows
            automatically and keep a backing store of the window contents.

            :event:
            Nr"   r  s    r$   	on_exposezBaseWindow.on_expose  r;   r#   paths	list[str]c                    dS )a  File(s) were dropped into the window.

            Args:
                x:
                    Distance in pixels from the left edge of the window where a drop occurred.
                y:
                    Distance in pixels from the bottom edge of the window where a drop occurred.
                paths:
                    File path strings that were dropped into the window.

            .. versionadded:: 1.5.1

            :event:
            Nr"   )r9   r2   r4   r  s       r$   on_file_dropzBaseWindow.on_file_drop  r;   r#   c                    dS )zThe window was hidden.

            This event is triggered when a window is minimised
            or hidden by the user.

            :event:
            Nr"   r  s    r$   on_hidezBaseWindow.on_hide  r;   r#   c                    dS )a  A key on the keyboard was pressed (and held down).

            Since pyglet 1.1 the default handler dispatches the :py:meth:`~pyglet.window.Window.on_close`
            event if the ``ESC`` key is pressed.

            Args:
                symbol:
                    The key symbol pressed.
                modifiers:
                    Bitwise combination of the key modifiers active.

            :event:
            Nr"   rj  s      r$   rk  zBaseWindow.on_key_press  r;   r#   c                    dS )zA key on the keyboard was released.

            Args:
                symbol:
                    The key symbol pressed.
                modifiers:
                    Bitwise combination of the key modifiers active.

            :event:
            Nr"   rj  s      r$   on_key_releasezBaseWindow.on_key_release  r;   r#   dxdyc                    dS )a  The mouse was moved with no buttons held down.

            Args:
                x:
                    Distance in pixels from the left edge of the window.
                y:
                    Distance in pixels from the bottom edge of the window.
                dx:
                    Relative X position from the previous mouse position.
                dy: int
                    Relative Y position from the previous mouse position.

            :event:
            Nr"   )r9   r2   r4   r  r  s        r$   on_mouse_motionzBaseWindow.on_mouse_motion  r;   r#   buttonsc                    dS )aY  The mouse was moved with one or more mouse buttons pressed.

            This event will continue to be fired even if the mouse leaves
            the window, so long as the drag buttons are continuously held down.

            Args:
                x:
                    Distance in pixels from the left edge of the window.
                y:
                    Distance in pixels from the bottom edge of the window.
                dx:
                    Relative X position from the previous mouse position.
                dy:
                    Relative Y position from the previous mouse position.
                buttons:
                    Bitwise combination of the mouse buttons currently pressed.
                modifiers:
                    Bitwise combination of any keyboard modifiers currently active.

            :event:
            Nr"   )r9   r2   r4   r  r  r  rd  s          r$   on_mouse_dragzBaseWindow.on_mouse_drag  r;   r#   buttonc                    dS )a  A mouse button was pressed (and held down).

            Args:
                x:
                    Distance in pixels from the left edge of the window.
                y:
                    Distance in pixels from the bottom edge of the window.
                button:
                    The mouse button that was pressed.
                modifiers:
                    Bitwise combination of any keyboard modifiers currently active.

            :event:
            Nr"   r9   r2   r4   r  rd  s        r$   on_mouse_presszBaseWindow.on_mouse_press  r;   r#   c                    dS )a  A mouse button was released.

            Args:
                x:
                    Distance in pixels from the left edge of the window.
                y:
                    Distance in pixels from the bottom edge of the window.
                button:
                    The mouse button that was released.
                modifiers:
                    Bitwise combination of any keyboard modifiers currently active.

            :event:
            Nr"   r  s        r$   on_mouse_releasezBaseWindow.on_mouse_release$  r;   r#   scroll_xscroll_yc                    dS )a  The mouse wheel was scrolled.

            Note that most mice have only a vertical scroll wheel, so
            scroll_x is usually 0.  An exception to this is the Apple Mighty
            Mouse, which has a mouse ball in place of the wheel which allows
            both ``scroll_x`` and ``scroll_y`` movement.

            Args:
                x:
                    Distance in pixels from the left edge of the window.
                y:
                    Distance in pixels from the bottom edge of the window.
                scroll_x:
                    Amount of movement on the horizontal axis.
                scroll_y:
                    Amount of movement on the vertical axis.

            :event:
            Nr"   )r9   r2   r4   r  r  s        r$   on_mouse_scrollzBaseWindow.on_mouse_scroll4  r;   r#   c                    dS )zThe mouse was moved into the window.

            This event will not be triggered if the mouse is currently being
            dragged.

            :event:
            Nr"   r8   s      r$   on_mouse_enterzBaseWindow.on_mouse_enterI  r;   r#   c                    dS )zThe mouse was moved outside the window.

            This event will not be triggered if the mouse is currently being dragged.

            .. note: Coordinates of the mouse pointer will be outside the window rectangle.

            :event:
            Nr"   r8   s      r$   on_mouse_leavezBaseWindow.on_mouse_leaveR  r;   r#   c                    dS )a  The window was moved.

            Args:
                x:
                    Distance from the left edge of the screen to the left edge of the window.
                y:
                    Distance from the top edge of the screen to the *top* edge of the window.

            .. note: This is one of few methods in pyglet which use a Y-down coordinate system.

            :event:
            Nr"   r8   s      r$   on_movezBaseWindow.on_move\  r;   r#   c                    dS )a  The window contents should be redrawn.

            The ``EventLoop`` will dispatch this event when the ``draw``
            method has been called. The window will already have the
            GL context, so there is no need to call :py:meth:`~pyglet.window.Window.switch_to`. The window's
            :py:meth:`~pyglet.window.Window.flip` method will be called immediately after this event, so your
            event handler should not.

            You should make no assumptions about the window contents when
            this event is triggered; a resize or expose event may have
            invalidated the framebuffer since the last time it was drawn.

            .. versionadded:: 2.0

            :event:
            Nr"   r@  s     r$   r>  zBaseWindow.on_refreshj  r;   r#   c                    dS )zThe window was resized.

            The window will have the GL context when this event is dispatched;
            there is no need to call :py:meth:`~pyglet.window.Window.switch_to` in this handler.

            :event:
            Nr"   r  s      r$   rn  zBaseWindow.on_resize|  r;   r#   c                    dS )zA default scale event handler.

            This default handler is called if the screen or system's DPI changes
            during runtime.
            Nr"   r|  s      r$   rw  zBaseWindow.on_scale  r;   r#   c                    dS )zThe window was shown.

            This event is triggered when a window is restored after being
            minimised, hidden, or after being displayed for the first time.

            :event:
            Nr"   r  s    r$   on_showzBaseWindow.on_show  r;   r#   c                    dS )af  The user input some text.

            Typically, this is called after :py:meth:`~pyglet.window.Window.on_key_press` and before
            :py:meth:`~pyglet.window.Window.on_key_release`, but may also be called multiple times if the key
            is held down (key repeating); or called without key presses if
            another input method was used (e.g., a pen input).

            You should always use this method for interpreting text, as the
            key symbols often have complex mappings to their unicode
            representation which this event takes care of.

            :event:
            Nr"   rW  s     r$   on_textzBaseWindow.on_text  r;   r#   motionc                    dS )ap  The user moved the text input cursor.

            Typically this is called after :py:meth:`~pyglet.window.Window.on_key_press` and before
            :py:meth:`~pyglet.window.Window.on_key_release`, but may also be called multiple times if the key
            is help down (key repeating).

            You should always use this method for moving the text input cursor
            (caret), as different platforms have different default keyboard
            mappings, and key repeats are handled correctly.

            The values that `motion` can take are defined in
            :py:mod:`pyglet.window.key`:

            * MOTION_UP
            * MOTION_RIGHT
            * MOTION_DOWN
            * MOTION_LEFT
            * MOTION_NEXT_WORD
            * MOTION_PREVIOUS_WORD
            * MOTION_BEGINNING_OF_LINE
            * MOTION_END_OF_LINE
            * MOTION_NEXT_PAGE
            * MOTION_PREVIOUS_PAGE
            * MOTION_BEGINNING_OF_FILE
            * MOTION_END_OF_FILE
            * MOTION_BACKSPACE
            * MOTION_DELETE
            * MOTION_COPY
            * MOTION_PASTE

            :event:
            Nr"   r9   r
  s     r$   on_text_motionzBaseWindow.on_text_motion  r;   r#   c                    dS )a  The user moved the text input cursor while extending the selection.

            Typically this is called after :py:meth:`~pyglet.window.Window.on_key_press` and before
            :py:meth:`~pyglet.window.Window.on_key_release`, but may also be called multiple times if the key
            is help down (key repeating).

            You should always use this method for responding to text selection
            events rather than the raw :py:meth:`~pyglet.window.Window.on_key_press`, as different platforms
            have different default keyboard mappings, and key repeats are
            handled correctly.

            The values that `motion` can take are defined in :py:mod:`pyglet.window.key`:

            * MOTION_UP
            * MOTION_RIGHT
            * MOTION_DOWN
            * MOTION_LEFT
            * MOTION_NEXT_WORD
            * MOTION_PREVIOUS_WORD
            * MOTION_BEGINNING_OF_LINE
            * MOTION_END_OF_LINE
            * MOTION_NEXT_PAGE
            * MOTION_PREVIOUS_PAGE
            * MOTION_BEGINNING_OF_FILE
            * MOTION_END_OF_FILE
            * MOTION_COPY
            * MOTION_PASTE

            :event:
            Nr"   r  s     r$   on_text_motion_selectz BaseWindow.on_text_motion_select  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   r5   r6   r5   r6   )r5   rh   )r%  r&  r5   r6   )r6  r   r5   r6   )r:  r;  r5   r6   )r5   rD  )r5   r;  )rg   rh   r5   r.   )r   rh   r5   r6   )rY  r/   r5   r6   )rc  r3   rd  r3   r5   r   )r   r3   r   r3   r5   r6   )rK  r;  ru  r3   r5   r6   )r   r3   r   r3   r5   r   )rK  r;  ru  r3   r5   r   )r   rh   r5   r6   )TNNNN)r   r/   r   r   r   r   r   r   r   r   r5   r6   )r   r   r   r3   r   r3   r5   rD  r<   )T)r   r/   r5   r6   )r   r/   r5   r6   r  )r  r  r5   r6   )r  r  r5   r6   )r  r/   r5   r6   )r  rC   r5   r6   )r5   r/   )r5   r   )r5   r   )r5   r   )r5   r   )r5   r3   )r  r3   r5   r6   )r  r3   r5   r6   )r  r  r5   r6   )r5   r   )r  r   r5   r6   )r5   r   )r  r   r5   r6   )r5   r   )r2   r3   r4   r3   r  r  r5   r   )
r2   r3   r4   r3   r  r3   r  r3   r5   r   )r2   r3   r4   r3   r  r3   r  r3   r  r3   rd  r3   r5   r   )
r2   r3   r4   r3   r  r3   rd  r3   r5   r   )
r2   r3   r4   r3   r  r;  r  r;  r5   r   )r2   r3   r4   r3   r5   r   )r:  r;  r5   r   )r   rh   r5   r   )r
  r3   r5   r   )r   r   r    r!   ro   rn   r=   r{   r}   r   r   r   r   CURSOR_DEFAULTr   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   r   r   mathr   r   r   r   r   r   r   r   r   r   r?   r   r   r   r   r   r   r   r   r   r   r   r  r  rL   r  r   r#  r   r   r(  r  staticmethodr.  r  r4  r9  r:   rB  r?  r  rH  rL  r  rO  rS  rU  rX  r[  r]  r_  rb  rk  rt  ry  rn  rw  r~  r  r   r  r  r  r  r  r  r  r  r  rx  r  r  r  r  propertyr   r  r   r   r   r   r   r   r   r   r   setterr   rK  ru  r   r  r  r  r  _is_pyglet_doc_runr  r  r  r  r=  r  r  r  r  r  r  r  r  r  r  r   r  r>  r  r	  r  r  rw   rx   s   @r$   rz   rz      s         2 9<==== "&%%%%'''''######/////$11111 ))))) N'''''KKIK $N#### !0//// *)))) #43333 ('''' "21111 (''''  .---------"33333KK))))) H G DNNNNFGHJ-F----KHFK!G!!!!$(G((((#H####%{//111111))++L+++++5I5555 .2N1111155555,0M0000,0M0000 %%%%%G 5G4F4H4HMHHHHHHN""""""""""L $$$$$"''''' NO  &*&*'+#(%9$)!%#$)+/)-)-+/+/b b b b bHW W W W   W W W W    ^    ^    ^ D D D \D$ $ $ $,+ + + + + +    ^   B B B B     ^       ^    ) ) ) )= = = =" " " "" " " "" " " "" " " " # # # ^#    ^   , , , ,/ / / /4 4 4 4          ^ osFJG8 G8 G8 G8 G8R   0+ + + +2+ + + +4F F F F$    ^            $* * * * *" " " " "$* * * * *"  	* 	* 	* 	* 	*- - - - -	 	 	 	 
 
 
 ^
    X    X    X       X     X    X    X    X    X    X
 " " " X" \. . . \. " " " X" ]. . . ].    X    X    X 
[! ! ! [!    X
 ' ' ' X'  ) ) ) ) 
! 
! 
! X
! 
[# # # [#    X _Q Q Q _Q  F		 		 		 			 	 	 	
	 
	 
	 
		 	 	 		 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	
	 
	 
	 
		 	 	 	 	 	 	 	.	 	 	 	 	 	 	 	 	 	 	 	*	 	 	 		 	 	 		 	 	 		 	 	 	$	 	 	 		 	 	 		 	 	 		 	 	 	 	  	  	  	D	 	 	 	 	 	 	 	QF F F Fr#   rz   )	metaclassrk  r  r	  r  r  r  r  r  r  r  r  r   rb  r  rt  ry  rn  rw  r  r  r  r  r  r  r  r  r=  r>  c                  H    e Zd ZU dZdZded<   	 	 dddZddZddZddZ	dS )
FPSDisplayab  Display of a window's framerate.

    This is a convenience class to aid in profiling and debugging.  Typical
    usage is to create an `FPSDisplay` for each window, and draw the display
    at the end of the windows' :py:meth:`~pyglet.window.Window.on_draw` event handler::

        from pyglet.window import Window, FPSDisplay

        window = Window()
        fps_display = FPSDisplay(window)

        @window.event
        def on_draw():
            # ... perform ordinary window drawing operations ...

            fps_display.draw()

    The style and position of the display can be modified via the ``label`` attribute. The display can be set to
    update more or less often by setting the `update_period` attribute.

    .. note: Setting the `update_period` to a value smaller than your Window refresh rate will cause
             inaccurate readings.
    g      ?r   label   r  r  r     windowpyglet.window.Windowcolorr   samplesr3   r5   r6   c                    ddl m} ddlm} ddlm} ddlm} || _        || _        |j	        | j
        c| _        |_	         |ddddd	|
          | _        d| _         |            | _         ||          | _        dS )aK  Create an FPS Display.

        Args:
            window:
                The Window you wish to display frame rate for.
            color:
                The RGBA color of the text display. Each channel represented as 0-255.
            samples:
                How many delta samples are used to calculate the mean FPS.
        r   r   )mean)timer    
   r   bold)r2   r4   	font_sizeweightr   g        )maxlenN)collectionsr   
statisticsr#  r$  pyglet.textr   _time_meanr?  
_hook_flip_window_flipr  _elapsed
_last_time_delta_times)r9   r  r   r!  r   r#  r$  r   s           r$   rL   zFPSDisplay.__init__$  s     	&%%%%%######%%%%%%

 *0do&6;U2rReTTT
$&&!E111r#   c                (   |                                  }|| j        z
  }| xj        |z  c_        | j                            |           || _        | j        | j        k    r2d| _        d|                     | j                  z  d| j        _        dS dS )zRecords a new data point at the current time.

        This method is called automatically when the window buffer is flipped.
        r   rm  z.2fN)	r.  r3  r2  r4  r\   update_periodr/  r  r   )r9   tdeltas      r$   rp   zFPSDisplay.update@  s    
 JJLLDO#  '''=D...DM!"TZZ0A%B%B!BHHDJOOO /.r#   c                8    | j                                          dS )zDraw the label.N)r  r:   r  s    r$   r:   zFPSDisplay.drawO  s    
r#   c                V    |                                   |                                  d S r  )rp   r1  r  s    r$   r0  zFPSDisplay._hook_flipS  s'    r#   N)r  r  )r  r  r   r   r!  r3   r5   r6   r  )
r   r   r    r!   r6  r=   rL   rp   r:   r0  r"   r#   r$   r  r    s          2 M LLLXl #2 2 2 2 28I I I I        r#   r  Window)	predicateheadless)HeadlessWindowdarwin)CocoaWindow)win32cygwin)Win32Window)
XlibWindow)r   r   rz   r;  r.   r?   rA   r  r   r*   r&   r(   r,   )rU   r   r5   r	   r^   )Or!   
__future__r   r   abcr   r+  r   typingr   r   r	   r
   r   pyglet.window.keypyglet.window.mouser   pyglet.eventr   r   pyglet.graphicsr   pyglet.mathr   pyglet.windowr   r   rz   r;  pyglet.display.baser   r   r   	pyglet.glr   r   r   r-  r   r[   r   r  	Exceptionr   r&   r(   r*   r,   r.   r?   rA   r_   rb   typerd   register_event_typer  inspectr   r    
getmembers
isfunction_
method_objreplacer   pyglet.window.headlessr>  compat_platformpyglet.window.cocoar@  pyglet.window.win32rC  pyglet.window.xlibrD  modulesr  _create_shadow_window__all__r"   r#   r$   <module>ra     s  X Xr # " " " " " 



             9 9 9 9 9 9 9 9 9 9 9 9                < < < < < < < < " " " " " "       $ $ $ $ $ $ $ $ "??????????8888888888!!!!!!WS"566P3;P < < < < <i < < <J J J J J_ J J JP P P P PO P P PT T T T T T T TB B B B B? B B B       0       (" (" (" (" ("{ (" (" ("V   6   
+ + + + +t + + +f f f f f,< f f f fR/   ~ . . . 
  / 0 0 0 
  y ) ) ) 
  / 0 0 0 
  6 7 7 7 
  0 1 1 1 
   / / / 
  / 0 0 0 
  1 2 2 2 
  0 1 1 1 
  / 0 0 0 
  / 0 0 0 
  z * * * 
  { + + + 
  4 5 5 5 
  3 4 4 4 
  { + + + 
  z * * * 
  y ) ) ) 
  } - - - 
   / / / 
  y ) ) ) 
  y ) ) ) 
  0 1 1 1 
  6 7 7 7 
  ~ . . . 
  y ) ) ) 
  | , , ,P P P P P P P Pf  <NNNFFO"F ,+Fg>PQQQ Z Z:","9"A"A,PX"Y"Y
Z
 ~j! <CCCCCCC		8	+	+=======		#6	6	6=======;;;;;;  K)FMBr#   