Skip to content

Add support for changing cursor bitmap. #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion adafruit_cursorcontrol/cursorcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ def __init__(self, display=None, display_group=None, bmp=None, is_hidden=False,
self._is_hidden = is_hidden
self._display_grp = display_group
self._disp_sz = display.height - 1, display.width - 1
self._cur_sprite = None
if bmp is None:
bmp = self._default_cursor_bitmap()
self._cursor_bitmap = self._default_cursor_bitmap()
else:
self._cursor_bitmap = bmp
self.generate_cursor(bmp)
# pylint: enable=too-many-arguments,line-too-long

Expand Down Expand Up @@ -208,6 +211,23 @@ def _default_cursor_bitmap(self):
return bmp
#pylint:enable=no-self-use

@property
def cursor_bitmap(self):
"""Return the cursor bitmap."""
return self._cursor_bitmap

@cursor_bitmap.setter
def cursor_bitmap(self, bmp):
"""Set a new cursor bitmap.

:param bmp: A Bitmap to use for the cursor
"""
self._cursor_bitmap = bmp
self._cursor_grp.remove(self._cur_sprite)
self._cur_sprite = displayio.TileGrid(bmp,
pixel_shader=self._cur_palette)
self._cursor_grp.append(self._cur_sprite)

def generate_cursor(self, bmp):
"""Generates a cursor icon"""
self._is_deinited()
Expand Down