Ghidra is a software reverse engineering (SRE) framework
GT-3410 addressed review concerns and resolved some component repaint issues.
ghidra1e0fe27ea9d92
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/BitFieldPlacementComponent.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/BitFieldPlacementComponent.javaindex 08af06b623..a4215acf60 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/BitFieldPlacementComponent.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/BitFieldPlacementComponent.java@@ -48,7 +48,7 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {private static final Color ACTIVE_BITFIELD_BITS_COLOR = Color.green;private static final Color CONFLICT_BITS_COLOR = Color.yellow;private static final Color BITFIELD_COMPONENT_COLOR = new Color(0xbfbfff);- private static final Color NON_BITFIELD_COMPONENT_COLOR = new Color(0xa4a4ff);+ private static final Color NON_BITFIELD_COMPONENT_COLOR = new Color(0xa0a0ff);private static final Color INTERIOR_LINE_COLOR = new Color(0xd4d4d4);private int bitWidth = 10;@@ -557,8 +557,6 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {@Overridepublic void paintComponent(Graphics g) {- //super.paintComponent(g);-int height = getHeight();int width = getWidth();@@ -653,18 +651,21 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {DataTypeComponent prevDtc = null;BitAttributes prevAttrs = null;- // start close to the left clip bounds- Rectangle clipBounds = g.getClipBounds();- int maxX = clipBounds.x + clipBounds.width - 1;+ // Limit rendered bits to those contained within the visible view port+ // of this scrolled component.++ JViewport viewPort = (JViewport) getParent();+ Rectangle bounds = viewPort.getViewRect();+ int maxX = bounds.x + bounds.width - 1;int width = bitAttributes[0].rectangle.width;- int startIndex = clipBounds.x / (bitAttributes[0].rectangle.width);+ int startIndex = bounds.x / (bitAttributes[0].rectangle.width);x += startIndex * width;int bitIndex;for (bitIndex = startIndex; bitIndex < bitAttributes.length; bitIndex++) {BitAttributes attrs = bitAttributes[bitIndex];if (x > maxX) {- break; // right clip - return early+ break; // right visible edge exceeded - return early}boolean paintRightLine = bitIndex != (bitAttributes.length - 1);attrs.paint(g, prevAttrs, paintRightLine);@@ -674,12 +675,14 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {paintComponentLabel(g, prevDtc, dtcRectangle);prevDtc = null;}+ Rectangle visibleBitRect = attrs.rectangle.intersection(bounds);if (prevDtc == null) {prevDtc = dtc;- dtcRectangle = new Rectangle(attrs.rectangle.intersection(clipBounds));+ dtcRectangle = visibleBitRect;+ }+ else {+ dtcRectangle.add(visibleBitRect);}- dtcRectangle.add(attrs.rectangle.intersection(clipBounds));-if (attrs.unallocated) {paintDit(g, attrs.rectangle);}@@ -734,6 +737,7 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {int textY = r.y + (r.height + fontMetrics.getMaxAscent() - BYTE_SEPARATOR_THICKNESS) / 2;int textX = r.x + (r.width - BYTE_SEPARATOR_THICKNESS - strWidth) / 2;+g.drawString(name, textX, textY);g.setColor(curColor);@@ -792,9 +796,6 @@ public class BitFieldPlacementComponent extends JPanel implements Scrollable {leftBit = leftAdj;}-// System.out.println(component.toString() + " >>> " + leftBit + " - " + rightBit +-// " oa: " + offsetAdjBytes);-// clip to allocation regionint allocBitSize = 8 * allocationByteSize;truncateRight = false;