Split button painting issues

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Split button painting issues

Postby kirillcool » Thu Jul 24, 2008 11:52 am

A split button marked with alwaysDropdown=true still shows the separator under toolbox and flat styles.

Thanks
Kirill
kirillcool
 
Posts: 19
Joined: Wed Sep 21, 2005 12:45 am

Postby JIDE Support » Thu Jul 24, 2008 1:03 pm

I see. Will fix it.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby kirillcool » Thu Jul 24, 2008 1:25 pm

Looking at the source code of BasicJideSplitButtonUI.paintBackground makes me a little dizzy. Is the current hierarchy of JideSplitButton a temporary thing? It extends JideMenu which extends a JMenu - i thought that JMenus are supposed to work only inside a JMenuBar or JPopupMenu.

That aside, there are unnecessary checks in BasicJideSplitButtonUI.paintBackground - once you cast the menuItem to JideSplitButton in line 211, there is no need to test if it's instanceof ButtonStyle or JMenu later on. Also, does it ever get inside the isTopLevelMenu test in line 279? Can you put a JideSplitButton inside a menu bar? The same question applies to paintText in line 769.

Last question on painting the arrow - this isn't really part of background painting. Just as you have a separate paintIcon and paintText, why not paintArrow as well?

Thanks
Kirill
kirillcool
 
Posts: 19
Joined: Wed Sep 21, 2005 12:45 am

Postby JIDE Support » Thu Jul 24, 2008 1:37 pm

Wll, no one said JMenu only can be used in JMenuBar or JPopupMenu. JideSplitButton has features similar to what JMenu has so why not leverage that.

It is pretty complex thing when you deal with different parents. JideSplitPane and JideMenu, not only can be used on JMenuBar, JPopupMenu, but also can be used JToolBar, CommandBar or any JPanel. For example, JMenu will have a drop down arrow if it is not on JMenuBar. To be frank, that's still not completely done.

The paint arrow shouldn't be part of the paint background. It should be in its own method. Actually I would love to see a better way to paint the arrow and the divider line. It doesn't work very good.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby JIDE Support » Thu Jul 24, 2008 1:41 pm

BTW, extra cast and paintArrow are fixed and checked in.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby kirillcool » Thu Jul 24, 2008 1:49 pm

So the current painting sequence is:

1. Paint arrow pointing to the right if it's not on menu bar
2. Fill the background if it's opaque - which effectively erases the arrow from 1
3. Paint the background and the border (including the separator?)
4. Paint arrow pointing to the bottom

I don't get number 1 - what is it for?
kirillcool
 
Posts: 19
Joined: Wed Sep 21, 2005 12:45 am

Postby JIDE Support » Thu Jul 24, 2008 1:52 pm

If you look at some MS application when JMenu or split button on a popup menu, you will see the arrow points to the right. The best way to see is to run Office 2003 and customize the menu to put a split button there.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby kirillcool » Thu Jul 24, 2008 1:55 pm

So what happens when you rollover that menu? Wouldn't the arrow be hidden by the background? And wouldn't that area have the downward-pointing arrow since that is the last thing painted in paintBackground (old implementation)?

I just don't see how !((JMenu) menuItem).isTopLevelMenu()) applies to the case that you gave. Wouldn't it be menuItem.getParent() instanceof JPopupMenu and then based on that you paint either vertical or horizontal arrow?
kirillcool
 
Posts: 19
Joined: Wed Sep 21, 2005 12:45 am

Postby JIDE Support » Thu Jul 24, 2008 2:02 pm

You probably missed the return statement in if(isTopLevelMenu).

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby kirillcool » Thu Jul 24, 2008 2:32 pm

So you overrode the implementation of isTopLevelMenu in JideMenu to mean a different thing in this context. If i place a split button in a simple panel, that button is considered to be a top-level menu. Kind of makes sense.

So what happens when you place a split button in a popup menu? Don't you paint the arrow icon twice? Once in VsnetMenuUI (line 132) when the arrow is only the outline, and the second time in BasicJideSplitButtonUI when the arrow is filled?
kirillcool
 
