-
Bug
-
Resolution: Fixed
-
P3
-
fx2.0
-
None
-
Mac & Windows
When styling a region from css you can specify one or more background images. For each of those images there are a number of settings such as -fx-background-position and -fx-background-size. Both of those can accept absolute sizes such as "10px" or percentage sizes like "100%". For example in Ensemble we want to style the toolbars with background images that stretched to fill, 100% width and 100% height.
#page-toolbar {
-fx-background-image: url("images/mid-bar-right.png");
-fx-background-size: 100% 100%;
}
I have investigated how we handle this and we have 2 issues with the current implementation.
(1) In com.sun.javafx.scene.layout.region.BackgroundImage we only have two propertyies to state if sizes are propotional(percentages) or not:
private boolean proportionalPosition = true;
private boolean proportionalSize = true;
That will not work with css like: -fx-background-size: 10px 100%; which is valid. So we need a boolean per property: x, y, width and height.
(2) We convert from proportional(percentage) to pixel units in:
javafx.scene.layout.Region
@Override public void impl_updatePG() {
line 1350
That will not work as it dosn't reflect the changing size of the region. ie if the region grows from 100px wide to 200px wide , a 100% width background image needs to grow to fill.
There are two ways we could fix this, one is to cause a recalculate/sync when region's size changes but the performance of that worries me. The better solution I think is to pass the proportional booleans and values done to the SG/NG layer and multiply them out at render time.
#page-toolbar {
-fx-background-image: url("images/mid-bar-right.png");
-fx-background-size: 100% 100%;
}
I have investigated how we handle this and we have 2 issues with the current implementation.
(1) In com.sun.javafx.scene.layout.region.BackgroundImage we only have two propertyies to state if sizes are propotional(percentages) or not:
private boolean proportionalPosition = true;
private boolean proportionalSize = true;
That will not work with css like: -fx-background-size: 10px 100%; which is valid. So we need a boolean per property: x, y, width and height.
(2) We convert from proportional(percentage) to pixel units in:
javafx.scene.layout.Region
@Override public void impl_updatePG() {
line 1350
That will not work as it dosn't reflect the changing size of the region. ie if the region grows from 100px wide to 200px wide , a 100% width background image needs to grow to fill.
There are two ways we could fix this, one is to cause a recalculate/sync when region's size changes but the performance of that worries me. The better solution I think is to pass the proportional booleans and values done to the SG/NG layer and multiply them out at render time.
- blocks
-
JDK-8115809 Rectangle ignores style set via setStyle()
- Closed
- relates to
-
JDK-8114333 Region: css "-fx-background-size" with percents doesn't work properly with background images
- Closed