Skip to content

Commit

Permalink
Update where app-model actions/providers/processors live in codebase (#…
Browse files Browse the repository at this point in the history
…416)

# References and relevant issues
Relates to napari/napari#6848
Depends on napari/napari#6743

# Description

Updates the info on where actions live in the napari codebase.

---------

Co-authored-by: Peter Sobolewski <[email protected]>
  • Loading branch information
lucyleeow and psobolewskiPhD authored Jun 7, 2024
1 parent 7125f16 commit ef267d3
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions docs/developers/architecture/app_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,20 @@ This is because command id's may currently only be registered once, and associat

### `Action`s in napari

In napari, non-Qt `Action`s are defined in
[`napari/_app_model/actions`](https://github.com/napari/napari/tree/main/napari/_app_model/actions)
while Qt `Action`s are defined in
[`napari/_qt/_qapp_model/qactions`](https://github.com/napari/napari/tree/main/napari/_qt/_qapp_model/qactions).
In napari, menu bar actions are defined in
[`napari/_qt/_qapp_model/qactions`](https://github.com/napari/napari/tree/main/napari/_qt/_qapp_model/qactions),
with one file per menu.
While not all menu bar actions strictly require Qt, they are defined for the purpose
of living in a menu and are thus considered 'GUI' actions.
This also ensures that there is only one file defining both actions and their
submenus.
Note if we move to supporting more GUI backends, we may want to move these out of
`_qt/` to a shared `gui/` folder, depending on implementation.

The layer context menu actions do not require a GUI (they only require the `layerlist`)
and thus live in
[`napari/_app_model/actions`](https://github.com/napari/napari/tree/main/napari/_app_model/actions).

Non-Qt `Action`s get registered with `app` during
initialization of the napari `app`, in `NapariApplication`'s
{meth}`~napari._app_model._app.NapariApplication.__init__`. Qt `Action`s
Expand Down Expand Up @@ -455,18 +465,17 @@ ways will not work:

### Providers and processors in napari

Non-Qt providers and processors are defined in
[`napari/_app_model/injection`](https://github.com/napari/napari/tree/main/napari/_app_model/injection).
Qt providers and processors are defined in
Currently there are only GUI related providers and processors.
They are defined in
[`napari/_qt/_qapp_model/injection`](https://github.com/napari/napari/tree/main/napari/_qt/_qapp_model/injection).
They are registered in {func}`~napari._qt._qapp_model.qactions.init_qactions`,
which gets called during initialization of `_QtMainWindow`. This is the same as
[registration of `Action`s](app-model-actions-napari).

Non-Qt providers and processors are registered in the `app` `Store` during
In future we intend to have non-GUI providers that will supply layer objects.
They would be registered in the `app` `Store` during
initialization of the napari `app`, in `NapariApplication`'s
{meth}`~napari._app_model._app.NapariApplication.__init__`.
Qt providers and processors are registered in
{func}`~napari._qt._qapp_model.qactions.init_qactions`, which gets called during
initialization of `_QtMainWindow`. This is the same as
[registration of `Action`s](app-model-actions-napari).

(app-model-testing)=

Expand Down

0 comments on commit ef267d3

Please sign in to comment.