|
@@ -1,6 +1,7 @@
|
|
|
import 'package:fis_measure/interfaces/enums/annotation.dart';
|
|
|
import 'package:fis_measure/interfaces/process/workspace/application.dart';
|
|
|
import 'package:fis_measure/interfaces/process/workspace/point_info.dart';
|
|
|
+import 'package:fis_measure/view/gesture/mouse_gesture.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
@@ -17,47 +18,54 @@ class AnnotationLabelDragTargetPanel extends StatefulWidget {
|
|
|
class _PanelState extends State<AnnotationLabelDragTargetPanel> {
|
|
|
late final application = Get.find<IApplication>();
|
|
|
final mouseState = Get.find<IMouseState>();
|
|
|
+ CursorDisplayType displayType = CursorDisplayType.none;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
- // TODO: implement initState
|
|
|
super.initState();
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return Container(
|
|
|
- // color: Colors.green,
|
|
|
- child: DragTarget<String>(
|
|
|
- builder: (context, candidateData, rejectedData) {
|
|
|
- return GestureDetector(
|
|
|
- onPanDown: (details) {
|
|
|
- application.createPointInfo(
|
|
|
- details.localPosition,
|
|
|
- PointInfoType.mouseDown,
|
|
|
- );
|
|
|
- application.switchAnnotation(AnnotationType.input);
|
|
|
+ return DragTarget<String>(
|
|
|
+ builder: (context, candidateData, rejectedData) {
|
|
|
+ return GestureDetector(
|
|
|
+ onPanDown: (details) {
|
|
|
+ application.createPointInfo(
|
|
|
+ details.localPosition,
|
|
|
+ PointInfoType.mouseDown,
|
|
|
+ );
|
|
|
+ application.switchAnnotation(AnnotationType.input);
|
|
|
+ },
|
|
|
+ child: MouseRegion(
|
|
|
+ cursor: SystemMouseCursors.none,
|
|
|
+ onHover: (event) {
|
|
|
+ mouseState.mousePosition = event.localPosition;
|
|
|
},
|
|
|
- child: MouseRegion(
|
|
|
- cursor: SystemMouseCursors.none,
|
|
|
- onHover: (event) {
|
|
|
- mouseState.mousePosition = event.localPosition;
|
|
|
- },
|
|
|
- child: Stack(
|
|
|
- children: const [
|
|
|
- PositionedCursor(),
|
|
|
- ],
|
|
|
- ),
|
|
|
+ onEnter: (e) {
|
|
|
+ setState(() {
|
|
|
+ displayType = CursorDisplayType.normal;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onExit: (e) {
|
|
|
+ setState(() {
|
|
|
+ displayType = CursorDisplayType.none;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ child: Stack(
|
|
|
+ children: [
|
|
|
+ _buildCursor(),
|
|
|
+ ],
|
|
|
),
|
|
|
- );
|
|
|
- },
|
|
|
- onMove: (details) {
|
|
|
- _notifyPosition(context, details.offset, PointInfoType.mouseMove);
|
|
|
- },
|
|
|
- onAcceptWithDetails: (details) {
|
|
|
- _notifyPosition(context, details.offset, PointInfoType.mouseUp);
|
|
|
- },
|
|
|
- ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ onMove: (details) {
|
|
|
+ _notifyPosition(context, details.offset, PointInfoType.mouseMove);
|
|
|
+ },
|
|
|
+ onAcceptWithDetails: (details) {
|
|
|
+ _notifyPosition(context, details.offset, PointInfoType.mouseUp);
|
|
|
+ },
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -77,9 +85,19 @@ class _PanelState extends State<AnnotationLabelDragTargetPanel> {
|
|
|
return renderBox.globalToLocal(globalPosition);
|
|
|
}
|
|
|
|
|
|
+ Widget _buildCursor() {
|
|
|
+ switch (displayType) {
|
|
|
+ case CursorDisplayType.none:
|
|
|
+ return Container();
|
|
|
+ case CursorDisplayType.normal:
|
|
|
+ return const PositionedCursor();
|
|
|
+ default:
|
|
|
+ return const PositionedCursor();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
void dispose() {
|
|
|
- // TODO: implement dispose
|
|
|
super.dispose();
|
|
|
}
|
|
|
}
|