chore!: rename controller to viewer in gesture detector widgets

This commit is contained in:
Nick Fisher
2024-09-12 08:54:07 +08:00
parent 0f5b7e5e6d
commit a5cb23c32e
3 changed files with 31 additions and 31 deletions

View File

@@ -15,14 +15,14 @@ class ThermionGestureDetector extends StatelessWidget {
/// ///
/// The content to display below the gesture detector/listener widget. /// The content to display below the gesture detector/listener widget.
/// This will usually be a ThermionWidget (so you can navigate by directly interacting with the viewport), but this is not necessary. /// This will usually be a ThermionWidget (so you can navigate by directly interacting with the viewport), but this is not necessary.
/// It is equally possible to render the viewport/gesture controls elsewhere in the widget hierarchy. The only requirement is that they share the same [FilamentController]. /// It is equally possible to render the viewport/gesture controls elsewhere in the widget hierarchy. The only requirement is that they share the same [Filamentviewer].
/// ///
final Widget? child; final Widget? child;
/// ///
/// The [controller] attached to the [ThermionWidget] you wish to control. /// The [viewer] attached to the [ThermionWidget] you wish to control.
/// ///
final ThermionViewer controller; final ThermionViewer viewer;
/// ///
/// If true, an overlay will be shown with buttons to toggle whether pointer movements are interpreted as: /// If true, an overlay will be shown with buttons to toggle whether pointer movements are interpreted as:
@@ -47,7 +47,7 @@ class ThermionGestureDetector extends StatelessWidget {
const ThermionGestureDetector( const ThermionGestureDetector(
{Key? key, {Key? key,
required this.controller, required this.viewer,
this.child, this.child,
this.showControlOverlay = false, this.showControlOverlay = false,
this.enableCamera = true, this.enableCamera = true,
@@ -60,7 +60,7 @@ class ThermionGestureDetector extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FutureBuilder( return FutureBuilder(
future: controller.initialized, future: viewer.initialized,
builder: (_, initialized) { builder: (_, initialized) {
if (initialized.data != true) { if (initialized.data != true) {
return child ?? Container(); return child ?? Container();
@@ -69,7 +69,7 @@ class ThermionGestureDetector extends StatelessWidget {
Platform.isWindows || Platform.isWindows ||
Platform.isMacOS) { Platform.isMacOS) {
return ThermionGestureDetectorDesktop( return ThermionGestureDetectorDesktop(
controller: controller, viewer: viewer,
child: child, child: child,
showControlOverlay: showControlOverlay, showControlOverlay: showControlOverlay,
enableCamera: enableCamera, enableCamera: enableCamera,
@@ -77,7 +77,7 @@ class ThermionGestureDetector extends StatelessWidget {
); );
} else { } else {
return ThermionGestureDetectorMobile( return ThermionGestureDetectorMobile(
controller: controller, viewer: viewer,
child: child, child: child,
showControlOverlay: showControlOverlay, showControlOverlay: showControlOverlay,
enableCamera: enableCamera, enableCamera: enableCamera,

View File

@@ -10,14 +10,14 @@ import 'package:vector_math/vector_math_64.dart' as v64;
class ThermionGestureDetectorDesktop extends StatefulWidget { class ThermionGestureDetectorDesktop extends StatefulWidget {
final Widget? child; final Widget? child;
final ThermionViewer controller; final ThermionViewer viewer;
final bool showControlOverlay; final bool showControlOverlay;
final bool enableCamera; final bool enableCamera;
final bool enablePicking; final bool enablePicking;
const ThermionGestureDetectorDesktop({ const ThermionGestureDetectorDesktop({
Key? key, Key? key,
required this.controller, required this.viewer,
this.child, this.child,
this.showControlOverlay = false, this.showControlOverlay = false,
this.enableCamera = true, this.enableCamera = true,
@@ -37,7 +37,7 @@ class _ThermionGestureDetectorDesktopState
super.initState(); super.initState();
_gestureHandler = ThermionGestureHandler( _gestureHandler = ThermionGestureHandler(
enableCamera: widget.enableCamera, enableCamera: widget.enableCamera,
enablePicking: widget.enablePicking, viewer: widget.controller, enablePicking: widget.enablePicking, viewer: widget.viewer,
); );
} }
@@ -46,7 +46,7 @@ class _ThermionGestureDetectorDesktopState
if (widget.enableCamera != oldWidget.enableCamera || if (widget.enableCamera != oldWidget.enableCamera ||
widget.enablePicking != oldWidget.enablePicking) { widget.enablePicking != oldWidget.enablePicking) {
_gestureHandler = ThermionGestureHandler( _gestureHandler = ThermionGestureHandler(
viewer: widget.controller, viewer: widget.viewer,
enableCamera: widget.enableCamera, enableCamera: widget.enableCamera,
enablePicking: widget.enablePicking, enablePicking: widget.enablePicking,
); );

View File

@@ -11,14 +11,14 @@ class ThermionGestureDetectorMobile extends StatefulWidget {
/// ///
/// The content to display below the gesture detector/listener widget. /// The content to display below the gesture detector/listener widget.
/// This will usually be a ThermionWidget (so you can navigate by directly interacting with the viewport), but this is not necessary. /// This will usually be a ThermionWidget (so you can navigate by directly interacting with the viewport), but this is not necessary.
/// It is equally possible to render the viewport/gesture controls elsewhere in the widget hierarchy. The only requirement is that they share the same [FilamentController]. /// It is equally possible to render the viewport/gesture controls elsewhere in the widget hierarchy. The only requirement is that they share the same [Filamentviewer].
/// ///
final Widget? child; final Widget? child;
/// ///
/// The [controller] attached to the [ThermionWidget] you wish to control. /// The [viewer] attached to the [ThermionWidget] you wish to control.
/// ///
final ThermionViewer controller; final ThermionViewer viewer;
/// ///
/// If true, an overlay will be shown with buttons to toggle whether pointer movements are interpreted as: /// If true, an overlay will be shown with buttons to toggle whether pointer movements are interpreted as:
@@ -45,7 +45,7 @@ class ThermionGestureDetectorMobile extends StatefulWidget {
const ThermionGestureDetectorMobile( const ThermionGestureDetectorMobile(
{Key? key, {Key? key,
required this.controller, required this.viewer,
this.child, this.child,
this.showControlOverlay = false, this.showControlOverlay = false,
this.enableCamera = true, this.enableCamera = true,
@@ -98,14 +98,14 @@ class _ThermionGestureDetectorMobileState
void _setFunction() { void _setFunction() {
switch (gestureType) { switch (gestureType) {
case GestureType.rotateCamera: case GestureType.rotateCamera:
_functionStart = widget.controller.rotateStart; _functionStart = widget.viewer.rotateStart;
_functionUpdate = widget.controller.rotateUpdate; _functionUpdate = widget.viewer.rotateUpdate;
_functionEnd = widget.controller.rotateEnd; _functionEnd = widget.viewer.rotateEnd;
break; break;
case GestureType.panCamera: case GestureType.panCamera:
_functionStart = widget.controller.panStart; _functionStart = widget.viewer.panStart;
_functionUpdate = widget.controller.panUpdate; _functionUpdate = widget.viewer.panUpdate;
_functionEnd = widget.controller.panEnd; _functionEnd = widget.viewer.panEnd;
break; break;
// TODO // TODO
case GestureType.panBackground: case GestureType.panBackground:
@@ -143,7 +143,7 @@ class _ThermionGestureDetectorMobileState
return; return;
} }
widget.controller.pick( widget.viewer.pick(
d.globalPosition.dx.toInt(), d.globalPosition.dy.toInt()); d.globalPosition.dx.toInt(), d.globalPosition.dy.toInt());
}, },
onDoubleTap: () { onDoubleTap: () {
@@ -158,13 +158,13 @@ class _ThermionGestureDetectorMobileState
} }
if (d.pointerCount == 2 && widget.enableCamera) { if (d.pointerCount == 2 && widget.enableCamera) {
_scaling = true; _scaling = true;
await widget.controller.zoomBegin(); await widget.viewer.zoomBegin();
} else if (!_scaling && widget.enableCamera) { } else if (!_scaling && widget.enableCamera) {
if (_rotateOnPointerMove) { if (_rotateOnPointerMove) {
widget.controller.rotateStart( widget.viewer.rotateStart(
d.localFocalPoint.dx, d.localFocalPoint.dy); d.localFocalPoint.dx, d.localFocalPoint.dy);
} else { } else {
widget.controller widget.viewer
.panStart(d.localFocalPoint.dx, d.localFocalPoint.dy); .panStart(d.localFocalPoint.dx, d.localFocalPoint.dy);
} }
} }
@@ -176,7 +176,7 @@ class _ThermionGestureDetectorMobileState
} }
if (d.pointerCount == 2 && widget.enableCamera) { if (d.pointerCount == 2 && widget.enableCamera) {
if (d.horizontalScale != _lastScale) { if (d.horizontalScale != _lastScale) {
widget.controller.zoomUpdate( widget.viewer.zoomUpdate(
d.localFocalPoint.dx, d.localFocalPoint.dx,
d.localFocalPoint.dy, d.localFocalPoint.dy,
d.horizontalScale > _lastScale ? 0.1 : -0.1); d.horizontalScale > _lastScale ? 0.1 : -0.1);
@@ -184,10 +184,10 @@ class _ThermionGestureDetectorMobileState
} }
} else if (!_scaling && widget.enableCamera) { } else if (!_scaling && widget.enableCamera) {
if (_rotateOnPointerMove) { if (_rotateOnPointerMove) {
widget.controller widget.viewer
.rotateUpdate(d.focalPoint.dx, d.focalPoint.dy); .rotateUpdate(d.focalPoint.dx, d.focalPoint.dy);
} else { } else {
widget.controller widget.viewer
.panUpdate(d.focalPoint.dx, d.focalPoint.dy); .panUpdate(d.focalPoint.dx, d.focalPoint.dy);
} }
} }
@@ -199,12 +199,12 @@ class _ThermionGestureDetectorMobileState
} }
if (d.pointerCount == 2 && widget.enableCamera) { if (d.pointerCount == 2 && widget.enableCamera) {
widget.controller.zoomEnd(); widget.viewer.zoomEnd();
} else if (!_scaling && widget.enableCamera) { } else if (!_scaling && widget.enableCamera) {
if (_rotateOnPointerMove) { if (_rotateOnPointerMove) {
widget.controller.rotateEnd(); widget.viewer.rotateEnd();
} else { } else {
widget.controller.panEnd(); widget.viewer.panEnd();
} }
} }
_scaling = false; _scaling = false;