bool Caret::moveToSystem(int system, bool keepStaff) { const int prevSystem = myLocation.getSystemIndex(); myLocation.setSystemIndex(boost::algorithm::clamp(system, 0, getLastSystemIndex())); if (myLocation.getSystemIndex() != prevSystem) { if (!keepStaff) myLocation.setStaffIndex(0); else { myLocation.setStaffIndex(boost::algorithm::clamp( myLocation.getStaffIndex(), 0, static_cast<int>(myLocation.getSystem().getStaves().size() - 1))); } myLocation.setPositionIndex(0); myLocation.setSelectionStart(0); myLocation.setString(0); onLocationChanged(); return true; } else return false; }
void Caret::moveVertical(int offset) { const int numStrings = myLocation.getStaff().getStringCount(); myLocation.setString((myLocation.getString() + offset + numStrings) % numStrings); onLocationChanged(); }
void Caret::moveToPosition(int position) { myLocation.setPositionIndex(boost::algorithm::clamp(position, 0, getLastPosition())); myLocation.setSelectionStart(myLocation.getPositionIndex()); onLocationChanged(); }
void Caret::moveToStaff(int staff) { myLocation.setStaffIndex(boost::algorithm::clamp( staff, 0, static_cast<int>(myLocation.getSystem().getStaves().size()) - 1)); onLocationChanged(); }
void EmberEntity::setGraphicalRepresentation(IGraphicalRepresentation* graphicalRepresentation) { if (graphicalRepresentation != mGraphicalRepresentation) { //We must delete the attachment before we delete the graphical representation. setAttachment(0); delete mGraphicalRepresentation; mGraphicalRepresentation = graphicalRepresentation; onLocationChanged(getLocation()); //This is needed to generate a new attachment. } }
void Caret::handleSelectionChanged(const ScoreLocation &location) { // Ignore mouse clicks while in playback mode. if (myInPlaybackMode) return; myLocation.setSystemIndex(location.getSystemIndex()); myLocation.setStaffIndex(location.getStaffIndex()); myLocation.setPositionIndex(location.getPositionIndex()); myLocation.setSelectionStart(location.getSelectionStart()); myLocation.setString(location.getString()); onLocationChanged(); }
void Caret::setIsInPlaybackMode(bool set) { myInPlaybackMode = set; // Trigger a redraw. onLocationChanged(); }