123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import 'package:fis_measure/interfaces/process/workspace/application.dart';
- import 'package:fis_measure/interfaces/process/workspace/point_info.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import '../positioned_cursor.dart';
- /// 文本注释拖拽目标面板
- class AnnotationLabelDragTargetPanel extends StatefulWidget {
- const AnnotationLabelDragTargetPanel({Key? key}) : super(key: key);
- @override
- State<StatefulWidget> createState() => _PanelState();
- }
- class _PanelState extends State<AnnotationLabelDragTargetPanel> {
- late final application = Get.find<IApplication>();
- @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 Container(
- child: Stack(
- children: const [
- PositionedCursor(),
- ],
- ),
- );
- },
- onMove: (details) {
- _notifyPosition(context, details.offset, PointInfoType.mouseMove);
- },
- onAcceptWithDetails: (details) {
- _notifyPosition(context, details.offset, PointInfoType.mouseUp);
- },
- ),
- );
- }
- void _notifyPosition(
- BuildContext context,
- Offset offset,
- PointInfoType type,
- ) {
- final localOffset = _findLocalPosition(context, offset);
- application.createPointInfo(localOffset, type);
- }
- Offset _findLocalPosition(BuildContext context, Offset globalPosition) {
- final renderBox = context.findRenderObject() as RenderBox?;
- if (renderBox == null) return globalPosition;
- return renderBox.globalToLocal(globalPosition);
- }
- @override
- void dispose() {
- // TODO: implement dispose
- super.dispose();
- }
- }
|