Skip to content

Commit ba2de75

Browse files
committed
Add some SDL modules to the documentation.
1 parent 858b630 commit ba2de75

File tree

7 files changed

+65
-6
lines changed

7 files changed

+65
-6
lines changed

docs/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ Contents:
3636
tcod/noise
3737
tcod/path
3838
tcod/random
39+
tcod/render
3940
tcod/tileset
4041
libtcodpy
42+
sdl/render
43+
sdl/video
4144

4245
Indices and tables
4346
==================

docs/sdl/render.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tcod.sdl.render - SDL Rendering
2+
===============================
3+
4+
.. automodule:: tcod.sdl.render
5+
:members:

docs/sdl/video.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tcod.sdl.video - SDL Window and Display API
2+
===========================================
3+
4+
.. automodule:: tcod.sdl.video
5+
:members:

docs/tcod/render.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tcod.render - Console Rendering Extension
2+
=========================================
3+
4+
.. automodule:: tcod.render
5+
:members:

tcod/render.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
"""Handle the rendering of libtcod's tilesets.
1+
"""Handles the rendering of libtcod's tilesets.
2+
3+
Using this module you can render a console to an SDL :any:`Texture` directly, letting you have full control over how
4+
conoles are displayed.
5+
This includes rendering multiple tilesets in a single frame and rendering consoles on top of each other.
26
37
Example::
48
@@ -19,6 +23,8 @@
1923
for event in tcod.event.wait():
2024
if isinstance(event, tcod.event.Quit):
2125
raise SystemExit()
26+
27+
.. versionadded:: 13.4
2228
"""
2329

2430
from __future__ import annotations

tcod/sdl/render.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""SDL2 Rendering functionality.
2+
3+
.. versionadded:: 13.4
4+
"""
15
from __future__ import annotations
26

37
import enum
@@ -23,6 +27,8 @@ class TextureAccess(enum.IntEnum):
2327

2428

2529
class Texture:
30+
"""SDL hardware textures."""
31+
2632
def __init__(self, sdl_texture_p: Any, sdl_renderer_p: Any = None) -> None:
2733
self.p = sdl_texture_p
2834
self._sdl_renderer_p = sdl_renderer_p # Keep alive.
@@ -114,6 +120,8 @@ def __exit__(self, *_: Any) -> None:
114120

115121

116122
class Renderer:
123+
"""SDL Renderer."""
124+
117125
def __init__(self, sdl_renderer_p: Any) -> None:
118126
if ffi.typeof(sdl_renderer_p) is not ffi.typeof("struct SDL_Renderer*"):
119127
raise TypeError(f"Expected a {ffi.typeof('struct SDL_Window*')} type (was {ffi.typeof(sdl_renderer_p)}).")

tcod/sdl/video.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
"""SDL2 specific functionality.
1+
"""SDL2 Window and Display handling.
22
3-
Add the line ``import tcod.sdl`` to include this module, as importing this
4-
module is not implied by ``import tcod``.
3+
.. versionadded:: 13.4
54
"""
65
from __future__ import annotations
76

@@ -33,33 +32,60 @@ class WindowFlags(enum.IntFlag):
3332
"""
3433

3534
FULLSCREEN = lib.SDL_WINDOW_FULLSCREEN or 0
35+
""""""
3636
FULLSCREEN_DESKTOP = lib.SDL_WINDOW_FULLSCREEN_DESKTOP or 0
37+
""""""
3738
OPENGL = lib.SDL_WINDOW_OPENGL or 0
39+
""""""
3840
SHOWN = lib.SDL_WINDOW_SHOWN or 0
41+
""""""
3942
HIDDEN = lib.SDL_WINDOW_HIDDEN or 0
43+
""""""
4044
BORDERLESS = lib.SDL_WINDOW_BORDERLESS or 0
45+
""""""
4146
RESIZABLE = lib.SDL_WINDOW_RESIZABLE or 0
47+
""""""
4248
MINIMIZED = lib.SDL_WINDOW_MINIMIZED or 0
49+
""""""
4350
MAXIMIZED = lib.SDL_WINDOW_MAXIMIZED or 0
51+
""""""
4452
MOUSE_GRABBED = lib.SDL_WINDOW_INPUT_GRABBED or 0
53+
""""""
4554
INPUT_FOCUS = lib.SDL_WINDOW_INPUT_FOCUS or 0
55+
""""""
4656
MOUSE_FOCUS = lib.SDL_WINDOW_MOUSE_FOCUS or 0
57+
""""""
4758
FOREIGN = lib.SDL_WINDOW_FOREIGN or 0
59+
""""""
4860
ALLOW_HIGHDPI = lib.SDL_WINDOW_ALLOW_HIGHDPI or 0
61+
""""""
4962
MOUSE_CAPTURE = lib.SDL_WINDOW_MOUSE_CAPTURE or 0
63+
""""""
5064
ALWAYS_ON_TOP = lib.SDL_WINDOW_ALWAYS_ON_TOP or 0
65+
""""""
5166
SKIP_TASKBAR = lib.SDL_WINDOW_SKIP_TASKBAR or 0
67+
""""""
5268
UTILITY = lib.SDL_WINDOW_UTILITY or 0
69+
""""""
5370
TOOLTIP = lib.SDL_WINDOW_TOOLTIP or 0
71+
""""""
5472
POPUP_MENU = lib.SDL_WINDOW_POPUP_MENU or 0
73+
""""""
5574
VULKAN = lib.SDL_WINDOW_VULKAN or 0
75+
""""""
5676
METAL = getattr(lib, "SDL_WINDOW_METAL", None) or 0x20000000 # SDL >= 2.0.14
77+
""""""
5778

5879

5980
class FlashOperation(enum.IntEnum):
81+
"""Values for :any:`Window.flash`."""
82+
6083
CANCEL = 0
84+
"""Stop flashing."""
6185
BRIEFLY = 1
86+
"""Flash breifly."""
6287
UNTIL_FOCUSED = 2
88+
"""Flash until focus is gained."""
6389

6490

6591
class _TempSurface:
@@ -185,7 +211,7 @@ def flags(self) -> WindowFlags:
185211
def fullscreen(self) -> int:
186212
"""Get or set the fullscreen status of this window.
187213
188-
Can be set to :any:`WindowFlags.FULLSCREEN` or :any:`WindowFlags.FULLSCREEN_DESKTOP` flags
214+
Can be set to the :any:`WindowFlags.FULLSCREEN` or :any:`WindowFlags.FULLSCREEN_DESKTOP` flags.
189215
190216
Example::
191217
@@ -304,8 +330,9 @@ def new_window(
304330
305331
Example::
306332
333+
import tcod.sdl.video
307334
# Create a new resizable window with a custom title.
308-
window = tcod.sdl.video.new_window(640, 480, title="Title bar text", flags=tcod.lib.SDL_WINDOW_RESIZABLE)
335+
window = tcod.sdl.video.new_window(640, 480, title="Title bar text", flags=tcod.sdl.video.WindowFlags.RESIZABLE)
309336
310337
.. seealso::
311338
:func:`tcod.sdl.render.new_renderer`

0 commit comments

Comments
 (0)