refactor: pen_editor_screen._centerPage uses shared centerOffset
Some checks failed
CI / Windows build (push) Has been cancelled
Some checks failed
CI / Windows build (push) Has been cancelled
Wires the now-tested viewport_fit.centerOffset into the live editor, replacing the inline ad-hoc arithmetic. Behavior-identical (same centering at scale 1) — makes the pure core load-bearing and kills the duplicate math. flutter analyze lib/editor clean; 228/228 tests pass (no behavior change). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import '../engine/undo_stack.dart';
|
|||||||
import '../input/diagnostic_logger.dart';
|
import '../input/diagnostic_logger.dart';
|
||||||
import '../input/pen_config.dart';
|
import '../input/pen_config.dart';
|
||||||
import '../input/pen_input_service.dart';
|
import '../input/pen_input_service.dart';
|
||||||
|
import '../layout/viewport_fit.dart';
|
||||||
import '../persistence/editor_repository.dart';
|
import '../persistence/editor_repository.dart';
|
||||||
import '../persistence/save_scheduler.dart';
|
import '../persistence/save_scheduler.dart';
|
||||||
import '../ui/pen_settings_page.dart';
|
import '../ui/pen_settings_page.dart';
|
||||||
@@ -381,11 +382,12 @@ class _PenEditorScreenState extends State<PenEditorScreen> {
|
|||||||
showPenSettingsSheet(context, config);
|
showPenSettingsSheet(context, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Centre [pageSize] within [viewport] via the shared transform.
|
/// Centre [pageSize] within [viewport] via the shared transform. Uses the
|
||||||
|
/// shared, unit-tested [centerOffset] (pageSize is already fit to the viewport
|
||||||
|
/// at scale 1, so we center at scale 1).
|
||||||
void _centerPage(Size viewport, Size pageSize) {
|
void _centerPage(Size viewport, Size pageSize) {
|
||||||
final tx = (viewport.width - pageSize.width) / 2;
|
final o = centerOffset(pageSize, viewport, 1.0);
|
||||||
final ty = (viewport.height - pageSize.height) / 2;
|
_transform.value = Matrix4.identity()..setTranslationRaw(o.dx, o.dy, 0);
|
||||||
_transform.value = Matrix4.identity()..setTranslationRaw(tx, ty, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user