import 'package:flyinsono/lab/pages/lab_image/widgets/image_measure_overlay/widgets/mouse_gesture_area.dart';
import 'package:flyinsono/lab/pages/lab_image/widgets/image_measure_overlay/controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

/// 该组件的原型来自 MeasureMouseGesturePanel
class MouseGestureLayer extends GetView<ImageMeasureOverlayController> {
  const MouseGestureLayer(
      {Key? key,
      this.onMouseDown,
      this.onMouseMove,
      required this.tabHashCode,
      required this.isLeftRight})
      : super(key: key);

  @override
  String? get tag => tabHashCode;

  final String tabHashCode;
  final bool isLeftRight;

  final ValueChanged<Offset>? onMouseDown;
  final ValueChanged<Offset>? onMouseMove;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<ImageMeasureOverlayController>(
      tag: tabHashCode,
      id: ImageMeasureOverlayController.mouseGestureLayerId,
      builder: (_) {
        /// FIXME 当光标样式或者size改变时，需要传入参数来更新MouseGestureArea
        return MouseGestureArea(
          tabHashCode: tabHashCode,
          onMouseDown: onMouseDown,
          onMouseMove: onMouseMove,
          ifContainerTissueTM: controller.ifContainerTissueTM,
          tissueTMPixelRegion: controller.tissueTMPixelRegion,
          isLeftRight: isLeftRight,
        );
      },
    );
  }
}
