VirtualBox

Changeset 81865 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 15, 2019 9:54:50 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134659
Message:

FE/Qt: bugref: 6143. Using the same radius everywhere.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r81864 r81865  
    5454#endif
    5555
     56/* External includes: */
     57# include <math.h>
     58
    5659/* Forward declarations: */
    5760class UISoftKeyboardColorButton;
     
    144147};
    145148
    146 QPointF linearInterpolation(qreal t, const QPointF &p0, const QPointF &p1)
    147 {
    148     if (t < 0)
    149         return p0;
    150     if (t> 1)
    151         return p1;
    152     return QPointF((1 - t) * p0 + t * p1);
     149/** Returns a QPointF which lies on the line [p0, p1] and with a distance @p fDistance to p0. */
     150QPointF pointInBetween(qreal fDistance, const QPointF &p0, const QPointF &p1)
     151{
     152    QPointF vectorP0P1 = p1 - p0;
     153    qreal length = sqrt(vectorP0P1.x() * vectorP0P1.x() + vectorP0P1.y() * vectorP0P1.y());
     154    if (length == 0)
     155        return QPointF();
     156    /* Normalize the vector and add it to starting point: */
     157    vectorP0P1 = (fDistance /length) * vectorP0P1 + p0;
     158    return vectorP0P1;
    153159}
    154160
     
    450456
    451457    void updateState(bool fPressed);
     458    /** Creates a path out of points m_points with rounded corners. */
    452459    void computePainterPath();
    453460
     
    17131720    if (m_points.size() < 3)
    17141721        return;
    1715     double d = 0.1;
    1716     m_painterPath = QPainterPath(linearInterpolation(d, m_points[0], m_points[1]));
     1722    qreal fRadius = 5;
     1723    m_painterPath = QPainterPath(pointInBetween(fRadius, m_points[0], m_points[1]));
    17171724    for (int i = 0; i < m_points.size(); ++i)
    17181725    {
    1719         QPointF p0 = linearInterpolation(1-d, m_points[i], m_points[(i+1)%m_points.size()]);
    1720         QPointF p1 = linearInterpolation(d, m_points[(i+1)%m_points.size()], m_points[(i+2)%m_points.size()]);
     1726        QPointF p0 = pointInBetween(fRadius, m_points[(i+1)%m_points.size()], m_points[i]);
     1727        QPointF p1 = pointInBetween(fRadius, m_points[(i+1)%m_points.size()], m_points[(i+2)%m_points.size()]);
    17211728        m_painterPath.lineTo(p0);
    17221729        m_painterPath.quadTo(m_points[(i+1)%m_points.size()], p1);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette