magland / sortingview

Web app for viewing results of ephys spike sorting
Apache License 2.0
25 stars 8 forks source link

Duplicate widgets #17

Closed khl02007 closed 2 years ago

khl02007 commented 3 years ago

It seems like right now one can create infinite instances of the same widget by repeatedly clicking on the same button under Open Views. Given that in many cases having multiple widgets of the same type doesn't give you more information (because the time axes are yoked), maybe clicking on a widget under Open Views should just activate the one that's already open (if there is one).

magland commented 3 years ago

Some plugin views (aka widgets) already have that behavior. For example, the units table. In the source code, there is a boolean property called "singleton" for this. See: https://github.com/magland/sortingview/blob/098ff4712d7f57126b82c3f78d964aebae7bc92a/src/python/sortingview/gui/extensions/unitstable/unitstable.tsx#L23-L23

Sometimes you may want to have two instances of a widget for comparison (like cross-correlograms where you select which histograms you want). For others that doesn't make sense.

@khl02007 perhaps you could make a list of the widget plugins which should have singleton: true? Or maybe they could all be singleton, and we should have a mechanism where the user can override that. Not sure.