Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2017-02-02 06:35:49 -0500
committerTom Schindl2017-02-02 06:35:49 -0500
commit954b44122c704474d541e5f54332c318705aff13 (patch)
tree15b7c695bfc76c4b649d3cece23a14e703e33915
parent2ea7cb81313c1ee284f38ee755dcdfbdbbebf0bb (diff)
downloadorg.eclipse.efxclipse-2.6.x.tar.gz
org.eclipse.efxclipse-2.6.x.tar.xz
org.eclipse.efxclipse-2.6.x.zip
Ensure that the final properties never see a NaN2.6.x
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/internal/ContentView.java37
1 files changed, 35 insertions, 2 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/internal/ContentView.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/internal/ContentView.java
index 9acd9f356..7d8c85b0a 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/internal/ContentView.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/internal/ContentView.java
@@ -754,8 +754,29 @@ public class ContentView extends Pane {
bar.setMin(0);
DoubleBinding max = this.contentBody.widthProperty().subtract(widthProperty());
DoubleBinding factor = this.contentBody.widthProperty().divide(max);
- bar.maxProperty().bind(this.contentBody.widthProperty().divide(factor));
- bar.visibleAmountProperty().bind(widthProperty().divide(factor));
+
+// DoubleProperty santizedFactor = new SimpleDoubleProperty();
+// santizedFactor.set( Double.isNaN(factor.get()) ? 1.0 : factor.get() );
+// factor.addListener( (ob,ol,ne) -> {
+// santizedFactor.set( Double.isNaN(ne.doubleValue()) ? 1.0 : ne.doubleValue() );
+// } );
+
+ maxValue = this.contentBody.widthProperty().divide(factor);
+ visibleAmount = widthProperty().divide(factor);
+
+ updateValue(maxValue.get(), bar.maxProperty());
+ updateValue(visibleAmount.get(), bar.visibleAmountProperty());
+
+ maxValue.addListener( o -> {
+ updateValue(maxValue.get(), bar.maxProperty());
+ });
+ visibleAmount.addListener( o -> {
+ updateValue(visibleAmount.get(), bar.visibleAmountProperty());
+ });
+
+// bar.maxProperty().bind(maxValue);
+// bar.visibleAmountProperty().bind(visibleAmount);
+
this.offsetX.bind(bar.valueProperty());
this.widthProperty().addListener((x, o, n) -> {
@@ -765,6 +786,14 @@ public class ContentView extends Pane {
});
}
+ private void updateValue(double v, DoubleProperty p) {
+ if( Double.isNaN(v) ) {
+ p.set(0);
+ } else {
+ p.set(v);
+ }
+ }
+
public void bindVerticalScrollbar(ScrollBar bar) {
this.heightProperty().addListener((x, o, n) -> {
if (!Double.isNaN(bar.getMax()) && !Double.isNaN(bar.getValue())) {
@@ -788,6 +817,10 @@ public class ContentView extends Pane {
private int insertionMarkerIndex = -1;
+ private DoubleBinding maxValue;
+
+ private DoubleBinding visibleAmount;
+
public void updateInsertionMarkerIndex(int index) {
if (this.insertionMarkerIndex != index) {
this.insertionMarkerIndex = index;

Back to the top