Posts: 19
Joined: Wed Sep 21, 2005 12:45 am

Postby JIDE Support » Thu Jul 24, 2008 3:12 pm

I don't think so. We shortcut it at the beginning of VsnetMenuUI#paintBackground and let VsnetMenuItemUI to paint the background.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby kirillcool » Thu Jul 24, 2008 5:03 pm

This kind of brings me back to the hierarchy of JideSplitButton. You said "JideSplitButton has features similar to what JMenu has so why not leverage that". I don't really see it that way, having implemented a split button in Flamingo.

Yes, a menu has text, icon and arrow. Yes, a menu can show a popup menu. But that's where it ends. The arrow points in a different direction, a menu (JMenu) doesn't have an action area, the popup is shown at a different location and the menu doesn't have a button style (toolbar / toolbox / flat). IMHO, the current hierarchy results in quite convoluted flow of painting in the UI delegates.

If you want to put a split button in a popup menu - why just not put a JMenu there? It's not like you can have the same Swing component under different parents in any case.

Thanks
Kirill
kirillcool
 
Posts: 19
Joined: Wed Sep 21, 2005 12:45 am

Postby JIDE Support » Thu Jul 24, 2008 5:25 pm

JideSplitButton has a drop down menu like JMenu but also has button. I can't use JMenu to replace JideSplitButton as JMenu doesn't have a button that I can click. Or I should say JideSplitButton with setAlwaysDropdown(true) == JMenu. This actually further proves JideSplitButton and JMenu are related. This is not surprise as JMenu also extends JMenuItem and it uses MenuItemUI paintBackground as well in certain cases. I agree it is kind of messy but what else we can do.

Sure, you don't have to make JideSplitButton extending JMenu but what you will miss is the menu feature and you have to keep track of the menu selection yourself instead of letting MenuSelectionManager do it for you. For example, in your implemention of the split button, can it be added to JPopupMenu. If yes, how do you handle the menu selection?
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby kirillcool » Thu Jul 24, 2008 5:37 pm

So the scenario that you're addressing is having a menu (in popup menu) that has a separate action and popup areas? The only place that i can think of in Office 2007 (don't know about older versions) is the main Office menu. But it can hardly be qualified as a popup menu since it has the left "main selection" pane and the right "contextual pane".

To your question - no, Flamingo's split button can not be put on a popup menu, and i don't see a compelling scenario to break the existing user expectations from a menu with an arrow (clicking anywhere in that menu brings up the popup menu).

And once you can't put this component in a popup menu, you don't need to track the menu selections. You just show a JPopupMenu under it and call its show() method.

It's just two different approaches, i just don't see a compelling use case that justifies the complexity of the current hierarchy. Am i missing one?

Thanks
Kirill
kirillcool
 
Posts: 19
Joined: Wed Sep 21, 2005 12:45 am

Postby JIDE Support » Thu Jul 24, 2008 5:46 pm

I was really coming from a different perspective when I designed JIDE Action Framework, in many ways, affluenced by MS Office's menu system. It does use split buttons in many places on popup menu. Office 2007 used even more. Once I had observed this use case and had it in mind, it is hard to make me not thinking that JideSplitButton is a JMenu, no matter how hard it is to implement.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby kirillcool » Thu Jul 24, 2008 11:13 pm

You're right in that Office 2007 provides an "actionable" menus in the popup menu on the canvas (by the way, couldn't find any on the ribbon itself), but it looks that those actionable menus have a richer popup than the usual menus.

Just open an empty document in Word and right-click somewhere on the canvas. The two actionable (split) menus - Bullets and Numbering show rich popups that show something similar to Flamingo's command button panels (icons separated into multiple groups). The three other menus (Synonims, Translate, Thesaurus) show simple popup menus with one column of menu items.
kirillcool
 
Posts: 19
Joined: Wed Sep 21, 2005 12:45 am

Postby JIDE Support » Wed Jul 30, 2008 6:46 pm

A split button marked with alwaysDropdown=true still shows the separator under toolbox and flat styles.
Just so you know, this is fixed in 2.2.12 release.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 95 guests