@@ -553,6 +553,29 @@ def size(self):
553
553
def offset (self ):
554
554
return (self .offset_x , self .offset_y )
555
555
556
+ def divide_padding (self , amount , ratio ):
557
+ sum = ratio [0 ] + ratio [1 ]
558
+ if sum > 0 :
559
+ return amount * ratio [0 ] / sum
560
+ else :
561
+ return 0
562
+
563
+ def adjust_to_aspect_ratio (self , aspect_ratio , vertical_padding_ratio = (1 ,1 ), horizontal_padding_ratio = (1 ,1 )):
564
+ """The new box will completely fit into the old one, have desired aspect ratio,
565
+ and will be padded with white space in required proportion.
566
+ Ratio parameters are two-element-tuples
567
+ (1,1) for padding means 'center!'
568
+ (1,2) for horizontal_padding means one third left and two thirds right
569
+ vertical ratio is bottom to top (upside down), horizontal is left to right """
570
+ new_width = self .height * aspect_ratio [0 ] / aspect_ratio [1 ]
571
+ new_height = self .width * aspect_ratio [1 ] / aspect_ratio [0 ]
572
+ if new_width <= self .width :
573
+ self .offset_x += self .divide_padding (self .width - new_width , horizontal_padding_ratio )
574
+ self .width = new_width
575
+ else :
576
+ self .offset_y += self .divide_padding (self .height - new_height , vertical_padding_ratio )
577
+ self .height = new_height
578
+
556
579
def glViewport (self ):
557
580
glViewport (self .offset_x , self .offset_y , self .width , self .height )
558
581
@@ -2634,13 +2657,6 @@ def TransitionTo(page):
2634
2657
PageEntered ()
2635
2658
if not PreloadNextPage (GetNextPage (Pcurrent , 1 )):
2636
2659
PreloadNextPage (GetNextPage (Pcurrent , - 1 ))
2637
- if DualHead : # show next page
2638
- print "PrompterNextFrame=" , PrompterNextFrame
2639
- PrompterNextFrame .glViewport ()
2640
- glClearColor (255 ,0 ,0 ,0 )
2641
- glClear (GL_COLOR_BUFFER_BIT )
2642
- DrawCurrentPage ()
2643
- WholeWindow .glViewport ()
2644
2660
return 1
2645
2661
2646
2662
# zoom mode animation
@@ -4068,11 +4084,15 @@ def ParseOptions(argv):
4068
4084
projection , prompter = arg .split ("," )
4069
4085
ProjectionFrame = FrameCoordinates .parse (projection )
4070
4086
PrompterWholeFrame = FrameCoordinates .parse (prompter )
4087
+ print "PrompterWholeFrame: " , PrompterWholeFrame
4088
+ prompter_width = PrompterWholeFrame .width * 9 / 10 / 2
4071
4089
PrompterCurrentFrame = FrameCoordinates (
4072
- PrompterWholeFrame . width / 2 , PrompterWholeFrame .height / 2 )
4090
+ prompter_width , PrompterWholeFrame .height )
4073
4091
PrompterNextFrame = FrameCoordinates (
4074
- PrompterWholeFrame .width / 2 , PrompterWholeFrame .height / 2 ,
4075
- PrompterWholeFrame .width / 2 )
4092
+ prompter_width , PrompterCurrentFrame .height ,
4093
+ PrompterWholeFrame .width - PrompterCurrentFrame .width )
4094
+ PrompterCurrentFrame .adjust_to_aspect_ratio ((4 ,3 ), (5 ,3 ), (0 ,1 ))
4095
+ PrompterNextFrame .adjust_to_aspect_ratio ((4 ,3 ), (5 ,3 ), (1 ,0 ))
4076
4096
UseAutoScreenSize = False
4077
4097
except :
4078
4098
opterr ("invalid parameter for --dual-head" )
0 commit comments