Add a model and collections for tracking menu items.

Review Request #13630 — Created March 13, 2024 and submitted

Information

Ink
master

Reviewers

This introduces the model-level support for menus, consisting of three
parts:

  • MenuItem: This is a model containing state for any kind of supported
    menu item (a standard action item, checkbox menu item, radio menu
    item, or a separator).

  • MenuItemsCollection: A collection of menu items, which will be used
    as the backing for a menu view.

  • MenuItemsRadioGroup: A radio group for tracking menu items, which
    ensures only one item can be marked as checked at a time.

The design for MenuItem consolidates all state for all types into one
model, rather than having subclasses for each type. There are a few
reasons for this:

  1. It makes it easier to maintain items in a collection and still allow
    instantiation of new entries via the collection's .add().

  2. It avoids needing to do instanceof checks for different operations.

  3. It seems to be common practice (looking at the Apple, Windows, and
    GTK foundational classes for menu items).

The upcoming MenuView will make use of these classes to provide a full
menu implementation.

Unit tests pass.

Tested this thoroughly with the in-progress MenuView work.

Summary ID
Add a model and collections for tracking menu items.
This introduces the model-level support for menus, consisting of three parts: * `MenuItem`: This is a model containing state for any kind of supported menu item (a standard action item, checkbox menu item, radio menu item, or a separator). * `MenuItemsCollection`: A collection of menu items, which will be used as the backing for a menu view. * `MenuItemsRadioGroup`: A radio group for tracking menu items, which ensures only one item can be marked as checked at a time. The design for `MenuItem` consolidates all state for all types into one model, rather than having subclasses for each type. There are a few reasons for this: 1. It makes it easier to maintain items in a collection and still allow instantiation of new entries via the collection's `.add()`. 2. It avoids needing to do `instanceof` checks for different operations. 3. It seems to be common practice (looking at the Apple, Windows, and GTK foundational classes for menu items). The upcoming `MenuView` will make use of these classes to provide a full menu implementation.
170360f5af6c75c26e4f86272597314bb89e1b68
Description From Last Updated

Needs a trailing comma.

daviddavid

Can you add a module comment to the top of the file?

daviddavid

Can you add a module comment to the top of the file?

daviddavid
david
  1. 
      
  2. Show all issues

    Needs a trailing comma.

    1. It's not allowed for ...args. TypeScript and ESLint will complain.

  3. Show all issues

    Can you add a module comment to the top of the file?

  4. Show all issues

    Can you add a module comment to the top of the file?

  5. 
      
chipx86
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (c50b9d1)