h2oai / wave

Realtime Web Apps and Dashboards for Python and R
https://wave.h2o.ai
Apache License 2.0
3.9k stars 324 forks source link

feat: Implement 'click' and 'tool_change' events for image annotator #2010 #2026

Closed marek-mihok closed 1 year ago

marek-mihok commented 1 year ago

This change adds event prop for ui.image_annotator component with an option to specify the click and tool_change events.

The click event contains the x and y coordinates of the clicked point on the image canvas. A tool_change event contains the name of the selected tool (rect, polygon or select).

Updated API is as follows:

export interface ImageAnnotator {
  /** An identifying name for this component. */
  name: Id
  /** The path or URL of the image to be presented for annotation. */
  image: S
  /** The image annotator's title. */
  title: S
  /** The master list of tags that can be used for annotations. */
  tags: ImageAnnotatorTag[]
  /** Annotations to display on the image, if any. */
  items?: ImageAnnotatorItem[]
  /** True if the form should be submitted as soon as an annotation is drawn. */
  trigger?: B
  /** The card’s image height. The actual image size is used by default. */
  image_height?: S
  /** List of allowed shapes. Available values are 'rect' and 'polygon'. If not set, all shapes are available by default. */
  allowed_shapes?: S[]
  /** The events to capture on this image annotator. One of `click` or `tool_change`. */
  events?: S[]
}

Closes #2010

mturoci commented 1 year ago

Thanks @marek-mihok, rebase the branch please and we are good to merge.