Add a model and collections for tracking menu items.
Review Request #13630 — Created March 13, 2024 and submitted
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:
-
It makes it easier to maintain items in a collection and still allow
instantiation of new entries via the collection's.add()
. -
It avoids needing to do
instanceof
checks for different operations. -
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.
-
-
-
src/ink/js/components/collections/tests/menuItemsRadioGroupTests.ts (Diff revision 1) Can you add a module comment to the top of the file?
-
src/ink/js/components/models/tests/menuItemModelTests.ts (Diff revision 1) Can you add a module comment to the top of the file?
Change Summary:
change:checked
signals are now always triggered, and are never silenced, letting UIs properly update their state when unchecking.- Added module-level docstrings for unit tests.
Commits: |
|
|||||||
---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+2354 -4) |
Checks run (2 succeeded)
Change Summary:
Actually updated with the new changes.
Commits: |
|
|||||||
---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+2382 -4) |