⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notepixmapfactory.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            m_p->drawArc            (x, y + i - tieCurve, tieCurve*2, tieCurve*2, 200*16, 70*16);            m_p->drawLine            (x + tieCurve, y + height - i - 1,             x + length - tieCurve - 2, y + height - i - 1);            m_p->drawArc            (x + length - 2*tieCurve - 1, y + i - tieCurve,             tieCurve*2, tieCurve*2, 270*16, 70*16);        }    }#else    int origLength = length;    int x = m_left + m_noteBodyWidth + m_noteBodyWidth / 4 + shift;    length = origLength - m_noteBodyWidth - m_noteBodyWidth / 3 - shift;    // if the length is short, move the tie a bit closer to both notes    if (length < m_noteBodyWidth*2) {        x = m_left + m_noteBodyWidth + shift;        length = origLength - m_noteBodyWidth - shift;    }    if (length < m_noteBodyWidth) {        length = m_noteBodyWidth;    }    // We can't request a smooth slur here, because that always involves    // creating a new pixmap    QPoint hotspot;    drawSlurAux(length, 0, above, false, true, false, hotspot,                &m_p->painter(),                x,                above ? m_above : m_above + m_noteBodyHeight);    //		above ? m_above - m_noteBodyHeight/2 :    //		        m_above + m_noteBodyHeight + m_noteBodyHeight/2);#endif}QCanvasPixmap*NotePixmapFactory::makeRestPixmap(const NotePixmapParameters &params){    Profiler profiler("NotePixmapFactory::makeRestPixmap");    CharName charName(m_style->getRestCharName(params.m_noteType,                      params.m_restOutsideStave));    // Check whether the font has the glyph for this charName;    // if not, substitute a rest-on-stave glyph for a rest-outside-stave glyph,    // and vice-versa.    NoteCharacter character;    if (!getCharacter(charName, character, PlainColour, false))        charName = m_style->getRestCharName(params.m_noteType,                                            !params.m_restOutsideStave);    bool encache = false;    if (params.m_tupletCount == 0 && !m_selected && !m_shaded &&            !params.m_restOutsideStave) {        if (params.m_dots == 0) {            return getCharacter(charName, PlainColour, false).getCanvasPixmap();        } else {            NotePixmapCache::iterator ci(m_dottedRestCache->find(charName));            if (ci != m_dottedRestCache->end())                return new QCanvasPixmap                       (*ci->second, QPoint(ci->second->offsetX(),                                            ci->second->offsetY()));            else                encache = true;        }    }    QPoint hotspot(m_font->getHotspot(charName));    drawRestAux(params, hotspot, 0, 0, 0);    QCanvasPixmap* canvasMap = makeCanvasPixmap(hotspot);    if (encache) {        m_dottedRestCache->insert(std::pair<CharName, QCanvasPixmap*>                                  (charName, new QCanvasPixmap                                   (*canvasMap, hotspot)));    }    return canvasMap;}voidNotePixmapFactory::drawRest(const NotePixmapParameters &params,                            QPainter &painter, int x, int y){    Profiler profiler("NotePixmapFactory::drawRest");    m_inPrinterMethod = true;    QPoint hotspot; // unused    drawRestAux(params, hotspot, &painter, x, y);    m_inPrinterMethod = false;}voidNotePixmapFactory::drawRestAux(const NotePixmapParameters &params,                               QPoint &hotspot, QPainter *painter, int x, int y){    CharName charName(m_style->getRestCharName(params.m_noteType,                      params.m_restOutsideStave));    NoteCharacter character = getCharacter(charName,                                           params.m_quantized ? QuantizedColour :                                           PlainColour,                                           false);    NoteCharacter dot = getCharacter(NoteCharacterNames::DOT, PlainColour, false);    int dotWidth = dot.getWidth();    if (dotWidth < getNoteBodyWidth() / 2)        dotWidth = getNoteBodyWidth() / 2;    m_above = m_left = 0;    m_below = dot.getHeight() / 2; // for dotted shallow rests like semibreve    m_right = dotWidth / 2 + dotWidth * params.m_dots;    m_noteBodyWidth = character.getWidth();    m_noteBodyHeight = character.getHeight();    if (params.m_tupletCount)        makeRoomForTuplingLine(params);    // we'll adjust this for tupling line after drawing rest character:    hotspot = m_font->getHotspot(charName);    if (params.m_restOutsideStave &&            (charName == NoteCharacterNames::MULTI_REST ||             charName == NoteCharacterNames::MULTI_REST_ON_STAFF)) {        makeRoomForLegerLines(params);    }    if (painter) {        painter->save();        m_p->beginExternal(painter);        painter->translate(x - m_left, y - m_above - hotspot.y());    } else {        createPixmapAndMask(m_noteBodyWidth + m_left + m_right,                            m_noteBodyHeight + m_above + m_below);    }    m_p->drawNoteCharacter(m_left, m_above, character);    if (params.m_tupletCount)        drawTuplingLine(params);    hotspot.setX(m_left);    hotspot.setY(m_above + hotspot.y());    int restY = hotspot.y() - dot.getHeight() - getStaffLineThickness();    if (params.m_noteType == Note::Semibreve ||            params.m_noteType == Note::Breve) {        restY += getLineSpacing();    }    for (int i = 0; i < params.m_dots; ++i) {        int x = m_left + m_noteBodyWidth + i * dotWidth + dotWidth / 2;        m_p->drawNoteCharacter(x, restY, dot);    }    if (params.m_restOutsideStave &&            (charName == NoteCharacterNames::MULTI_REST ||             charName == NoteCharacterNames::MULTI_REST_ON_STAFF)) {        drawLegerLines(params);    }    if (painter) {        painter->restore();    }}QCanvasPixmap*NotePixmapFactory::makeClefPixmap(const Clef &clef){    Profiler profiler("NotePixmapFactory::makeClefPixmap");    NoteCharacter plain = getCharacter(m_style->getClefCharName(clef),                                       PlainColour, false);    int oct = clef.getOctaveOffset();    if (oct == 0)        return plain.getCanvasPixmap();    QFont defaultOctaveFont(defaultSerifFontFamily);    KConfig* config = kapp->config();    config->setGroup(NotationViewConfigGroup);    QFont octaveFont = config->readFontEntry("textfont", &defaultOctaveFont);    octaveFont.setPixelSize(getLineSpacing() * 3 / 2);    QFontMetrics octaveFontMetrics(octaveFont);    // fix #1522784 and use 15 rather than 16 for double octave offset    int adjustedOctave = (8 * (oct < 0 ? -oct : oct));    if (adjustedOctave > 8)        adjustedOctave--;    else if (adjustedOctave < 8)        adjustedOctave++;    QString text = QString("%1").arg(adjustedOctave);    QRect rect = octaveFontMetrics.boundingRect(text);    createPixmapAndMask(plain.getWidth(),                        plain.getHeight() + rect.height());    if (m_selected) {        m_p->painter().setPen(GUIPalette::getColour(GUIPalette::SelectedElement));    }    m_p->drawNoteCharacter(0, oct < 0 ? 0 : rect.height(), plain);    m_p->painter().setFont(octaveFont);    if (!m_inPrinterMethod)        m_p->maskPainter().setFont(octaveFont);    m_p->drawText(plain.getWidth() / 2 - rect.width() / 2,                  oct < 0 ? plain.getHeight() + rect.height() - 1 :                  rect.height(), text);    m_p->painter().setPen(Qt::black);    QPoint hotspot(plain.getHotspot());    if (oct > 0)        hotspot.setY(hotspot.y() + rect.height());    return makeCanvasPixmap(hotspot);}QCanvasPixmap*NotePixmapFactory::makePedalDownPixmap(){    return getCharacter(NoteCharacterNames::PEDAL_MARK, PlainColour, false)           .getCanvasPixmap();}QCanvasPixmap*NotePixmapFactory::makePedalUpPixmap(){    return getCharacter(NoteCharacterNames::PEDAL_UP_MARK, PlainColour, false)           .getCanvasPixmap();}QCanvasPixmap*NotePixmapFactory::makeUnknownPixmap(){    Profiler profiler("NotePixmapFactory::makeUnknownPixmap");    return getCharacter(NoteCharacterNames::UNKNOWN, PlainColour, false)           .getCanvasPixmap();}QCanvasPixmap*NotePixmapFactory::makeToolbarPixmap(const char *name, bool menuSize){    QString pixmapDir = KGlobal::dirs()->findResource("appdata", "pixmaps/");    QString fileBase = pixmapDir + "/toolbar/";    if (menuSize) fileBase += "menu-";    fileBase += name;    if (QFile(fileBase + ".png").exists()) {        return new QCanvasPixmap(fileBase + ".png");    } else if (QFile(fileBase + ".xpm").exists()) {        return new QCanvasPixmap(fileBase + ".xpm");    } else if (menuSize) {        return makeToolbarPixmap(name, false);    } else {        // this will fail, but we don't want to return a null pointer        return new QCanvasPixmap(fileBase + ".png");    }}QCanvasPixmap*NotePixmapFactory::makeNoteMenuPixmap(timeT duration,                                      timeT &errorReturn){    Note nearestNote = Note::getNearestNote(duration);    bool triplet = false;    errorReturn = 0;    if (nearestNote.getDuration() != duration) {        Note tripletNote = Note::getNearestNote(duration * 3 / 2);        if (tripletNote.getDuration() == duration * 3 / 2) {            nearestNote = tripletNote;            triplet = true;        } else {            errorReturn = duration - nearestNote.getDuration();        }    }    QString noteName = NotationStrings::getReferenceName(nearestNote);    if (triplet)        noteName = "3-" + noteName;    noteName = "menu-" + noteName;    return makeToolbarPixmap(noteName);}QCanvasPixmap *NotePixmapFactory::makeMarkMenuPixmap(Mark mark){    if (mark == Marks::Sforzando ||            mark == Marks::Rinforzando) {        return makeToolbarPixmap(mark.c_str());    } else {        NoteFont *font = 0;        try {            font = NoteFontFactory::getFont                   (NoteFontFactory::getDefaultFontName(), 6);        } catch (Exception) {            font = NoteFontFactory::getFont                   (NoteFontFactory::getDefaultFontName(),                    NoteFontFactory::getDefaultSize(NoteFontFactory::getDefaultFontName()));        }        NoteCharacter character = font->getCharacter                                  (NoteStyleFactory::getStyle(NoteStyleFactory::DefaultStyle)->                                   getMarkCharName(mark));        return character.getCanvasPixmap();    }}QCanvasPixmap*NotePixmapFactory::makeKeyPixmap(const Key &key,                                 const Clef &clef,                                 Key previousKey){    Profiler profiler("NotePixmapFactory::makeKeyPixmap");    std::vector<int> ah0 = previousKey.getAccidentalHeights(clef);    std::vector<int> ah1 = key.getAccidentalHeights(clef);    int cancelCount = 0;    if (key.isSharp() != previousKey.isSharp())        cancelCount = ah0.size();    else if (ah1.size() < ah0.size())        cancelCount = ah0.size() - ah1.size();    CharName keyCharName;    if (key.isSharp())        keyCharName = NoteCharacterNames::SHARP;    else        keyCharName = NoteCharacterNames::FLAT;    NoteCharacter keyCharacter;    NoteCharacter cancelCharacter;    keyCharacter = getCharacter(keyCharName, PlainColour, false);    if (cancelCount > 0) {        cancelCharacter = getCharacter(NoteCharacterNames::NATURAL, PlainColour, false);    }    int x = 0;    int lw = getLineSpacing();    int keyDelta = keyCharacter.getWidth() - keyCharacter.getHotspot().x();    int cancelDelta = 0;    int between = 0;    if (cancelCount > 0) {        cancelDelta = cancelCharacter.getWidth() + cancelCharacter.getWidth() / 3;        between = cancelCharacter.getWidth();    }    createPixmapAndMask(keyDelta * ah1.size() + cancelDelta * cancelCount + between +                        keyCharacter.getWidth() / 4, lw * 8 + 1);    if (key.isSharp() != previousKey.isSharp()) {        // cancellation first        for (int i = 0; i < cancelCount; ++i) {            int h = ah0[ah0.size() - cancelCount + i];            int y = (lw * 2) + ((8 - h) * lw) / 2 - cancelCharacter.getHotspot().y();            m_p->drawNoteCharacter(x, y, cancelCharacter);            x += cancelDelta;        }        if (cancelCount > 0) {            x += between;        }    }    for (unsigned int i = 0; i < ah1.size(); ++i) {        int h = ah1[i];        int y = (lw * 2) + ((8 - h) * lw) / 2 - keyCharacter.getHotspot().y();        m_p->drawNoteCharacter(x, y, keyCharacter);        x += keyDelta;    }    if (key.isSharp() == previousKey.isSharp()) {        // cancellation afterwards        if (cancelCount > 0) {            x += between;        }        for (int i = 0; i < cancelCount; ++i) {            int h = ah0[ah0.size() - cancelCount + i];            int y = (lw * 2) + ((8 - h) * lw) / 2 - cancelCharacter.getHotspot().y();            m_p->drawNoteCharacter(x, y, cancelCharacter);            x += cancelDelta;        }    }    return makeCanvasPixmap(m_pointZero);}QCanvasPixmap*NotePixmapFactory::makeClefDisplayPixmap(const Clef &clef){    QCanvasPixmap* clefPixmap = makeClefPixmap(clef);   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -