fix: light zoom at back
This commit is contained in:
@@ -28,6 +28,7 @@ import 'widgets/grouping_stats.dart';
|
||||
|
||||
class AnalysisScreen extends StatelessWidget {
|
||||
final String imagePath;
|
||||
final String? originalImagePath; // AJOUT : image source avant le crop à 85%
|
||||
final TargetType targetType;
|
||||
final double? initialCenterX;
|
||||
final double? initialCenterY;
|
||||
@@ -38,6 +39,7 @@ class AnalysisScreen extends StatelessWidget {
|
||||
const AnalysisScreen({
|
||||
super.key,
|
||||
required this.imagePath,
|
||||
this.originalImagePath, // AJOUT
|
||||
required this.targetType,
|
||||
this.initialCenterX,
|
||||
this.initialCenterY,
|
||||
@@ -75,6 +77,7 @@ class AnalysisScreen extends StatelessWidget {
|
||||
return p;
|
||||
},
|
||||
child: _AnalysisScreenContent(
|
||||
originalImagePath: originalImagePath, // AJOUT
|
||||
cropScale: cropScale,
|
||||
cropOffset: cropOffset,
|
||||
cropRotation: cropRotation, // Envoyé à la structure d'affichage
|
||||
@@ -84,11 +87,13 @@ class AnalysisScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _AnalysisScreenContent extends StatefulWidget {
|
||||
final String? originalImagePath; // AJOUT
|
||||
final double? cropScale;
|
||||
final Offset? cropOffset;
|
||||
final double? cropRotation;
|
||||
|
||||
const _AnalysisScreenContent({
|
||||
this.originalImagePath, // AJOUT
|
||||
this.cropScale,
|
||||
this.cropOffset,
|
||||
this.cropRotation,
|
||||
@@ -155,15 +160,24 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
///
|
||||
/// Sans cette remise à zéro, le facteur de zoom accumulé en mode Plotting
|
||||
/// persiste dans le TransformationController et se réapplique au retour,
|
||||
/// ce qui faisait "zoomer" légèrement la photo à chaque aller-retour
|
||||
/// Plotting <-> Centrage. On repart donc toujours d'une transformation
|
||||
/// identité (zoom 1.0).
|
||||
/// ce qui faisait "zoomer" légèrement la photo. On repart donc toujours
|
||||
/// d'une transformation identité (zoom 1.0).
|
||||
void _enterCalibration() {
|
||||
_transformationController.value = Matrix4.identity();
|
||||
_currentZoomScale = 1.0;
|
||||
setState(() => _isCalibrating = true);
|
||||
}
|
||||
|
||||
/// Chemin à utiliser pour repartir dans le CropScreen lors d'un retour arrière.
|
||||
///
|
||||
/// On privilégie TOUJOURS l'image source non rognée (originalImagePath).
|
||||
/// Repartir de l'image déjà croppée à 85% provoquait un rognage cumulatif
|
||||
/// (0.85 x 0.85 x ...) qui re-zoomait la photo à chaque aller-retour
|
||||
/// entre la capture/crop et la calibration.
|
||||
String _backCropImagePath(AnalysisProvider provider) {
|
||||
return widget.originalImagePath ?? provider.imagePath!;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = context.watch<AnalysisProvider>();
|
||||
@@ -189,7 +203,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CropScreen(
|
||||
imagePath: provider.imagePath!,
|
||||
// CORRECTION : on repart de l'image SOURCE (non rognée) pour
|
||||
// éviter le rognage cumulatif à 85% qui re-zoomait à chaque retour.
|
||||
imagePath: _backCropImagePath(provider),
|
||||
targetType: provider.targetType!,
|
||||
initialScale: widget.cropScale,
|
||||
initialOffset: widget.cropOffset,
|
||||
@@ -722,7 +738,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
final path = provider.imagePath!;
|
||||
// CORRECTION : on repart aussi de l'image SOURCE non rognée ici.
|
||||
final path = _backCropImagePath(provider);
|
||||
final type = provider.targetType!;
|
||||
|
||||
Navigator.pushReplacement(
|
||||
|
||||
@@ -419,6 +419,10 @@ class _CropScreenState extends State<CropScreen> {
|
||||
MaterialPageRoute(
|
||||
builder: (_) => AnalysisScreen(
|
||||
imagePath: croppedImagePath,
|
||||
// AJOUT : on conserve la SOURCE non rognée pour les retours arrière.
|
||||
// Sans cela, revenir au crop repartait de l'image déjà rognée à 85%,
|
||||
// provoquant un zoom cumulatif (0.85 x 0.85 x ...) à chaque aller-retour.
|
||||
originalImagePath: widget.imagePath,
|
||||
targetType: widget.targetType,
|
||||
initialCenterX: targetCenterX,
|
||||
initialCenterY: targetCenterY,
|
||||
|
||||
Reference in New Issue
Block a user