Browse Source

REPORT-133897 fix:TabPane垂直布局调整

fbp/merge
Levy.Xie-解安森 3 months ago
parent
commit
2e479691f6
  1. 28
      designer-base/src/main/java/com/fr/design/gui/frpane/FineTabbedPane.java

28
designer-base/src/main/java/com/fr/design/gui/frpane/FineTabbedPane.java

@ -43,7 +43,7 @@ public class FineTabbedPane extends Box {
private final UIButtonGroup<String> tabGroup;
private final Map<String, JComponent> tabComponents;
private final int[] tabLayout;
private final boolean useFitTab ;
private final boolean useFitTab;
private FineTabbedPane(Map<String, JComponent> tabComponents, float headRatio, int[] tabLayout, boolean useFitTab) {
this.headRatio = headRatio;
@ -142,35 +142,45 @@ public class FineTabbedPane extends Box {
initCoreComponents();
setMatchParentSize(true);
float flexRatio = (1 - headRatio) / 2;
int headHeight = FlatUIUtils.getUIInt("Component.defaultHeight",24) * tabLayout.length / 2;
Component component = useFitTab ? row(flex(), cell(tabGroup), flex()).getComponent() : row(flex(flexRatio), cell(tabGroup).weight(headRatio), flex(flexRatio)).getComponent();
int headHeight = FlatUIUtils.getUIInt("Component.defaultHeight", 24) * tabLayout.length / 2;
Component tabRow = useFitTab ? row(flex(), cell(tabGroup), flex()).getComponent() : row(flex(flexRatio), cell(tabGroup).weight(headRatio), flex(flexRatio)).getComponent();
Component backgroundComp = createBackGroundComp();
add(
column(
cell(component),
flex()
cell(tabRow),
cell(centerPane).with(it -> it.setBorder(new ScaledEmptyBorder(10, 10, 10, 10))).weight(1)
),
column(
fix(headHeight),
cell(centerPane).with(it -> it.setBorder(new ScaledEmptyBorder(headHeight + 10, 10, 10, 10))).weight(1)
cell(backgroundComp).weight(1)
)
);
fillBackgroundColor();
}
private Component createBackGroundComp() {
JPanel pane = new JPanel();
pane.putClientProperty(PANEL_TYPE, ROUNDED_PANEL);
pane.setBackground(getFillColor());
return pane;
}
private void initCoreComponents() {
cards = new CardLayout();
centerPane = new JPanel(cards);
centerPane.putClientProperty(PANEL_TYPE, ROUNDED_PANEL);
tabComponents.forEach((key, value) -> {
value.setOpaque(false);
centerPane.add(value, key);
});
}
private Color getFillColor() {
return FineUIUtils.getUIColor("FineTabbedPane.background", "fill.gray");
}
private void fillBackgroundColor() {
Color fillColor = FineUIUtils.getUIColor("FineTabbedPane.background", "fill.gray");
Color defaultColor = FineUIUtils.getUIColor("default.background", "Component.background");
ColorUtils.syncBackgroundIfAbsent(centerPane, fillColor, defaultColor);
ColorUtils.syncBackgroundIfAbsent(centerPane, getFillColor(), defaultColor);
}
private void initListeners() {

Loading…
Cancel
Save