Skip to content

Commit 1632604

Browse files
MikeGillottipre-commit-ci[bot]jeertmans
authored
Mouse Show/Hide feature (#56)
* Mouse Show/Hide feature * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Mouse Hide/Show Fix Applied requested changes for PR * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jérome Eertmans <[email protected]>
1 parent 241419a commit 1632604

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

manim_slides/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Config(BaseModel):
4141
REVERSE: Key = Key(ids=[Qt.Key_V], name="REVERSE")
4242
REWIND: Key = Key(ids=[Qt.Key_R], name="REWIND")
4343
PLAY_PAUSE: Key = Key(ids=[Qt.Key_Space], name="PLAY / PAUSE")
44+
HIDE_MOUSE: Key = Key(ids=[Qt.Key_H], name="HIDE / SHOW MOUSE")
4445

4546
@root_validator
4647
def ids_are_unique_across_keys(cls, values):

manim_slides/present.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class Display(QThread):
284284
def __init__(
285285
self,
286286
presentations,
287-
config,
287+
config: Config = Config(),
288288
start_paused=False,
289289
skip_all=False,
290290
record_to=None,
@@ -517,6 +517,7 @@ class App(QWidget):
517517
def __init__(
518518
self,
519519
*args,
520+
config: Config = Config(),
520521
fullscreen: bool = False,
521522
resolution: Tuple[int, int] = (1980, 1080),
522523
hide_mouse: bool = False,
@@ -528,8 +529,9 @@ def __init__(
528529
self.setWindowTitle(WINDOW_NAME)
529530
self.display_width, self.display_height = resolution
530531
self.aspect_ratio = aspect_ratio
531-
532-
if hide_mouse:
532+
self.hide_mouse = hide_mouse
533+
self.config = config
534+
if self.hide_mouse:
533535
self.setCursor(Qt.BlankCursor)
534536

535537
self.label = QLabel(self)
@@ -541,7 +543,7 @@ def __init__(
541543
self.label.setMinimumSize(1, 1)
542544

543545
# create the video capture thread
544-
self.thread = Display(*args, **kwargs)
546+
self.thread = Display(*args, config=config, **kwargs)
545547
# create the info dialog
546548
self.info = Info()
547549
self.info.show()
@@ -562,7 +564,15 @@ def __init__(
562564
self.thread.start()
563565

564566
def keyPressEvent(self, event):
567+
565568
key = event.key()
569+
if self.config.HIDE_MOUSE.match(key):
570+
if self.hide_mouse:
571+
self.setCursor(Qt.ArrowCursor)
572+
self.hide_mouse = False
573+
else:
574+
self.setCursor(Qt.BlankCursor)
575+
self.hide_mouse = True
566576
# We send key to be handled by video display
567577
self.send_key_signal.emit(key)
568578
event.accept()

0 commit comments

Comments
 (0)