Skip to content

Commit

Permalink
Merge branch 'main' into window-get_surface
Browse files Browse the repository at this point in the history
  • Loading branch information
MyreMylar authored Oct 15, 2023
2 parents f998095 + e3d34b4 commit 8086695
Show file tree
Hide file tree
Showing 70 changed files with 10,430 additions and 7,937 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- run:
name: Build the Linux wheels.
command: |
pip3 install --user cibuildwheel==2.16.1
pip3 install --user cibuildwheel==2.16.2
PATH="$HOME/.local/bin:$PATH" cibuildwheel --output-dir wheelhouse
- store_artifacts:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
fail-on-cache-miss: true

- name: Build and test wheels
uses: pypa/[email protected].1
uses: pypa/[email protected].2

- uses: actions/upload-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-manylinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
CIBW_MANYLINUX_I686_IMAGE: ghcr.io/${{ github.repository }}_i686:${{ steps.meta.outputs.version }}
CIBW_MANYLINUX_PYPY_I686_IMAGE: ghcr.io/${{ github.repository }}_i686:${{ steps.meta.outputs.version }}

uses: pypa/[email protected].1
uses: pypa/[email protected].2

# We upload the generated files under github actions assets
- name: Upload dist
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-ubuntu-sdist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ jobs:
- name: Install deps
# install numpy from pip and not apt because the one from pip is newer,
# and has typestubs
# https://github.com/actions/runner-images/issues/7192
# https://github.com/orgs/community/discussions/47863
run: |
sudo apt-mark hold grub-efi-amd64-signed
sudo apt-get update --fix-missing
sudo apt-get upgrade
sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libfreetype6-dev libportmidi-dev libjpeg-dev python3-setuptools python3-dev
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
set MSSdk=1
python -m pip install setuptools wheel requests numpy Sphinx"<7.2.0"
python setup.py docs
python -m pip --disable-pip-version-check install cibuildwheel==2.16.1
python -m pip --disable-pip-version-check install cibuildwheel==2.16.2
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ jobs:
- uses: actions/[email protected]

- name: Install deps
# https://github.com/actions/runner-images/issues/7192
# https://github.com/orgs/community/discussions/47863
run: |
sudo apt-mark hold grub-efi-amd64-signed
sudo apt-get update --fix-missing
sudo apt-get upgrade
sudo apt install cppcheck
Expand Down
1 change: 1 addition & 0 deletions buildconfig/Setup.Android.SDL2.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ math src_c/math.c $(SDL) $(DEBUG)
pixelcopy src_c/pixelcopy.c $(SDL) $(DEBUG)
newbuffer src_c/newbuffer.c $(SDL) $(DEBUG)
_window src_c/window.c $(SDL) $(DEBUG)
geometry src_c/geometry.c $(SDL) $(DEBUG)
1 change: 1 addition & 0 deletions buildconfig/Setup.Emscripten.SDL2.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ rect src_c/void.c
rwobject src_c/void.c
system src_c/void.c
_window src_c/void.c
geometry src_c/void.c

#_sdl2.controller src_c/_sdl2/controller.c $(SDL) $(DEBUG) -Isrc_c
_sdl2.controller_old src_c/void.c
Expand Down
1 change: 1 addition & 0 deletions buildconfig/Setup.SDL2.in
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ math src_c/math.c $(SDL) $(DEBUG)
pixelcopy src_c/pixelcopy.c $(SDL) $(DEBUG)
newbuffer src_c/newbuffer.c $(SDL) $(DEBUG)
system src_c/system.c $(SDL) $(DEBUG)
geometry src_c/geometry.c $(SDL) $(DEBUG)
_window src_c/window.c $(SDL) $(DEBUG)
2 changes: 2 additions & 0 deletions buildconfig/stubs/gen_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"sysfont",
"_debug",
"system",
"geometry",
]

# pygame classes that are autoimported into main namespace are kept in this dict
Expand All @@ -68,6 +69,7 @@
"mixer": ["Channel"],
"time": ["Clock"],
"joystick": ["Joystick"],
"geometry": ["Circle"],
}

# pygame modules from which __init__.py does the equivalent of
Expand Down
8 changes: 7 additions & 1 deletion buildconfig/stubs/pygame/_window.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,20 @@ class Window:
def update_from_surface(self) -> None: ...
@overload
def update_from_surface(self, rects: Sequence[RectValue]) -> None: ...
grab: bool

grab_mouse: bool
grab_keyboard: bool
title: str
resizable: bool
borderless: bool
always_on_top: bool
relative_mouse: bool
opacity: float

@property
def mouse_grabbed(self) -> bool: ...
@property
def keyboard_grabbed(self) -> bool: ...
@property
def id(self) -> int: ...
@property
Expand Down
14 changes: 13 additions & 1 deletion buildconfig/stubs/pygame/display.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import Dict, List, Optional, Tuple, Union, overload
from typing import Dict, List, Optional, Tuple, Union, overload, Literal

