Skip to content

Commit

Permalink
Trying to fix SceneBuilder.
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainBertrand committed Jul 11, 2023
1 parent bc66cad commit 48f8caf
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
4 changes: 1 addition & 3 deletions jfoenix/src/main/java/com/jfoenix/controls/JFXTooltip.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.jfoenix.transitions.JFXKeyFrame;
import com.jfoenix.transitions.JFXKeyValue;
import com.sun.javafx.event.EventHandlerManager;
import com.sun.javafx.scene.NodeHelper;

import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
Expand Down Expand Up @@ -619,8 +618,7 @@ private void ensureHoveredNodeIsVisible(Runnable visibleRunnable)
final Window owner = getWindow(hoveredNode);
if (owner != null && owner.isShowing())
{
final boolean treeVisible = NodeHelper.isTreeVisible(hoveredNode);
if (treeVisible)
if (hoveredNode.isVisible())
{
visibleRunnable.run();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.jfoenix.controls.JFXProgressBar;
import com.jfoenix.utils.JFXNodeUtils;
import com.sun.javafx.scene.NodeHelper;

import javafx.animation.Animation;
import javafx.animation.Interpolator;
Expand Down Expand Up @@ -144,7 +143,7 @@ protected void layoutChildren(double x, double y, double w, double h)
if (getSkinnable().isIndeterminate())
{
createIndeterminateTimeline();
if (NodeHelper.isTreeShowing(getSkinnable()))
if (getSkinnable().isVisible() && getSkinnable().getScene() != null)
{
indeterminateTransition.play();
}
Expand Down
44 changes: 36 additions & 8 deletions jfoenix/src/main/java/com/jfoenix/skins/JFXSpinnerSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
package com.jfoenix.skins;

import com.jfoenix.controls.JFXSpinner;
import com.sun.javafx.scene.NodeHelper;

import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.beans.binding.Bindings;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.SkinBase;
import javafx.scene.layout.Region;
Expand Down Expand Up @@ -94,6 +95,7 @@ public JFXSpinnerSkin(JFXSpinner control)
fillRect = new Rectangle();
fillRect.setFill(Color.TRANSPARENT);
text = new Text();
text.setStyle("-fx-font-size:null");
text.getStyleClass().setAll("text", "percentage");
final Group group = new Group(fillRect, track, arc, text);
group.setManaged(false);
Expand All @@ -104,7 +106,7 @@ public JFXSpinnerSkin(JFXSpinner control)
// register listeners
registerChangeListener(control.indeterminateProperty(), obs -> initialize());
registerChangeListener(control.progressProperty(), obs -> updateProgress());
// registerChangeListener(NodeHelper.treeShowingProperty(control), obs -> updateAnimation());
registerChangeListener(Bindings.selectBoolean(control.sceneProperty(), "window", "showing"), obs -> updateAnimation());
registerChangeListener(control.sceneProperty(), obs -> updateAnimation());
}

Expand All @@ -115,7 +117,7 @@ private void initialize()
if (timeline == null)
{
createTransition();
if (NodeHelper.isTreeShowing(getSkinnable()))
if (isShowing(getSkinnable()))
{
timeline.play();
}
Expand Down Expand Up @@ -170,7 +172,8 @@ private void pauseTimeline(boolean pause)
private void updateAnimation()
{
ProgressIndicator control = getSkinnable();
final boolean isTreeShowing = NodeHelper.isTreeShowing(control) && control.getScene() != null;
final boolean isTreeShowing = isShowing(control);

if (timeline != null)
{
pauseTimeline(!isTreeShowing);
Expand All @@ -181,6 +184,17 @@ else if (isTreeShowing)
}
}

// TODO Not sure if Node.isVisible() actually accounts for a parent not visible
private boolean isShowing(Node control)
{
return control.isVisible() && control.getScene() != null;
}

private double computeSize()
{
return control.getRadius() * 2 + arc.getStrokeWidth() * 2;
}

@Override
protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
{
Expand All @@ -190,7 +204,7 @@ protected double computeMaxHeight(double width, double topInset, double rightIns
}
else
{
return control.getRadius() * 2 + arc.getStrokeWidth() * 2;
return computeSize();
}
}

Expand All @@ -203,20 +217,34 @@ protected double computeMaxWidth(double height, double topInset, double rightIns
}
else
{
return control.getRadius() * 2 + arc.getStrokeWidth() * 2;
return computeSize();
}
}

@Override
protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
{
return arcPane.prefWidth(-1);
if (Region.USE_COMPUTED_SIZE == control.getRadius())
{
return arcPane.prefWidth(-1);
}
else
{
return computeSize();
}
}

@Override
protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
{
return arcPane.prefHeight(-1);
if (Region.USE_COMPUTED_SIZE == control.getRadius())
{
return arcPane.prefHeight(-1);
}
else
{
return computeSize();
}
}

/**
Expand Down
3 changes: 1 addition & 2 deletions jfoenix/src/main/java/com/jfoenix/utils/JFXHighlighter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Set;

import com.sun.javafx.geom.RectBounds;
import com.sun.javafx.scene.NodeHelper;
import com.sun.javafx.scene.text.TextLayout;
import com.sun.javafx.scene.text.TextLine;

Expand Down Expand Up @@ -106,7 +105,7 @@ public synchronized void highlight(Parent pane, String query)
{
Text text = ((Text) node);
final int beginIndex = text.getText().toLowerCase().indexOf(query.toLowerCase());
if (beginIndex > -1 && NodeHelper.isTreeVisible(node))
if (beginIndex > -1 && node.isVisible() && node.getScene() != null)
{
ArrayList<Bounds> boundingBoxes = getMatchingBounds(query, text);
ArrayList<Rectangle> rectangles = new ArrayList<>();
Expand Down

0 comments on commit 48f8caf

Please sign in to comment.