From 3ec63c50584783013bf2ab3fcf051c07bf119032 Mon Sep 17 00:00:00 2001 From: renekton Date: Tue, 10 Sep 2024 20:32:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../background/gradient/GradientBar.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java index 74afec7efd..923c8ec39e 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java @@ -318,13 +318,25 @@ public class GradientBar extends AbstractComponentPopBox implements UIObserver, private void dragAction(MouseEvent e) { int oldIndex = index; - for (int i = 0; i < list.size(); i++) { + int size = list.size(); + for (int i = 0; i < size; i++) { if (list.get(i).contains(e.getX(), e.getY())) { index = i; break; } } - if (OperatingSystem.isLinux() && AssistUtils.equals(oldIndex, index)) { + updateX(oldIndex, index, e); + + GradientBar.this.repaint(); + if (index == 1) { + endLabel.setText(Double.toString(p2.getX())); + } else { + startLabel.setText(Double.toString(p1.getX())); + } + } + + private void updateX(int oldIndex, int newIndex, MouseEvent e) { + if (OperatingSystem.isLinux() && AssistUtils.equals(oldIndex, newIndex)) { if (Math.abs(p1.getX() - e.getX()) > Math.abs(p2.getX() - e.getX())) { index = 1; } else { @@ -335,9 +347,5 @@ public class GradientBar extends AbstractComponentPopBox implements UIObserver, if (x && e.getY() < MAX_VERTICAL) { list.get(index).setX(e.getX()); } - - GradientBar.this.repaint(); - startLabel.setText(Double.toString(p1.getX())); - endLabel.setText(Double.toString(p2.getX())); } } \ No newline at end of file