from pygame.constants import FULLSCREEN
from pygame.surface import Surface

from pygame._sdl2 import Window

from ._common import (
ColorValue,
Coordinate,
Expand All @@ -29,6 +31,7 @@ class _VidInfo:
blit_sw_A: int
current_h: int
current_w: int
pixel_format: str

def init() -> None: ...
def quit() -> None: ...
Expand Down Expand Up @@ -86,3 +89,12 @@ def is_fullscreen() -> bool: ...
def is_vsync() -> bool: ...
def get_current_refresh_rate() -> int: ...
def get_desktop_refresh_rates() -> List[int]: ...
def message_box(
title: str,
message: Optional[str] = None,
message_type: Literal["info", "warn", "error"] = "info",
parent_window: Optional[Window] = None,
buttons: Sequence[str] = ("OK",),
return_button: int = 0,
escape_button: Optional[int] = None,
) -> int: ...
2 changes: 0 additions & 2 deletions buildconfig/stubs/pygame/draw.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ def aaline(
color: ColorValue,
start_pos: Coordinate,
end_pos: Coordinate,
blend: int = 1,
) -> Rect: ...
def aalines(
surface: Surface,
color: ColorValue,
closed: bool,
points: Sequence[Coordinate],
blend: int = 1,
) -> Rect: ...
20 changes: 20 additions & 0 deletions buildconfig/stubs/pygame/geometry.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from typing import (
Sequence,
overload,
)

class Circle:
x: float
y: float
r: float

@overload
def __init__(self, x: float, y: float, r: float) -> None: ...
@overload
def __init__(self, pos: Sequence[float], r: float) -> None: ...
@overload
def __init__(self, circle: Circle) -> None: ...
@overload
def __init__(self, obj_with_circle_attr) -> None: ...
def __copy__(self) -> Circle: ...
copy = __copy__
1 change: 1 addition & 0 deletions buildconfig/stubs/pygame/rect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class _GenericRect(Collection[_N]):
def move_ip(self, x: float, y: float) -> None: ...
@overload
def move_ip(self, move_by: Coordinate) -> None: ...
def move_to(self, **kwargs: Union[float, Coordinate]) -> Self: ...
@overload
def inflate(self, x: float, y: float) -> Self: ...
@overload
Expand Down
1 change: 0 additions & 1 deletion buildconfig/stubs/pygame/system.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ from typing_extensions import TypedDict
from pygame._data_classes import PowerState

class _InstructionSets(TypedDict):
RDTSC: bool
ALTIVEC: bool
MMX: bool
SSE: bool
Expand Down
2 changes: 1 addition & 1 deletion docs/reST/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# The short X.Y version.
version = '2.4.0'
# The full version, including alpha/beta/rc tags.
release = '2.4.0.dev1'
release = '2.4.0.dev3'

# Format strings for the version directives
versionadded_format = 'New in pygame-ce %s'
Expand Down
1 change: 1 addition & 0 deletions docs/reST/ext/boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ def lowercase_name(d):
"music",
"pygame",
"Rect",
"geometry",
"Surface",
"sprite",
"time",
Expand Down
64 changes: 51 additions & 13 deletions docs/reST/ref/display.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,9 @@ required).
are set to ``0``, the Surface will have the same width or height as the
screen resolution.

It is usually best to not pass the depth argument. It will default to the
best and fastest color depth for the system. If your game requires a
specific color format you can control the depth with this argument. Pygame
will emulate an unavailable color depth which can be slow.
Since pygame 2, the depth argument is ignored, in favour of the best
and fastest one. It also raises a deprecation warning since pygame-ce
2.4.0 if the passed in depth is not 0 or the one pygame selects.

When requesting fullscreen display modes, sometimes an exact match for the
requested size cannot be made. In these situations pygame will select
Expand Down Expand Up @@ -213,6 +212,8 @@ required).

.. versionchanged:: 2.2.0 ``vsync=1`` does not require ``SCALED`` or ``OPENGL``

.. deprecated:: 2.4.0 The depth argument is ignored, and will be set to the optimal value


Basic example:

Expand Down Expand Up @@ -311,26 +312,33 @@ required).
mode to verify specific display options were satisfied. The VidInfo object
has several attributes:

