12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import 'package:fis_measure/interfaces/enums/annotation.dart';
- import 'package:fis_measure/interfaces/process/workspace/application.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import '../positioned_cursor.dart';
- import 'arrow_gesture_panel.dart';
- import 'input_position_panel.dart';
- import 'label_drag_target_pannel.dart';
- /// 注释手势层
- class AnnotationGestureLayer extends StatefulWidget {
- const AnnotationGestureLayer({Key? key}) : super(key: key);
- @override
- State<AnnotationGestureLayer> createState() => _AnnotationGestureLayerState();
- }
- class _AnnotationGestureLayerState extends State<AnnotationGestureLayer> {
- late final application = Get.find<IApplication>();
- final mouseState = Get.put<IMouseState>(MouseState());
- @override
- Widget build(BuildContext context) {
- return _buildItemPanel();
- // TODO: melon - optimize with handlers
- return Stack(
- children: [
- _buildItemPanel(),
- _buildTopGesture(),
- ],
- );
- }
- Widget _buildTopGesture() {
- return GestureDetector(
- onPanUpdate: (details) {
- mouseState.mousePosition = details.localPosition;
- },
- child: MouseRegion(
- cursor: SystemMouseCursors.none,
- onHover: (details) {
- mouseState.mousePosition = details.localPosition;
- },
- child: Stack(
- children: const [
- PositionedCursor(),
- ],
- ),
- ),
- );
- }
- Widget _buildItemPanel() {
- final item = application.activeAnnotationItem;
- if (item == null) {
- return const SizedBox();
- }
- final type = item.type;
- switch (type) {
- case AnnotationType.label:
- return const AnnotationLabelDragTargetPanel();
- case AnnotationType.input:
- return const AnnotationInputPositionPanel();
- case AnnotationType.arrow:
- return const AnnotationArrowGesturePanel();
- }
- }
- }
|