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

JSplitPane setOneTouchExpandable useful control? #198

Closed
kingthorin opened this issue Oct 28, 2020 · 9 comments
Closed

JSplitPane setOneTouchExpandable useful control? #198

kingthorin opened this issue Oct 28, 2020 · 9 comments
Milestone

Comments

@kingthorin
Copy link
Contributor

kingthorin commented Oct 28, 2020

Is there a way to control the size or visibility of the "oneTouchExpandable" controls on a JSplitPane?

Here's a screenshot, note the little arrow'ish controls in the red box:
image

Note, if I'm being totally fair I don't think this issue is limited to FlatLaf. (I believe at one point I tested this and found the controls minimally useful in Nimbus as well.)

@DevCharly
Copy link
Collaborator

The "oneTouchExpandable" controls are not visible by default in FlatLaf.
So there must be something like mySplitPane.setOneTouchExpandable(true)
in your code, which you can remove to hide the controls.

The reason for the cut-off arrow painting is that the divider size seems to be
changed to 3px in you app, right? (default is 5px in FlatLaf)

I'll try to optimize arrow painting for the small size...

@kingthorin
Copy link
Contributor Author

Yes that's how I'd turned it on. I was hoping there was a useful option because I know it was problematic when we were using Nimbus. We recently switched to FlatLaf, I don't think anything would be overriding the divider size but I'll look into it. Thanks for the tip.

@DevCharly
Copy link
Collaborator

There are several places in zaproxy where the divider size is set to 3px:
https://github.com/zaproxy/zaproxy/search?q=setDividerSize

There are some options to control the size and the position of the controls.

With UIManager.put( "SplitPane.oneTouchButtonOffset", 20 ) you can change the position.
E.g. 20px between top edge of split pane and the controls.

With UIManager.put( "SplitPane.oneTouchButtonSize", 10 ) you can change the size of the controls,
but this is limited by the divider size.

@kingthorin
Copy link
Contributor Author

@DevCharly thanks that was above and beyond! I woulda looked. I should have been more specific in my earlier reply, I was fairly certain it wasn't overridden in the class where I turned on the option, but I hadn't looked for other impacts. Thanks!

@kingthorin
Copy link
Contributor Author

I'll try to optimize arrow painting for the small size...

If you want to do this for others that's cool, but please don't worry about it for our use, I think 5px looks fine. (At least that's my opinion, I haven't asked others yet 😉 ).

@kingthorin
Copy link
Contributor Author

Do you know of a way to set a tooltips (hover text) for those controls? [I know that's totally out of scope for your LaF project so I'll understand if you don't know or choose not to comment.]

@DevCharly
Copy link
Collaborator

There is no API or resource file to set tooltip on the arrow, but I can add something.

The question is: how many different texts do we need?
The arrow button functionality depends on the state of the divider.

When divider is in the middle:

  • left arrow button does "collapse left"
  • right arrow button does "collapse right"

When left is collapsed (divider on left edge):

  • left arrow button does nothing (IMO should be better disabled or hidden)
  • right arrow button does "expand left"

When right is collapsed (divider on right edge):

  • left arrow button does "expand right"
  • right arrow button does nothing

So 4 texts are needed for horizontal split panes and another 4 for vertical split panes.
Or do you have a better idea for the texts?

@kingthorin
Copy link
Contributor Author

That’d be totally wonderful. I kinda figured if there was an API it’d only support one message like most Java controls. So I was picturing a generic message “Expand or collapse abc pane or xyz pane.”.

@DevCharly
Copy link
Collaborator

Now implemented in master branch:

  • arrow buttons now have tooltips
  • when collapsed, useless arrow buttons are now hidden
  • made arrow button slightly larger to avoid cut arrows at small divider sizes

grafik

grafik

grafik

The default tooltip texts (shown in above screenshots) are:

SplitPaneDivider.collapseLeftToolTipText=Collapse Left Pane
SplitPaneDivider.collapseRightToolTipText=Collapse Right Pane
SplitPaneDivider.collapseTopToolTipText=Collapse Top Pane
SplitPaneDivider.collapseBottomToolTipText=Collapse Bottom Pane
SplitPaneDivider.expandLeftToolTipText=Expand Left Pane
SplitPaneDivider.expandRightToolTipText=Expand Right Pane
SplitPaneDivider.expandTopToolTipText=Expand Top Pane
SplitPaneDivider.expandBottomToolTipText=Expand Bottom Pane

If you want change them for all split panes in the application use:

UIManager.put( "SplitPaneDivider.collapseLeftToolTipText", "Collapse left view" );

If you want change them for single splitpane use:

splitPane1.putClientProperty( "SplitPaneDivider.collapseLeftToolTipText", "Collapse tree view" );

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

No branches or pull requests

2 participants