void BarLine::drawDots(QPainter* painter, qreal x) const { qreal _spatium = spatium(); if (parent() == 0) { // for use in palette drawSymbol(SymId::repeatDot, painter, QPointF(x, 2.0 * _spatium)); drawSymbol(SymId::repeatDot, painter, QPointF(x, 3.0 * _spatium)); } else if (parent()->type() == Element::Type::SEGMENT) { System* s = static_cast<Segment*>(parent())->measure()->system(); int staffIdx1 = staffIdx(); int staffIdx2 = staffIdx1 + _span - 1; int sp = _span; if (staffIdx2 >= score()->nstaves()) { qDebug("BarLine: bad _span %d", _span); staffIdx2 = score()->nstaves() - 1; sp = staffIdx2 - staffIdx1 + 1; } qreal dy = s->staff(staffIdx1)->y(); for (int i = 0; i < sp; ++i) { Staff* staff = score()->staff(staffIdx1 + i); StaffType* st = staff->staffType(); qreal doty1 = (st->doty1() + .5) * _spatium; qreal doty2 = (st->doty2() + .5) * _spatium; qreal staffy = s->staff(staffIdx1 + i)->y() - dy; drawSymbol(SymId::repeatDot, painter, QPointF(x, staffy + doty1)); drawSymbol(SymId::repeatDot, painter, QPointF(x, staffy + doty2)); } } }
int TestHR() { Staff *hr = new HR(1, "123123"); cout << "get1:" << hr->calculateSalary() << endl; cout << "get2:" << hr->calculateSomeThing() << endl; system("pause"); return 0; }
void NoteEntryAction::renderKeyboardPreview(QPainter& painter, const MusicCursor& cursor) { Staff* staff = cursor.staff(); Part* part = staff->part(); Sheet* sheet = part->sheet(); Bar* bar = sheet->bar(cursor.bar()); QPointF p = bar->position() + QPointF(0, staff->top()); Voice* voice = cursor.staff()->part()->voice(cursor.voice()); VoiceBar* vb = voice->bar(bar); if (cursor.element() >= vb->elementCount()) { // cursor is past last element in bar, position of cursor is // halfway between last element and end of bar if (vb->elementCount() == 0) { // unless entire voicebar is still empty p.rx() += 15.0; } else { VoiceElement* ve = vb->element(vb->elementCount()-1); p.rx() += (ve->x() + bar->size()) / 2; } } else { // cursor is on an element, get the position of that element p.rx() += vb->element(cursor.element())->x(); } p.ry() += (cursor.staff()->lineCount() - 1)* cursor.staff()->lineSpacing(); p.ry() -= cursor.staff()->lineSpacing() * cursor.line() / 2; m_tool->shape()->renderer()->renderNote(painter, m_duration < QuarterNote ? QuarterNote : m_duration, p, 0, Qt::magenta); }
void InspectorBarLine::manageSpanData() { #if 0 BarLine* bl = toBarLine(inspector->element()); // determine MIN and MAX for SPANFROM and SPANTO Staff* staffFrom = bl->staff(); Staff* staffTo = bl->score()->staff(bl->staffIdx() + bl->span() - 1); int staffFromLines= (staffFrom ? staffFrom->lines(bl->tick()) : 5); int staffToLines = (staffTo ? staffTo->lines(bl->tick()) : 5); // From: min = minimum possible according to number of staff lines // max = if same as To, at least 1sp (2 units) above To; if not, max possible according to num.of lines int min = staffFromLines == 1 ? BARLINE_SPAN_1LINESTAFF_FROM : MIN_BARLINE_SPAN_FROMTO; int max = bl->span() < 2 ? bl->spanTo() - MIN_BARLINE_FROMTO_DIST : (staffFromLines == 1 ? BARLINE_SPAN_1LINESTAFF_TO : (staffFromLines-1) * 2 + 2); b.spanFrom->setMinimum(min); b.spanFrom->setMaximum(max); // To: min = if same as From, at least 1sp (2 units) below From; if not, min possible according to num.of lines // max = max possible according to number of staff lines min = bl->span() < 2 ? bl->spanFrom() + MIN_BARLINE_FROMTO_DIST : (staffToLines == 1 ? BARLINE_SPAN_1LINESTAFF_FROM : MIN_BARLINE_SPAN_FROMTO); max = staffToLines == 1 ? BARLINE_SPAN_1LINESTAFF_TO : (staffToLines-1) * 2 + 2; b.spanTo->setMinimum(min); b.spanTo->setMaximum(max); // determine MAX for SPAN max = bl->score()->nstaves() - bl->staffIdx(); b.span->setMaximum(max); #endif }
void Ambitus::draw(QPainter* p) const { qreal _spatium = spatium(); qreal lw = lineWidth().val() * _spatium; p->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap)); drawSymbol(noteHead(), p, _topPos); drawSymbol(noteHead(), p, _bottomPos); if (_hasLine) p->drawLine(_line); // draw ledger lines (if not in a palette) if (segment() && track() > -1) { int tick = segment()->tick(); Staff* stf = score()->staff(staffIdx()); qreal lineDist = stf->lineDistance(tick); int numOfLines = stf->lines(tick); qreal step = lineDist * _spatium; qreal stepTolerance = step * 0.1; qreal ledgerOffset = score()->styleS(Sid::ledgerLineLength).val() * 0.5 * _spatium; p->setPen(QPen(curColor(), score()->styleS(Sid::ledgerLineWidth).val() * _spatium, Qt::SolidLine, Qt::RoundCap) ); if (_topPos.y()-stepTolerance <= -step) { qreal xMin = _topPos.x() - ledgerOffset; qreal xMax = _topPos.x() + headWidth() + ledgerOffset; for (qreal y = -step; y >= _topPos.y()-stepTolerance; y -= step) p->drawLine(QPointF(xMin, y), QPointF(xMax, y)); } if (_bottomPos.y()+stepTolerance >= numOfLines * step) { qreal xMin = _bottomPos.x() - ledgerOffset; qreal xMax = _bottomPos.x() + headWidth() + ledgerOffset; for (qreal y = numOfLines*step; y <= _bottomPos.y()+stepTolerance; y += step) p->drawLine(QPointF(xMin, y), QPointF(xMax, y)); } } }
void Stem::draw(QPainter* painter) const { bool useTab = false; Staff* st = staff(); if (st && st->isTabStaff()) { // stems used in palette do not have a staff if (st->staffType()->slashStyle()) return; useTab = true; } qreal lw = point(score()->styleS(ST_stemWidth)); painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap)); painter->drawLine(line); // NOT THE BEST PLACE FOR THIS? // with tablatures, dots are not drawn near 'notes', but near stems // TODO: adjust bounding rectangle in layout() if (useTab) { int nDots = chord()->dots(); if (nDots > 0) { qreal sp = spatium(); qreal y = stemLen() - ( ((StaffTypeTablature*)st->staffType())->stemsDown() ? (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 ); symbols[score()->symIdx()][dotSym].draw(painter, magS(), QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots); } } }
std::vector<Staff *> TimePointInterface::GetTstampStaves(Measure *measure) { std::vector<Staff *> staves; std::vector<int>::iterator iter; std::vector<int> staffList; if (this->HasStaff()) { staffList = this->GetStaff(); } else if (m_start) { Staff *staff = dynamic_cast<Staff *>(m_start->GetFirstParent(STAFF)); if (staff) staffList.push_back(staff->GetN()); } for (iter = staffList.begin(); iter != staffList.end(); iter++) { AttCommonNComparison comparison(STAFF, *iter); Staff *staff = dynamic_cast<Staff *>(measure->FindChildByAttComparison(&comparison, 1)); if (!staff) { // LogDebug("Staff with @n '%d' not found in measure '%s'", *iter, measure->GetUuid().c_str()); continue; } staves.push_back(staff); } if (staves.empty()) LogDebug("Empty @staff array"); return staves; }
void Measure::AddChild(Object *child) { if (child->IsControlElement()) { assert(dynamic_cast<ControlElement *>(child)); } else if (child->IsEditorialElement()) { assert(dynamic_cast<EditorialElement *>(child)); } else if (child->Is(STAFF)) { Staff *staff = dynamic_cast<Staff *>(child); assert(staff); if (staff && (staff->GetN() < 1)) { // This is not 100% safe if we have a <app> and <rdg> with more than // one staff as a previous child. staff->SetN(this->GetChildCount()); } } else { LogError("Adding '%s' to a '%s'", child->GetClassName().c_str(), this->GetClassName().c_str()); assert(false); } child->SetParent(this); m_children.push_back(child); Modify(); }
bool Arpeggio::edit(MuseScoreView*, int curGrip, int key, Qt::KeyboardModifiers modifiers, const QString&) { if (curGrip != 1 || !(modifiers & Qt::ShiftModifier)) return false; if (key == Qt::Key_Down) { Staff* s = staff(); Part* part = s->part(); int n = part->nstaves(); int ridx = part->staves()->indexOf(s); if (ridx >= 0) { if (_span + ridx < n) ++_span; } } else if (key == Qt::Key_Up) { if (_span > 1) --_span; } else return false; layout(); Chord* c = chord(); rxpos() = -(width() + spatium() * .5); c->layoutArpeggio2(); return true; }
void BarLine::drawDots(QPainter* painter, qreal x) const { const Sym& dotsym = symbols[score()->symIdx()][dotSym]; qreal mags = magS(); qreal _spatium = spatium(); if (parent() == 0) { // for use in palette dotsym.draw(painter, mags, QPointF(x, 1.5 * _spatium)); dotsym.draw(painter, mags, QPointF(x, 2.5 * _spatium)); } else if (parent()->type() == SEGMENT) { System* s = static_cast<Segment*>(parent())->measure()->system(); int staffIdx1 = staffIdx(); int staffIdx2 = staffIdx1 + _span - 1; int sp = _span; if (staffIdx2 >= score()->nstaves()) { qDebug("BarLine: bad _span %d", _span); staffIdx2 = score()->nstaves() - 1; sp = staffIdx2 - staffIdx1 + 1; } qreal dy = s->staff(staffIdx1)->y(); for (int i = 0; i < sp; ++i) { Staff* staff = score()->staff(staffIdx1 + i); StaffType* st = staff->staffType(); qreal doty1 = st->doty1() * _spatium; qreal doty2 = st->doty2() * _spatium; qreal staffy = s->staff(staffIdx1 + i)->y() - dy; dotsym.draw(painter, mags, QPointF(x, staffy + doty1)); dotsym.draw(painter, mags, QPointF(x, staffy + doty2)); } } }
Score::FileError importBww(MasterScore* score, const QString& path) { qDebug("Score::importBww(%s)", qPrintable(path)); QFile fp(path); if(!fp.exists()) return Score::FileError::FILE_NOT_FOUND; if (!fp.open(QIODevice::ReadOnly)) return Score::FileError::FILE_OPEN_ERROR; QString id("importBww"); Part* part = new Part(score); part->setId(id); score->appendPart(part); Staff* staff = new Staff(score); staff->setPart(part); part->staves()->push_back(staff); score->staves().push_back(staff); Bww::Lexer lex(&fp); Bww::MsScWriter wrt; wrt.setScore(score); score->style()->set(StyleIdx::measureSpacing, 1.0); Bww::Parser p(lex, wrt); p.parse(); score->setSaved(false); score->setCreated(true); score->connectTies(); qDebug("Score::importBww() done"); return Score::FileError::FILE_NO_ERROR; // OK }
/// Tests the Position Functions /// @return True if all tests were executed, false if not bool StaffTestSuite::TestCasePositionArray() { //------Last Checked------// // - Jan 25, 2005 Staff staff; staff.m_positionArray[0].Add(new Position); staff.m_positionArray[1].Add(new Position); wxUint32 i = 0; for (; i <= NUM_STAFF_VOICES; i++) { wxUint32 j = 0; for (; j < 2; j++) { TEST(wxString::Format(wxT("IsValidPositionIndex - %d, %d"), i, j), (staff.IsValidPositionIndex(i, j) == ((i < NUM_STAFF_VOICES) && (j == 0))) ); bool valid = ((i < NUM_STAFF_VOICES) && (j == 0)); bool validPointer = (staff.GetPosition(i, j) != NULL); TEST(wxString::Format(wxT("GetPosition - %d, %d"), i, j), (valid == validPointer) ); } } return (true); }
bool Part::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "Staff") { Staff* staff = new Staff(score()); staff->setPart(this); score()->staves().push_back(staff); _staves.push_back(staff); staff->read(e); } else if (tag == "Instrument") { Instrument* instr = new Instrument; instr->read(e, this); setInstrument(instr, -1); } else if (tag == "name") instrument()->setLongName(e.readElementText()); else if (tag == "shortName") instrument()->setShortName(e.readElementText()); else if (tag == "trackName") _partName = e.readElementText(); else if (tag == "show") _show = e.readInt(); else return false; return true; }
void Part::read(XmlReader& e) { while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "Staff") { Staff* staff = new Staff(_score); staff->setPart(this); _score->staves().push_back(staff); _staves.push_back(staff); staff->read(e); } else if (tag == "Instrument") { Instrument* instr = new Instrument; instr->read(e); setInstrument(instr, -1); } else if (tag == "name") instrument()->setLongName(e.readElementText()); else if (tag == "shortName") instrument()->setShortName(e.readElementText()); else if (tag == "trackName") _partName = e.readElementText(); else if (tag == "show") _show = e.readInt(); else e.unknown(); } if (_partName.isEmpty()) _partName = instrument()->trackName(); }
void Part::read(XmlReader* r) { int rstaff = 0; QString val; while (r->readElement()) { MString8 tag(r->tag()); if (tag == "Staff") { Staff* staff = new Staff(_score, this, rstaff); _score->staves().push_back(staff); _staves.push_back(staff); staff->read(r); ++rstaff; } else if (tag == "Instrument") instr(0)->read(r); else if (r->readString("name", &val)) { ; // instr(0)->longName() = QTextDocumentFragment::fromHtml(val); } else if (r->readString("shortName", &val)) { ; // instr(0)->shortName() = QTextDocumentFragment::fromHtml(val); } else if (r->readString("trackName", &_trackName)) ; else if (r->readBool("show", &_show)) _show = val.toInt(); else r->unknown(); } }
void BarLine::drawDots(QPainter* painter, qreal x) const { const Sym& dotsym = symbols[score()->symIdx()][dotSym]; qreal mags = magS(); qreal _spatium = spatium(); if (parent() == 0) { // for use in palette dotsym.draw(painter, mags, QPointF(x, 1.5 * _spatium)); dotsym.draw(painter, mags, QPointF(x, 2.5 * _spatium)); } else { System* s = measure()->system(); int _staffIdx = staffIdx(); qreal dy = s->staff(_staffIdx)->y(); for (int i = 0; i < _span; ++i) { Staff* staff = score()->staff(_staffIdx + i); StaffType* st = staff->staffType(); qreal doty1 = st->doty1() * _spatium; qreal doty2 = st->doty2() * _spatium; qreal staffy = s->staff(_staffIdx + i)->y() - dy; dotsym.draw(painter, mags, QPointF(x, staffy + doty1)); dotsym.draw(painter, mags, QPointF(x, staffy + doty2)); } } }
/// Tests the Clef Functions /// @return True if all tests were executed, false if not bool StaffTestSuite::TestCaseClef() { //------Last Checked------// // - Jan 5, 2005 // TEST CASE: IsValidClef { wxByte i = Staff::TREBLE_CLEF; for (; i <= (Staff::BASS_CLEF + 1); i++) TEST(wxString::Format(wxT("IsValidClef - %d"), i), (Staff::IsValidClef(i) == (i <= Staff::BASS_CLEF)) ); } // TEST CASE: SetClef { Staff staff; wxByte i = Staff::TREBLE_CLEF; for (; i <= (Staff::BASS_CLEF + 1); i++) TEST(wxString::Format(wxT("SetClef - %d"), i), (staff.SetClef(i) == (i <= Staff::BASS_CLEF)) && ((i > Staff::BASS_CLEF) ? 1 : (staff.GetClef() == i)) ); } return (true); }
/// Tests the Tablature Staff Type Functions /// @return True if all tests were executed, false if not bool StaffTestSuite::TestCaseTablatureStaffType() { //------Last Checked------// // - Jan 5, 2005 // TEST CASE: IsValidTablatureStaffType { wxByte i = Staff::MIN_TABLATURE_STAFF_TYPE - 1; for (; i <= (Staff::MAX_TABLATURE_STAFF_TYPE + 1); i++) TEST(wxString::Format(wxT("IsValidTablatureStaffType - %d"), i), (Staff::IsValidTablatureStaffType(i) == ((i >= Staff::MIN_TABLATURE_STAFF_TYPE) && (i <= Staff::MAX_TABLATURE_STAFF_TYPE))) ); } // TEST CASE: SetTablatureStaffType { Staff staff; wxByte i = Staff::MIN_TABLATURE_STAFF_TYPE - 1; for (; i <= (Staff::MAX_TABLATURE_STAFF_TYPE + 1); i++) TEST(wxString::Format(wxT("SetTablatureStaffType - %d"), i), (staff.SetTablatureStaffType(i) == ((i >= Staff::MIN_TABLATURE_STAFF_TYPE) && (i <= Staff::MAX_TABLATURE_STAFF_TYPE))) && (((i < Staff::MIN_TABLATURE_STAFF_TYPE) || (i > Staff::MAX_TABLATURE_STAFF_TYPE)) ? 1 : (staff.GetTablatureStaffType() == i)) ); } return (true); }
void Lilypond::addNote(const LNote& lnote) { createMeasure(); Segment* segment = new Segment(measure); segment->setSubtype(SegChordRest); segment->setTick(tick); segment->setParent(measure); measure->add(segment); Chord* chord = new Chord(score); chord->setTrack(staff->idx() * VOICES); chord->setParent(segment); Duration d; d.setVal(lnote.len); chord->setDurationType(d); segment->add(chord); Note* note = new Note(score); note->setPitch(lnote.pitch); note->setTpcFromPitch(); note->setParent(chord); note->setTrack(staff->idx() * VOICES); chord->add(note); tick += lnote.len; }
data_STEMDIRECTION Layer::GetDrawingStemDir(const ArrayOfBeamElementCoords *coords) { assert(!coords->empty()); // Adjust the x position of the first and last element for taking into account the stem width LayerElement *first = dynamic_cast<LayerElement *>(coords->front()->m_element); LayerElement *last = dynamic_cast<LayerElement *>(coords->back()->m_element); if (!first || !last) { return m_drawingStemDir; } Measure *measure = dynamic_cast<Measure *>(this->GetFirstParent(MEASURE)); assert(measure); // First check if there is any <space> in the measure - if not we can return the layer stem direction if (!measure->FindChildByType(SPACE)) { return m_drawingStemDir; } Alignment *alignmentFirst = first->GetAlignment(); assert(alignmentFirst); Alignment *alignmentLast = last->GetAlignment(); assert(alignmentLast); // We are ignoring cross-staff situation here because this should not be called if we have one Staff *staff = dynamic_cast<Staff *>(first->GetFirstParent(STAFF)); assert(staff); double time = alignmentFirst->GetTime(); double duration = alignmentLast->GetTime() - time + last->GetAlignmentDuration(); duration = durRound(duration); return GetDrawingStemDir(time, duration, measure, staff->GetN()); }
TEST(TestMeiDocument, FlattenedDocTree) { Mei *mei = new Mei(); Music *mus = new Music(); Body *body = new Body(); Staff *staff = new Staff(); Staff *s2 = new Staff(); Note *n1 = new Note(); Note *n2 = new Note(); Note *n3 = new Note(); MeiDocument *doc = new MeiDocument(); mei->addChild(mus); // empty since mei not added as document root yet ASSERT_TRUE(doc->getFlattenedTree().empty()); doc->setRootElement(mei); ASSERT_EQ(2, doc->getFlattenedTree().size()); mus->addChild(body); body->addChild(staff); body->addChild(s2); staff->addChild(n1); staff->addChild(n2); s2->addChild(n3); doc->lookBack(n2, "mei"); ASSERT_EQ(8, doc->getFlattenedTree().size()); staff->removeChild(n2); ASSERT_EQ(7, doc->getFlattenedTree().size()); ASSERT_EQ(s2, doc->getFlattenedTree()[5]); staff->removeChildrenWithName("note"); ASSERT_EQ(6, doc->getFlattenedTree().size()); body->deleteAllChildren(); ASSERT_EQ(3, doc->getFlattenedTree().size()); std::vector<MeiElement*> newChildren; Staff *newStaff1 = new Staff(); Staff *newStaff2 = new Staff(); newChildren.push_back(newStaff1); newChildren.push_back(newStaff2); body->setChildren(newChildren); ASSERT_EQ(5, doc->getFlattenedTree().size()); // check contents MeiElement* elements[] = { mei, mus, body, newStaff1, newStaff2 }; std::vector<MeiElement*> rightOrder (elements, elements + sizeof(elements) / sizeof(MeiElement)); for (int i = 0; i < rightOrder.size(); i++) { // check don't overshoot memory allocation ASSERT_LT(i, doc->getFlattenedTree().size()); ASSERT_EQ(rightOrder[i], doc->getFlattenedTree()[i]); } }
void GameController::spawnWaiter() { Staff *waiter = new Staff(GameData::getInstance()->npcNames[rand() % GameData::getInstance()->npcNames.size()], Person::WAITER, "waiter.png", 90, 140, 1); GameData::getInstance()->personTable.insert(make_pair(waiter->getID(), waiter)); GameData::getInstance()->getScene3D()->addCollisionChild(waiter); waiter->movePerson((TavernResources::getInstance()->barList.front()->barPos.x-1)*5, 3.5, TavernResources::getInstance()->barList.front()->barPos.z*5); waiter->playAnimation("botRight", 1, false); staff.push_back(waiter); }
void GameController::spawnMC() { Staff *barKeepMC = new Staff("MC", Person::BARKEEP, "BarKeep.png", 90, 140, 1); GameData::getInstance()->personTable.insert(make_pair(barKeepMC->getID(), barKeepMC)); GameData::getInstance()->getScene3D()->addCollisionChild(barKeepMC); barKeepMC->movePerson(TavernResources::getInstance()->barList.front()->barkeepTile.x*5, 3.5, TavernResources::getInstance()->barList.front()->barkeepTile.z*5); barKeepMC->playAnimation("botRight", 1, false); staff.push_back(barKeepMC); }
/// Tests the Tablature Staff Below Spacing Functions /// @return True if all tests were executed, false if not bool StaffTestSuite::TestCaseTablatureStaffBelowSpacing() { //------Last Checked------// // - Jan 5, 2005 Staff staff; staff.SetTablatureStaffBelowSpacing(45); TEST(wxT("SetTablatureStaffBelowSpacing"), staff.GetTablatureStaffBelowSpacing() == 45); return (true); }
/// Tests the Standard Notation Staff Above Spacing Functions /// @return True if all tests were executed, false if not bool StaffTestSuite::TestCaseStandardNotationStaffAboveSpacing() { //------Last Checked------// // - Jan 5, 2005 Staff staff; staff.SetStandardNotationStaffAboveSpacing(45); TEST(wxT("SetStandardNotationStaffAboveSpacing"), staff.GetStandardNotationStaffAboveSpacing() == 45); return (true); }
void Fingering::layout() { TextBase::layout(); if (autoplace() && note()) { Chord* chord = note()->chord(); Staff* staff = chord->staff(); Part* part = staff->part(); int n = part->nstaves(); bool voices = chord->measure()->hasVoices(staff->idx()); bool below = voices ? !chord->up() : (n > 1) && (staff->rstaff() == n-1); bool tight = voices && !chord->beam(); qreal x = 0.0; qreal y = 0.0; qreal headWidth = note()->bboxRightPos(); qreal headHeight = note()->headHeight(); qreal fh = headHeight; // TODO: fingering number height if (chord->notes().size() == 1) { x = headWidth * .5; if (below) { // place fingering below note y = fh + spatium() * .4; if (tight) { y += 0.5 * spatium(); if (chord->stem()) x += 0.5 * spatium(); } else if (chord->stem() && !chord->up()) { // on stem side y += chord->stem()->height(); x -= spatium() * .4; } } else { // place fingering above note y = -headHeight - spatium() * .4; if (tight) { y -= 0.5 * spatium(); if (chord->stem()) x -= 0.5 * spatium(); } else if (chord->stem() && chord->up()) { // on stem side y -= chord->stem()->height(); x += spatium() * .4; } } } else { x -= spatium(); } setUserOff(QPointF(x, y)); } }
void Ottava::endEdit() { if (editTick != tick() || editTick2 != tick2()) { Staff* s = staff(); s->updateOttava(); score()->addLayoutFlags(LayoutFlag::FIX_PITCH_VELO); score()->setPlaylistDirty(true); } TextLine::endEdit(); }
void MuseScore::updateInputState(Score* score) { InputState& is = score->inputState(); if (is.noteEntryMode()) { Staff* staff = score->staff(is.track() / VOICES); switch (staff->staffType()->group()) { case StaffGroup::STANDARD: changeState(STATE_NOTE_ENTRY_PITCHED); break; case StaffGroup::TAB: changeState(STATE_NOTE_ENTRY_TAB); break; case StaffGroup::PERCUSSION: changeState(STATE_NOTE_ENTRY_DRUM); break; } } getAction("pad-rest")->setChecked(is.rest()); getAction("pad-dot")->setChecked(is.duration().dots() == 1); getAction("pad-dotdot")->setChecked(is.duration().dots() == 2); getAction("note-longa")->setChecked(is.duration() == TDuration::DurationType::V_LONG); getAction("note-breve")->setChecked(is.duration() == TDuration::DurationType::V_BREVE); getAction("pad-note-1")->setChecked(is.duration() == TDuration::DurationType::V_WHOLE); getAction("pad-note-2")->setChecked(is.duration() == TDuration::DurationType::V_HALF); getAction("pad-note-4")->setChecked(is.duration() == TDuration::DurationType::V_QUARTER); getAction("pad-note-8")->setChecked(is.duration() == TDuration::DurationType::V_EIGHT); getAction("pad-note-16")->setChecked(is.duration() == TDuration::DurationType::V_16TH); getAction("pad-note-32")->setChecked(is.duration() == TDuration::DurationType::V_32ND); getAction("pad-note-64")->setChecked(is.duration() == TDuration::DurationType::V_64TH); getAction("pad-note-128")->setChecked(is.duration() == TDuration::DurationType::V_128TH); // uncheck all voices if multi-selection int voice = score->selection().isSingle() ? is.voice() : -1; getAction("voice-1")->setChecked(voice == 0); getAction("voice-2")->setChecked(voice == 1); getAction("voice-3")->setChecked(voice == 2); getAction("voice-4")->setChecked(voice == 3); getAction("acciaccatura")->setChecked(is.noteType() == NoteType::ACCIACCATURA); getAction("appoggiatura")->setChecked(is.noteType() == NoteType::APPOGGIATURA); getAction("grace4")->setChecked(is.noteType() == NoteType::GRACE4); getAction("grace16")->setChecked(is.noteType() == NoteType::GRACE16); getAction("grace32")->setChecked(is.noteType() == NoteType::GRACE32); getAction("grace8after")->setChecked(is.noteType() == NoteType::GRACE8_AFTER); getAction("grace16after")->setChecked(is.noteType() == NoteType::GRACE16_AFTER); getAction("grace32after")->setChecked(is.noteType() == NoteType::GRACE32_AFTER); getAction("beam-start")->setChecked(is.beamMode() == BeamMode::BEGIN); getAction("beam-mid")->setChecked(is.beamMode() == BeamMode::MID); getAction("no-beam")->setChecked(is.beamMode() == BeamMode::NONE); getAction("beam32")->setChecked(is.beamMode() == BeamMode::BEGIN32); getAction("auto-beam")->setChecked(is.beamMode() == BeamMode::AUTO); getAction("repitch")->setChecked(is.repitchMode()); }
void Stem::draw(QPainter* painter) const { Staff* st = staff(); bool useTab = st && st->isTabStaff(); if (useTab && st->staffType()->slashStyle()) return; qreal lw = lineWidth(); painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::RoundCap)); painter->drawLine(line); if (!useTab) return; // TODO: adjust bounding rectangle in layout() for dots and for slash StaffTypeTablature* stt = static_cast<StaffTypeTablature*>(st->staffType()); qreal sp = spatium(); // slashed half note stem if (chord() && chord()->durationType().type() == TDuration::V_HALF && stt->minimStyle() == TAB_MINIM_SLASHED) { qreal wdt = sp * STAFFTYPE_TAB_SLASH_WIDTH; qreal sln = sp * STAFFTYPE_TAB_SLASH_SLANTY; qreal thk = sp * STAFFTYPE_TAB_SLASH_THICK; qreal displ = sp * STAFFTYPE_TAB_SLASH_DISPL; QPainterPath path; qreal y = stt->stemsDown() ? _len - STAFFTYPE_TAB_SLASH_2STARTY_DN*sp : -_len + STAFFTYPE_TAB_SLASH_2STARTY_UP*sp; for (int i = 0; i < 2; ++i) { path.moveTo( wdt*0.5-lw, y); // top-right corner path.lineTo( wdt*0.5-lw, y+thk); // bottom-right corner path.lineTo(-wdt*0.5, y+thk+sln);// bottom-left corner path.lineTo(-wdt*0.5, y+sln); // top-left corner path.closeSubpath(); y += displ; } // setbbox(path.boundingRect()); painter->setBrush(QBrush(curColor())); painter->setPen(Qt::NoPen); painter->drawPath(path); } // dots // NOT THE BEST PLACE FOR THIS? // with tablatures, dots are not drawn near 'notes', but near stems int nDots = chord()->dots(); if (nDots > 0) { qreal y = stemLen() - (stt->stemsDown() ? (STAFFTYPE_TAB_DEFAULTSTEMLEN_DN - 0.75) * sp : 0.0 ); symbols[score()->symIdx()][dotSym].draw(painter, magS(), QPointF(STAFFTYPE_TAB_DEFAULTDOTDIST_X * sp, y), nDots); } }
void SSLoginWindow::Login() { Staff* stu = new Staff(); stu->SetID(idLineEdit->text().toUInt()); stu->SetPassword(pwLineEdit->text().toStdString()); Message* action = new Message(stu); action->setType(ACTION_LOGIN); m_uiHandler->StartAction(*action); delete action; pwLineEdit->clear(); }