From 98d7740bf2c72029574241eeba5e4f6a9ed67039 Mon Sep 17 00:00:00 2001 From: svsdval Date: Tue, 23 May 2023 15:17:17 +0700 Subject: [PATCH] =?UTF-8?q?-=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=20=D1=8D=D0=BA?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B0,=20=D1=87=D1=82=D0=BE=20=D0=B1=D1=8B?= =?UTF-8?q?=20=D0=BE=D0=BA=D0=BD=D0=BE=20=D0=B2=D1=81=D0=B5=D0=B3=D0=B4?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=BE=D0=BC=D0=B5=D1=89=D0=B0=D0=BB=D0=BE=D1=81?= =?UTF-8?q?=D1=8C=20=D0=B2=20=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=20=20-=20?= =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=B2=D0=BE=D0=B7?= =?UTF-8?q?=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D1=81=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=20=D0=BE=D0=BA=D0=BD=D0=B0.=20=D0=9D=D1=83=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=20=D1=83=D1=87=D0=B8=D1=82=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20?= =?UTF-8?q?=D1=87=D1=82=D0=BE=20=D0=BA=D0=BB=D0=B0=D0=B2=D0=B8=D1=88=D0=B8?= =?UTF-8?q?=20=D0=B2=D1=81=D0=B5=D0=B3=D0=B4=D0=B0=20=D0=BF=D0=BE=D0=B7?= =?UTF-8?q?=D0=B8=D1=86=D0=B8=D0=BE=D0=BD=D0=B8=D1=80=D1=83=D1=8E=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=B2=20=D0=B0=D0=B1=D1=81=D0=BE=D0=BB=D1=8E?= =?UTF-8?q?=D1=82=D0=BD=D1=8B=D1=85=20=D0=BA=D0=BE=D0=BE=D1=80=D0=B4=D0=B8?= =?UTF-8?q?=D0=BD=D0=B0=D1=82=D0=B0=D1=85.=20=D0=A1=D0=BB=D0=B5=D0=B4?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=BA?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BD=D0=B0=20=D0=BD=D0=B8=D1=85=20=D0=BD=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0=D0=BA=20=D0=BD=D0=B5=20=D0=B2=D0=BB=D0=B8=D1=8F?= =?UTF-8?q?=D0=B5=D1=82.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2m.py | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/v2m.py b/v2m.py index cfc324d..5f4968d 100755 --- a/v2m.py +++ b/v2m.py @@ -115,6 +115,21 @@ width = video_width height = video_height +def fit_to_the_screen(): + global width, height + infoObject = pygame.display.Info() + if (width > infoObject.current_w) or ( height > infoObject.current_h): + print("try fit window to the screen") + print("curent window size: %sx%s" %(width,height)) + print("curent screen size: %0.2fx%s" %(infoObject.current_w, infoObject.current_h)) + ratio = ( width / infoObject.current_w) + width = int(width / ratio * 0.9 ) + height = int(height / ratio *0.9) + print("new window size: %sx%s" %(width,height)) + +pygame.init() +fit_to_the_screen() + endframe = length showoutputpath = 0 @@ -128,7 +143,8 @@ def resize_window(): else: width = video_width height = video_height - screen = pygame.display.set_mode((width,height), DOUBLEBUF|OPENGL) + fit_to_the_screen() + screen = pygame.display.set_mode((width,height), DOUBLEBUF|OPENGL|pygame.RESIZABLE) # doinit() @@ -219,6 +235,8 @@ def update_size(): if ( prefs.resize == 1 ): width = prefs.resize_width height = prefs.resize_height + else: + fit_to_the_screen() def loadsettings(cfgfile): global colorBtns, colorWindow_colorBtns_channel_labels @@ -840,9 +858,10 @@ def getkeyp_pixel_pos( x, y ): if ( pixx >= width ) or ( pixy >= height ) or ( pixx < 0 ) or ( pixy < 0 ): return [-1,-1] - if ( prefs.resize == 1 ): - pixx= int(round( pixx * ( video_width / float(prefs.resize_width) ))) - pixy= int(round( pixy * ( video_height / float(prefs.resize_height) ))) + #if ( prefs.resize == 1 ): + if 1==1: #disabled + pixx= int(round( pixx * ( video_width / float(width) ))) + pixy= int(round( pixy * ( video_height / float(height) ))) if ( pixx > video_width -1 ): pixx = video_width-1 if ( pixy > video_height-1 ): pixy= video_height-1 return [pixx,pixy] @@ -1384,9 +1403,9 @@ def main(): keygrabaddx=0 lastkeygrabid=-1 - pygame.init() #pyfont = pygame.font.SysFont('Sans', 20) - screen = pygame.display.set_mode( (width,height) , DOUBLEBUF|OPENGL) + #pygame.RESIZABLE + screen = pygame.display.set_mode( (width,height) , DOUBLEBUF|OPENGL|pygame.RESIZABLE) pygame.display.set_caption(filepath) doinit() @@ -1407,14 +1426,13 @@ def main(): running = 0 pygame.quit() quit() -# elif event.type == pygame.VIDEORESIZE: -# resize = 1 -# resize_width = event.w -# resize_height = event.h -# width = resize_width -# height = resize_height -# screen = pygame.display.set_mode( (width,height) , DOUBLEBUF|OPENGL|pygame.RESIZABLE) - + elif event.type == pygame.VIDEORESIZE: + prefs.resize = 1 + prefs.resize_width = event.w + prefs.resize_height = event.h + width = prefs.resize_width + height = prefs.resize_height + screen = pygame.display.set_mode( (width,height) , DOUBLEBUF|OPENGL|pygame.RESIZABLE) elif event.type == pygame.KEYUP: for wnd in glwindows: wnd.update_key_up(event.key)