Refactor visibility calculations in VideoEditor to ensure proper cropping bounds
This commit updates the visibility width and height calculations in the VideoEditor class to use the minimum of the new dimensions and the window dimensions when cropping due to zoom. This change enhances the accuracy of the displayed area during zoom operations, ensuring that the canvas scaling is correctly applied and improving the overall user experience in video editing.
This commit is contained in:
@@ -1328,10 +1328,11 @@ class VideoEditor:
|
|||||||
offy = 0
|
offy = 0
|
||||||
zx = rx2 * self.zoom_factor - offx
|
zx = rx2 * self.zoom_factor - offx
|
||||||
zy = ry2 * self.zoom_factor - offy
|
zy = ry2 * self.zoom_factor - offy
|
||||||
visible_w = new_w if not cropped_due_to_zoom else self.window_width
|
visible_w = new_w if not cropped_due_to_zoom else min(new_w, self.window_width)
|
||||||
visible_h = new_h if not cropped_due_to_zoom else self.window_height
|
visible_h = new_h if not cropped_due_to_zoom else min(new_h, self.window_height)
|
||||||
available_height = self.window_height - (0 if self.is_image_mode else self.TIMELINE_HEIGHT)
|
available_height = self.window_height - (0 if self.is_image_mode else self.TIMELINE_HEIGHT)
|
||||||
scale_canvas = min(self.window_width / max(1, visible_w), available_height / max(1, visible_h))
|
scale_raw = min(self.window_width / max(1, visible_w), available_height / max(1, visible_h))
|
||||||
|
scale_canvas = scale_raw if scale_raw < 1.0 else 1.0
|
||||||
final_w = int(visible_w * scale_canvas)
|
final_w = int(visible_w * scale_canvas)
|
||||||
final_h = int(visible_h * scale_canvas)
|
final_h = int(visible_h * scale_canvas)
|
||||||
start_x_canvas = (self.window_width - final_w) // 2
|
start_x_canvas = (self.window_width - final_w) // 2
|
||||||
|
Reference in New Issue
Block a user