getZoomButtonX method
Calculates optimal X position for zoom button
Tries to place the zoom button in the following priority order:
- To the right of main button (if space available)
- To the left of main button (if space available)
- Aligned with main button but constrained to screen bounds
Implementation
double getZoomButtonX(Size screenSize, double buttonX) {
const double buttonWidth = 56.0;
const double spacing = 14.0;
// Try to place to the right of main button
double rightPosition = buttonX + buttonWidth + spacing;
// If there's space on the right, use it
if (rightPosition + buttonWidth <= screenSize.width) {
return rightPosition;
}
// Otherwise, place to the left of main button
double leftPosition = buttonX - buttonWidth - spacing;
// If there's space on the left, use it
if (leftPosition >= 0) {
return leftPosition;
}
// If neither side works, place it aligned with main button but constrained to screen
return buttonX.clamp(0.0, screenSize.width - buttonWidth);
}