Skip to content

Commit

Permalink
Make paining of expanded lines more robust.
Browse files Browse the repository at this point in the history
When a property is expanded, we draw a line encapsulating all
sub-properties. We calculate this line by multiplying the column height
with the number of children. The problem here is that this approach no
longer works when spacing is taken into consideration.

To fix this, get the edit parts for each property and calculate the
length by using the bounds of figures enclosed by the first and last
edit part.
  • Loading branch information
ptziegler committed May 15, 2024
1 parent d472620 commit 34a70b6
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -972,14 +972,21 @@ private void drawExpandLines(Graphics graphics, Rectangle clientArea) {
}
index2--;
// draw line if there are children
if (index2 > index
&& getEditPartRegistry().get(propertyInfo) instanceof PropertyEditPart editPart) {
int y = editPart.getFigure().getBounds().top();
int x = getTitleX(propertyInfo) + xOffset;
int y1 = y + height - yOffset;
int y2 = y + m_rowHeight * (index2 - index) + m_rowHeight / 2;
graphics.drawLine(x, y1, x, y2);
graphics.drawLine(x, y2, x + m_rowHeight / 3, y2);
if (index2 > index) {
PropertyInfo nextPropertyInfo = m_properties.get(index2);
GraphicalEditPart editPart = (GraphicalEditPart) getEditPartRegistry()
.get(propertyInfo);
GraphicalEditPart nextEditPart = (GraphicalEditPart) getEditPartRegistry()
.get(nextPropertyInfo);
if (editPart != null && nextEditPart != null) {
Rectangle bounds = editPart.getFigure().getBounds();
Rectangle nextBounds = nextEditPart.getFigure().getBounds();
int x = getTitleX(propertyInfo) + xOffset;
int y1 = bounds.top() + height - yOffset;
int y2 = nextBounds.top() + m_rowHeight / 2;
graphics.drawLine(x, y1, x, y2);
graphics.drawLine(x, y2, x + m_rowHeight / 3, y2);
}
}
}
//
Expand Down

0 comments on commit 34a70b6

Please sign in to comment.