Custom Border for Callout Popup
Jonathan Giles
jonathan.giles at oracle.com
Mon May 7 15:39:06 PDT 2012
CSS is crucial to building custom controls, so the ability to expose
pseudoclass states and CSS properties is absolutely necessary. How we
go about exposing this as public API is still a topic that is up for
discussion.
-- Jonathan
On Tuesday, 8 May 2012 10:35:45 a.m., Kim Topley wrote:
> That's good news. Does the same apply to CSS - for example, will the
> styleable property classes (or something equivalent) be part of the
> public API?
>
> On Mon, May 7, 2012 at 6:32 PM, Jonathan Giles
> <jonathan.giles at oracle.com <mailto:jonathan.giles at oracle.com>> wrote:
>
> The intention is to fully support custom control development in
> JavaFX 3.0. As you note, today it is supported with the use of the
> Skin interface, but for real control development it is desirable
> to have a more fleshed-out base implementation (i.e. SkinBase and
> friends).
>
> -- Jonathan
>
>
> On Tuesday, 8 May 2012 10:23:03 a.m., Kim Topley wrote:
>
> Richard,
>
> Your comment about SkinBase here reminds me of a question that
> I have been
> meaning to ask for some time. Is it likely that the classes
> and methods
> necessary to write CSS-aware and skinnable custom controls
> will be made
> public any time soon (e.g. for JavaFX 3.0?). I have never yet
> worked on a
> project of any size that did not require lots of custom AWT or
> Swing
> controls. At the moment, if I wanted to do move such an
> application to
> JavaFX, or to write a library of custom controls for JavaFX, I
> would need
> to either use non-public APIs or swallow the expense of
> writing everything
> myself. Either way, I would then have to rewrite everything
> later when the
> real APIs are made available. Given that the skinning and CSS
> APIs seem to
> be quite stable now, and you already have many controls that
> are designed
> around them, how much of a problem would it be to have a quick
> review and
> make them all public?
>
> Kim
>
>
> On Mon, May 7, 2012 at 5:54 PM, Richard
> Bair<richard.bair at oracle.com
> <mailto:richard.bair at oracle.com>>__wrote:
>
> I think what I would have done would be to extend from
> PopupControl. Then
> write a new Skin for your Callout. The skin would add the
> path as one of
> its children, and whatever content is added to the content
> would then be
> added after the path. The path would have "managed" set to
> false. Then, in
> the layoutChildren() method of your Callout, you would
> reposition the path
> based on the current bounds and then call
> super.layoutChildren() which
> would position and layout the content.
>
> So something like:
>
> public class Callout extends PopupControl {
> ...
> }
>
> // Doh! SkinBase is a private class, but you can
> copy/paste it into your
> code if it is GPL+classpath..., otherwise just see what it
> does and write a
> fresh Skin that does the same
> public class CalloutSkin extends SkinBase<Callout> {
> private Path path;
> ...
> }
>
> Richard
>
>
>
> On May 7, 2012, at 12:32 PM, Werner Lehmann wrote:
>
> Hi,
>
> I am creating a popup for a callout. The callout is
> basically a
>
> rectangle with a small arrow/tail on the top right corner
> and a single node
> for its content. That node may resize later and the
> callout has to adjust.
> http://i49.tinypic.com/__21crux3.jpg
> <http://i49.tinypic.com/21crux3.jpg>
>
>
> First I tried to do this with -fx-shape and an svg
> path but without
>
> luck: could not make this work, never saw that shape.
> Unfortunately I also
> did not find any example... I suppose even an SVG path
> border would not
> resize automatically when the content changes - otherwise
> this would be
> exactly what I need ;-)
>
>
> Plan B is to use a Popup with a Path in the
> appropriate shape. This
>
> works but I am battling two things:
>
>
> 1. I have to know the popup content layout bounds
> before I can position
>
> the popup "right aligned". Currently solved by showing the
> popup offscreen
> (at -10000, 0) to get valid layoutBounds. Then I move it
> to the correct
> position. Is there a better way to get layoutBounds before
> showing a window?
>
>
> 2. When the content size changes, a similar problem
> arises: now I have
>
> to determine the new popup size, change the border Path to
> match the new
> size (PathElement binding might work here) and reposition
> the window. A
> resize animation would be nice, and some clipping will be
> needed also...
>
>
> This is when I got an idea: is it possible to create
> and use a custom
>
> border class? Looks as if I could extend
> com.sun.javafx.scene.layout.__region.Border... In this way
> I would get
> content clipping and resizing (position of arrow/tail must
> be adjusted) for
> free.
>
>
> Any thoughts?
>
> Thanks.
> Werner
>
>
>
>
More information about the openjfx-dev
mailing list