Logo Search packages:      
Sourcecode: rosegarden version File versions

bool NotationStaff::elementShiftedOnly ( NotationElementList::iterator  i  )  [protected, virtual]

Returns true if the item at the given iterator appears to have moved horizontally without the spacing around it changing.

In practice, calculates the offset between the intended layout and current canvas coordinates of the item at the given iterator, and returns true if this offset is equal to those of all other following iterators at the same time as well as the first iterator found at a greater time.

Definition at line 817 of file notationstaff.cpp.

References LinedStaff::getCanvasCoordsForLayoutCoords(), NotationElement::getCanvasItem(), NotationElement::getCanvasX(), NotationElement::getCanvasY(), Rosegarden::ViewElement::getLayoutX(), Rosegarden::ViewElement::getLayoutY(), NotationElement::getViewAbsoluteTime(), and Rosegarden::Staff::getViewElementList().

    int shift = 0;
    bool ok = false;

    for (NotationElementList::iterator j = i;
       j != getViewElementList()->end(); ++j) {

      NotationElement *elt = static_cast<NotationElement*>(*j);
      if (!elt->getCanvasItem()) break;

      LinedStaffCoords coords = getCanvasCoordsForLayoutCoords
          (elt->getLayoutX(), (int)elt->getLayoutY());
      // regard any shift in y as suspicious
      if ((int)(elt->getCanvasY()) != (int)(coords.second)) break;

      int myShift = (int)(elt->getCanvasX()) - (int)(coords.first);
      if (j == i) shift = myShift;
      else if (myShift != shift) break;
      if (elt->getViewAbsoluteTime() > (*i)->getViewAbsoluteTime()) {
          // all events up to and including this one have passed
          ok = true;

    if (!ok) {
          << "elementShiftedOnly: elt at " << (*i)->getViewAbsoluteTime()
          << ", ok is " << ok << endl;

    return ok;

Generated by  Doxygen 1.6.0   Back to index