Browse Source

代码质量

feature/ru^2
zack 4 weeks ago
parent
commit
bbc701f081
  1. 31
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java
  2. 4
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

31
designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java

@ -359,9 +359,21 @@ public class UIEastResizableContainer extends JPanel {
}
}
/**
* This inner class handles mouse events for resizing the container
* by dragging the left edge of the right pane.
*/
public class ResizeListener extends MouseAdapter implements MouseMotionListener {
// Stores the point where the mouse was initially pressed
private Point mouseDownCompCoords;
/**
* This method is called when the mouse is moved within the component.
* It changes the cursor to indicate that resizing is possible.
*
* @param e The MouseEvent.
*/
@Override
public void mouseMoved(MouseEvent e) {
if (e.getX() <= RESIZE_RANGE) {
@ -371,6 +383,12 @@ public class UIEastResizableContainer extends JPanel {
}
}
/**
* This method is called when the mouse is pressed near the left edge.
* If within the resize area, the mouse position is stored for dragging.
*
* @param e The MouseEvent.
*/
@Override
public void mousePressed(MouseEvent e) {
if (e.getX() <= RESIZE_RANGE) {
@ -378,11 +396,18 @@ public class UIEastResizableContainer extends JPanel {
}
}
/**
* This method is called when the mouse is dragged after being pressed
* near the left edge. It adjusts the container width based on drag distance.
*
* @param e The MouseEvent.
*/
@Override
public void mouseDragged(MouseEvent e) {
if (mouseDownCompCoords != null && getCursor().equals(westResizeCursor)) {
Point currCoords = e.getLocationOnScreen();
int newWidth = containerWidth - (currCoords.x - mouseDownCompCoords.x);
// Update container width within allowed range
if (newWidth >= MIN_CONTAINER_WIDTH && newWidth <= MAX_CONTAINER_WIDTH) {
containerWidth = newWidth;
mouseDownCompCoords = currCoords;
@ -391,6 +416,12 @@ public class UIEastResizableContainer extends JPanel {
}
}
/**
* This method is called when the mouse button is released.
* It clears the stored starting point for dragging.
*
* @param e The MouseEvent.
*/
@Override
public void mouseReleased(MouseEvent e) {
mouseDownCompCoords = null;

4
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -1424,7 +1424,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseDragged(MouseEvent e) {
if (mouseDownCompCoords == null) return;
if (mouseDownCompCoords == null) {
return;
}
Rectangle bounds = getBounds();
Point currCoords = e.getLocationOnScreen();

Loading…
Cancel
Save