Changeset 81865 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 15, 2019 9:54:50 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134659
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r81864 r81865 54 54 #endif 55 55 56 /* External includes: */ 57 # include <math.h> 58 56 59 /* Forward declarations: */ 57 60 class UISoftKeyboardColorButton; … … 144 147 }; 145 148 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. */ 150 QPointF 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; 153 159 } 154 160 … … 450 456 451 457 void updateState(bool fPressed); 458 /** Creates a path out of points m_points with rounded corners. */ 452 459 void computePainterPath(); 453 460 … … 1713 1720 if (m_points.size() < 3) 1714 1721 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])); 1717 1724 for (int i = 0; i < m_points.size(); ++i) 1718 1725 { 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()]); 1721 1728 m_painterPath.lineTo(p0); 1722 1729 m_painterPath.quadTo(m_points[(i+1)%m_points.size()], p1);
Note:
See TracChangeset
for help on using the changeset viewer.