Skip to content

Commit e3fc45f

Browse files
committed
Have enum properties return enum instances.
1 parent 571eafd commit e3fc45f

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Changes relevant to the users of python-tcod are documented here.
44
This project adheres to [Semantic Versioning](https://semver.org/) since version `2.0.0`.
55

66
## [Unreleased]
7+
### Changed
8+
- `Texture.access` and `Texture.blend_mode` properties now return enum instances.
9+
You can still set them with `int` but Mypy will complain.
710

811
## [13.4.0] - 2022-02-04
912
### Added

tcod/sdl/render.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,15 @@ def format(self) -> int:
177177
return int(buffer[0])
178178

179179
@property
180-
def access(self) -> int:
181-
"""Texture access mode, read only."""
180+
def access(self) -> TextureAccess:
181+
"""Texture access mode, read only.
182+
183+
.. versionadded:: unreleased
184+
Property now returns a TextureAccess instance.
185+
"""
182186
buffer = ffi.new("int*")
183187
lib.SDL_QueryTexture(self.p, ffi.NULL, buffer, ffi.NULL, ffi.NULL)
184-
return int(buffer[0])
188+
return TextureAccess(buffer[0])
185189

186190
@property
187191
def width(self) -> int:
@@ -209,11 +213,15 @@ def alpha_mod(self, value: int) -> None:
209213
_check(lib.SDL_SetTextureAlphaMod(self.p, value))
210214

211215
@property
212-
def blend_mode(self) -> int:
213-
"""Texture blend mode, can be set."""
216+
def blend_mode(self) -> BlendMode:
217+
"""Texture blend mode, can be set.
218+
219+
.. versionadded:: unreleased
220+
Property now returns a BlendMode instance.
221+
"""
214222
out = ffi.new("SDL_BlendMode*")
215223
_check(lib.SDL_GetTextureBlendMode(self.p, out))
216-
return int(out[0])
224+
return BlendMode(out[0])
217225

218226
@blend_mode.setter
219227
def blend_mode(self, value: int) -> None:
@@ -366,14 +374,14 @@ def draw_color(self, rgba: Tuple[int, int, int, int]) -> None:
366374
_check(lib.SDL_SetRenderDrawColor(self.p, *rgba))
367375

368376
@property
369-
def draw_blend_mode(self) -> int:
377+
def draw_blend_mode(self) -> BlendMode:
370378
"""Get or set the active blend mode of this renderer.
371379
372380
.. versionadded:: unreleased
373381
"""
374382
out = ffi.new("SDL_BlendMode*")
375383
_check(lib.SDL_GetRenderDrawBlendMode(self.p, out))
376-
return int(out[0])
384+
return BlendMode(out[0])
377385

378386
@draw_blend_mode.setter
379387
def draw_blend_mode(self, value: int) -> None:

0 commit comments

Comments
 (0)