StageStyle and unified toolbars on the Mac
Mike Swingler
swingler at apple.com
Fri Mar 16 12:58:46 PDT 2012
We never did get this right in Swing...but I do see two ways to proceed:
The cheap way:
Don't paint the background yourself...just draw your controls on a transparent backdrop, and let the underlying window show through.
The better way:
Make a specific affordance for the toolbar, and "micro-embed" each control in it's own native NSToolbar item wrapper, which will give you the drag-reordering and correct hiding/showing/label/resizing behavior. This will allow the toolbar to "do the right thing" in fullscreen, and any other new mode the AppKit teams dreams up. You also get drag-from-toolbar window movement optimized in the window server with this approach. On other platforms, you could set policy to support features like tear-off, or ribbon button grouping.
Regards,
Mike Swingler
Apple Inc.
On Mar 16, 2012, at 12:01 PM, Jasper Potts wrote:
> On mac in XCode when you add a toolbar to top of a window it changes the look for the toolbar and the window automatically which looks like they merge. I don't know how the Apple JDK was achieving this look with swing but seems like we need special support in glass to make the OS draw the window decorations in a style that works with integrated tool bar. I don't know if JavaFX should be drawing transparent or drawing the bottom part of the toolbar its self. The issue is, if we draw in FX then getting it to match and look good may be hard but if OS draws then we need to tell it to draw and tell it the height of the toolbar.
>
> Jasper
>
> On Feb 23, 2012, at 9:30 AM, Richard Bair wrote:
>
>> Ok, I had been thinking it is just a normal decorated stage but transparent scene would be supported in that case. But I guess that is not enough because it draws the title bar wrong?
>>
>> On Feb 23, 2012, at 6:08 AM, Kevin Rushforth wrote:
>>
>>> In that case, maybe a separate property would be better, rather than a new StageStyle.
>>>
>>> -- Kevin
>>>
>>>
>>> Pavel Safrata wrote:
>>>> Kevin, if I understand the request correctly, the goal is to have system default background, not transparent one and not white one.
>>>> Pavel
>>>>
>>>> On 23.2.2012 14:47, Kevin Rushforth wrote:
>>>>> But since there will always be a Scene, wouldn't the following suffice?
>>>>>
>>>>> scene.setFill(Color.TRANSPARENT);
>>>>> stage.initStageStyle(StageStyle.DECORATED_TRANSPARENT);
>>>>> stage.setScene(scene);
>>>>>
>>>>> -- Kevin
>>>>>
>>>>>
>>>>> Stephen Winnall wrote:
>>>>>> Hi Kevin
>>>>>>
>>>>>> Whereas DECORATED_TRANSPARENT is also a possible desirable StageStyle, it wouldn't solve my problem. I just need DECORATED_WITHOUT_ANYTHING_ELSE (what I call bare boards). I think the point is that the Stage should not provide any sort of background, just what the native windowing system provides. Any background is a task for the Scene. In my view, instead of StageStyle, Stage should have provided #decorated, #transparent and #utility as three independent properties.
>>>>>>
>>>>>> Cheers
>>>>>> Steve
>>>>>>
>>>>>> On 23 Feb 2012, at 14:04, Kevin Rushforth wrote:
>>>>>>
>>>>>>> Thanks for filing this. I added the following comment to the JIRA:
>>>>>>>
>>>>>>> "One way to provide the desired capability would be to add StageStyle.DECORATED_TRANSPARENT, perhaps with a shorter name."
>>>>>>>
>>>>>>> -- Kevin
>>>>>>>
>>>>>>>
>>>>>>> Stephen Winnall wrote:
>>>>>>>> Given the text of the StageStyle Javadoc:
>>>>>>>>
>>>>>>>> " DECORATED
>>>>>>>> Defines a normal Stage style with a solid white background and platform decorations.
>>>>>>>>
>>>>>>>> TRANSPARENT
>>>>>>>> Defines a Stage style with a transparent background and no decorations.
>>>>>>>>
>>>>>>>> UNDECORATED
>>>>>>>> Defines a Stage style with a solid white background and no decorations.
>>>>>>>>
>>>>>>>> UTILITY
>>>>>>>> Defines a Stage style with a solid white background and minimal platform decorations used for a utility window.
>>>>>>>> ", I suspect the software is performing to spec., i.e. it's not a bug, strictly speaking :-)
>>>>>>>>
>>>>>>>> But I've submitted a feature report (I'm not that familiar with Jira and am new to JavaFX 2). You can see it at
>>>>>>>>
>>>>>>>> http://javafx-jira.kenai.com/browse/RT-19834
>>>>>>>>
>>>>>>>> Cheers
>>>>>>>> Steve
>>>>>>>>
>>>>>>>> On 22 Feb 2012, at 19:27, Richard Bair wrote:
>>>>>>>>
>>>>>>>>> Hmm, tried a transparent background but it didn't look like it would work. You may want to file a bug on this.
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>> Richard
>>>>>>>>>
>>>>>>>>> On Feb 22, 2012, at 7:04 AM, Stephen Winnall wrote:
>>>>>>>>>
>>>>>>>>>> I'm trying to create a unified toolbar on the Mac using JavaFX 2.1 b13. For those who don't know what that is, there's an example (albeit for Qt) at
>>>>>>>>>>
>>>>>>>>>> http://labs.qt.nokia.com/wp-content/uploads/2007/03/oldandunified.png
>>>>>>>>>>
>>>>>>>>>> (The bottom variant is the unified toolbar).
>>>>>>>>>>
>>>>>>>>>> I've managed this with Swing using Java 1.6. You do it by creating a JFrame with apple.awt.brushMetalLook set to TRUE and adding a transparent JToolBar at the top of the frame. It looks like this (after appropriate styling of the JToolBar and its buttons):
>>>>>>>>>>
>>>>>>>>>> http://yfrog.com/mrh1ydp
>>>>>>>>>>
>>>>>>>>>> You can then add further content (e.g. in a JPanel with a white background) after the toolbar.
>>>>>>>>>>
>>>>>>>>>> I can't see how to do this with JavaFX. In fact, I suspect it is impossible, because a Stage either has a solid white background or is completely transparent according to StageStyle. Is there any way of suppressing the sold white background? Why does a Stage have to have a white background at all? Shouldn't it just provide the boards (to stick with the theatre metaphor)? The white background belongs to the scene, surely?
>>>>>>>>>>
>>>>>>>>>> Perhaps there's another way of making a unified toolbar?
>>>>>>>>>>
>>>>>>>>>> Cheers
>>>>>>>>>> Steve
>>>>>>>>
>>>>>>
>>
>
More information about the openjfx-dev
mailing list