Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify tab transitions with the other transitions #1332

Merged
merged 2 commits into from
Nov 9, 2023
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
32 changes: 6 additions & 26 deletions desktop/src/main/java/bisq/desktop/common/Transitions.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static Timeline slideOutHorizontal(Region node, Runnable finishedHandler,
}


int duration = DEFAULT_DURATION / 2;
int duration = DEFAULT_DURATION / 4;
ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
keyFrames.add(new KeyFrame(Duration.millis(0),
new KeyValue(node.opacityProperty(), 1, Interpolator.LINEAR),
Expand Down Expand Up @@ -402,10 +402,10 @@ public static void flapOut(Node node, Runnable onFinishedHandler) {
}
}

public static void transitRightOut(Region nodeIn, Region nodeOut, int customDuration) {
public static void transitRightOut(Region nodeIn, Region nodeOut) {
nodeIn.setOpacity(0);
UIScheduler.run(() -> slideInLeft(nodeIn, () -> {
})).after(customDuration);
})).after(DEFAULT_DURATION / 4);
slideOutRight(nodeOut, () -> {
Parent parent = nodeOut.getParent();
if (parent != null) {
Expand All @@ -417,14 +417,10 @@ public static void transitRightOut(Region nodeIn, Region nodeOut, int customDura
});
}

public static void transitRightOut(Region nodeIn, Region nodeOut) {
transitRightOut(nodeIn, nodeOut, DEFAULT_DURATION / 4);
}

public static void transitLeftOut(Region nodeIn, Region nodeOut, int customDuration) {
public static void transitLeftOut(Region nodeIn, Region nodeOut) {
nodeIn.setOpacity(0);
UIScheduler.run(() -> slideInRight(nodeIn, () -> {
})).after(customDuration);
})).after(DEFAULT_DURATION / 4);
slideOutLeft(nodeOut, () -> {
Parent parent = nodeOut.getParent();
if (parent != null) {
Expand All @@ -436,10 +432,6 @@ public static void transitLeftOut(Region nodeIn, Region nodeOut, int customDurat
});
}

public static void transitLeftOut(Region nodeIn, Region nodeOut) {
transitLeftOut(nodeIn, nodeOut, DEFAULT_DURATION / 4);
}

public static void transitInNewTab(Region nodeIn) {
nodeIn.setOpacity(0);
fadeIn(nodeIn, DEFAULT_DURATION / 2);
Expand All @@ -457,7 +449,7 @@ public static void transitContentViews(View<? extends Parent, ? extends Model, ?
((TransitionedView) newView).onStartTransition();
}
fadeIn(nodeIn,
DEFAULT_DURATION / 2,
DEFAULT_DURATION / 4,
() -> {
if (newView instanceof TransitionedView) {
((TransitionedView) newView).onTransitionCompleted();
Expand Down Expand Up @@ -990,18 +982,6 @@ public static Timeline pulse(Node node, double duration, double delay,
return timeline;
}

public static void animateTabView(Region nodeIn, Region nodeOut, Region tabButtonNode, double targetX) {
double startX = tabButtonNode.getLayoutX();
int duration = getDuration(DEFAULT_DURATION / 10);
if (startX == 0) {
transitRightOut(nodeIn, nodeOut, duration);
} else if (startX > targetX) {
transitLeftOut(nodeIn, nodeOut, duration);
} else {
transitRightOut(nodeIn, nodeOut, duration);
}
}

public static boolean getUseAnimations() {
return settingsService.getUseAnimations().get();
}
Expand Down
22 changes: 12 additions & 10 deletions desktop/src/main/java/bisq/desktop/common/view/TabView.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,6 @@ void onViewAttachedInternal() {

viewListener = (observable, oldValue, newValue) -> {
onChildView(oldValue, newValue);

if (newValue != null) {
Region childRoot = newValue.getRoot();
if (oldValue != null) {
Transitions.animateTabView(childRoot, oldValue.getRoot(), selectionMarker,
getSelectionMarkerX(model.getSelectedTabButton().get()));
} else {
Transitions.fadeIn(childRoot);
}
}
};
model.getView().addListener(viewListener);
onChildView(null, model.getView().get());
Expand All @@ -123,10 +113,22 @@ void onViewAttachedInternal() {

protected void onChildView(View<? extends Parent, ? extends Model, ? extends Controller> oldValue,
View<? extends Parent, ? extends Model, ? extends Controller> newValue) {
if (oldValue != null) {
Transitions.slideOutRight(oldValue.getRoot(), () -> setNewContent(newValue));
} else {
setNewContent(newValue);
}
}

private void setNewContent(View<? extends Parent, ? extends Model, ? extends Controller> newValue) {
if (newValue != null) {
newValue.getRoot().setOpacity(0);

scrollPane.setFitToHeight(useFitToHeight(newValue));
scrollPane.setContent(newValue.getRoot());
scrollPane.setVvalue(0);

Transitions.fadeIn(newValue.getRoot());
} else {
scrollPane.setContent(null);
}
Expand Down