zooui.objects.objectsutils.zoom.zoommanager module¶
Zoom Manager for enforcing zoom limits and preventing crashes.
- class zooui.objects.objectsutils.zoom.zoommanager.ZoomManager(config=None)[source]¶
Bases:
objectManages zoom limits and validation to prevent crashes at extreme zoom levels.
Zoom levels use base-2 exponential scale: - zoomlevel = 0: 1x scale (2**0 = 1) - zoomlevel = 1: 2x scale (2**1 = 2) - zoomlevel = -1: 0.5x scale (2**-1 = 0.5)
Default limits: -10 to +12 (safe for StringMediaObjects) - -10: 0.00098x scale (0.098%) - +12: 4096x scale
Initialize ZoomManager with configuration.
- Parameters:
config – Zoom configuration dictionary with keys: - min_zoomlevel: Minimum allowed zoom level (default: -10.0) - max_zoomlevel: Maximum allowed zoom level (default: 12.0) - clamp_enabled: Whether to clamp values (default: True)
- validate(zoomlevel)[source]¶
Validate and optionally clamp zoom level.
- Parameters:
zoomlevel – Zoom level to validate
- Returns:
Validated (and possibly clamped) zoom level
Note
If clamp_enabled is False and zoomlevel is out of bounds, the value is returned unchanged (no clamping).