Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
void Caret::moveVertical(int offset)
{
    const int numStrings = myLocation.getStaff().getStringCount();
    myLocation.setString((myLocation.getString() + offset + numStrings) %
                         numStrings);

    onLocationChanged();
}
Ejemplo n.º 3
0
void Caret::moveToPosition(int position)
{
    myLocation.setPositionIndex(boost::algorithm::clamp(position, 0,
                                                        getLastPosition()));
    myLocation.setSelectionStart(myLocation.getPositionIndex());

    onLocationChanged();
}
Ejemplo n.º 4
0
void Caret::moveToStaff(int staff)
{
    myLocation.setStaffIndex(boost::algorithm::clamp(
        staff, 0,
        static_cast<int>(myLocation.getSystem().getStaves().size()) - 1));

    onLocationChanged();
}
Ejemplo n.º 5
0
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.
  }
}
Ejemplo n.º 6
0
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();
}
Ejemplo n.º 7
0
void Caret::setIsInPlaybackMode(bool set)
{
    myInPlaybackMode = set;
    // Trigger a redraw.
    onLocationChanged();
}