From cb193f62e79ae5f2ba75d8c7435ac10dc85499ee Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 10 Apr 2011 15:42:21 +0000 Subject: added some scrolling stuff and fixed segfault when closing --- muse2/muse/app.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'muse2/muse/app.cpp') diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index 3ca47fbc..00af02e9 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -3429,8 +3429,6 @@ void MusE::startScoreEdit(PartList* pl, bool showDefaultCtrls) { ScoreEdit* scoreedit = new ScoreEdit(pl, this, 0, arranger->cursorValue()); - if(showDefaultCtrls) // p4.0.12 - scoreedit->addCtrl(); scoreedit->show(); toplevels.push_back(Toplevel(Toplevel::PIANO_ROLL, (unsigned long)(scoreedit), scoreedit)); connect(scoreedit, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long))); -- cgit v1.2.3 From 84fdf802caa8a37cbbc3e8d2a4b33e7e89251604 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Fri, 15 Apr 2011 16:37:42 +0000 Subject: added menus for adding new staves to score windows introduced Toplevel::SCORE cleaned up the code a bit still TODO: support and display score-names possible bugs: ScoreEdit::parts() isn't kept --- muse2/muse/app.cpp | 126 ++++++++++++++++++++++++++++++++------ muse2/muse/app.h | 16 +++-- muse2/muse/cobject.h | 2 +- muse2/muse/midiedit/scoreedit.cpp | 108 ++++++++++++++++++++------------ muse2/muse/midiedit/scoreedit.h | 38 +++--------- 5 files changed, 199 insertions(+), 91 deletions(-) (limited to 'muse2/muse/app.cpp') diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index 58de4584..c4ed06dc 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -114,6 +114,20 @@ pthread_t splashThread; // // pyscript->runPythonScript(script); // } + +void MusE::clearScoreMenuMappers() +{ + delete scoreOneStaffPerTrackMapper; + delete scoreAllInOneMapper; + + scoreOneStaffPerTrackMapper = new QSignalMapper(this); + scoreAllInOneMapper = new QSignalMapper(this); + + connect(scoreOneStaffPerTrackMapper, SIGNAL(mapped(QWidget*)), this, SLOT(openInScoreEdit_oneStaffPerTrack(QWidget*))); + connect(scoreAllInOneMapper, SIGNAL(mapped(QWidget*)), this, SLOT(openInScoreEdit_allInOne(QWidget*))); +} + + //--------------------------------------------------------- // sleep function //--------------------------------------------------------- @@ -803,6 +817,8 @@ MusE::MusE(int argc, char** argv) : QMainWindow() editSignalMapper = new QSignalMapper(this); midiPluginSignalMapper = new QSignalMapper(this); followSignalMapper = new QSignalMapper(this); + scoreOneStaffPerTrackMapper = new QSignalMapper(this); + scoreAllInOneMapper = new QSignalMapper(this); song = new Song("song"); song->blockSignals(true); @@ -977,7 +993,15 @@ MusE::MusE(int argc, char** argv) : QMainWindow() editOutsideLoopAction = new QAction(QIcon(*select_outside_loopIcon), tr("&Outside Loop"), this); editAllPartsAction = new QAction( QIcon(*select_all_parts_on_trackIcon), tr("All &Parts on Track"), this); - startScoreEditAction = new QAction(*scoreIconSet, tr("Score"), this); + + scoreSubmenu = new QMenu(tr("Score"), this); + scoreSubmenu->setIcon(QIcon(*scoreIconSet)); + + scoreAllInOneSubsubmenu = new QMenu(tr("all parts in one staff"), this); + scoreOneStaffPerTrackSubsubmenu = new QMenu(tr("one staff per part"), this); + + updateScoreMenus(); + startPianoEditAction = new QAction(*pianoIconSet, tr("Pianoroll"), this); startDrumEditAction = new QAction(QIcon(*edit_drummsIcon), tr("Drums"), this); startListEditAction = new QAction(QIcon(*edit_listIcon), tr("List"), this); @@ -1127,10 +1151,12 @@ MusE::MusE(int argc, char** argv) : QMainWindow() connect(editSignalMapper, SIGNAL(mapped(int)), this, SLOT(cmd(int))); connect(startPianoEditAction, SIGNAL(activated()), SLOT(startPianoroll())); - connect(startScoreEditAction, SIGNAL(activated()), SLOT(startScoreEdit())); connect(startDrumEditAction, SIGNAL(activated()), SLOT(startDrumEditor())); connect(startListEditAction, SIGNAL(activated()), SLOT(startListEditor())); connect(startWaveEditAction, SIGNAL(activated()), SLOT(startWaveEditor())); + connect(scoreOneStaffPerTrackMapper, SIGNAL(mapped(QWidget*)), this, SLOT(openInScoreEdit_oneStaffPerTrack(QWidget*))); + connect(scoreAllInOneMapper, SIGNAL(mapped(QWidget*)), this, SLOT(openInScoreEdit_allInOne(QWidget*))); + connect(masterGraphicAction, SIGNAL(activated()), SLOT(startMasterEditor())); connect(masterListAction, SIGNAL(activated()), SLOT(startLMasterEditor())); @@ -1346,7 +1372,9 @@ MusE::MusE(int argc, char** argv) : QMainWindow() menuEdit->addSeparator(); menuEdit->addAction(startPianoEditAction); - menuEdit->addAction(startScoreEditAction); + menuEdit->addMenu(scoreSubmenu); + scoreSubmenu->addMenu(scoreAllInOneSubsubmenu); + scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu); menuEdit->addAction(startDrumEditAction); menuEdit->addAction(startListEditAction); menuEdit->addAction(startWaveEditAction); @@ -3416,27 +3444,83 @@ PartList* MusE::getMidiPartsToEdit() return pl; } + + +void MusE::updateScoreMenus() +{ + QAction* action; + + + scoreOneStaffPerTrackSubsubmenu->clear(); + scoreAllInOneSubsubmenu->clear(); + + + action=new QAction(tr("New"), this); + connect(action, SIGNAL(activated()), scoreOneStaffPerTrackMapper, SLOT(map())); + scoreOneStaffPerTrackMapper->setMapping(action, (QWidget*)NULL); + scoreOneStaffPerTrackSubsubmenu->addAction(action); + + + action=new QAction(tr("New"), this); //the above action may NOT be reused! + connect(action, SIGNAL(activated()), scoreAllInOneMapper, SLOT(map())); + scoreAllInOneMapper->setMapping(action, (QWidget*)NULL); + scoreAllInOneSubsubmenu->addAction(action); + + for (ToplevelList::iterator it=toplevels.begin(); it!=toplevels.end(); it++) + if (it->type()==Toplevel::SCORE) + { + ScoreEdit* score = (ScoreEdit*) it->cobject(); + + action=new QAction(tr("foo"), this); //TODO FLO: use proper name instead of "foo" + connect(action, SIGNAL(activated()), scoreOneStaffPerTrackMapper, SLOT(map())); + scoreOneStaffPerTrackMapper->setMapping(action, (QWidget*)score); + scoreOneStaffPerTrackSubsubmenu->addAction(action); + + + action=new QAction(tr("foo"), this); //the above action may NOT be reused! //TODO FLO: see above + connect(action, SIGNAL(activated()), scoreAllInOneMapper, SLOT(map())); + scoreAllInOneMapper->setMapping(action, (QWidget*)score); + scoreAllInOneSubsubmenu->addAction(action); + } +} + //--------------------------------------------------------- // startScoreEdit //--------------------------------------------------------- -void MusE::startScoreEdit() - { - PartList* pl = getMidiPartsToEdit(); - if (pl == 0) - return; - startScoreEdit(pl, true); - } +void MusE::openInScoreEdit_oneStaffPerTrack(QWidget* dest) +{ + openInScoreEdit((ScoreEdit*)dest, false); +} -void MusE::startScoreEdit(PartList* pl, bool showDefaultCtrls) - { +void MusE::openInScoreEdit_allInOne(QWidget* dest) +{ + openInScoreEdit((ScoreEdit*)dest, true); +} - ScoreEdit* scoreedit = new ScoreEdit(pl, this, 0, arranger->cursorValue()); - scoreedit->show(); - toplevels.push_back(Toplevel(Toplevel::PIANO_ROLL, (unsigned long)(scoreedit), scoreedit)); - connect(scoreedit, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long))); - connect(muse, SIGNAL(configChanged()), scoreedit, SLOT(configChanged())); - } +void MusE::openInScoreEdit(ScoreEdit* destination, bool allInOne) +{ + PartList* pl = getMidiPartsToEdit(); + if (pl == 0) + return; + openInScoreEdit(destination, pl, allInOne); +} + +void MusE::openInScoreEdit(ScoreEdit* destination, PartList* pl, bool allInOne) +{ + if (destination==NULL) // if no destination given, create a new one + { + destination = new ScoreEdit(pl, this, 0, arranger->cursorValue()); + destination->show(); + toplevels.push_back(Toplevel(Toplevel::SCORE, (unsigned long)(destination), destination)); + connect(destination, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long))); + connect(muse, SIGNAL(configChanged()), destination, SLOT(configChanged())); + + updateScoreMenus(); + } + + destination->add_parts(pl, allInOne); +} //--------------------------------------------------------- // startPianoroll @@ -3657,6 +3741,7 @@ void MusE::toplevelDeleted(unsigned long tl) { for (iToplevel i = toplevels.begin(); i != toplevels.end(); ++i) { if (i->object() == tl) { + bool mustUpdateScoreMenus=false; switch(i->type()) { case Toplevel::MARKER: break; @@ -3675,8 +3760,12 @@ void MusE::toplevelDeleted(unsigned long tl) case Toplevel::WAVE: case Toplevel::LMASTER: break; + case Toplevel::SCORE: + mustUpdateScoreMenus=true; } toplevels.erase(i); + if (mustUpdateScoreMenus) + updateScoreMenus(); return; } } @@ -4829,6 +4918,7 @@ again: case Toplevel::MARKER: break; case Toplevel::PIANO_ROLL: + case Toplevel::SCORE: case Toplevel::LISTE: case Toplevel::DRUM: case Toplevel::MASTER: diff --git a/muse2/muse/app.h b/muse2/muse/app.h index 168602d3..3555ce87 100644 --- a/muse2/muse/app.h +++ b/muse2/muse/app.h @@ -65,6 +65,7 @@ class Appearance; class WaveTrack; class AudioOutput; class EditInstrument; +class ScoreEdit; #define MENU_ADD_SYNTH_ID_BASE 0x1000 @@ -109,7 +110,7 @@ class MusE : public QMainWindow QAction *editInvertSelectionAction, *editInsideLoopAction, *editOutsideLoopAction, *editAllPartsAction; QAction *trackMidiAction, *trackDrumAction, *trackWaveAction, *trackAOutputAction, *trackAGroupAction; QAction *trackAInputAction, *trackAAuxAction; - QAction *startPianoEditAction, *startDrumEditAction, *startListEditAction, *startWaveEditAction, *startScoreEditAction; + QAction *startPianoEditAction, *startDrumEditAction, *startListEditAction, *startWaveEditAction; QAction *masterGraphicAction, *masterListAction; QAction *midiTransposeAction; QAction *midiTransformerAction; @@ -158,6 +159,7 @@ class MusE : public QMainWindow QMenu* menu_audio, *menuAutomation; QMenu* menu_functions, *menuScriptPlugins; QMenu* select, *master, *midiEdit, *addTrack; + QMenu *scoreSubmenu, *scoreOneStaffPerTrackSubsubmenu, *scoreAllInOneSubsubmenu; // Special 'stay-open' menu for routes. PopupMenu* routingPopupMenu; @@ -220,6 +222,8 @@ class MusE : public QMainWindow QSignalMapper *editSignalMapper; QSignalMapper *midiPluginSignalMapper; QSignalMapper *followSignalMapper; + QSignalMapper *scoreOneStaffPerTrackMapper; + QSignalMapper *scoreAllInOneMapper; signals: void configChanged(); @@ -261,8 +265,12 @@ class MusE : public QMainWindow void startDrumEditor(); void startDrumEditor(PartList* /*pl*/, bool /*showDefaultCtrls*/ = false); void startEditor(Track*); - void startScoreEdit(); - void startScoreEdit(PartList* /*pl*/, bool /*showDefaultCtrls*/ = false); + void openInScoreEdit(ScoreEdit* destination, PartList* pl, bool allInOne=false); + void openInScoreEdit(ScoreEdit* destination, bool allInOne=false); + void openInScoreEdit_allInOne(QWidget* destination); + void openInScoreEdit_oneStaffPerTrack(QWidget* destination); + void updateScoreMenus(); + void clearScoreMenuMappers(); void startPianoroll(); void startPianoroll(PartList* /*pl*/, bool /*showDefaultCtrls*/ = false); void startWaveEditor(); @@ -320,7 +328,7 @@ class MusE : public QMainWindow void execDeliveredScript(int); void execUserScript(int); - + public slots: bool saveAs(); void bounceToFile(AudioOutput* ao = 0); diff --git a/muse2/muse/cobject.h b/muse2/muse/cobject.h index 8e21eaf0..9a80b2b1 100644 --- a/muse2/muse/cobject.h +++ b/muse2/muse/cobject.h @@ -38,7 +38,7 @@ class TopWin : public QMainWindow class Toplevel { public: enum ToplevelType { PIANO_ROLL, LISTE, DRUM, MASTER, WAVE, - LMASTER, CLIPLIST, MARKER + LMASTER, CLIPLIST, MARKER, SCORE #ifdef PATCHBAY , M_PATCHBAY #endif /* PATCHBAY */ diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 2077b202..0e164a2a 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -159,24 +159,30 @@ bool pixmaps_loaded=false; ScoreEdit::ScoreEdit(PartList* pl, QWidget* parent, const char* name, unsigned initPos) : MidiEditor(0, 0, pl, parent, name) { - ScoreCanvas* test=new ScoreCanvas(this, mainw, 1, 1); + score_canvas=new ScoreCanvas(this, mainw, 1, 1); hscroll = new QScrollBar(Qt::Horizontal, mainw); + connect(hscroll, SIGNAL(valueChanged(int)), score_canvas, SLOT(scroll_event(int))); + connect(score_canvas, SIGNAL(xpos_changed(int)), hscroll, SLOT(setValue(int))); + connect(score_canvas, SIGNAL(canvas_width_changed(int)), SLOT(canvas_width_changed(int))); + connect(score_canvas, SIGNAL(viewport_width_changed(int)), SLOT(viewport_width_changed(int))); + connect(song, SIGNAL(songChanged(int)), score_canvas, SLOT(song_changed(int))); -connect(hscroll, SIGNAL(valueChanged(int)), test, SLOT(scroll_event(int))); -connect(test, SIGNAL(xpos_changed(int)), hscroll, SLOT(setValue(int)));connect(song, SIGNAL(songChanged(int)), test, SLOT(song_changed(int))); -connect(test, SIGNAL(canvas_width_changed(int)), SLOT(canvas_width_changed(int))); -connect(test, SIGNAL(viewport_width_changed(int)), SLOT(viewport_width_changed(int))); + mainGrid->addWidget(score_canvas, 0, 0); + mainGrid->addWidget(hscroll,1,0); - mainGrid->addWidget(test, 0, 0); - mainGrid->addWidget(hscroll,1,0); + hscroll->setMinimum(0); -hscroll->setMinimum(0); -test->song_changed(0); -test->goto_tick(initPos,true); + score_canvas->song_changed(0); + score_canvas->goto_tick(initPos,true); } +void ScoreEdit::add_parts(PartList* pl, bool all_in_one) +{ + score_canvas->add_staves(pl, all_in_one); +} + //--------------------------------------------------------- // ~ScoreEdit //--------------------------------------------------------- @@ -208,7 +214,55 @@ void ScoreEdit::closeEvent(QCloseEvent* e) +void ScoreCanvas::add_staves(PartList* pl, bool all_in_one) +{ + staff_t staff; + + if (all_in_one) + { + staff.parts.clear(); + for (ciPart part_it=pl->begin(); part_it!=pl->end(); part_it++) + staff.parts.insert(part_it->second); + + staff.split_note=SPLIT_NOTE; + + staff.type=GRAND_TOP; //FINDMICH + staff.clef=VIOLIN; + staffs.push_back(staff); + + staff.type=GRAND_BOTTOM; + staff.clef=BASS; + staffs.push_back(staff); + } + else + { + set tracks; + + for (ciPart it=pl->begin(); it!=pl->end(); it++) + tracks.insert(it->second->track()); + + for (set::iterator it=tracks.begin(); it!=tracks.end(); it++) + { + staff.parts.clear(); + for (ciPart part_it=pl->begin(); part_it!=pl->end(); part_it++) + if (part_it->second->track() == *it) + staff.parts.insert(part_it->second); + + staff.split_note=SPLIT_NOTE; + + staff.type=GRAND_TOP; //FINDMICH + staff.clef=VIOLIN; + staffs.push_back(staff); + staff.type=GRAND_BOTTOM; + staff.clef=BASS; + staffs.push_back(staff); + } + } + + recalc_staff_pos(); + song_changed(0); +} ScoreCanvas::ScoreCanvas(MidiEditor* pr, QWidget* parent, @@ -228,39 +282,12 @@ ScoreCanvas::ScoreCanvas(MidiEditor* pr, QWidget* parent, mouse_erases_notes=false; mouse_inserts_notes=true; - curr_part=editor->parts()->begin()->second; + curr_part=editor->parts()->begin()->second; //TODO FINDMICH last_len=384; new_len=-1; dragging_staff=false; - - //each track gets its own staff - staff_t staff; - set tracks; - - for (ciPart it=editor->parts()->begin(); it!=editor->parts()->end(); it++) - tracks.insert(it->second->track()); - - for (set::iterator it=tracks.begin(); it!=tracks.end(); it++) - { - staff.parts.clear(); - for (ciPart part_it=editor->parts()->begin(); part_it!=editor->parts()->end(); part_it++) - if (part_it->second->track() == *it) - staff.parts.insert(part_it->second); - - staff.split_note=SPLIT_NOTE; - - staff.type=GRAND_TOP; - staff.clef=VIOLIN; - staffs.push_back(staff); - - staff.type=GRAND_BOTTOM; - staff.clef=BASS; - staffs.push_back(staff); - } - - recalc_staff_pos(); scroll_speed=0; @@ -2861,7 +2888,8 @@ list::iterator ScoreCanvas::staff_at_y(int y) * o when pressing "STOP", the active note isn't redrawn "normally" * * CURRENT TODO - * > o menu entries etc for creating new staves etc. + * o use correct names in score-menus + * o must add_parts() update the part-list? * * IMPORTANT TODO * o support adding staves to existing score window @@ -2891,6 +2919,8 @@ list::iterator ScoreCanvas::staff_at_y(int y) * o redraw is called too often * for example, when scroll is continuous, and note-hilighting has * changed, redraw() is called twice + * o song_changed() should distinguish between relevant and + * irrelevant changes. (for example controllers can be ignored) * o ties aren't always drawn correctly when the destination note * is out of view * o tied notes don't work properly when there's a key-change in diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h index e78b4a8e..a199e49f 100644 --- a/muse2/muse/midiedit/scoreedit.h +++ b/muse2/muse/midiedit/scoreedit.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "noteinfo.h" @@ -37,38 +38,12 @@ using std::map; using std::list; using std::vector; -class MidiPart; -class TimeLabel; -class PitchLabel; -class QLabel; -class PianoCanvas; -class MTScale; -class Track; -class QToolButton; -class QToolBar; -class QPushButton; -class CtrlEdit; -class Splitter; -class Toolbar1; -class Xml; -class QuantConfig; -class ScrollScale; -class Part; -class SNode; -class QMenu; -class QAction; -class QWidget; -class QScrollBar; -class MidiTrackInfo; -class QScrollArea; - - - +class ScoreCanvas; //--------------------------------------------------------- // ScoreEdit @@ -82,6 +57,7 @@ class ScoreEdit : public MidiEditor virtual void closeEvent(QCloseEvent*); QScrollBar* hscroll; + ScoreCanvas* score_canvas; private slots: @@ -99,6 +75,8 @@ class ScoreEdit : public MidiEditor ~ScoreEdit(); static void readConfiguration(Xml&){}; //TODO does nothing static void writeConfiguration(int, Xml&){}; //TODO does nothing + + void add_parts(PartList* pl, bool all_in_one=false); }; @@ -478,7 +456,7 @@ struct staff_t staff_type_t type; clef_t clef; - unsigned split_note; + int split_note; void create_appropriate_eventlist(const set& parts); void create_itemlist(); @@ -491,7 +469,7 @@ struct staff_t clef=VIOLIN; } - staff_t (staff_type_t type_, clef_t clef_, set parts_, unsigned split_note_=0) + staff_t (staff_type_t type_, clef_t clef_, set parts_, int split_note_=0) { type=type_; clef=clef_; @@ -664,6 +642,8 @@ class ScoreCanvas : public View ScoreCanvas(MidiEditor*, QWidget*, int, int); ~ScoreCanvas(){}; + void add_staves(PartList* pl, bool all_in_one); + }; int calc_measure_len(const list& nums, int denom); -- cgit v1.2.3 From d7e222752028fd0bed037c06806d252a66c5db88 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Fri, 15 Apr 2011 17:12:51 +0000 Subject: scores now have names; the user can't change them yet, but implementing this will be no problem --- muse2/muse/app.cpp | 9 ++++-- muse2/muse/app.h | 5 +++- muse2/muse/midiedit/scoreedit.cpp | 59 +++++++++++++++++++++++++++++++++------ muse2/muse/midiedit/scoreedit.h | 10 ++++++- 4 files changed, 70 insertions(+), 13 deletions(-) (limited to 'muse2/muse/app.cpp') diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index c4ed06dc..a96b7e9b 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -3444,7 +3444,10 @@ PartList* MusE::getMidiPartsToEdit() return pl; } - +void MusE::scoreNamingChanged() +{ + updateScoreMenus(); +} void MusE::updateScoreMenus() { @@ -3471,13 +3474,13 @@ void MusE::updateScoreMenus() { ScoreEdit* score = (ScoreEdit*) it->cobject(); - action=new QAction(tr("foo"), this); //TODO FLO: use proper name instead of "foo" + action=new QAction(QString(score->get_name().c_str()), this); connect(action, SIGNAL(activated()), scoreOneStaffPerTrackMapper, SLOT(map())); scoreOneStaffPerTrackMapper->setMapping(action, (QWidget*)score); scoreOneStaffPerTrackSubsubmenu->addAction(action); - action=new QAction(tr("foo"), this); //the above action may NOT be reused! //TODO FLO: see above + action=new QAction(QString(score->get_name().c_str()), this); //the above action may NOT be reused! connect(action, SIGNAL(activated()), scoreAllInOneMapper, SLOT(map())); scoreAllInOneMapper->setMapping(action, (QWidget*)score); scoreAllInOneSubsubmenu->addAction(action); diff --git a/muse2/muse/app.h b/muse2/muse/app.h index 3555ce87..8a9fdac0 100644 --- a/muse2/muse/app.h +++ b/muse2/muse/app.h @@ -265,12 +265,15 @@ class MusE : public QMainWindow void startDrumEditor(); void startDrumEditor(PartList* /*pl*/, bool /*showDefaultCtrls*/ = false); void startEditor(Track*); + void openInScoreEdit(ScoreEdit* destination, PartList* pl, bool allInOne=false); void openInScoreEdit(ScoreEdit* destination, bool allInOne=false); void openInScoreEdit_allInOne(QWidget* destination); void openInScoreEdit_oneStaffPerTrack(QWidget* destination); - void updateScoreMenus(); void clearScoreMenuMappers(); + void updateScoreMenus(); + void scoreNamingChanged(); + void startPianoroll(); void startPianoroll(PartList* /*pl*/, bool /*showDefaultCtrls*/ = false); void startWaveEditor(); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 0e164a2a..18c3bc71 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -67,6 +67,9 @@ using namespace std; #include "sig.h" +string IntToStr(int i); + + #define SPLIT_NOTE 60 //TODO: let the user specify that somehow? @@ -102,10 +105,21 @@ using namespace std; #define STAFF_DISTANCE (10*YLEN) #define GRANDSTAFF_DISTANCE (8*YLEN) -KeyList keymap; +string create_random_string(int len=8) +{ + string result; + + for (int i=0;i ScoreEdit::names; //--------------------------------------------------------- // ScoreEdit @@ -175,6 +190,11 @@ ScoreEdit::ScoreEdit(PartList* pl, QWidget* parent, const char* name, unsigned i score_canvas->song_changed(0); score_canvas->goto_tick(initPos,true); + + if (name!=NULL) + set_name(name, false, true); + else + set_name("Score "+IntToStr(serial++), false, true); } @@ -183,6 +203,32 @@ void ScoreEdit::add_parts(PartList* pl, bool all_in_one) score_canvas->add_staves(pl, all_in_one); } +bool ScoreEdit::set_name(string newname, bool emit_signal, bool emergency_name) +{ + if (names.find(newname)==names.end()) + { + names.erase(name); + names.insert(newname); + + name=newname; + + if (emit_signal) + emit name_changed(); + + return true; + } + else + { + if (emergency_name) + { + while (set_name(create_random_string(), emit_signal, false) == false); + return true; + } + else + return false; + } +} + //--------------------------------------------------------- // ~ScoreEdit //--------------------------------------------------------- @@ -2888,14 +2934,10 @@ list::iterator ScoreCanvas::staff_at_y(int y) * o when pressing "STOP", the active note isn't redrawn "normally" * * CURRENT TODO - * o use correct names in score-menus - * o must add_parts() update the part-list? + * o y-scroll for staff window, with automatic margin-scrolling + * o let the user edit the score's name * * IMPORTANT TODO - * o support adding staves to existing score window - * o support changing between "all into one" and "each gets one staff" - * - * o y-scroll for staff window, with automatic margin-scrolling * o removing the part the score's working on isn't handled * o let the user select the currently edited part * o let the user select between "colors after the parts", @@ -2906,6 +2948,7 @@ list::iterator ScoreCanvas::staff_at_y(int y) * o check if "moving away" works for whole notes [seems to NOT work properly] * * less important stuff + * o must add_parts() update the part-list? * o support different keys in different tracks at the same time * calc_pos_add_list and calc_item_pos will be affected by this * calc_pos_add_list must be called before calc_item_pos then, diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h index a199e49f..a296d8a8 100644 --- a/muse2/muse/midiedit/scoreedit.h +++ b/muse2/muse/midiedit/scoreedit.h @@ -31,13 +31,14 @@ #include #include #include +#include using std::set; using std::pair; using std::map; using std::list; using std::vector; - +using std::string; @@ -59,12 +60,18 @@ class ScoreEdit : public MidiEditor QScrollBar* hscroll; ScoreCanvas* score_canvas; + static int serial; + static set names; + + string name; + bool set_name(string newname, bool emit_signal=true, bool emergency_name=false); private slots: signals: void deleted(unsigned long); + void name_changed(); public slots: void canvas_width_changed(int); @@ -77,6 +84,7 @@ class ScoreEdit : public MidiEditor static void writeConfiguration(int, Xml&){}; //TODO does nothing void add_parts(PartList* pl, bool all_in_one=false); + string get_name() { return name; } }; -- cgit v1.2.3 From 0f64da6e5a36729218f3d3f5ba5b127be7defbf2 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 18 Apr 2011 16:16:42 +0000 Subject: score editor now listens to most (if not all) interesting signals and redraws changed pcanvas.cpp to emit a signal when changing a part's color changed app.cpp to not connect scoreedit's configChanged slot --- muse2/muse/app.cpp | 4 +- muse2/muse/arranger/pcanvas.cpp | 3 +- muse2/muse/midiedit/scoreedit.cpp | 121 ++++++++++++++++++++------------------ muse2/muse/midiedit/scoreedit.h | 5 +- 4 files changed, 73 insertions(+), 60 deletions(-) (limited to 'muse2/muse/app.cpp') diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index 9f10a614..3357fac1 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -3525,7 +3525,9 @@ void MusE::openInScoreEdit(ScoreEdit* destination, PartList* pl, bool allInOne) destination->show(); toplevels.push_back(Toplevel(Toplevel::SCORE, (unsigned long)(destination), destination)); connect(destination, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long))); - connect(muse, SIGNAL(configChanged()), destination, SLOT(configChanged())); + //connect(muse, SIGNAL(configChanged()), destination, SLOT(config_changed())); + //commented out by flo, because the ScoreEditor connects to all + //relevant signals on his own updateScoreMenus(); } diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index e2c2b32d..6068c743 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -994,7 +994,8 @@ void PartCanvas::itemPopup(CItem* item, int n, const QPoint& pt) // If no items selected, use the one clicked on. if(!selfound) item->part()->setColorIndex(curColorIndex); - + + song->update(SC_PART_MODIFIED); redraw(); break; } diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index c8e91153..b2b2e72c 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -37,6 +37,7 @@ #include using namespace std; +#include "app.h" #include "xml.h" #include "mtscale.h" #include "prcanvas.h" @@ -161,7 +162,7 @@ ScoreEdit::ScoreEdit(PartList* pl, QWidget* parent, const char* name, unsigned i xscroll->setMinimum(0); yscroll->setMinimum(0); - score_canvas->song_changed(0); + score_canvas->song_changed(SC_EVENT_INSERTED); score_canvas->goto_tick(initPos,true); if (name!=NULL) @@ -272,11 +273,11 @@ void ScoreCanvas::add_staves(PartList* pl, bool all_in_one) staff.type=GRAND_TOP; //FINDMICH staff.clef=VIOLIN; - staffs.push_back(staff); + staves.push_back(staff); staff.type=GRAND_BOTTOM; staff.clef=BASS; - staffs.push_back(staff); + staves.push_back(staff); } else { @@ -296,16 +297,16 @@ void ScoreCanvas::add_staves(PartList* pl, bool all_in_one) staff.type=GRAND_TOP; //FINDMICH staff.clef=VIOLIN; - staffs.push_back(staff); + staves.push_back(staff); staff.type=GRAND_BOTTOM; staff.clef=BASS; - staffs.push_back(staff); + staves.push_back(staff); } } recalc_staff_pos(); - song_changed(0); + song_changed(SC_EVENT_INSERTED); } @@ -342,7 +343,8 @@ ScoreCanvas::ScoreCanvas(MidiEditor* pr, QWidget* parent, connect (heartBeatTimer, SIGNAL(timeout()), SLOT(heartbeat_timer_event())); connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(pos_changed(int,unsigned,bool))); - + connect(song, SIGNAL(playChanged(bool)), SLOT(play_changed(bool))); + connect(muse, SIGNAL(configChanged()), SLOT(config_changed())); staff_menu=new QMenu(this); @@ -396,7 +398,7 @@ void ScoreCanvas::set_staffmode(list::iterator it, staff_mode_t mode) tmp++; if (tmp->type!=GRAND_BOTTOM) cout << "THIS SHOULD NEVER HAPPEN: grand_top without bottom!"<::iterator it, staff_mode_t mode) it->clef=BASS; it->split_note=SPLIT_NOTE; - staffs.insert(it, staff_t(GRAND_TOP, VIOLIN, it->parts, it->split_note)); + staves.insert(it, staff_t(GRAND_TOP, VIOLIN, it->parts, it->split_note)); break; default: @@ -424,7 +426,7 @@ void ScoreCanvas::set_staffmode(list::iterator it, staff_mode_t mode) } recalc_staff_pos(); - song_changed(0); + song_changed(SC_EVENT_INSERTED); } void ScoreCanvas::remove_staff(list::iterator it) @@ -438,18 +440,18 @@ void ScoreCanvas::remove_staff(list::iterator it) if (it->type == NORMAL) { - staffs.erase(it); + staves.erase(it); } else if (it->type == GRAND_TOP) { - staffs.erase(it++); + staves.erase(it++); if (it->type!=GRAND_BOTTOM) cout << "THIS SHOULD NEVER HAPPEN: grand_top without bottom!"<::iterator dest, list::iterator src) @@ -485,39 +487,44 @@ void ScoreCanvas::merge_staves(list::iterator dest, list::iter remove_staff(src); recalc_staff_pos(); - song_changed(0); + song_changed(SC_EVENT_INSERTED); } -void ScoreCanvas::song_changed(int) +void ScoreCanvas::song_changed(int flags) { - cout << "song changed!" << endl; - - calc_pos_add_list(); - - for (list::iterator it=staffs.begin(); it!=staffs.end(); it++) + if (flags & (SC_PART_INSERTED | SC_PART_MODIFIED | SC_PART_REMOVED | + SC_EVENT_INSERTED | SC_EVENT_MODIFIED | SC_EVENT_REMOVED | + SC_SIG) ) { - it->create_appropriate_eventlist(it->parts); - it->create_itemlist(); - it->process_itemlist(); // do note- and rest-grouping and collision avoiding - it->calc_item_pos(); - } - - redraw(); - cout << "song had changed, recalculation complete" << endl; + cout << "song changed!" << endl; + + calc_pos_add_list(); + + for (list::iterator it=staves.begin(); it!=staves.end(); it++) + { + it->create_appropriate_eventlist(it->parts); + it->create_itemlist(); + it->process_itemlist(); // do note- and rest-grouping and collision avoiding + it->calc_item_pos(); + } + + redraw(); + cout << "song had changed, recalculation complete" << endl; - emit canvas_width_changed(canvas_width()); + emit canvas_width_changed(canvas_width()); + } } int ScoreCanvas::canvas_width() { - //return tick_to_x(staffs.begin()->itemlist.rbegin()->first); + //return tick_to_x(staves.begin()->itemlist.rbegin()->first); return tick_to_x(SONG_LENGTH); } int ScoreCanvas::canvas_height() { - return staffs.rbegin()->y_bottom; + return staves.rbegin()->y_bottom; } int ScoreCanvas::viewport_width() @@ -2188,7 +2195,7 @@ void ScoreCanvas::draw_items(QPainter& p, int y_offset, staff_t& staff, ScoreIte bool ScoreCanvas::need_redraw_for_hilighting() { - for (list::iterator it=staffs.begin(); it!=staffs.end(); it++) + for (list::iterator it=staves.begin(); it!=staves.end(); it++) if (need_redraw_for_hilighting(it->itemlist)) return true; return false; @@ -2345,7 +2352,7 @@ void ScoreCanvas::draw(QPainter& p, const QRect&) p.setPen(Qt::black); - for (list::iterator it=staffs.begin(); it!=staffs.end(); it++) + for (list::iterator it=staves.begin(); it!=staves.end(); it++) { //TODO: maybe only draw visible staves? draw_note_lines(p,it->y_draw - y_pos); @@ -2508,7 +2515,7 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) int tick=flo_quantize_floor(x_to_tick(x)); //TODO quantizing must (maybe?) be done with the proper functions - if (it!=staffs.end()) + if (it!=staves.end()) { if (event->x() <= x_left) //clicked in the preamble? { @@ -2635,7 +2642,7 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) mouse_operation=NO_OP; mouse_x_drag_operation=LENGTH; - song_changed(0); + song_changed(SC_EVENT_INSERTED); setMouseTracking(true); dragging=true; @@ -2730,7 +2737,7 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) audio->msgChangeEvent(dragged_event, tmp, dragged_event_part, false, false, false); dragged_event=tmp; - song_changed(0); + song_changed(SC_EVENT_INSERTED); } break; @@ -2746,7 +2753,7 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) audio->msgChangeEvent(dragged_event, tmp, dragged_event_part, false, false, false); dragged_event=tmp; - song_changed(0); + song_changed(SC_EVENT_INSERTED); } break; @@ -2763,7 +2770,7 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) audio->msgChangeEvent(dragged_event, tmp, dragged_event_part, false, false, false); dragged_event=tmp; - song_changed(0); + song_changed(SC_EVENT_INSERTED); } break; @@ -2937,7 +2944,7 @@ void ScoreCanvas::recalc_staff_pos() { int y=0; - for (list::iterator it=staffs.begin(); it!=staffs.end(); it++) + for (list::iterator it=staves.begin(); it!=staves.end(); it++) { it->y_top=y; switch (it->type) @@ -2965,13 +2972,25 @@ void ScoreCanvas::recalc_staff_pos() list::iterator ScoreCanvas::staff_at_y(int y) { - for (list::iterator it=staffs.begin(); it!=staffs.end(); it++) + for (list::iterator it=staves.begin(); it!=staves.end(); it++) if ((y >= it->y_top) && (y < it->y_bottom)) return it; - return staffs.end(); + return staves.end(); +} + +void ScoreCanvas::play_changed(bool) +{ + redraw(); } +void ScoreCanvas::config_changed() +{ + redraw(); +} + + + //the following assertions are made: // pix_quarter.width() == pix_half.width() @@ -2996,8 +3015,6 @@ list::iterator ScoreCanvas::staff_at_y(int y) * o when the keymap is not used, this will probably lead to a bug * o when adding a note, it's added to the first stave * the problem is: there's always the first part selected - * o when changing color of a displayed part, note heads aren't redrawn - * o when pressing "STOP", the active note isn't redrawn "normally" * * CURRENT TODO * o let the user edit the score's name @@ -3011,6 +3028,9 @@ list::iterator ScoreCanvas::staff_at_y(int y) * o emit a "song-changed" signal instead of calling our * internal song_changed() function * o check if "moving away" works for whole notes [seems to NOT work properly] + * o more fine-grained redrawing in song_changed: sometimes, + * only a redraw and not a recalc is needed + * o do all the song_changed(SC_EVENT_INSERTED) properly * * less important stuff * o must add_parts() update the part-list? @@ -3021,19 +3041,12 @@ list::iterator ScoreCanvas::staff_at_y(int y) * keeping its own pos_add variable (which is only an optimisation) * o use nearest part instead of curr_part, maybe expand * o draw measure numbers - * o use "unsigned" whereever "unsigned" is meant * o when moving or resizing a note, so that its end is out-of-part, * there's strange behaviour - * o redraw is called too often - * for example, when scroll is continuous, and note-hilighting has - * changed, redraw() is called twice - * o song_changed() should distinguish between relevant and - * irrelevant changes. (for example controllers can be ignored) * o ties aren't always drawn correctly when the destination note * is out of view * o tied notes don't work properly when there's a key-change in * between, for example, when a cis is tied to a des - * o display only the part, not the whole song filled with rests? * o let the user select whether the preamble should have * a fixed length (?) * o let the user select what the preamble has to contain @@ -3043,14 +3056,8 @@ list::iterator ScoreCanvas::staff_at_y(int y) * o use bars instead of flags over groups of 8ths / 16ths etc * o (change ItemList into map< pos_t , mutable_stuff_t >) [no] * o deal with expanding parts or clip (expanding is better) - * o check if making the program clef-aware hasn't broken anything - * e.g. accidentials, creating notes, rendering etc. - * o check if the new function for drawing accidential works * o refuse to resize so that width gets smaller or equal than x_left - * o set distances properly [looks okay, doesn't it?] - * o change iterators into const iterators * o add tracks in correct order to score - * o rename staffs to staves * * stuff for the other muse developers * o check if dragging notes is done correctly diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h index 4b72b69c..0c4c8bf1 100644 --- a/muse2/muse/midiedit/scoreedit.h +++ b/muse2/muse/midiedit/scoreedit.h @@ -518,7 +518,7 @@ class ScoreCanvas : public View std::map pos_add_list; - list staffs; + list staves; // the drawing area is split into a "preamble" containing clef, // key and time signature, and the "item's area" containing the @@ -583,6 +583,9 @@ class ScoreCanvas : public View void staffmode_bass_slot(); void staffmode_both_slot(); void remove_staff_slot(); + + void play_changed(bool); + void config_changed(); public slots: void x_scroll_event(int); -- cgit v1.2.3 From 653ee946365c935bbbfdb092cc50ed92f5159e43 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Tue, 19 Apr 2011 17:10:43 +0000 Subject: added some menus changed some strings to QStrings TODO: color notes by their velocity --- muse2/muse/app.cpp | 5 +- muse2/muse/midiedit/scoreedit.cpp | 174 ++++++++++++++++++++++++++++++++------ muse2/muse/midiedit/scoreedit.h | 23 +++-- 3 files changed, 168 insertions(+), 34 deletions(-) (limited to 'muse2/muse/app.cpp') diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index 3357fac1..efa6b86d 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -3482,13 +3482,13 @@ void MusE::updateScoreMenus() { ScoreEdit* score = (ScoreEdit*) it->cobject(); - action=new QAction(QString(score->get_name().c_str()), this); + action=new QAction(score->get_name(), this); connect(action, SIGNAL(activated()), scoreOneStaffPerTrackMapper, SLOT(map())); scoreOneStaffPerTrackMapper->setMapping(action, (QWidget*)score); scoreOneStaffPerTrackSubsubmenu->addAction(action); - action=new QAction(QString(score->get_name().c_str()), this); //the above action may NOT be reused! + action=new QAction(score->get_name(), this); //the above action may NOT be reused! connect(action, SIGNAL(activated()), scoreAllInOneMapper, SLOT(map())); scoreAllInOneMapper->setMapping(action, (QWidget*)score); scoreAllInOneSubsubmenu->addAction(action); @@ -3525,6 +3525,7 @@ void MusE::openInScoreEdit(ScoreEdit* destination, PartList* pl, bool allInOne) destination->show(); toplevels.push_back(Toplevel(Toplevel::SCORE, (unsigned long)(destination), destination)); connect(destination, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long))); + connect(destination, SIGNAL(name_changed()), SLOT(scoreNamingChanged())); //connect(muse, SIGNAL(configChanged()), destination, SLOT(config_changed())); //commented out by flo, because the ScoreEditor connects to all //relevant signals on his own diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index a29337d5..a9b0ecac 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -64,6 +67,7 @@ using namespace std; string IntToStr(int i); +QString IntToQStr(int i); #define SPLIT_NOTE 60 @@ -100,14 +104,14 @@ string IntToStr(int i); #define STAFF_DISTANCE (10*YLEN) #define GRANDSTAFF_DISTANCE (8*YLEN) -string create_random_string(int len=8) +QString create_random_string(int len=8) { string result; for (int i=0;i ScoreEdit::names; +set ScoreEdit::names; //--------------------------------------------------------- // ScoreEdit @@ -162,6 +166,8 @@ ScoreEdit::ScoreEdit(PartList* pl, QWidget* parent, const char* name, unsigned i xscroll->setMinimum(0); yscroll->setMinimum(0); + menu_mapper=new QSignalMapper(this); + connect(menu_mapper, SIGNAL(mapped(int)), SLOT(menu_command(int))); @@ -186,6 +192,44 @@ ScoreEdit::ScoreEdit(PartList* pl, QWidget* parent, const char* name, unsigned i transport_toolbar->addActions(transportAction->actions()); + QMenu* settings_menu = menuBar()->addMenu(tr("&Settings")); + + QMenu* color_menu = settings_menu->addMenu(tr("Note head &colors")); + QActionGroup* color_actions = new QActionGroup(this); + QAction* color_black_action = color_menu->addAction(tr("&Black"), menu_mapper, SLOT(map())); + QAction* color_velo_action = color_menu->addAction(tr("&Velocity"), menu_mapper, SLOT(map())); + QAction* color_part_action = color_menu->addAction(tr("&Part"), menu_mapper, SLOT(map())); + color_black_action->setCheckable(true); + color_velo_action->setCheckable(true); + color_part_action->setCheckable(true); + color_actions->addAction(color_black_action); + color_actions->addAction(color_velo_action); + color_actions->addAction(color_part_action); + menu_mapper->setMapping(color_black_action, CMD_COLOR_BLACK); + menu_mapper->setMapping(color_velo_action, CMD_COLOR_VELO); + menu_mapper->setMapping(color_part_action, CMD_COLOR_PART); + + color_black_action->setChecked(true); + menu_command(CMD_COLOR_BLACK); + + QMenu* preamble_menu = settings_menu->addMenu(tr("Set up &preamble")); + QAction* preamble_keysig_action = preamble_menu->addAction(tr("Display &key signature")); + QAction* preamble_timesig_action = preamble_menu->addAction(tr("Display &time signature")); + connect(preamble_keysig_action, SIGNAL(toggled(bool)), score_canvas, SLOT(preamble_keysig_slot(bool))); + connect(preamble_timesig_action, SIGNAL(toggled(bool)), score_canvas, SLOT(preamble_timesig_slot(bool))); + + preamble_keysig_action->setCheckable(true); + preamble_timesig_action->setCheckable(true); + + preamble_keysig_action->setChecked(true); + preamble_timesig_action->setChecked(true); + + QAction* set_name_action = settings_menu->addAction(tr("Set Score &name"), menu_mapper, SLOT(map())); + menu_mapper->setMapping(set_name_action, CMD_SET_NAME); + + + + /* TODO FINDMICHJETZT addToolBarBreak(); info = new NoteInfo(this); @@ -201,7 +245,7 @@ ScoreEdit::ScoreEdit(PartList* pl, QWidget* parent, const char* name, unsigned i if (name!=NULL) set_name(name, false, true); else - set_name("Score "+IntToStr(serial++), false, true); + set_name("Score "+IntToQStr(serial++), false, true); } @@ -210,7 +254,7 @@ void ScoreEdit::add_parts(PartList* pl, bool all_in_one) score_canvas->add_staves(pl, all_in_one); } -bool ScoreEdit::set_name(string newname, bool emit_signal, bool emergency_name) +bool ScoreEdit::set_name(QString newname, bool emit_signal, bool emergency_name) { if (names.find(newname)==names.end()) { @@ -290,6 +334,28 @@ void ScoreEdit::closeEvent(QCloseEvent* e) e->accept(); } +void ScoreEdit::menu_command(int cmd) +{ + switch (cmd) + { + case CMD_SET_NAME: + { + bool ok; + QString newname = QInputDialog::getText(this, tr("Enter the new score title"), + tr("Enter the new score title"), QLineEdit::Normal, + name, &ok); + if (ok) + { + if (!set_name(newname)) + QMessageBox::warning(this, tr("Error"), tr("Changing score title failed:\nthe selected title is not unique")); + } + } + + default: + score_canvas->menu_command(cmd); + } +} + void ScoreCanvas::add_staves(PartList* pl, bool all_in_one) @@ -369,6 +435,11 @@ ScoreCanvas::ScoreCanvas(MidiEditor* pr, QWidget* parent, dragging_staff=false; + coloring_mode=COLOR_MODE_BLACK; + preamble_contains_keysig=true; + preamble_contains_timesig=true; + + x_scroll_speed=0; x_scroll_pos=0; y_scroll_speed=0; @@ -577,6 +648,11 @@ string IntToStr(int i) return s.str(); } +QString IntToQStr(int i) +{ + return QString(IntToStr(i).c_str()); +} + void color_image(QImage& img, const QColor& color) { uchar* ptr=img.bits(); @@ -669,7 +745,7 @@ void ScoreCanvas::load_pixmaps() pix_clef_bass->load(museGlobalShare + "/scoreglyphs/clef_bass_big.png"); for (int i=0;i<10;i++) - pix_num[i].load(museGlobalShare + "/scoreglyphs/"+QString(IntToStr(i).c_str())+".png"); + pix_num[i].load(museGlobalShare + "/scoreglyphs/"+IntToQStr(i)+".png"); pixmaps_loaded=true; } @@ -2080,11 +2156,25 @@ void ScoreCanvas::draw_items(QPainter& p, int y_offset, staff_t& staff, ScoreIte it->is_active= ( (song->cpos() >= it->source_event->tick() + it->source_part->tick()) && (song->cpos() < it->source_event->endTick() + it->source_part->tick()) ); - int color_index=it->source_part->colorIndex(); + int color_index; + switch (coloring_mode) + { + case COLOR_MODE_BLACK: + color_index=BLACK_PIXMAP; + break; + + case COLOR_MODE_PART: + color_index=it->source_part->colorIndex(); + break; + + case COLOR_MODE_PITCH: //TODO + break; + } if (audio->isPlaying() && it->is_active) color_index=HIGHLIGHTED_PIXMAP; + draw_pixmap(p,it->x -x_pos+x_left,y_offset + it->y,it->pix[color_index]); //TODO FINDMICH maybe draw a margin around bright colors? //maybe draw the default color in black? @@ -2308,25 +2398,35 @@ void ScoreCanvas::draw_preamble(QPainter& p, int y_offset, clef_t clef) draw_pixmap(p,CLEF_LEFTMARGIN + pix_clef->width()/2,y_offset + y_coord,*pix_clef); - x_left= CLEF_LEFTMARGIN + pix_clef->width() + CLEF_RIGHTMARGIN + KEYCHANGE_ACC_LEFTDIST; + x_left= CLEF_LEFTMARGIN + pix_clef->width() + CLEF_RIGHTMARGIN; // draw accidentials ------------------------------------------------ - key_enum key=key_at_tick(tick); - QPixmap* pix_acc=is_sharp_key(key) ? &pix_sharp[BLACK_PIXMAP] : &pix_b[BLACK_PIXMAP]; - list acclist=calc_accidentials(key,clef); - - draw_accidentials(p,x_left, y_offset, acclist ,*pix_acc); - - x_left+=acclist.size()*KEYCHANGE_ACC_DIST + KEYCHANGE_ACC_RIGHTDIST + TIMESIG_LEFTMARGIN; + if (preamble_contains_keysig) + { + x_left+=KEYCHANGE_ACC_LEFTDIST; + + key_enum key=key_at_tick(tick); + QPixmap* pix_acc=is_sharp_key(key) ? &pix_sharp[BLACK_PIXMAP] : &pix_b[BLACK_PIXMAP]; + list acclist=calc_accidentials(key,clef); + + draw_accidentials(p,x_left, y_offset, acclist ,*pix_acc); + + x_left+=acclist.size()*KEYCHANGE_ACC_DIST + KEYCHANGE_ACC_RIGHTDIST; + } // draw time signature ---------------------------------------------- - timesig_t timesig=timesig_at_tick(tick); + if (preamble_contains_timesig) + { + x_left+=TIMESIG_LEFTMARGIN; + + timesig_t timesig=timesig_at_tick(tick); - draw_timesig(p, x_left, y_offset, timesig.num, timesig.denom); + draw_timesig(p, x_left, y_offset, timesig.num, timesig.denom); - x_left+=calc_timesig_width(timesig.num, timesig.denom)+TIMESIG_RIGHTMARGIN; + x_left+=calc_timesig_width(timesig.num, timesig.denom)+TIMESIG_RIGHTMARGIN; + } // draw bar --------------------------------------------------------- p.setPen(Qt::black); @@ -3034,6 +3134,27 @@ void ScoreCanvas::set_tool(int tool) } } +void ScoreCanvas::menu_command(int cmd) +{ + switch (cmd) + { + case CMD_COLOR_BLACK: coloring_mode=COLOR_MODE_BLACK; redraw(); break; + case CMD_COLOR_PART: coloring_mode=COLOR_MODE_PART; redraw(); break; + default: + cout << "ILLEGAL FUNCTION CALL: ScoreCanvas::menu_command called with unknown command ("<toolbar] + * o velocity/release-velo for already existing notes + * - do this by right-click -> some dialog shows up? + * - or by selecting the note and changing the values in the same widget which also is used for new notes? + * o initiate "select current part" +*/ /* how to use the score editor with multiple tracks @@ -3194,3 +3315,4 @@ void ScoreCanvas::set_tool(int tool) * REASON: this is only a nice-to-have, which can however be * easily implemented when 4) is done */ + diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h index cd320eb2..078d7969 100644 --- a/muse2/muse/midiedit/scoreedit.h +++ b/muse2/muse/midiedit/scoreedit.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "noteinfo.h" @@ -43,7 +44,8 @@ using std::string; - +enum {CMD_COLOR_BLACK, CMD_COLOR_VELO, CMD_COLOR_PART, + CMD_SET_NAME}; class ScoreCanvas; @@ -63,14 +65,17 @@ class ScoreEdit : public MidiEditor ScoreCanvas* score_canvas; static int serial; - static set names; + static set names; + + QString name; - string name; + QSignalMapper* menu_mapper; - bool set_name(string newname, bool emit_signal=true, bool emergency_name=false); + bool set_name(QString newname, bool emit_signal=true, bool emergency_name=false); + private slots: + void menu_command(int); - signals: void deleted(unsigned long); void name_changed(); @@ -88,7 +93,7 @@ class ScoreEdit : public MidiEditor static void writeConfiguration(int, Xml&){}; //TODO does nothing void add_parts(PartList* pl, bool all_in_one=false); - string get_name() { return name; } + QString get_name() { return name; } }; @@ -565,6 +570,9 @@ class ScoreCanvas : public View + enum {COLOR_MODE_BLACK, COLOR_MODE_PART, COLOR_MODE_PITCH} coloring_mode; + bool preamble_contains_keysig; + bool preamble_contains_timesig; //menu stuff @@ -596,6 +604,9 @@ class ScoreCanvas : public View void heartbeat_timer_event(); void set_tool(int); + void menu_command(int); + void preamble_keysig_slot(bool); + void preamble_timesig_slot(bool); signals: void xscroll_changed(int); -- cgit v1.2.3 From 928081edaa0752e14577c36b6b595ab38079224a Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Tue, 26 Apr 2011 18:33:00 +0000 Subject: added "new score window"-menu-entry for quickly opening a new score window with one staff per track added "score"-entries for the popup-menu in the arranger changed arranger's popup-menu: now the pianoroll etc. actions are the same as the "Edit"-Menu's actions --- muse2/muse/app.cpp | 13 +++++++++++-- muse2/muse/app.h | 11 +++++++---- muse2/muse/arranger/pcanvas.cpp | 24 +++++++----------------- muse2/muse/midiedit/scoreedit.cpp | 8 ++++---- muse2/muse/widgets/canvas.cpp | 2 +- 5 files changed, 30 insertions(+), 28 deletions(-) (limited to 'muse2/muse/app.cpp') diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index 9bbe8736..80a7b7ef 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -999,9 +999,13 @@ MusE::MusE(int argc, char** argv) : QMainWindow() scoreAllInOneSubsubmenu = new QMenu(tr("all parts in one staff"), this); scoreOneStaffPerTrackSubsubmenu = new QMenu(tr("one staff per part"), this); + + scoreSubmenu->addMenu(scoreAllInOneSubsubmenu); + scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu); updateScoreMenus(); + startScoreEditAction = new QAction(*scoreIconSet, tr("New score window"), this); startPianoEditAction = new QAction(*pianoIconSet, tr("Pianoroll"), this); startDrumEditAction = new QAction(QIcon(*edit_drummsIcon), tr("Drums"), this); startListEditAction = new QAction(QIcon(*edit_listIcon), tr("List"), this); @@ -1151,6 +1155,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() connect(editSignalMapper, SIGNAL(mapped(int)), this, SLOT(cmd(int))); connect(startPianoEditAction, SIGNAL(activated()), SLOT(startPianoroll())); + connect(startScoreEditAction, SIGNAL(activated()), SLOT(startScoreQuickly())); connect(startDrumEditAction, SIGNAL(activated()), SLOT(startDrumEditor())); connect(startListEditAction, SIGNAL(activated()), SLOT(startListEditor())); connect(startWaveEditAction, SIGNAL(activated()), SLOT(startWaveEditor())); @@ -1373,8 +1378,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() menuEdit->addAction(startPianoEditAction); menuEdit->addMenu(scoreSubmenu); - scoreSubmenu->addMenu(scoreAllInOneSubsubmenu); - scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu); + menuEdit->addAction(startScoreEditAction); menuEdit->addAction(startDrumEditAction); menuEdit->addAction(startListEditAction); menuEdit->addAction(startWaveEditAction); @@ -3536,6 +3540,11 @@ void MusE::openInScoreEdit(ScoreEdit* destination, PartList* pl, bool allInOne) destination->add_parts(pl, allInOne); } +void MusE::startScoreQuickly() +{ + openInScoreEdit_oneStaffPerTrack(NULL); +} + //--------------------------------------------------------- // startPianoroll //--------------------------------------------------------- diff --git a/muse2/muse/app.h b/muse2/muse/app.h index 8a9fdac0..2fd83854 100644 --- a/muse2/muse/app.h +++ b/muse2/muse/app.h @@ -69,6 +69,8 @@ class ScoreEdit; #define MENU_ADD_SYNTH_ID_BASE 0x1000 + + //--------------------------------------------------------- // MusE //--------------------------------------------------------- @@ -110,12 +112,14 @@ class MusE : public QMainWindow QAction *editInvertSelectionAction, *editInsideLoopAction, *editOutsideLoopAction, *editAllPartsAction; QAction *trackMidiAction, *trackDrumAction, *trackWaveAction, *trackAOutputAction, *trackAGroupAction; QAction *trackAInputAction, *trackAAuxAction; - QAction *startPianoEditAction, *startDrumEditAction, *startListEditAction, *startWaveEditAction; QAction *masterGraphicAction, *masterListAction; QAction *midiTransposeAction; QAction *midiTransformerAction; QAction *editSongInfoAction; - + public: + QAction *startScoreEditAction, *startPianoEditAction, *startDrumEditAction, *startListEditAction, *startWaveEditAction; + QMenu *scoreSubmenu, *scoreOneStaffPerTrackSubsubmenu, *scoreAllInOneSubsubmenu; + private: // View Menu actions QAction *viewTransportAction, *viewBigtimeAction, *viewMixerAAction, *viewMixerBAction, *viewCliplistAction, *viewMarkerAction; @@ -159,7 +163,6 @@ class MusE : public QMainWindow QMenu* menu_audio, *menuAutomation; QMenu* menu_functions, *menuScriptPlugins; QMenu* select, *master, *midiEdit, *addTrack; - QMenu *scoreSubmenu, *scoreOneStaffPerTrackSubsubmenu, *scoreAllInOneSubsubmenu; // Special 'stay-open' menu for routes. PopupMenu* routingPopupMenu; @@ -273,7 +276,7 @@ class MusE : public QMainWindow void clearScoreMenuMappers(); void updateScoreMenus(); void scoreNamingChanged(); - + void startScoreQuickly(); void startPianoroll(); void startPianoroll(PartList* /*pl*/, bool /*showDefaultCtrls*/ = false); void startWaveEditor(); diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index 6068c743..c76e4421 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -783,19 +783,17 @@ QMenu* PartCanvas::genItemPopup(CItem* item) partPopup->addSeparator(); switch(trackType) { case Track::MIDI: { - QAction *act_pianoroll = partPopup->addAction(QIcon(*pianoIconSet), tr("pianoroll")); - act_pianoroll->setData(10); - QAction *act_mlist = partPopup->addAction(QIcon(*edit_listIcon), tr("list")); - act_mlist->setData(12); + partPopup->addAction(muse->startPianoEditAction); + partPopup->addMenu(muse->scoreSubmenu); + partPopup->addAction(muse->startScoreEditAction); + partPopup->addAction(muse->startListEditAction); QAction *act_mexport = partPopup->addAction(tr("save part to disk")); act_mexport->setData(16); } break; case Track::DRUM: { - QAction *act_dlist = partPopup->addAction(QIcon(*edit_listIcon), tr("list")); - act_dlist->setData(12); - QAction *act_drums = partPopup->addAction(QIcon(*edit_drummsIcon), tr("drums")); - act_drums->setData(13); + partPopup->addAction(muse->startDrumEditAction); + partPopup->addAction(muse->startListEditAction); QAction *act_dexport = partPopup->addAction(tr("save part to disk")); act_dexport->setData(16); } @@ -866,15 +864,7 @@ void PartCanvas::itemPopup(CItem* item, int n, const QPoint& pt) case 5: copy(pl); break; - case 10: // pianoroll edit - emit startEditor(pl, 0); - return; - case 12: // list edit - emit startEditor(pl, 1); - return; - case 13: // drum edit - emit startEditor(pl, 3); - return; + case 14: // wave edit { // Changed to allow multiple selected parts to be shown. By T356 diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 98568325..de397c30 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -3469,10 +3469,6 @@ set staff_t::parts_at_tick(unsigned tick) * x nothing atm * * less important stuff - * o use the proper quantisation functions instead of - * flo_quantize() and flo_quantize_floor() - * o let the user set up SPLIT_NOTE - * o let the user decide about the initial clef (search for FINDME_INITCLEF) * o deal with expanding parts or clip (expanding is better) * o offer functions like in the pianoroll: quantize etc. * o support selections @@ -3488,6 +3484,10 @@ set staff_t::parts_at_tick(unsigned tick) * keeping its own pos_add variable (which is only an optimisation) * o draw a margin around notes which are in a bright color * o refuse to resize so that width gets smaller or equal than x_left + * o use the proper quantisation functions instead of + * flo_quantize() and flo_quantize_floor() + * o let the user set up SPLIT_NOTE + * o let the user decide about the initial clef (search for FINDME_INITCLEF) * * stuff for the other muse developers * o process accurate timesignatures from muse's list (has to be implemented first in muse) diff --git a/muse2/muse/widgets/canvas.cpp b/muse2/muse/widgets/canvas.cpp index 596e4067..14f414b7 100644 --- a/muse2/muse/widgets/canvas.cpp +++ b/muse2/muse/widgets/canvas.cpp @@ -557,7 +557,7 @@ void Canvas::viewMousePressEvent(QMouseEvent* event) itemPopupMenu = genItemPopup(curItem); if (itemPopupMenu) { QAction *act = itemPopupMenu->exec(QCursor::pos()); - if (act) + if (act && act->data().isValid()) itemPopup(curItem, act->data().toInt(), start); delete itemPopupMenu; } -- cgit v1.2.3