Skip to content

Commit

Permalink
RFE: Auto height (#944)
Browse files Browse the repository at this point in the history
Added auto height property and functionality
  • Loading branch information
Jugen authored Aug 13, 2020
1 parent bec3e38 commit 10849d9
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,40 @@ public void dispose() {
* *
* ********************************************************************** */

private BooleanProperty autoHeightProp = new SimpleBooleanProperty();

public BooleanProperty autoHeightProperty() {
return autoHeightProp;
}
public void setAutoHeight( boolean value ) {
autoHeightProp.set( value );
}
public boolean isAutoHeight() {
return autoHeightProp.get();
}

@Override
protected double computePrefHeight( double width )
{
if ( autoHeightProp.get() )
{
if ( getWidth() == 0.0 ) Platform.runLater( () -> requestLayout() );
else
{
double height = 0.0;
Insets in = getInsets();

for ( int p = 0; p < getParagraphs().size(); p++ ) {
height += getCell( p ).getHeight();
}
if ( height > 0.0 ) {
return height + in.getTop() + in.getBottom();
}
}
}
return super.computePrefHeight( width );
}

@Override
protected void layoutChildren() {
Insets ins = getInsets();
Expand Down

0 comments on commit 10849d9

Please sign in to comment.