Make GTK2 dashed line appearance similar to MSW See #26449
| ... | ... | @@ -1605,9 +1605,9 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) |
| 1605 | 1605 | }
|
| 1606 | 1606 | |
| 1607 | 1607 | static const wxDash dotted[] = {1, 1};
|
| 1608 | - static const wxDash short_dashed[] = {2, 2};
|
|
| 1609 | - static const wxDash wxCoord_dashed[] = {2, 4};
|
|
| 1610 | - static const wxDash dotted_dashed[] = {3, 3, 1, 3};
|
|
| 1608 | + static const wxDash short_dashed[] = { 3, 1 };
|
|
| 1609 | + static const wxDash long_dashed[] = { 6, 1 };
|
|
| 1610 | + static const wxDash dotted_dashed[] = { 3, 1, 1, 1 };
|
|
| 1611 | 1611 | |
| 1612 | 1612 | // We express dash pattern in pen width unit, so we are
|
| 1613 | 1613 | // independent of zoom factor and so on...
|
| ... | ... | @@ -1627,7 +1627,7 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) |
| 1627 | 1627 | break;
|
| 1628 | 1628 | case wxPENSTYLE_LONG_DASH:
|
| 1629 | 1629 | req_nb_dash = 2;
|
| 1630 | - req_dash = wxCoord_dashed;
|
|
| 1630 | + req_dash = long_dashed;
|
|
| 1631 | 1631 | break;
|
| 1632 | 1632 | case wxPENSTYLE_SHORT_DASH:
|
| 1633 | 1633 | req_nb_dash = 2;
|
| ... | ... | @@ -1654,8 +1654,17 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) |
| 1654 | 1654 | wxScopedArray<wxDash> real_req_dash(req_nb_dash);
|
| 1655 | 1655 | if (real_req_dash)
|
| 1656 | 1656 | {
|
| 1657 | + const bool isCapButt = m_pen.GetCap() == wxCAP_BUTT;
|
|
| 1657 | 1658 | for (int i = 0; i < req_nb_dash; i++)
|
| 1658 | - real_req_dash[i] = req_dash[i] * width;
|
|
| 1659 | + {
|
|
| 1660 | + wxDash dash = req_dash[i];
|
|
| 1661 | + if ((i & 1) && !isCapButt)
|
|
| 1662 | + {
|
|
| 1663 | + // the caps intrude into "off" length by 0.5 at each end
|
|
| 1664 | + dash++;
|
|
| 1665 | + }
|
|
| 1666 | + real_req_dash[i] = dash * width;
|
|
| 1667 | + }
|
|
| 1659 | 1668 | gdk_gc_set_dashes( m_penGC, 0, real_req_dash.get(), req_nb_dash );
|
| 1660 | 1669 | }
|
| 1661 | 1670 | else
|
| ... | ... | @@ -1672,7 +1681,7 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) |
| 1672 | 1681 | case wxCAP_BUTT: { capStyle = GDK_CAP_BUTT; break; }
|
| 1673 | 1682 | case wxCAP_ROUND:
|
| 1674 | 1683 | default:
|
| 1675 | - if (width <= 1)
|
|
| 1684 | + if (width <= 1 && lineStyle == GDK_LINE_SOLID)
|
|
| 1676 | 1685 | {
|
| 1677 | 1686 | width = 0;
|
| 1678 | 1687 | capStyle = GDK_CAP_NOT_LAST;
|
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help