fix(canvas): compact page pill + pen diagnostic
All checks were successful
CI / Windows build (push) Successful in 10m45s
All checks were successful
CI / Windows build (push) Successful in 10m45s
Page slider is no longer persistent: a compact prev/'n/total'/next pill; tapping the label reveals the slider (collapses again), so it stops blocking the page. Add a pen-pressure diagnostic toggle (bug icon) that shows the live kind/pressure/min/max Windows delivers — to pin down why pressure reads flat on the Surface Pen.
This commit is contained in:
@@ -42,8 +42,14 @@ class PenCanvas extends StatefulWidget {
|
||||
this.allowFingerDrawing = false,
|
||||
this.minScale = 0.5,
|
||||
this.maxScale = 8.0,
|
||||
this.onPenDebug,
|
||||
});
|
||||
|
||||
/// Debug hook: called with a readout of the latest pen event
|
||||
/// (kind / pressure / pressureMin / pressureMax) so we can see what Windows
|
||||
/// actually delivers. Null in release UI.
|
||||
final void Function(String readout)? onPenDebug;
|
||||
|
||||
/// The rendered PDF page bitmap, already sized to [pageSize].
|
||||
final Widget pageWidget;
|
||||
|
||||
@@ -249,8 +255,18 @@ class _PenCanvasState extends State<PenCanvas> {
|
||||
|
||||
// --- Listener callbacks ---------------------------------------------------
|
||||
|
||||
void _emitPenDebug(PointerEvent event) {
|
||||
final cb = widget.onPenDebug;
|
||||
if (cb == null) return;
|
||||
cb('${event.kind.name} p=${event.pressure.toStringAsFixed(3)} '
|
||||
'min=${event.pressureMin.toStringAsFixed(2)} '
|
||||
'max=${event.pressureMax.toStringAsFixed(2)} '
|
||||
'tilt=${event.tilt.toStringAsFixed(2)}');
|
||||
}
|
||||
|
||||
void _onPointerHover(PointerHoverEvent event) {
|
||||
if (_isStylus(event.kind)) {
|
||||
_emitPenDebug(event);
|
||||
// Detect eraser (barrel button / inverted) while hovering.
|
||||
_eraserActive = _isEraserSignal(event);
|
||||
}
|
||||
@@ -258,6 +274,7 @@ class _PenCanvasState extends State<PenCanvas> {
|
||||
|
||||
void _onPointerDown(PointerDownEvent event) {
|
||||
if (event.kind == PointerDeviceKind.trackpad) return;
|
||||
if (_isStylus(event.kind)) _emitPenDebug(event);
|
||||
|
||||
_activePointers[event.pointer] = event.kind;
|
||||
|
||||
@@ -282,6 +299,7 @@ class _PenCanvasState extends State<PenCanvas> {
|
||||
}
|
||||
|
||||
void _onPointerMove(PointerMoveEvent event) {
|
||||
if (_isStylus(event.kind)) _emitPenDebug(event);
|
||||
if (event.pointer != _drawPointer) return;
|
||||
if (_activePointers.length >= 2) return; // pinch owns it
|
||||
_extendStroke(event);
|
||||
|
||||
Reference in New Issue
Block a user