Browse Source

REPORT-133167 fix: 帆软通行证面板自适应尺寸

fbp/release
Levy.Xie-解安森 3 months ago
parent
commit
49ace5bc96
  1. 3
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  2. 21
      designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java

3
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties

@ -1186,7 +1186,8 @@ South.SheetSelectedColor = #FFF
#---- North ----
North.userinfoLabel.borderMargins=2, 16, 2, 16
North.userinfoLabel.width=80
North.userinfoLabel.maxWidth=176
North.userinfoLabel.minWidth=80
North.userinfoLabel.height=24
North.border = $defaultBorderColor
North.messageLabel.foreground=$text.placeholder

21
designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java

@ -3,7 +3,6 @@
*/
package com.fr.design.mainframe.bbs;
import com.fine.theme.utils.FineUIScale;
import com.fr.base.FRContext;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager;
@ -29,6 +28,8 @@ import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.fine.theme.utils.FineUIScale.scale;
/**
* @author neil
@ -63,12 +64,11 @@ public class UserInfoPane extends BasicPane {
* 构造函数
*/
private UserInfoPane() {
this.setPreferredSize(FineUIScale.scale(new Dimension(UIManager.getInt("North.userinfoLabel.width"), UIManager.getInt("North.userinfoLabel.height"))));
this.setLayout(new BorderLayout());
this.userInfoLabel = new UserInfoLabel(this);
Insets insets = UIManager.getInsets("North.userinfoLabel.borderMargins");
Insets scaledInsets = FineUIScale.scale(insets);
Insets scaledInsets = scale(insets);
this.userInfoLabel.setBorder(BorderFactory.createEmptyBorder(scaledInsets.top, scaledInsets.left, scaledInsets.bottom, scaledInsets.right));
this.markUnSignIn();
@ -105,6 +105,7 @@ public class UserInfoPane extends BasicPane {
public void markUnSignIn() {
this.userInfoLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Onclick"));
this.userInfoLabel.resetUserName();
fitSize();
}
/**
@ -115,6 +116,18 @@ public class UserInfoPane extends BasicPane {
public void markSignIn(String userName) {
this.userInfoLabel.setText(userName);
this.userInfoLabel.setUserName(userName);
fitSize();
}
private void fitSize() {
int height = UIManager.getInt("North.userinfoLabel.height");
int maxWidth = UIManager.getInt("North.userinfoLabel.maxWidth");
int minWidth = UIManager.getInt("North.userinfoLabel.minWidth");
int labelWidth = userInfoLabel.getPreferredSize().width;
// 自适应尺寸,并限制最大最小尺寸
int preferWidth = Math.min(Math.max(minWidth, labelWidth), maxWidth);
Dimension fitDimension = scale(new Dimension(preferWidth, height));
setPreferredSize(fitDimension);
}
@Override
@ -199,6 +212,4 @@ public class UserInfoPane extends BasicPane {
});
executorService.shutdown();
}
}

Loading…
Cancel
Save