[draft] menu items spec

Status

  • NC and JNI drafted, 2022-06-28

This document is intended to collect questions around menu item design.

Parts of this might inform a NAP.

Example manifest

name: my-plugin display_name: My Plugin on_activate: my_plugin:activate on_deactivate: my_plugin:deactivate contributions: commands: - id: my-plugin.hello_world title: Hello World - id: my-plugin.another_command title: Another Command menus: /napari/layer_context: - submenu: my-plugin.mysubmenu - command: my-plugin.hello_world submenus: - id: my-plugin.mysubmenu label: My SubMenu contents: - command: my-plugin.another_command - command: my-plugin.another_command

Definitions

  • submenu id - the unique id for a plugin submenu.
  • label - text displayed for a submenu
  • command - a plugin command contribution. This is the functionality to invoke when a user clicks on a menu item.

Allowable top level menu locations

Open questions

1. Foreign submenu references. Can a plugin attach submenus to other plugin's submenus.

Probably have agreement here:

  • Yes, items appended
  • missing foreign references are ignored

2. Menu path collisions. How to handle when two submenu/menu trees from different plugins are the same.

e.g. Different id's, same label.

  • Plugin A: "/napari/layer_context/Image/Shape"
  • Plugin B: "/napari/layer_context/Image/Shape"
    What to do about "Shape?"

Options:

  1. Put plugin name in parentheses to disambiguate.
  2. NO OTHER OPTIONS. DONE

3. Top-level menu-items

Options:

  • Robert-like
  • Permissive top-level whitelist. Effectively allow plugins to add most anywhere, but there is a whitelist that might change over time.
  • blacklist, but otherwise anything goes
  • Allow menus to add anywhere