17
17
18
18
from .commons import config_path_option
19
19
from .config import Config , PresentationConfig , SlideConfig , SlideType
20
- from .defaults import CONFIG_PATH , FOLDER_PATH
20
+ from .defaults import CONFIG_PATH , FOLDER_PATH , FONT_ARGS
21
21
22
22
WINDOW_NAME = "Manim Slides"
23
+ WINDOW_INFO_NAME = f"{ WINDOW_NAME } : Info"
23
24
24
25
25
26
@unique
@@ -251,6 +252,7 @@ def __init__(
251
252
start_paused = False ,
252
253
fullscreen = False ,
253
254
skip_all = False ,
255
+ resolution = (1280 , 720 ),
254
256
):
255
257
self .presentations = presentations
256
258
self .start_paused = start_paused
@@ -267,6 +269,11 @@ def __init__(
267
269
self .lag = 0
268
270
self .last_time = now ()
269
271
272
+ cv2 .namedWindow (
273
+ WINDOW_INFO_NAME ,
274
+ cv2 .WINDOW_GUI_NORMAL | cv2 .WINDOW_FREERATIO | cv2 .WINDOW_AUTOSIZE ,
275
+ )
276
+
270
277
if self .is_windows :
271
278
user32 = ctypes .windll .user32
272
279
self .screen_width , self .screen_height = user32 .GetSystemMetrics (
@@ -278,6 +285,12 @@ def __init__(
278
285
cv2 .setWindowProperty (
279
286
WINDOW_NAME , cv2 .WND_PROP_FULLSCREEN , cv2 .WINDOW_FULLSCREEN
280
287
)
288
+ else :
289
+ cv2 .namedWindow (
290
+ WINDOW_NAME ,
291
+ cv2 .WINDOW_GUI_NORMAL | cv2 .WINDOW_FREERATIO | cv2 .WINDOW_NORMAL ,
292
+ )
293
+ cv2 .resizeWindow (WINDOW_NAME , * resolution )
281
294
282
295
def resize_frame_to_screen (self , frame : np .ndarray ):
283
296
"""
@@ -318,6 +331,8 @@ def run(self):
318
331
self .current_presentation_index += 1
319
332
self .state = State .PLAYING
320
333
self .handle_key ()
334
+ if self .exit :
335
+ continue
321
336
self .show_video ()
322
337
self .show_info ()
323
338
@@ -336,7 +351,7 @@ def show_video(self):
336
351
def show_info (self ):
337
352
"""Shows updated information about presentations."""
338
353
info = np .zeros ((130 , 420 ), np .uint8 )
339
- font_args = (cv2 . FONT_HERSHEY_SIMPLEX , 0.7 , 255 )
354
+ font_args = (FONT_ARGS [ 0 ] , 0.7 , * FONT_ARGS [ 2 :] )
340
355
grid_x = [30 , 230 ]
341
356
grid_y = [30 , 70 , 110 ]
342
357
@@ -368,7 +383,7 @@ def show_info(self):
368
383
* font_args ,
369
384
)
370
385
371
- cv2 .imshow (f" { WINDOW_NAME } : Info" , info )
386
+ cv2 .imshow (WINDOW_INFO_NAME , info )
372
387
373
388
def handle_key (self ):
374
389
"""Handles key strokes."""
@@ -461,8 +476,17 @@ def _list_scenes(folder) -> List[str]:
461
476
is_flag = True ,
462
477
help = "Skip all slides, useful the test if slides are working." ,
463
478
)
479
+ @click .option (
480
+ "--resolution" ,
481
+ type = (int , int ),
482
+ default = (1280 , 720 ),
483
+ help = "Window resolution used if fullscreen is not set. You may manually resize the window afterward." ,
484
+ show_default = True ,
485
+ )
464
486
@click .help_option ("-h" , "--help" )
465
- def present (scenes , config_path , folder , start_paused , fullscreen , skip_all ):
487
+ def present (
488
+ scenes , config_path , folder , start_paused , fullscreen , skip_all , resolution
489
+ ):
466
490
"""Present the different scenes."""
467
491
468
492
if len (scenes ) == 0 :
@@ -527,5 +551,6 @@ def value_proc(value: str):
527
551
start_paused = start_paused ,
528
552
fullscreen = fullscreen ,
529
553
skip_all = skip_all ,
554
+ resolution = resolution ,
530
555
)
531
556
display .run ()
0 commit comments