Skip to content

Conversation

@tferr
Copy link
Contributor

@tferr tferr commented Apr 4, 2022

@ctrueden, this PR is a proposal on how Flatlaf could be used as an optional L&F for Swing components in Fiji/SciJava in direct response to #61. The advantages of FlatLaf L&Fs are discussed in #61, and include:

  • Proper hiDPI scaling under Java 8 (this is mainly relevant to linux nowadays, but still relevant to other OSes: e.g., Native L&F on the mac scales everything without judgment, and so margins and borders become awkwardly exaggerated: this does not happen with FlatFlaf)
  • Much more modern and polished 'feel' relative to JVM default options
  • Several fixes for current Swing bugs and limitations that will not be fixed upstream
  • Many improvements like improved submenu navigation
  • Dark themes, that have been asked several times, e.g., in the script editor here, and here

This PR also includes a static method so that Look and Feel can be set more easily at startup. E.g., for Fjii the following
call in the StartupMacros could now be used to set the Look and Feel programmatically:

eval("js","importClass(Packages.org.scijava.ui.swing.options.OptionsLookAndFeel);OptionsLookAndFeel.setupLookAndFeel('FlatLaf Dark');") 

A couple of notes:

  • The flatlaf dependency is now being declared in this pom. I assume it should be declared in the parent pom-scijava? I imagine multiple releases of components would be needed, so if you don't mind I would pass that work onto you
  • If this gets merged, dark themes in Fiji would still remain problematic. In addition to the obvious fact that java.awt components will not change, there are currently some hardwired colors in several components (e.g., Console) that would need to be patched for dark themes to work properly. One would need to remove/adjust explicit setColor() references in the code. I am not doing that here, in case there are technical issues with adopting third-party L&F libraries that I am not foreseeing, and this cannot be merged.
  • I would actually vote for FlatLaf to be the default in Fiji (for the reasons above). However, on the Mac AWT and Swing are too intertwined, and currently choosing a flatlaf theme on MacOS, makes some components of the GenericDialog loose rounded edges. So it may be wise for the time being to consider the possibility of having it as a default only on Windows and Linux. I will open an issue there to see if this can be fixed.

@ctrueden ctrueden self-assigned this Apr 8, 2022
@ctrueden ctrueden self-requested a review April 8, 2022 21:22
@ctrueden
Copy link
Member

ctrueden commented Apr 8, 2022

@tferr This is great. Just a heads up that @hinerm did look at this briefly, and I am planning to look at this soon, but we both ran out of time for the moment.

@imagesc-bot
Copy link

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/flatlaf-in-fiji/68921/1

@imagesc-bot
Copy link

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/flatlaf-does-not-seem-to-work-with-fiji/69704/2

@imagesc-bot
Copy link

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/timeline-for-the-next-fiji-update/69640/7

This implements support for FlatLaf Look and Feels.
A static method is also included so that Look and Feel can be set at
startup. E.g., for Fjii the following call in the StartupMacros could be
used to set the Look and Feel programmatically at startup:

    eval("js","importClass(Packages.org.scijava.ui.swing.options.OptionsLookAndFeel);OptionsLookAndFeel.setupLookAndFeel('FlatLaf Dark');")

NB: there are currently several hardwired foreground/background colors in several classes (e.g., ConsolePanel) that will interfere with dark themes.

Signed-off-by: Curtis Rueden <[email protected]>
@ctrueden ctrueden merged commit d3373ff into scijava:master Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants