|
|
|
@ -263,29 +263,31 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
|
|
|
|
|
/** |
|
|
|
|
* 重新调整子组件的宽度 |
|
|
|
|
* @param width 宽度 |
|
|
|
|
* @param actualSize 是否按照实际大小计算 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void recalculateChildWidth(int width){ |
|
|
|
|
public void recalculateChildWidth(int width, boolean actualSize){ |
|
|
|
|
ArrayList<?> childrenList = this.getTargetChildrenList(); |
|
|
|
|
int size = childrenList.size(); |
|
|
|
|
if (size > 0) { |
|
|
|
|
for (int j = 0; j < size; j++) { |
|
|
|
|
XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList |
|
|
|
|
.get(j); |
|
|
|
|
tabLayout.setBackupBound(tabLayout.getBounds()); |
|
|
|
|
int refSize = tabLayout.getWidth(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dimension d = new Dimension(tabLayout.toData().getContainerWidth(), tabLayout.toData().getContainerHeight()); |
|
|
|
|
Rectangle rec = actualSize? new Rectangle(d): tabLayout.getBounds(); |
|
|
|
|
// 容器大小改变时,设下backupBound为其之前的实际大小
|
|
|
|
|
tabLayout.setBackupBound(rec); |
|
|
|
|
int refSize = rec.width; |
|
|
|
|
int offest = width - refSize; |
|
|
|
|
double percent = (double) offest / refSize; |
|
|
|
|
if (percent < 0 && !tabLayout.canReduce(percent)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
tabLayout.setSize(tabLayout.getWidth() + offest, |
|
|
|
|
tabLayout.getHeight()); |
|
|
|
|
for (int m = 0; m < tabLayout.getComponentCount(); m++) { |
|
|
|
|
XCreator childCreator = tabLayout.getXCreator(m); |
|
|
|
|
BoundsWidget wgt = (BoundsWidget) tabLayout.toData() |
|
|
|
|
.getBoundsWidget(childCreator.toData()); |
|
|
|
|
wgt.setBounds(tabLayout.getComponent(m).getBounds()); |
|
|
|
|
tabLayout.setSize(rec.width + offest, rec.height); |
|
|
|
|
if(!actualSize){ |
|
|
|
|
updateChildWidgetBounds(tabLayout); |
|
|
|
|
} |
|
|
|
|
tabLayout.adjustCreatorsWidth(percent); |
|
|
|
|
} |
|
|
|
@ -295,38 +297,52 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
|
|
|
|
|
/** |
|
|
|
|
* 重新调整子组件的高度 |
|
|
|
|
* @param height 高度 |
|
|
|
|
* @param actualSize 是否按照实际大小计算 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void recalculateChildHeight(int height){ |
|
|
|
|
public void recalculateChildHeight(int height, boolean actualSize){ |
|
|
|
|
ArrayList<?> childrenList = this.getTargetChildrenList(); |
|
|
|
|
int size = childrenList.size(); |
|
|
|
|
if (size > 0) { |
|
|
|
|
for (int j = 0; j < size; j++) { |
|
|
|
|
XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList |
|
|
|
|
.get(j); |
|
|
|
|
tabLayout.setBackupBound(tabLayout.getBounds()); |
|
|
|
|
int refSize = tabLayout.getHeight(); |
|
|
|
|
Dimension d = new Dimension(tabLayout.toData().getContainerWidth(), tabLayout.toData().getContainerHeight()); |
|
|
|
|
Rectangle rec = actualSize? new Rectangle(d): tabLayout.getBounds(); |
|
|
|
|
// 容器大小改变时,设下backupBound为其之前的实际大小
|
|
|
|
|
tabLayout.setBackupBound(rec); |
|
|
|
|
int refSize = rec.height; |
|
|
|
|
int offset = height - refSize - WCardMainBorderLayout.TAB_HEIGHT; |
|
|
|
|
if(offset < 0){ |
|
|
|
|
// 缩放时需要备份原tab布局宽高
|
|
|
|
|
tabLayout.setReferDim(new Dimension(tabLayout.getWidth(),tabLayout.getHeight())); |
|
|
|
|
tabLayout.setReferDim(new Dimension(rec.width, rec.height)); |
|
|
|
|
} |
|
|
|
|
double percent = (double) offset / refSize; |
|
|
|
|
if (percent < 0 && !tabLayout.canReduce(percent)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
tabLayout.setSize(tabLayout.getWidth(), |
|
|
|
|
tabLayout.getHeight() + offset); |
|
|
|
|
tabLayout.setSize(rec.width, rec.height + offset); |
|
|
|
|
if(!actualSize){ |
|
|
|
|
updateChildWidgetBounds(tabLayout); |
|
|
|
|
} |
|
|
|
|
tabLayout.adjustCreatorsHeight(percent); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 更新下子组件bounds |
|
|
|
|
* @param tabLayout tabFit布局 |
|
|
|
|
*/ |
|
|
|
|
private void updateChildWidgetBounds(XWTabFitLayout tabLayout){ |
|
|
|
|
for (int m = 0; m < tabLayout.getComponentCount(); m++) { |
|
|
|
|
XCreator childCreator = tabLayout.getXCreator(m); |
|
|
|
|
BoundsWidget wgt = (BoundsWidget) tabLayout.toData() |
|
|
|
|
.getBoundsWidget(childCreator.toData()); |
|
|
|
|
wgt.setBounds(tabLayout.getComponent(m).getBounds()); |
|
|
|
|
} |
|
|
|
|
tabLayout.adjustCreatorsHeight(percent); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|