Skip to content

Commit a790dd5

Browse files
Draw big parenthesis as a single polygon.
1 parent 8afe55a commit a790dd5

File tree

3 files changed

+50
-31
lines changed

3 files changed

+50
-31
lines changed

src/GroupCell.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,7 @@ void GroupCell::DrawBracket()
12401240
if (drawBracket)
12411241
{
12421242
adc->SetBrush(dc->GetBrush());
1243+
SetPen(1.5);
12431244
int bracketWidth = configuration->GetCellBracketWidth() - configuration->GetDefaultLineWidth();
12441245
if (IsFoldable())
12451246
{ // draw the square that allows hiding and unhiding the cell

src/ParenCell.cpp

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -354,39 +354,57 @@ void ParenCell::Draw(wxPoint point)
354354
SetPen(1.0);
355355

356356
int signWidth = m_signWidth - Scale_Px(2);
357-
358-
wxPoint pointList[5];
357+
358+
wxPointList points;
359359
// Left bracket
360-
pointList[0] = wxPoint(point.x + Scale_Px(1) + signWidth,
361-
point.y - m_center + Scale_Px(4));
362-
pointList[1] = wxPoint(point.x + Scale_Px(1) + signWidth / 2,
363-
point.y - m_center + signWidth / 2 + Scale_Px(4));
364-
pointList[2] = wxPoint(point.x + Scale_Px(1),
365-
point.y);
366-
pointList[3] = wxPoint(point.x + Scale_Px(1) + signWidth / 2,
367-
point.y + m_center - signWidth / 2 - Scale_Px(4));
368-
pointList[4] = wxPoint(point.x + Scale_Px(1) + signWidth,
369-
point.y + m_center - Scale_Px(4));
370-
configuration->GetAntialiassingDC()->DrawSpline(5,pointList);
371-
pointList[2] = wxPoint(point.x + Scale_Px(1.5),
372-
point.y);
373-
adc->DrawSpline(5,pointList);
374-
360+
points.Append(new wxPoint(point.x + Scale_Px(1) + signWidth,
361+
point.y - m_center + Scale_Px(4)));
362+
points.Append(new wxPoint(point.x + Scale_Px(1) + signWidth / 2,
363+
point.y - m_center + signWidth / 2 + Scale_Px(4)));
364+
points.Append(new wxPoint(point.x + Scale_Px(1),
365+
point.y));
366+
points.Append(new wxPoint(point.x + Scale_Px(1) + signWidth / 2,
367+
point.y + m_center - signWidth / 2 - Scale_Px(4)));
368+
points.Append(new wxPoint(point.x + Scale_Px(1) + signWidth,
369+
point.y + m_center - Scale_Px(4)));
370+
// Appending the last point twice should allow for an abrupt 180° turn
371+
points.Append(new wxPoint(point.x + Scale_Px(1) + signWidth,
372+
point.y + m_center - Scale_Px(4)));
373+
points.Append(new wxPoint(point.x + Scale_Px(1) + signWidth / 2,
374+
point.y + m_center - signWidth / 2 - Scale_Px(4)));
375+
// The middle point of the 2nd run of the parenthesis is at a different place
376+
// making the parenthesis wider here
377+
points.Append(new wxPoint(point.x + Scale_Px(2),
378+
point.y));
379+
points.Append(new wxPoint(point.x + Scale_Px(1) + signWidth / 2,
380+
point.y - m_center + signWidth / 2 + Scale_Px(4)));
381+
points.Append(new wxPoint(point.x + Scale_Px(1) + signWidth,
382+
point.y - m_center + Scale_Px(4)));
383+
adc->DrawSpline(&points);
384+
385+
points.Clear();
375386
// Right bracket
376-
pointList[0] = wxPoint(point.x + m_width - Scale_Px(1) - signWidth,
377-
point.y - m_center + Scale_Px(4));
378-
pointList[1] = wxPoint(point.x + m_width - Scale_Px(1) - signWidth / 2,
379-
point.y - m_center + signWidth / 2 + Scale_Px(4));
380-
pointList[2] = wxPoint(point.x + m_width - Scale_Px(1.5),
381-
point.y);
382-
pointList[3] = wxPoint(point.x + m_width - Scale_Px(1) - signWidth / 2,
383-
point.y + m_center - signWidth / 2 - Scale_Px(4));
384-
pointList[4] = wxPoint(point.x + m_width - Scale_Px(1) - signWidth,
385-
point.y + m_center - Scale_Px(4));
386-
configuration->GetAntialiassingDC()->DrawSpline(5,pointList);
387-
pointList[2] = wxPoint(point.x + m_width - Scale_Px(1),
388-
point.y);
389-
adc->DrawSpline(5,pointList);
387+
points.Append(new wxPoint(point.x + m_width - Scale_Px(1) - signWidth,
388+
point.y - m_center + Scale_Px(4)));
389+
points.Append(new wxPoint(point.x + m_width - Scale_Px(1) - signWidth / 2,
390+
point.y - m_center + signWidth / 2 + Scale_Px(4)));
391+
points.Append(new wxPoint(point.x + m_width - Scale_Px(1.5),
392+
point.y));
393+
points.Append(new wxPoint(point.x + m_width - Scale_Px(1) - signWidth / 2,
394+
point.y + m_center - signWidth / 2 - Scale_Px(4)));
395+
points.Append(new wxPoint(point.x + m_width - Scale_Px(1) - signWidth,
396+
point.y + m_center - Scale_Px(4)));
397+
points.Append(new wxPoint(point.x + m_width - Scale_Px(1) - signWidth,
398+
point.y + m_center - Scale_Px(4)));
399+
points.Append(new wxPoint(point.x + m_width - Scale_Px(1) - signWidth / 2,
400+
point.y + m_center - signWidth / 2 - Scale_Px(4)));
401+
points.Append(new wxPoint(point.x + m_width - Scale_Px(2),
402+
point.y));
403+
points.Append(new wxPoint(point.x + m_width - Scale_Px(1) - signWidth / 2,
404+
point.y - m_center + signWidth / 2 + Scale_Px(4)));
405+
points.Append(new wxPoint(point.x + m_width - Scale_Px(1) - signWidth,
406+
point.y - m_center + Scale_Px(4)));
407+
adc->DrawSpline(&points);
390408
}
391409
break;
392410
}

test/testbench_simple.wxmx

-4.73 KB
Binary file not shown.

0 commit comments

Comments
 (0)