Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface NodeResolver {
/// @param selector the CSS selector to find the node
/// @return a resolver that finds the node by selector
static NodeResolver selector(@NonNull String selector) {
return scene -> scene.getRoot().lookupAll(selector).stream().filter(NodeHelper::isTreeVisible).findFirst();
return scene -> scene.getRoot().lookupAll(selector).stream().filter(NodeResolver::isVisible).findFirst();
}

/// Creates a resolver that finds a node by its fx:id. The returned node is
Expand All @@ -62,7 +62,7 @@ static NodeResolver buttonWithGraphic(IconTheme.JabRefIcons glyph) {
.concat(scene.getRoot().lookupAll(".button").stream(),
scene.getRoot().lookupAll(".icon-button").stream())
.filter(node -> {
if (!(node instanceof ButtonBase button) || !NodeHelper.isTreeVisible(button)) {
if (!(node instanceof ButtonBase button) || !NodeResolver.isVisible(button)) {
return false;
}
Node graphic = button.getGraphic();
Expand All @@ -79,7 +79,7 @@ static NodeResolver buttonWithGraphic(IconTheme.JabRefIcons glyph) {
/// @return a resolver that finds the node matching the predicate
static NodeResolver predicate(@NonNull Predicate<Node> predicate) {
return scene -> Optional.ofNullable(findNode(scene.getRoot(),
node -> NodeHelper.isTreeVisible(node) && predicate.test(node)));
node -> NodeResolver.isVisible(node) && predicate.test(node)));
}

/// Creates a resolver that finds a button by its StandardAction. The button is
Expand All @@ -90,7 +90,7 @@ static NodeResolver predicate(@NonNull Predicate<Node> predicate) {
/// @return a resolver that finds the button by action
static NodeResolver action(@NonNull StandardActions action) {
return scene -> Optional.ofNullable(findNode(scene.getRoot(), node -> {
if (!(node instanceof ButtonBase button) || !NodeHelper.isTreeVisible(button)) {
if (!(node instanceof ButtonBase button) || !NodeResolver.isVisible(button)) {
return false;
}

Expand Down Expand Up @@ -165,7 +165,7 @@ static NodeResolver menuItem(@NonNull String key) {
}

return menu.getItems().stream()
.filter(item -> NodeHelper.isTreeVisible(item.getStyleableNode()))
.filter(item -> NodeResolver.isVisible(item.getStyleableNode()))
.filter(item -> Optional
.ofNullable(item.getText())
.map(str -> str.contains(Localization.lang(key)))
Expand All @@ -191,4 +191,8 @@ private static Node findNode(@NonNull Node root, @NonNull Predicate<Node> predic

return null;
}

private static boolean isVisible(@Nullable Node node) {
return node != null && NodeHelper.isTreeVisible(node);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ protected void setupListeners(@NonNull Node node) {
setupWindowListeners(scene.getWindow());
}

node.sceneProperty().addListener((_, _, newScene) -> {
subscriptions.add(EasyBind.listen(node.sceneProperty(), (_, _, newScene) -> {
if (newScene != null) {
subscriptions.add(EasyBind.listen(newScene.widthProperty(), debouncedUpdater));
subscriptions.add(EasyBind.listen(newScene.heightProperty(), debouncedUpdater));
setupWindowListeners(newScene.getWindow());
}
});
}));
}

protected void setupPaneListeners() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import org.jabref.gui.walkthrough.utils.WalkthroughUtils;

import com.tobiasdiez.easybind.EasyBind;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -76,10 +77,10 @@ public void transitionTo(@NonNull Node newNode) {
);

InvalidationListener updater = _ -> updateOverlayShape();
hole.xProperty().addListener(updater);
hole.yProperty().addListener(updater);
hole.widthProperty().addListener(updater);
hole.heightProperty().addListener(updater);
subscriptions.add(EasyBind.listen(hole.xProperty(), updater));
subscriptions.add(EasyBind.listen(hole.yProperty(), updater));
subscriptions.add(EasyBind.listen(hole.widthProperty(), updater));
subscriptions.add(EasyBind.listen(hole.heightProperty(), updater));

transitionAnimation.setOnFinished(_ -> {
if (this.node != null) {
Expand All @@ -88,11 +89,6 @@ public void transitionTo(@NonNull Node newNode) {
this.node = newNode;
setupListeners(this.node);
updateLayout();

hole.xProperty().removeListener(updater);
hole.yProperty().removeListener(updater);
hole.widthProperty().removeListener(updater);
hole.heightProperty().removeListener(updater);
});

transitionAnimation.play();
Expand All @@ -104,14 +100,14 @@ public void setOnClick(@Nullable Runnable onClickHandler) {

@Override
public void detach() {
super.detach();
if (node == null) {
throw new IllegalStateException("Spotlight is not attached to any node.");
}
if (transitionAnimation != null) {
transitionAnimation.stop();
transitionAnimation = null;
}
super.detach();
Shape overlayShape = this.overlayShape;
if (overlayShape != null && overlayShape.getParent() instanceof Pane parentPane) {
parentPane.getChildren().remove(overlayShape);
Expand Down
10 changes: 0 additions & 10 deletions jabgui/src/main/java/org/jabref/gui/welcome/WelcomeTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,6 @@ private void updateColumnsLayout(@NonNull GridPane grid,
grid.add(leftColumn, 0, 0);
grid.add(rightColumn, 1, 0);
}
//
// Node parent = getContent() != null ? getContent().getParent() : null;
// if (parent != null) {
// double parentHeight = parent.getBoundsInParent().getHeight();
// double topTitleHeight = main.getChildren().get(0).getBoundsInParent().getHeight();
// double communityLinksHeight = main.getChildren().get(2).getBoundsInParent().getHeight();
// double space = main.getSpacing() * 2 + main.getPadding().getTop() + main.getPadding().getBottom();
// double requiredHeight = topTitleHeight + communityLinksHeight + leftColumn.getBoundsInParent().getHeight() + space;
// scrollNeeded = parentHeight < requiredHeight;
// }

if (!scrollNeeded) {
if (!(main.getChildren().get(1) instanceof GridPane)) {
Expand Down
3 changes: 2 additions & 1 deletion jabgui/src/main/resources/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -2886,7 +2886,8 @@ journalInfo .grid-cell-b {

.walkthrough-tooltip .border {
/* The arrow of the PopOver. Need to override the default `.popover > .border` (https://github.com/controlsfx/controlsfx/blob/194b10bb948389bf18c463006adcec7c92ca6403/controlsfx/src/main/resources/org/controlsfx/control/popover.css#L8) */
-fx-fill: -jr-background-alt!important;
/* -jr-background-alt. Variable is not used because the variable cannot be properly resolved and lead to transparent fill. */
-fx-fill: #f3f3f3 !important;
}

.walkthrough-tooltip-content-container {
Expand Down
5 changes: 5 additions & 0 deletions jabgui/src/main/resources/org/jabref/gui/Dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,8 @@
/* -jr-accent with 75% Alpha */
-fx-fill: rgba(37, 86, 82, 0.75);
}

.walkthrough-tooltip .border {
/* -jr-background-alt. Variable is not used because the variable cannot be properly resolved and lead to transparent fill. */
-fx-fill: #151924 !important;
}