::
.. code-block:: text
hw: 1 if the display is hardware accelerated
wm: 1 if windowed display modes can be used
video_mem: The megabytes of video memory on the display. This is 0 if
unknown
video_mem: The megabytes of video memory on the display.
This is 0 if unknown
bitsize: Number of bits used to store each pixel
bytesize: Number of bytes used to store each pixel
masks: Four values used to pack RGBA values into pixels
shifts: Four values used to pack RGBA values into pixels
losses: Four values used to pack RGBA values into pixels
blit_hw: 1 if hardware Surface blitting is accelerated
blit_hw_CC: 1 if hardware Surface colorkey blitting is accelerated
blit_hw_A: 1 if hardware Surface pixel alpha blitting is accelerated
blit_hw_A: 1 if hardware Surface pixel alpha blitting is
accelerated
blit_sw: 1 if software Surface blitting is accelerated
blit_sw_CC: 1 if software Surface colorkey blitting is accelerated
blit_sw_A: 1 if software Surface pixel alpha blitting is accelerated
current_h, current_w: Height and width of the current video mode, or
of the desktop mode if called before the display.set_mode
is called. They are -1 on error.
blit_sw_CC: 1 if software Surface colorkey blitting is
accelerated
blit_sw_A: 1 if software Surface pixel alpha blitting is
accelerated
current_h, current_w: Height and width of the current video
mode, or of the desktop mode if called before
the display.set_mode is called. They are -1 on error.
pixel_format: The pixel format of the display Surface as a string.
E.g PIXELFORMAT_RGB888.
.. versionchanged:: 2.4.0 ``pixel_format`` attribute added.

.. ## pygame.display.Info ##
Expand Down Expand Up @@ -794,4 +802,34 @@ required).
.. versionadded:: 2.2.0
.. ## pygame.display.set_allow_screensaver ##
.. function:: message_box

| :sl:`Create a native GUI message box`
| :sg:`message_box(title, message=None, message_type='info', parent_window=None, buttons=('OK',), return_button=0, escape_button=None) -> int`
:param str title: A title string.
:param str message: A message string. If this parameter is set to ``None``, the message will be the title.
:param str message_type: Set the type of message_box, could be ``"info"``, ``"warn"`` or ``"error"``.
:param tuple buttons: An optional sequence of button name strings to show to the user.
:param int return_button: Button index to use if the return key is hit, ``0`` by default.
:param int escape_button: Button index to use if the escape key is hit, ``None`` for no button linked by default.
..
(Uncomment this after the window API is published)
:param Window parent_window: The parent window of the message_box
..
:return: The index of the button that was pushed.

This function should be called on the thread that ``set_mode()`` is called.
It will block execution of that thread until the user clicks a button or
closes the message_box.

This function may be called at any time, even before ``pygame.init()``.

Negative values of ``return_button`` and ``escape_button`` are allowed
just like standard Python list indexing.

.. versionadded:: 2.4.0


.. ## pygame.display ##
9 changes: 2 additions & 7 deletions docs/reST/ref/draw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ object around the draw calls (see :func:`pygame.Surface.lock` and

| :sl:`draw a straight antialiased line`
| :sg:`aaline(surface, color, start_pos, end_pos) -> Rect`
| :sg:`aaline(surface, color, start_pos, end_pos, blend=1) -> Rect`
Draws a straight antialiased line on the given surface.

Expand Down Expand Up @@ -488,8 +487,6 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
:param end_pos: end position of the line, (x, y)
:type end_pos: tuple(int or float, int or float) or
list(int or float, int or float) or Vector2(int or float, int or float)
:param int blend: (optional) (deprecated) if non-zero (default) the line will be blended
with the surface's existing pixel shades, otherwise it will overwrite them

:returns: a rect bounding the changed pixels, if nothing is drawn the
bounding rect's position will be the ``start_pos`` parameter value (float
Expand All @@ -500,14 +497,14 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
two numbers

.. versionchangedold:: 2.0.0 Added support for keyword arguments.
.. versionchanged:: 2.4.0 Removed deprecated 'blend' argument

.. ## pygame.draw.aaline ##
.. function:: aalines

| :sl:`draw multiple contiguous straight antialiased line segments`
| :sg:`aalines(surface, color, closed, points) -> Rect`
| :sg:`aalines(surface, color, closed, points, blend=1) -> Rect`
Draws a sequence of contiguous straight antialiased lines on the given
surface.
Expand All @@ -527,9 +524,6 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
additionally if the ``closed`` parameter is ``True`` another line segment
will be drawn from ``(x3, y3)`` to ``(x1, y1)``
:type points: tuple(coordinate) or list(coordinate)
:param int blend: (optional) (deprecated) if non-zero (default) each line will be blended
with the surface's existing pixel shades, otherwise the pixels will be
overwritten

:returns: a rect bounding the changed pixels, if nothing is drawn the
bounding rect's position will be the position of the first point in the
Expand All @@ -542,6 +536,7 @@ object around the draw calls (see :func:`pygame.Surface.lock` and
contain number pairs

.. versionchangedold:: 2.0.0 Added support for keyword arguments.
.. versionchanged:: 2.4.0 Removed deprecated 'blend' argument

.. ## pygame.draw.aalines ##
Expand Down
Loading

0 comments on commit 8086695

Please sign in to comment.