mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
a bit of DRY in SingleRowLayoutStrategy
This commit is contained in:
@@ -181,10 +181,8 @@ public class SingleRowLayout extends TabLayout {
|
||||
}
|
||||
|
||||
private void layoutLabelsAndGhosts(final SingleRowPassInfo data) {
|
||||
final int fixedPosition = getStrategy().getFixedPosition(data);
|
||||
|
||||
if (data.firstGhostVisible || myTabs.isGhostsAlwaysVisible()) {
|
||||
data.firstGhost = getStrategy().getLayoutRec(data.position, fixedPosition, myTabs.getGhostTabLength(), getStrategy().getFixedFitLength(data));
|
||||
data.firstGhost = getStrategy().getLayoutRect(data, data.position, myTabs.getGhostTabLength());
|
||||
myTabs.layout(myLeftGhost, data.firstGhost);
|
||||
data.position += getStrategy().getLengthIncrement(data.firstGhost.getSize()) + myTabs.getInterTabSpaceLength();
|
||||
}
|
||||
@@ -205,12 +203,12 @@ public class SingleRowLayout extends TabLayout {
|
||||
boolean isLast = data.toLayout.indexOf(eachInfo) == data.toLayout.size() - 1;
|
||||
|
||||
if (!isLast || deltaToFit == 0) {
|
||||
Rectangle rec = getStrategy().getLayoutRec(data.position, fixedPosition, getStrategy().getLengthIncrement(eachSize) + deltaToFit, getStrategy().getFixedFitLength(data));
|
||||
Rectangle rec = getStrategy().getLayoutRect(data, data.position, getStrategy().getLengthIncrement(eachSize) + deltaToFit);
|
||||
myTabs.layout(label, rec);
|
||||
}
|
||||
else {
|
||||
int length = data.toFitLength - totalLength;
|
||||
final Rectangle rec = getStrategy().getLayoutRec(data.position, fixedPosition, length, getStrategy().getFixedFitLength(data));
|
||||
final Rectangle rec = getStrategy().getLayoutRect(data, data.position, length);
|
||||
myTabs.layout(label, rec);
|
||||
}
|
||||
|
||||
@@ -227,7 +225,7 @@ public class SingleRowLayout extends TabLayout {
|
||||
}
|
||||
|
||||
if (data.lastGhostVisible || myTabs.isGhostsAlwaysVisible()) {
|
||||
data.lastGhost = getStrategy().getLayoutRec(data.position, fixedPosition, myTabs.getGhostTabLength(), getStrategy().getFixedFitLength(data));
|
||||
data.lastGhost = getStrategy().getLayoutRect(data, data.position, myTabs.getGhostTabLength());
|
||||
myTabs.layout(myRightGhost, data.lastGhost);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -43,11 +43,15 @@ public abstract class SingleRowLayoutStrategy {
|
||||
|
||||
public abstract int getMaxPosition(final Rectangle bounds);
|
||||
|
||||
public abstract int getFixedFitLength(final SingleRowPassInfo data);
|
||||
protected abstract int getFixedFitLength(final SingleRowPassInfo data);
|
||||
|
||||
public abstract Rectangle getLayoutRec(final int position, final int fixedPos, final int length, final int fixedFitLength);
|
||||
public Rectangle getLayoutRect(final SingleRowPassInfo data, final int position, final int length) {
|
||||
return getLayoutRec(getFixedPosition(data), position, length, getFixedFitLength(data));
|
||||
}
|
||||
|
||||
public abstract int getFixedPosition(final SingleRowPassInfo data);
|
||||
protected abstract Rectangle getLayoutRec(final int position, final int fixedPos, final int length, final int fixedFitLength);
|
||||
|
||||
protected abstract int getFixedPosition(final SingleRowPassInfo data);
|
||||
|
||||
public abstract Rectangle getMoreRect(final SingleRowPassInfo data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user