From 60530fad6bb7b5fcea9f2b0af990527aa38208b6 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Thu, 19 Sep 2024 12:52:16 +0800 Subject: [PATCH] widget updates --- .../thermion_gesture_detector_desktop.dart | 2 +- .../gestures/thermion_gesture_handler.dart | 3 +- .../thermion/widgets/lights/light_slider.dart | 364 +++++++++--------- 3 files changed, 185 insertions(+), 184 deletions(-) diff --git a/thermion_flutter/thermion_flutter/lib/thermion/widgets/camera/gestures/thermion_gesture_detector_desktop.dart b/thermion_flutter/thermion_flutter/lib/thermion/widgets/camera/gestures/thermion_gesture_detector_desktop.dart index 948b92ab..aa766ab4 100644 --- a/thermion_flutter/thermion_flutter/lib/thermion/widgets/camera/gestures/thermion_gesture_detector_desktop.dart +++ b/thermion_flutter/thermion_flutter/lib/thermion/widgets/camera/gestures/thermion_gesture_detector_desktop.dart @@ -35,7 +35,7 @@ class _ThermionGestureDetectorDesktopState Widget build(BuildContext context) { return Listener( onPointerHover: (event) => - widget.gestureHandler.onPointerHover(event.localPosition), + widget.gestureHandler.onPointerHover(event.localPosition, event.delta), onPointerSignal: (PointerSignalEvent pointerSignal) { if (pointerSignal is PointerScrollEvent) { widget.gestureHandler.onPointerScroll( diff --git a/thermion_flutter/thermion_flutter/lib/thermion/widgets/camera/gestures/thermion_gesture_handler.dart b/thermion_flutter/thermion_flutter/lib/thermion/widgets/camera/gestures/thermion_gesture_handler.dart index 0306afa4..454e9846 100644 --- a/thermion_flutter/thermion_flutter/lib/thermion/widgets/camera/gestures/thermion_gesture_handler.dart +++ b/thermion_flutter/thermion_flutter/lib/thermion/widgets/camera/gestures/thermion_gesture_handler.dart @@ -16,7 +16,8 @@ enum GestureType { SCALE1, SCALE2, SCROLLWHEEL, - POINTER_MOVE + POINTER_MOVE, + KEYDOWN } enum GestureAction { diff --git a/thermion_flutter/thermion_flutter/lib/thermion/widgets/lights/light_slider.dart b/thermion_flutter/thermion_flutter/lib/thermion/widgets/lights/light_slider.dart index a355b29f..10ca8d82 100644 --- a/thermion_flutter/thermion_flutter/lib/thermion/widgets/lights/light_slider.dart +++ b/thermion_flutter/thermion_flutter/lib/thermion/widgets/lights/light_slider.dart @@ -1,194 +1,194 @@ -import 'package:thermion_dart/thermion_dart/thermion_viewer.dart'; -import 'package:thermion_dart/thermion_dart/utils/light_options.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; +// import 'package:thermion_dart/thermion_dart/thermion_viewer.dart'; +// import 'package:thermion_dart/thermion_dart/utils/light_options.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/widgets.dart'; -import 'package:vector_math/vector_math_64.dart' as v; +// import 'package:vector_math/vector_math_64.dart' as v; -class LightSliderWidget extends StatefulWidget { - final ThermionViewer controller; +// class LightSliderWidget extends StatefulWidget { +// final ThermionViewer controller; - final LightOptions options; - final bool showControls; +// final LightOptions options; +// final bool showControls; - LightSliderWidget( - {super.key, - required this.controller, - this.showControls = false, - required this.options}); - @override - State createState() => _LightSliderWidgetState(); -} +// LightSliderWidget( +// {super.key, +// required this.controller, +// this.showControls = false, +// required this.options}); +// @override +// State createState() => _LightSliderWidgetState(); +// } -class _LightSliderWidgetState extends State { - ThermionEntity? _light; +// class _LightSliderWidgetState extends State { +// ThermionEntity? _light; - @override - void initState() { - _set(); - super.initState(); - } +// @override +// void initState() { +// _set(); +// super.initState(); +// } - Future _set() async { - await widget.controller.clearLights(); +// Future _set() async { +// await widget.controller.clearLights(); - if (widget.options.iblPath != null) { - _light = await widget.controller.loadIbl(widget.options.iblPath!, - intensity: widget.options.iblIntensity); - } +// if (widget.options.iblPath != null) { +// _light = await widget.controller.loadIbl(widget.options.iblPath!, +// intensity: widget.options.iblIntensity); +// } - _light = await widget.controller.addLight( - LightType.values[ - widget.options.directionalType], - widget.options.directionalColor, - widget.options.directionalIntensity, - widget.options.directionalPosition.x, - widget.options.directionalPosition.y, - widget.options.directionalPosition.z, - widget.options.directionalDirection.x, - widget.options.directionalDirection.y, - widget.options.directionalDirection.z, - castShadows:widget.options.directionalCastShadows); +// _light = await widget.controller.addLight( +// LightType.values[ +// widget.options.directionalType], +// widget.options.directionalColor, +// widget.options.directionalIntensity, +// widget.options.directionalPosition.x, +// widget.options.directionalPosition.y, +// widget.options.directionalPosition.z, +// widget.options.directionalDirection.x, +// widget.options.directionalDirection.y, +// widget.options.directionalDirection.z, +// castShadows:widget.options.directionalCastShadows); - setState(() {}); - } +// setState(() {}); +// } - @override - Widget build(BuildContext context) { - if (_light == null || !widget.showControls) { - return Container(); - } - return Theme( - data: ThemeData(platform: TargetPlatform.android), - child: Container( - decoration: BoxDecoration(color: Colors.white.withOpacity(0.5)), - child: SliderTheme( - data: const SliderThemeData( - showValueIndicator: ShowValueIndicator.always, - valueIndicatorTextStyle: TextStyle(color: Colors.black)), - child: Column(mainAxisSize: MainAxisSize.min, children: [ - Text("Directional"), - Row(children: [ - Expanded( - child: Slider( - label: - "POSX ${widget.options.directionalPosition.x}", - value: widget.options.directionalPosition.x, - min: -10.0, - max: 10.0, - onChanged: (value) { - widget.options.directionalPosition.x = value; - _set(); - })), - Expanded( - child: Slider( - label: - "POSY ${widget.options.directionalPosition.y}", - value: widget.options.directionalPosition.y, - min: -100.0, - max: 100.0, - onChanged: (value) { - widget.options.directionalPosition.y = value; - _set(); - })), - Expanded( - child: Slider( - label: - "POSZ ${widget.options.directionalPosition.z}", - value: widget.options.directionalPosition.z, - min: -100.0, - max: 100.0, - onChanged: (value) { - widget.options.directionalPosition.z = value; - _set(); - })) - ]), - Row(children: [ - Expanded( - child: Slider( - label: "DIRX", - value: widget.options.directionalDirection.x, - min: -1.0, - max: 1.0, - onChanged: (value) { - widget.options.directionalDirection.x = value; - _set(); - })), - Expanded( - child: Slider( - label: "DIRY", - value: widget.options.directionalDirection.y, - min: -1.0, - max: 1.0, - onChanged: (value) { - widget.options.directionalDirection.y = value; - _set(); - })), - Expanded( - child: Slider( - label: "DIRZ", - value: widget.options.directionalDirection.z, - min: -1.0, - max: 1.0, - onChanged: (value) { - widget.options.directionalDirection.z = value; - _set(); - })) - ]), - Slider( - label: "Color", - value: widget.options.directionalColor, - min: 0, - max: 16000, - onChanged: (value) { - widget.options.directionalColor = value; - _set(); - }), - Slider( - label: "Intensity ${widget.options.directionalIntensity}", - value: widget.options.directionalIntensity, - min: 0, - max: 1000000, - onChanged: (value) { - widget.options.directionalIntensity = value; - _set(); - }), - DropdownButton( - onChanged: (v) { - this.widget.options.directionalType = v; - _set(); - }, - value: this.widget.options.directionalType, - items: List.generate( - 5, - (idx) => DropdownMenuItem( - value: idx, - child: Text("$idx"), - ))), - Row(children: [ - Text( - "Shadows: ${this.widget.options.directionalCastShadows}"), - Checkbox( - value: widget.options.directionalCastShadows, - onChanged: (v) { - this.widget.options.directionalCastShadows = v!; - _set(); - }) - ]), - Text("Indirect"), - Row(children: [ - Expanded( - child: Slider( - label: "Intensity ${widget.options.iblIntensity}", - value: widget.options.iblIntensity, - min: 0.0, - max: 200000, - onChanged: (value) { - widget.options.iblIntensity = value; - _set(); - })), - ]) - ])))); - } -} +// @override +// Widget build(BuildContext context) { +// if (_light == null || !widget.showControls) { +// return Container(); +// } +// return Theme( +// data: ThemeData(platform: TargetPlatform.android), +// child: Container( +// decoration: BoxDecoration(color: Colors.white.withOpacity(0.5)), +// child: SliderTheme( +// data: const SliderThemeData( +// showValueIndicator: ShowValueIndicator.always, +// valueIndicatorTextStyle: TextStyle(color: Colors.black)), +// child: Column(mainAxisSize: MainAxisSize.min, children: [ +// Text("Directional"), +// Row(children: [ +// Expanded( +// child: Slider( +// label: +// "POSX ${widget.options.directionalPosition.x}", +// value: widget.options.directionalPosition.x, +// min: -10.0, +// max: 10.0, +// onChanged: (value) { +// widget.options.directionalPosition.x = value; +// _set(); +// })), +// Expanded( +// child: Slider( +// label: +// "POSY ${widget.options.directionalPosition.y}", +// value: widget.options.directionalPosition.y, +// min: -100.0, +// max: 100.0, +// onChanged: (value) { +// widget.options.directionalPosition.y = value; +// _set(); +// })), +// Expanded( +// child: Slider( +// label: +// "POSZ ${widget.options.directionalPosition.z}", +// value: widget.options.directionalPosition.z, +// min: -100.0, +// max: 100.0, +// onChanged: (value) { +// widget.options.directionalPosition.z = value; +// _set(); +// })) +// ]), +// Row(children: [ +// Expanded( +// child: Slider( +// label: "DIRX", +// value: widget.options.directionalDirection.x, +// min: -1.0, +// max: 1.0, +// onChanged: (value) { +// widget.options.directionalDirection.x = value; +// _set(); +// })), +// Expanded( +// child: Slider( +// label: "DIRY", +// value: widget.options.directionalDirection.y, +// min: -1.0, +// max: 1.0, +// onChanged: (value) { +// widget.options.directionalDirection.y = value; +// _set(); +// })), +// Expanded( +// child: Slider( +// label: "DIRZ", +// value: widget.options.directionalDirection.z, +// min: -1.0, +// max: 1.0, +// onChanged: (value) { +// widget.options.directionalDirection.z = value; +// _set(); +// })) +// ]), +// Slider( +// label: "Color", +// value: widget.options.directionalColor, +// min: 0, +// max: 16000, +// onChanged: (value) { +// widget.options.directionalColor = value; +// _set(); +// }), +// Slider( +// label: "Intensity ${widget.options.directionalIntensity}", +// value: widget.options.directionalIntensity, +// min: 0, +// max: 1000000, +// onChanged: (value) { +// widget.options.directionalIntensity = value; +// _set(); +// }), +// DropdownButton( +// onChanged: (v) { +// this.widget.options.directionalType = v; +// _set(); +// }, +// value: this.widget.options.directionalType, +// items: List.generate( +// 5, +// (idx) => DropdownMenuItem( +// value: idx, +// child: Text("$idx"), +// ))), +// Row(children: [ +// Text( +// "Shadows: ${this.widget.options.directionalCastShadows}"), +// Checkbox( +// value: widget.options.directionalCastShadows, +// onChanged: (v) { +// this.widget.options.directionalCastShadows = v!; +// _set(); +// }) +// ]), +// Text("Indirect"), +// Row(children: [ +// Expanded( +// child: Slider( +// label: "Intensity ${widget.options.iblIntensity}", +// value: widget.options.iblIntensity, +// min: 0.0, +// max: 200000, +// onChanged: (value) { +// widget.options.iblIntensity = value; +// _set(); +// })), +// ]) +// ])))); +// } +// }