|
@@ -1,9 +1,13 @@
|
|
|
+// ignore_for_file: constant_identifier_names
|
|
|
+
|
|
|
import 'package:fis_measure/interfaces/process/workspace/application.dart';
|
|
|
import 'package:fis_measure/interfaces/process/workspace/point_info.dart';
|
|
|
import 'package:fis_measure/values/colors.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
+import '../positioned_cursor.dart';
|
|
|
+
|
|
|
/// 自定义注释文本框定位面板
|
|
|
class AnnotationInputPositionPanel extends StatefulWidget {
|
|
|
const AnnotationInputPositionPanel({Key? key}) : super(key: key);
|
|
@@ -14,6 +18,7 @@ class AnnotationInputPositionPanel extends StatefulWidget {
|
|
|
|
|
|
class _PanelState extends State<AnnotationInputPositionPanel> {
|
|
|
late final application = Get.find<IApplication>();
|
|
|
+ final mouseState = Get.put<IMouseState>(MouseState()..cursorSize = 10);
|
|
|
|
|
|
Offset? position;
|
|
|
|
|
@@ -26,27 +31,48 @@ class _PanelState extends State<AnnotationInputPositionPanel> {
|
|
|
application.createPointInfo(position!, PointInfoType.mouseDown);
|
|
|
});
|
|
|
},
|
|
|
- child: Stack(
|
|
|
- children: [
|
|
|
- if (position != null)
|
|
|
- Positioned(
|
|
|
- child: const _InputWidget(),
|
|
|
- left: position!.dx,
|
|
|
- top: position!.dy,
|
|
|
- ),
|
|
|
- ],
|
|
|
+ child: MouseRegion(
|
|
|
+ cursor: SystemMouseCursors.none,
|
|
|
+ onHover: (event) {
|
|
|
+ mouseState.mousePosition = event.localPosition +
|
|
|
+ const Offset(
|
|
|
+ _InputWidget.C_MIN_WIDTH / 2,
|
|
|
+ _InputWidget.C_MAX_HEIGHT / 2,
|
|
|
+ );
|
|
|
+ },
|
|
|
+ child: Stack(
|
|
|
+ children: [
|
|
|
+ if (position != null)
|
|
|
+ Positioned(
|
|
|
+ child: _InputWidget(
|
|
|
+ key: UniqueKey(),
|
|
|
+ onChanged: (value) {
|
|
|
+ application.activeAnnotationItem?.text = value;
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ left: position!.dx,
|
|
|
+ top: position!.dy,
|
|
|
+ ),
|
|
|
+ const PositionedCursor(),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+typedef _InputValueChanged = void Function(String value);
|
|
|
+
|
|
|
class _InputWidget extends StatelessWidget {
|
|
|
- // ignore: constant_identifier_names
|
|
|
static const C_BG_COLOR = Color.fromARGB(255, 121, 135, 151);
|
|
|
+ static const C_MIN_WIDTH = 40.0;
|
|
|
+ static const C_MAX_HEIGHT = 28.0;
|
|
|
|
|
|
final FocusNode? focusNode;
|
|
|
+ final _InputValueChanged onChanged;
|
|
|
|
|
|
const _InputWidget({
|
|
|
+ required this.onChanged,
|
|
|
Key? key,
|
|
|
this.focusNode,
|
|
|
}) : super(key: key);
|
|
@@ -64,6 +90,7 @@ class _InputWidget extends StatelessWidget {
|
|
|
style: const TextStyle(color: MeasureColors.Primary),
|
|
|
cursorColor: MeasureColors.Primary,
|
|
|
cursorWidth: 1.0,
|
|
|
+ onChanged: onChanged,
|
|
|
decoration: const InputDecoration(
|
|
|
border: border,
|
|
|
enabledBorder: border,
|
|
@@ -73,7 +100,8 @@ class _InputWidget extends StatelessWidget {
|
|
|
fillColor: C_BG_COLOR,
|
|
|
isCollapsed: false,
|
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 2, vertical: 8),
|
|
|
- constraints: BoxConstraints(minWidth: 40, maxHeight: 28),
|
|
|
+ constraints:
|
|
|
+ BoxConstraints(minWidth: C_MIN_WIDTH, maxHeight: C_MAX_HEIGHT),
|
|
|
),
|
|
|
);
|
|
|
return Container(
|