mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-2977 tweak PairLayout to respect row visibility
This commit is contained in:
@@ -75,24 +75,24 @@ public class PairLayout implements LayoutManager {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Dimension preferredLayoutSize(Container parent) {
|
public Dimension preferredLayoutSize(Container parent) {
|
||||||
computeSizes(parent);
|
int visibleRowCount = computeSizes(parent);
|
||||||
int rowCount = (parent.getComponentCount() + 1) / 2;
|
|
||||||
Insets insets = parent.getInsets();
|
Insets insets = parent.getInsets();
|
||||||
Dimension d = new Dimension(0, 0);
|
Dimension d = new Dimension(0, 0);
|
||||||
d.width = leftColumnWidth + hgap + preferredRightColumnWidth + insets.left + insets.right;
|
d.width = leftColumnWidth + hgap + preferredRightColumnWidth + insets.left + insets.right;
|
||||||
d.height = rowHeight * rowCount + vgap * (rowCount - 1) + insets.top + insets.bottom;
|
d.height =
|
||||||
|
rowHeight * visibleRowCount + vgap * (visibleRowCount - 1) + insets.top + insets.bottom;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension minimumLayoutSize(Container parent) {
|
public Dimension minimumLayoutSize(Container parent) {
|
||||||
// resulting min width equals the label column's (leftColumnWidth) width
|
// resulting min width equals the label column's (leftColumnWidth) width
|
||||||
computeSizes(parent);
|
int visibleRowCount = computeSizes(parent);
|
||||||
int rowCount = (parent.getComponentCount() + 1) / 2;
|
|
||||||
Insets insets = parent.getInsets();
|
Insets insets = parent.getInsets();
|
||||||
Dimension d = new Dimension(0, 0);
|
Dimension d = new Dimension(0, 0);
|
||||||
d.width = leftColumnWidth + hgap + insets.left + insets.right;
|
d.width = leftColumnWidth + hgap + insets.left + insets.right;
|
||||||
d.height = rowHeight * rowCount + vgap * (rowCount - 1) + insets.top + insets.bottom;
|
d.height =
|
||||||
|
rowHeight * visibleRowCount + vgap * (visibleRowCount - 1) + insets.top + insets.bottom;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +113,9 @@ public class PairLayout implements LayoutManager {
|
|||||||
leftColumnComponent.setBounds(x, y, leftColumnWidth, rowHeight);
|
leftColumnComponent.setBounds(x, y, leftColumnWidth, rowHeight);
|
||||||
if (componentCount > i * 2 + 1) {
|
if (componentCount > i * 2 + 1) {
|
||||||
Component rightColumnComponent = parent.getComponent(i * 2 + 1);
|
Component rightColumnComponent = parent.getComponent(i * 2 + 1);
|
||||||
|
if (!leftColumnComponent.isVisible() && !rightColumnComponent.isVisible()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
rightColumnComponent.setBounds(x + leftColumnWidth + hgap, y, rightColumnWidth,
|
rightColumnComponent.setBounds(x + leftColumnWidth + hgap, y, rightColumnWidth,
|
||||||
rowHeight);
|
rowHeight);
|
||||||
y += rowHeight + vgap;
|
y += rowHeight + vgap;
|
||||||
@@ -120,9 +123,10 @@ public class PairLayout implements LayoutManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void computeSizes(Container parent) {
|
private int computeSizes(Container parent) {
|
||||||
int componentCount = parent.getComponentCount();
|
int componentCount = parent.getComponentCount();
|
||||||
int rowCount = (componentCount + 1) / 2;
|
int rowCount = (componentCount + 1) / 2;
|
||||||
|
int visibleRowCount = 0;
|
||||||
|
|
||||||
leftColumnWidth = 0;
|
leftColumnWidth = 0;
|
||||||
rowHeight = 0;
|
rowHeight = 0;
|
||||||
@@ -138,9 +142,13 @@ public class PairLayout implements LayoutManager {
|
|||||||
d = rightColumnComponent.getPreferredSize();
|
d = rightColumnComponent.getPreferredSize();
|
||||||
rowHeight = Math.max(rowHeight, d.height);
|
rowHeight = Math.max(rowHeight, d.height);
|
||||||
preferredRightColumnWidth = Math.max(preferredRightColumnWidth, d.width);
|
preferredRightColumnWidth = Math.max(preferredRightColumnWidth, d.width);
|
||||||
|
if (!leftColumnComponent.isVisible() && !rightColumnComponent.isVisible()) {
|
||||||
|
continue; // don't count this row
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
visibleRowCount++;
|
||||||
}
|
}
|
||||||
|
return visibleRowCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user