Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Support for Runtime LAF Switching #77

Closed
wants to merge 4 commits into from
Closed

Improved Support for Runtime LAF Switching #77

wants to merge 4 commits into from

Conversation

bobbylight
Copy link
Contributor

This patch fixes the majority of issues when switching from WebLAF to another LAF at runtime. There are still a couple of minor issues I haven't figured out yet, but this patch fixes the majority of things.

What's included:

  • Fixed bug - keep user borders if they're instances of UIResource,
    not BorderUIResource
  • In UI delegate classes, set opaque property with LookAndFeel.installProperty()
    to avoid overriding possible values set by the developer.
  • Don't call setOpaque(true) in UI delegate uninstall() methods; standard
    LAFs don't do this either. Can cause issues.
  • WebButtonUI should remember previous values of several button properties
    so it can revert them back to the previous values.
  • WebListUI should set colors wrapped in ColorUIResources.
  • Label foreground and disabled foreground set in UIDefaults table for
    convenience.
  • Removed unnecessary code in WebTextPaneUI.
  • WeblafBorder now extends EmptyBorderUIResource.
  • Table.scrollPaneBorder set to null in UIDefaults to avoid it becoming
    a bevel border due to the changes above.
  • Remove custom minimize/maximize buttons when uninstalling WebRootPaneUI

BTW - this LAF is super easy to configure and use, good job! Much cleaner than Substance.

@mgarin
Copy link
Owner

mgarin commented Jan 22, 2014

Thanks for these changes, great job :)
Most of them indeed fix some of L&F switching issues.

Though i have a few notes...

Border update

In updateBorder methods within UIs there is no point for a separate component.getBorder () != null check - it can be included in the SwingUtils.isPreserveBorders method (and it is already included as i recall).

L&F defaults

A few changes in L&F defaults might also cause some issues.

It is incorrect to put Viewport background from just table constant:

table.put ( "Viewport.background", WebTableStyle.background );

As all other components placed within scroll pane will get the same background. And also, I didn't add any specific to Viewport because I didn't actually want to change the default one used by Viewport.

And about this one:

table.put ( "Table.scrollPaneBorder", null ); // Force JScrollPane to keep its border

I didn't really understand how will that force JScrollPane to keep its border :)
WebScrollPaneUI also sets its own WebLaF border to style things properly.

Other changes

All other changes, as i said in the beginning, seems to be fine :)
Though i will check whether they will work fine or will cause some issues.
It is hard to say right away as i might be missing something important.

Also some of these changes are already deprecated as i have added similar fixes into the local WebLaF version that i didn't yet commit/release. I think i will add your changes manually (not through the pull) so you can leave it as it is now and simply update your local version later after i release the update.

@mgarin
Copy link
Owner

mgarin commented Jan 22, 2014

BTW - this LAF is super easy to configure and use, good job! Much cleaner than Substance.

Actually it is dirty as hell :)
But it will become clean after the StyleManager release - all the settings will be unified.
I will also remove a lot of unnecessary things from the code and will make it faster.

@ghost ghost assigned mgarin Jan 22, 2014
@bobbylight
Copy link
Contributor Author

Responses to your response:

  • Extra null checks in UI delegates: you're right, those aren't necessary when the null check is also done in isPreserveBorders. I accidentally left that in when refactoring stuff, meant to take it out before submitting the patch.
  • About setting a default for Viewport.background - I figured it was OK to do as it's done in BasicLookAndFeel also. I did this specifically for the scenario where a JTable is in a JScrollPane, but isn't "tall" enough to fill the scroll pane's contents. Without it you'd see a different color between the standard JTable row background and the viewport background. I think the typical approach to "fixing" this is to call table.setFillsViewportHeight(), which applications can typically do, but I saw you specifically set that property to false in WebTableUI. Changing that to true would be another, perhaps cleaner, "fix" for this, but I didn't know if there was a specific reason you defaulted that property to false. Anyway, I suppose this change isn't required either since there is a 1-line fix for applications.
  • As for Table.scrollPaneBorder being set to null, this was needed after causing the WebBorders to be UIResources. When a JTable is added to a JScrollPane, it checks whether the scroll pane's border is a UIResource. With this patch, that is true. In this case, JTable sets the JScrollPane's border to an instance of Table.scrollPaneBorder, if that property is non-null. BasicLookAndFeel defaults that property to an ugly bevel border, so you get an inconsistent border for JTables in JScrollPanes. Setting that property to null will cause the JScrollPane to keep its standard WebLAF border.

Of the three points above, I think the third is the most important one. :)

@mgarin
Copy link
Owner

mgarin commented Jan 22, 2014

Yes, indeed, the third one is most important and a bit tricky :)
I will be adding these changes manually into upcoming update and will check them once more.

mgarin added a commit that referenced this pull request Jan 29, 2014
#70 - WebRootPaneUI fix for empty title and window drag
#36 - More fixes for Swing borders honor option
WebRootPaneUI fix for resizable window property changes
Empty title and max title width added into WebRootPaneUI style settings
WebImageDrop JavaDoc and small improvements added
Disabled icons caching added to improve performance
ReflectUtils type check for null arguments fix
WebComboBoxUI wheel scrolling through choices fix
Additional "show" methods for WebPopOver
Background color can now be easily set for WebPopOver
WebSplitButtonUI creation fix
WebToolBarUI incorrect buttons border updates fix
FormLayout improvements
Small readme updates
mgarin added a commit that referenced this pull request Jan 29, 2014
#77 - Even more changes for Swing UI properties
Improvements made to Painter interface
Full painter support implemented for WebScrollBarUI
A lot of improvements done to WebScrollBarUI
WebListUI rollover cell display fixed
WebFileChooserPanel history list file name length limit added
WebSplitButton UI class name fixed
Various small JavaDoc fixes
@mgarin
Copy link
Owner

mgarin commented Jan 30, 2014

I have merged almost all of these changes in v1.26 release and also added more similar changes to UIs you have missed. Thanks again for those improvements :)

@mgarin mgarin closed this Jan 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants