Exemple #1
0
QRectF Dynamic::drag(EditData* ed)
      {
      QRectF f = Element::drag(ed);

      //
      // move anchor
      //
      Qt::KeyboardModifiers km = qApp->keyboardModifiers();
      if (km != (Qt::ShiftModifier | Qt::ControlModifier)) {
            int si;
            Segment* seg = 0;
            if (score()->pos2measure(ed->pos, &si, 0, &seg, 0) == nullptr)
                  return f;
            if (seg && (seg != segment() || staffIdx() != si)) {
                  QPointF pos1(canvasPos());
                  score()->undo(new ChangeParent(this, seg, si));
                  setUserOff(QPointF());
                  layout();
                  QPointF pos2(canvasPos());
                  setUserOff(pos1 - pos2);
                  ed->startMove = pos2;
                  }
            }
      return f;
      }
Exemple #2
0
QLineF BSymbol::dragAnchor() const
      {
      if (parent() && parent()->type() == SEGMENT) {
            System* system = segment()->measure()->system();
            qreal y        = system->staff(staffIdx())->y() + system->y();
            QPointF anchor(segment()->pageX(), y);
            return QLineF(canvasPos(), anchor);
            }
      else {
            return QLineF(canvasPos(), parent()->canvasPos());
            }
      }
QLineF Dynamic::dragAnchor() const
      {
      qreal xp = 0.0;
      for (Element* e = parent(); e; e = e->parent())
            xp += e->x();
      qreal yp = measure()->system()->staffYpage(staffIdx());
      QPointF p(xp, yp);
      return QLineF(p, canvasPos());
      }
Exemple #4
0
bool Text::setCursor(const QPointF& p, QTextCursor::MoveMode mode)
      {
      QPointF pt  = p - canvasPos();
      if (!bbox().contains(pt))
            return false;

      int idx = _doc->documentLayout()->hitTest(pt, Qt::FuzzyHit);
      if (idx == -1)
            return true;
      if (_cursor) {
            _cursor->setPosition(idx, mode);
            if (_cursor->hasSelection())
                  QApplication::clipboard()->setText(_cursor->selectedText(), QClipboard::Selection);
            }
      return true;
      }
Exemple #5
0
QLineF FretDiagram::dragAnchor() const
      {
      qreal xp = 0.0;
      for (Element* e = parent(); e; e = e->parent())
            xp += e->x();
      qreal yp;
      if (parent()->type() == ElementType::SEGMENT) {
            System* system = static_cast<Segment*>(parent())->measure()->system();
            yp = system->staffCanvasYpage(staffIdx());
            }
      else
            yp = parent()->canvasPos().y();
      QPointF p1(xp, yp);
      return QLineF(p1, canvasPos());
#if 0 // TODOxx
      if (parent()->type() == ElementType::SEGMENT) {
            Segment* s     = static_cast<Segment*>(parent());
            Measure* m     = s->measure();
            System* system = m->system();
            qreal yp      = system->staff(staffIdx())->y() + system->y();
            qreal xp      = m->tick2pos(s->tick()) + m->pagePos().x();
            QPointF p1(xp, yp);

            qreal x  = 0.0;
            qreal y  = 0.0;
            qreal tw = width();
            qreal th = height();
            if (_align & Align::BOTTOM)
                  y = th;
            else if (_align & Align::VCENTER)
                  y = (th * .5);
            else if (_align & Align::BASELINE)
                  y = baseLine();
            if (_align & Align::RIGHT)
                  x = tw;
            else if (_align & Align::HCENTER)
                  x = (tw * .5);
            return QLineF(p1, abbox().topLeft() + QPointF(x, y));
            }
      return QLineF(parent()->pagePos(), abbox().topLeft());
#endif
      }
Exemple #6
0
QLineF Text::dragAnchor() const
      {
      QPointF p1;

      if (parent()->type() == MEASURE) {
            Measure* m     = static_cast<Measure*>(parent());
            System* system = m->system();
            qreal yp       = system->staff(staffIdx())->y() + system->y() + system->page()->pos().x();
            qreal xp       = m->canvasPos().x(); // m->tick2pos(tick()) + m->canvasPos().x();
            p1 = QPointF(xp, yp);
            }
      else {
            p1 = parent()->canvasPos(); // QPointF(parent()->canvasBoundingRect().topLeft());
            if (parent()->type() == SEGMENT) {
                  Segment* s = static_cast<Segment*>(parent());
                  p1.ry() += s ? s->measure()->system()->staff(staffIdx())->y() : 0.0;
                  }
            }

      QPointF p2;
      QRectF r(canvasBoundingRect());

      if (align() & ALIGN_BOTTOM)
            p2.ry() = r.bottom();
      else if (align() & ALIGN_VCENTER)
            p2.ry() = r.center().y();
      else if (align() & ALIGN_BASELINE)
            p2.ry() = canvasPos().y();
      else // ALIGN_TOP
            p2.ry() = r.top();

      if (align() & ALIGN_RIGHT)
            p2.rx() = r.right();
      else if (align() & ALIGN_HCENTER)
            p2.rx() = r.center().x();
      else  // ALIGN_LEFT
            p2.rx() = r.left();

      return QLineF(p1, p2);
      }
Exemple #7
0
QLineF Articulation::dragAnchor() const
      {
      return QLineF(canvasPos(), parent()->canvasPos());
      }
Exemple #8
0
QLineF Fermata::dragAnchor() const
      {
      return QLineF(canvasPos(), parent()->canvasPos());
      }