Ejemplo n.º 1
0
CodeDocument::Position CodeDocument::findWordBreakBefore (const Position& position) const noexcept
{
    auto p = position;
    const int maxDistance = 256;
    int i = 0;
    bool stoppedAtLineStart = false;

    while (i < maxDistance)
    {
        auto c = p.movedBy (-1).getCharacter();

        if (c == '\r' || c == '\n')
        {
            stoppedAtLineStart = true;

            if (i > 0)
                break;
        }

        if (! CharacterFunctions::isWhitespace (c))
            break;

        p.moveBy (-1);
        ++i;
    }

    if (i < maxDistance && ! stoppedAtLineStart)
    {
        auto type = getCharacterType (p.movedBy (-1).getCharacter());

        while (i < maxDistance && type == getCharacterType (p.movedBy (-1).getCharacter()))
        {
            p.moveBy (-1);
            ++i;
        }
    }

    return p;
}
Ejemplo n.º 2
0
static QList<int> bounce(QPoint & p0, QVector2D vel, QSize size, const QRectList & rectsIn)
{
  QList<int> touched;
#if 0
  QList<QPair<int, QRect> > rects;
  QRect swept = QRect(p0, size).united(QRect(movedBy(p0, vel), size));
  for (int i = 0; i < rectsIn.count(); ++i)
    if (rectsIn.at(i).intersects(swept)) rects << qMakePair(i, rectsIn.at(i));
  QVector2D p(p0.x(), p0.y());
  QVector2D d(td.manhattanNormalize(vel));
  while (vel.lengthSquared() > d.lengthSquared()) {

  }

#endif
  return touched;
}
Ejemplo n.º 3
0
void Item::moveBy( double dx, double dy )
{
	KtlQCanvasPolygon::moveBy(dx,dy);
	emit movedBy( dx, dy );
}
Ejemplo n.º 4
0
		RoundRect movedBy(double _x, double _y) const { return movedBy({ _x, _y }); }
Ejemplo n.º 5
0
		Polygon movedBy(const Vec2& v) const
		{
			return movedBy(v.x, v.y);
		}
Ejemplo n.º 6
0
		[[nodiscard]] constexpr Ellipse movedBy(const position_type& v) const noexcept
		{
			return movedBy(v.x, v.y);
		}
Ejemplo n.º 7
0
		RoundRect operator - (const Vec2& v) const { return movedBy(-v); }
Ejemplo n.º 8
0
		Cylinder movedBy(double _x, double _y, double _z) const { return movedBy({ _x, _y, _z }); }
Ejemplo n.º 9
0
		constexpr Line movedBy(const position_type& v) const noexcept
		{
			return movedBy(v.x, v.y);
		}
Ejemplo n.º 10
0
		Shape operator - (const Vec2& v) const
		{
			return movedBy(-v);
		}
Ejemplo n.º 11
0
		Shape operator + (const Vec2& v) const
		{
			return movedBy(v);
		}
Ejemplo n.º 12
0
		Shape movedBy(double x, double y) const
		{
			return movedBy({ x, y });
		}