gluonhq / scenebuilder

Scene Builder is a visual, drag 'n' drop, layout tool for designing JavaFX application user interfaces.
https://gluonhq.com/products/scene-builder/
Other
708 stars 218 forks source link

Custom Control question. #693

Open xdsswar opened 2 weeks ago

xdsswar commented 2 weeks ago

``Hi, first thanks for taking the time to read my question.

I'm developing a new Java-fx custom control that will facilitate responsive UI design by having size breakpoints , similar to bootstrap or any other web css lib for responsive design. My question is :

How can I archive the same as the AnchorPane does with the static methods setTopAnchor, setLeftAnchor, etc, the constraints , and be able to load that in SceneBuilder in order to set the values for each Node inside it. My control have a similar approach to set properties for each child node independently, like col-span, col-offset, etc, but I'm unable to get that to work in SceneBuilder. The only way I was able to do that was by creating a Node Wrapper and declaring the properties inside that class, but that means adding another Node extra for each child and I don't wan that . If you guys use a specific way to do that and can point me in the right direction I will appreciate it . Thanks

Example of custom Node props:

/**
 * Column count for extra small screens.
 */
private static final String EXTRA_SMALL_COLS = "xs-cols";

/**
 * Sets the column span for extra small screens.
 *
 * @param node The node to set the column span on.
 * @param value The column span value.
 */
public static void setXsColSpan(Node node, Double value) {
    setConstraint(node, EXTRA_SMALL_COLS, value);
}

/**
 * Retrieves the column span for extra small screens.
 *
 * @param node The node to get the column span from.
 * @return The column span value.
 */
public static Integer getXsColSpan(Node node) {
    return (Integer) getConstraint(node, EXTRA_SMALL_COLS);
}
xdsswar commented 2 weeks ago

Maybe using reflection I'm able to place the properties 😵

Oliver-Loeffler commented 2 weeks ago

Not sure yet how I would do that, but its a thing where I'll dive into.

xdsswar commented 2 weeks ago

I have this demo where you can see the layout in action and its properties

https://youtu.be/Mpv68iuaPCs