From 8aaa0c5c526dfda87cb8b2c1ee33c2bfc00a23db Mon Sep 17 00:00:00 2001 From: axpoems <145597137+axpoems@users.noreply.github.com> Date: Tue, 7 Nov 2023 21:26:01 +0100 Subject: [PATCH 1/2] Unify tab transitions with the other transitions Resolve #1328 --- .../java/bisq/desktop/common/Transitions.java | 28 +++---------------- .../bisq/desktop/common/view/TabView.java | 22 ++++++++------- 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/common/Transitions.java b/desktop/src/main/java/bisq/desktop/common/Transitions.java index a50f3e6dcf..7754a3fc92 100644 --- a/desktop/src/main/java/bisq/desktop/common/Transitions.java +++ b/desktop/src/main/java/bisq/desktop/common/Transitions.java @@ -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) { @@ -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) { @@ -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); @@ -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(); } diff --git a/desktop/src/main/java/bisq/desktop/common/view/TabView.java b/desktop/src/main/java/bisq/desktop/common/view/TabView.java index d63ef655d7..ae2baf462b 100644 --- a/desktop/src/main/java/bisq/desktop/common/view/TabView.java +++ b/desktop/src/main/java/bisq/desktop/common/view/TabView.java @@ -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()); @@ -123,10 +113,22 @@ void onViewAttachedInternal() { protected void onChildView(View oldValue, View newValue) { + if (oldValue != null) { + Transitions.slideOutRight(oldValue.getRoot(), () -> setNewContent(newValue)); + } else { + setNewContent(newValue); + } + } + + private void setNewContent(View 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); } From a65df235ee7a810d5e06d35b68a6db7db38fd926 Mon Sep 17 00:00:00 2001 From: axpoems <145597137+axpoems@users.noreply.github.com> Date: Wed, 8 Nov 2023 17:07:26 +0100 Subject: [PATCH 2/2] Change default duration for Transitions.transitContentViews --- desktop/src/main/java/bisq/desktop/common/Transitions.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/common/Transitions.java b/desktop/src/main/java/bisq/desktop/common/Transitions.java index 7754a3fc92..0927a4e6ff 100644 --- a/desktop/src/main/java/bisq/desktop/common/Transitions.java +++ b/desktop/src/main/java/bisq/desktop/common/Transitions.java @@ -160,7 +160,7 @@ public static Timeline slideOutHorizontal(Region node, Runnable finishedHandler, } - int duration = DEFAULT_DURATION / 2; + int duration = DEFAULT_DURATION / 4; ObservableList keyFrames = timeline.getKeyFrames(); keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 1, Interpolator.LINEAR), @@ -449,7 +449,7 @@ public static void transitContentViews(View { if (newView instanceof TransitionedView) { ((TransitionedView) newView).onTransitionCompleted();