double tap to rotate
This commit is contained in:
@@ -34,6 +34,8 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
|
|||||||
GestureType.RotateCamera: Icons.rotate_90_degrees_ccw
|
GestureType.RotateCamera: Icons.rotate_90_degrees_ccw
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool _rotating = false;
|
||||||
|
|
||||||
// to avoid duplicating code for pan/rotate (panStart, panUpdate, panEnd, rotateStart, rotateUpdate etc)
|
// to avoid duplicating code for pan/rotate (panStart, panUpdate, panEnd, rotateStart, rotateUpdate etc)
|
||||||
// we have only a single function for start/update/end.
|
// we have only a single function for start/update/end.
|
||||||
// when the gesture type is changed, these properties are updated to point to the correct function.
|
// when the gesture type is changed, these properties are updated to point to the correct function.
|
||||||
@@ -91,6 +93,10 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
|
|||||||
// - outer is a GestureDetector only for pinch zoom
|
// - outer is a GestureDetector only for pinch zoom
|
||||||
// - inner is a Listener for all other gestures (including scroll zoom on desktop)
|
// - inner is a Listener for all other gestures (including scroll zoom on desktop)
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
|
onDoubleTap: () {
|
||||||
|
_rotating = !_rotating;
|
||||||
|
print("Set rotating to $_rotating");
|
||||||
|
},
|
||||||
onScaleStart: !widget.enableControls
|
onScaleStart: !widget.enableControls
|
||||||
? null
|
? null
|
||||||
: (d) async {
|
: (d) async {
|
||||||
@@ -140,7 +146,7 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
|
|||||||
onPointerDown: !widget.enableControls
|
onPointerDown: !widget.enableControls
|
||||||
? null
|
? null
|
||||||
: (d) async {
|
: (d) async {
|
||||||
if (d.buttons == kTertiaryButton) {
|
if (d.buttons == kTertiaryButton || _rotating) {
|
||||||
await widget.controller.rotateStart(
|
await widget.controller.rotateStart(
|
||||||
d.localPosition.dx, d.localPosition.dy);
|
d.localPosition.dx, d.localPosition.dy);
|
||||||
} else {
|
} else {
|
||||||
@@ -151,7 +157,7 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
|
|||||||
onPointerMove: !widget.enableControls
|
onPointerMove: !widget.enableControls
|
||||||
? null
|
? null
|
||||||
: (d) async {
|
: (d) async {
|
||||||
if (d.buttons == kTertiaryButton) {
|
if (d.buttons == kTertiaryButton || _rotating) {
|
||||||
await widget.controller.rotateUpdate(
|
await widget.controller.rotateUpdate(
|
||||||
d.localPosition.dx, d.localPosition.dy);
|
d.localPosition.dx, d.localPosition.dy);
|
||||||
} else {
|
} else {
|
||||||
@@ -162,7 +168,7 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
|
|||||||
onPointerUp: !widget.enableControls
|
onPointerUp: !widget.enableControls
|
||||||
? null
|
? null
|
||||||
: (d) async {
|
: (d) async {
|
||||||
if (d.buttons == kTertiaryButton) {
|
if (d.buttons == kTertiaryButton || _rotating) {
|
||||||
await widget.controller.rotateEnd();
|
await widget.controller.rotateEnd();
|
||||||
} else {
|
} else {
|
||||||
await _functionEnd();
|
await _functionEnd();
|
||||||
|
|||||||
Reference in New Issue
Block a user