void GRSingleRest::tellPosition( GObject * caller, const NVPoint & newPosition ) { if (mFillsBar && caller == secondbar) { // then we have a bar filler .... // now we need to check, wether the firstbar exists ... // if not, we need the horizontal position of the firstglue // of the first systemslice .... float posx = -1; if (firstbar) { // we need to check, if the systems of the firstbar // and secondbar are identical .... GRSystem * sys1 = firstbar->getGRStaff()->getGRSystem(); GRSystem * sys2 = secondbar->getGRStaff()->getGRSystem(); if (sys1 == sys2) posx = firstbar->getPosition().x; } if ((posx < 0 || !firstbar) && mGrStaff) { // this will only work, if we are at // the very beginning, and there was no // "artificial" begin-slice. GRGlue * myglue = mGrStaff->getSecondGlue(); if (myglue) posx = myglue->getPosition().x; else { GRSystem * grsystem = mGrStaff->getGRSystem(); // take the first systemslice .... if (grsystem) { GRSystemSlice * grsysslc = grsystem->getFirstGRSystemSlice(); if (grsysslc) { myglue = grsysslc->getEndGlue(); if (myglue) posx = myglue->getPosition().x; } } } } setHPosition((float)((secondbar->getPosition().x - posx) * 0.5f + posx)); return; } if ( mNeedsSpring == 0 && mSpringID == -1) setHPosition(newPosition.x); }
void GRGrace::tellPosition(GObject *caller, const NVPoint & inPos ) { if (mAssociated->GetCount() != 1) { GuidoWarn("More than one association for GRGrace"); return; } // this is called by the "super-event" const float graceOffset = 60; // Hardcoded setHPosition( inPos.x - graceOffset ); // mAssociated->setPosition(position); }
void GRGlobalStem::tellPosition(GObject * obj, const NVPoint & pt) { if (error) return; if (dynamic_cast<GRNotationElement *>(obj) == mFirstEl) // useless cast ? { if (mIsSystemCall) { // this is the staff, to which the stem belongs .... const GRStaff * stemstaff = mFirstEl->getGRStaff(); // update the position of the stem and of the flag .... // determine the lowest and highest position ... GRNotationElement * el = mAssociated->GetTail(); NVPoint offset; if (el) { offset = el->getGRStaff()->getPosition(); mLowestY = el->getPosition().y + offset.y; mHighestY = mLowestY; } else { mLowestY = 0; mHighestY = 0; } GuidoPos pos = mAssociated->GetHeadPosition(); while (pos) { GRNotationElement * el = mAssociated->GetNext(pos); if (el && !dynamic_cast<GREmpty *>(el)) { offset = el->getGRStaff()->getPosition(); if (mLowestY > el->getPosition().y + offset.y) mLowestY = el->getPosition().y + offset.y; if (mHighestY < el->getPosition().y + offset.y) mHighestY = el->getPosition().y + offset.y; } } offset = stemstaff->getPosition(); mLowestY -= offset.y; mHighestY -= offset.y; GDirection stemdir = theStem->getStemDir(); // now we have the position of the lowest or highest note ... if (stemdir == dirUP) { theStem->setPosition(NVPoint(0, (GCoord)mHighestY)); } else if (stemdir == dirDOWN) { theStem->setPosition(NVPoint(0, (GCoord)mLowestY)); } // now we have to deal with the length ... if (stemstate && stemstate->getLength()->TagIsSet()) { // we have a length, that was definitly set .... theStem->setStemLength( stemstate->getLength()->getValue()); stemlengthset = true; } else { // length was not set .... const float theLength = (float)(mHighestY - mLowestY + stemstaff->getStaffLSPACE() * 3.5f); theStem->setStemLength(theLength); } // here we have to add the flags ... // theFlag = new GRFlag(this, // dispdur,stemdir,theStem->getStemLength()); if (stemdir == dirUP) { theFlag->setPosition(NVPoint(0, (GCoord)mHighestY)); } else if (stemdir == dirDOWN) { theFlag->setPosition(NVPoint(0, (GCoord)mLowestY)); } GRNotationElement * tmpel = mAssociated->GetHead(); if (tmpel) updateGlobalStem(tmpel->getGRStaff()); } setHPosition(pt.x); } }