Skip to content

Commit 819ee6d

Browse files
authored
Overlayupdate (#179)
* Add overlay redraw flag to display * Update display documentation * Update HyDE for new overlay features
1 parent e36c129 commit 819ee6d

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/launcher/HyDE.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,9 +1153,12 @@ def main_loop():
11531153
if prev_locked_keys != INPUT.locked_keys:
11541154
prev_locked_keys = INPUT.locked_keys.copy()
11551155
redraw_display = True
1156+
display.Display.draw_overlays = True
11561157

11571158
if keys:
11581159
redraw_display = True
1160+
display.Display.draw_overlays = True
1161+
11591162

11601163
for key in keys:
11611164
if "CTL" in mod_keys:

src/lib/display/display.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class Display(st7789.ST7789):
2727
Subclasses the device-specific display driver.
2828
"""
2929

30+
# Set to True to redraw all overlays next time show is called
31+
draw_overlays = False
32+
# A public list of overlay functions, to be called in order.
3033
overlay_callbacks = []
3134

3235
def __new__(cls, **kwargs): # noqa: ARG003, D102
@@ -85,5 +88,7 @@ def _draw_overlays(self):
8588

8689
def show(self):
8790
"""Write changes to display."""
88-
self._draw_overlays()
91+
if Display.draw_overlays:
92+
self._draw_overlays()
93+
Display.draw_overlays = False
8994
super().show()

src/lib/userinput/userinput.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ def handle_locking_keys(self):
215215
# key already in locked keys, must have been pressed twice.
216216
locked_keys.remove(key)
217217
tracker[key] = False
218+
# Redraw the locked keys overlay
219+
Display.draw_overlays = True
218220

219221
elif len(self.key_state) > 1:
220222
# multiple keys are being pressed together, dont lock this key
@@ -223,6 +225,8 @@ def handle_locking_keys(self):
223225
# key has just been released and should be locked
224226
locked_keys.append(key)
225227
tracker.pop(key)
228+
# Redraw the locked keys overlay
229+
Display.draw_overlays = True
226230

227231
# tracker val is False
228232
elif not is_being_pressed:

wiki/Display.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,10 @@ display.show()
277277
## Overlay Callbacks:
278278
The Display also has an attribute for storing overlay drawing functions.
279279
280-
`Display.overlay_callbacks` is a list of callbacks, to be called every time `Display.show()` is called (before writing the framebuffer).
280+
`Display.draw_overlays` is a boolean flag that tells the display to redraw the overlays. *(Set this to `True` to flag that something on the display has changed, and so the overlays should be redrawn)*
281+
282+
`Display.overlay_callbacks` is a public list of callback functions, to be called when `Display.show()` is called *(If `Display.draw_overlays` is `True`).*
283+
281284
The callbacks should accept the the `Display` object as a single positional argument.
282285
283286
This is how the `userinput` module is able to draw 'locked' modifier keys over top of the other graphics on screen.

0 commit comments

Comments
 (0)