imagej / imagej-legacy

ImageJ+ImageJ2 compatibility layer
https://imagej.net/libs/imagej-legacy
BSD 2-Clause "Simplified" License
16 stars 25 forks source link

Reset LookAndFeel in ImageJ1Helper #268

Closed K-Meech closed 2 years ago

K-Meech commented 2 years ago

When using the @Parameter notation for a File in a fiji plugin - the look and feel is changed on Windows (e.g. see this issue: https://github.com/mobie/mobie-viewer-fiji/issues/525). This is due to the LegacyUI chooseFile calling IJ1Helper functions here.

E.g. for ij1Helper().getDirectory() this calls the imagej1 DirectoryChooser here. This changes the look and feel here to the system one - which is not the same as the one fiji opens with for Windows.

Would it be possible to record and reset the swing look and feel for all the IJ1Helper functions called in chooseFile? i.e. ij1Helper().getDirectory(), ij1Helper().saveDialog() and ij1Helper().openDialog()? Thanks!

imagejan commented 2 years ago

Great suggestion, @K-Meech!

In my opinion, the general issue is that ImageJ (1.x) modifies the look and feel at all, instead of respecting the current one. But there are also plugins out there that change the LaF globally. But modifying IJ1Helper to avoid as much as possible any changes to the global state is certainly desirable.

Do you think that remembering the current LaF and resetting it after this line: https://github.com/imagej/imagej-legacy/blob/0944272eb82ecc39ac9ceb8b7b63f6d6ce711155/src/main/java/net/imagej/legacy/IJ1Helper.java#L1353 ... would do it?

Or otherwise (and maybe better?), suggest a change to DirectoryChooser in the original ImageJ to be less intrusive (i.e. reset to UIManager.getLookAndFeel after having set to system look and feel just for the directory chooser)?

K-Meech commented 2 years ago

I think that would solve it yes - thanks @imagejan! Although, I imagine this would also have to be done for parts that use the ImageJ1 SaveDialog / OpenDialog as well - I think they do the same setting to system LAF.

Modifying it directly in the original ImageJ is probably the cleanest solution though! Where would I suggest this change? I'm happy to put a PR together, but I wasn't sure which repository to do it against?

imagejan commented 2 years ago

Let's ping @rasband here:

Wayne, do you think the DirectoryChooser can be modified in a way to reset the original look-and-feel after temporarily using the system look-and-feel for the folder choice dialog on Windows?

rasband commented 2 years ago

The latest ImageJ daily build (1.53o15) restores the original look and feel after temporarily using the system look and feel with Windows dialogs

The commit is at https://github.com/imagej/imagej1/commit/834d41b87163c879dc623ab2ee4d7121d6b2ea07

K-Meech commented 2 years ago

Great - thanks @rasband!