Now CONTAINER resizes automatically to ScrollPane bounds
This commit is contained in:
parent
4e5980c175
commit
124df8489b
|
@ -2,11 +2,17 @@ package Classes.css.user;
|
|||
|
||||
import Classes.css.core.Context;
|
||||
import Classes.css.core.Ruleset;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.geometry.Bounds;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
|
||||
public class ContainerScrollStyleSheet{
|
||||
|
||||
/* Builds all necessary CSS/layout rules */
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public ContainerScrollStyleSheet(Node target) throws Exception{
|
||||
|
||||
/* (1) Set rules */
|
||||
|
@ -16,6 +22,22 @@ public class ContainerScrollStyleSheet{
|
|||
.add("right", 0)
|
||||
// .add("pref-height", )
|
||||
.apply();
|
||||
|
||||
/* (2) Manage dynamic 1st children bounds to it */
|
||||
ScrollPane spane = (ScrollPane) target;
|
||||
|
||||
spane.layoutBoundsProperty().addListener(new ChangeListener(){
|
||||
|
||||
@Override
|
||||
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
|
||||
System.out.println(spane.getLayoutBounds().getWidth());
|
||||
FlowPane child = (FlowPane) spane.getContent();
|
||||
child.setPrefWidth( spane.getLayoutBounds().getWidth() );
|
||||
child.setPrefHeight( spane.getLayoutBounds().getHeight() );
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@
|
|||
</children></VBox>
|
||||
<ScrollPane id="scroll_container" fx:id="scroll_container" hbarPolicy="NEVER" pickOnBounds="false" prefHeight="651.0" prefWidth="1015.0" style="-fx-background-color: transparent;" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="49.0">
|
||||
<content>
|
||||
<FlowPane id="container" fx:id="container" alignment="TOP_CENTER" columnHalignment="CENTER" prefHeight="650.0" prefWidth="1000.0" prefWrapLength="1000.0" stylesheets="@../css/container.css">
|
||||
<FlowPane id="container" fx:id="container" alignment="TOP_CENTER" columnHalignment="CENTER" prefHeight="650.0" prefWrapLength="1000.0" stylesheets="@../css/container.css">
|
||||
<children>
|
||||
<TextField id="mag_searchbar" fx:id="mag_searchbar" prefHeight="26.0" prefWidth="759.0" promptText="Search...">
|
||||
<FlowPane.margin>
|
||||
|
|
Loading…
Reference in New Issue