1717
1818from .commons import config_path_option
1919from .config import Config , PresentationConfig , SlideConfig , SlideType
20- from .defaults import CONFIG_PATH , FOLDER_PATH
20+ from .defaults import CONFIG_PATH , FOLDER_PATH , FONT_ARGS
2121
2222WINDOW_NAME = "Manim Slides"
23+ WINDOW_INFO_NAME = f"{ WINDOW_NAME } : Info"
2324
2425
2526@unique
@@ -251,6 +252,7 @@ def __init__(
251252 start_paused = False ,
252253 fullscreen = False ,
253254 skip_all = False ,
255+ resolution = (1280 , 720 ),
254256 ):
255257 self .presentations = presentations
256258 self .start_paused = start_paused
@@ -267,6 +269,11 @@ def __init__(
267269 self .lag = 0
268270 self .last_time = now ()
269271
272+ cv2 .namedWindow (
273+ WINDOW_INFO_NAME ,
274+ cv2 .WINDOW_GUI_NORMAL | cv2 .WINDOW_FREERATIO | cv2 .WINDOW_AUTOSIZE ,
275+ )
276+
270277 if self .is_windows :
271278 user32 = ctypes .windll .user32
272279 self .screen_width , self .screen_height = user32 .GetSystemMetrics (
@@ -278,6 +285,12 @@ def __init__(
278285 cv2 .setWindowProperty (
279286 WINDOW_NAME , cv2 .WND_PROP_FULLSCREEN , cv2 .WINDOW_FULLSCREEN
280287 )
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 )
281294
282295 def resize_frame_to_screen (self , frame : np .ndarray ):
283296 """
@@ -318,6 +331,8 @@ def run(self):
318331 self .current_presentation_index += 1
319332 self .state = State .PLAYING
320333 self .handle_key ()
334+ if self .exit :
335+ continue
321336 self .show_video ()
322337 self .show_info ()
323338
@@ -336,7 +351,7 @@ def show_video(self):
336351 def show_info (self ):
337352 """Shows updated information about presentations."""
338353 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 :] )
340355 grid_x = [30 , 230 ]
341356 grid_y = [30 , 70 , 110 ]
342357
@@ -368,7 +383,7 @@ def show_info(self):
368383 * font_args ,
369384 )
370385
371- cv2 .imshow (f" { WINDOW_NAME } : Info" , info )
386+ cv2 .imshow (WINDOW_INFO_NAME , info )
372387
373388 def handle_key (self ):
374389 """Handles key strokes."""
@@ -461,8 +476,17 @@ def _list_scenes(folder) -> List[str]:
461476 is_flag = True ,
462477 help = "Skip all slides, useful the test if slides are working." ,
463478)
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+ )
464486@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+ ):
466490 """Present the different scenes."""
467491
468492 if len (scenes ) == 0 :
@@ -527,5 +551,6 @@ def value_proc(value: str):
527551 start_paused = start_paused ,
528552 fullscreen = fullscreen ,
529553 skip_all = skip_all ,
554+ resolution = resolution ,
530555 )
531556 display .run ()
0 commit comments