Skip to content

Commit

Permalink
Unify tab transitions with the other transitions
Browse files Browse the repository at this point in the history
Resolve #1328
  • Loading branch information
axpoems committed Nov 7, 2023
1 parent 06357c5 commit 8aaa0c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 34 deletions.
28 changes: 4 additions & 24 deletions desktop/src/main/java/bisq/desktop/common/Transitions.java
Original file line number Diff line number Diff line change
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 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

0 comments on commit 8aaa0c5

Please sign in to comment.