summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-04-15 16:37:42 +0000
committerFlorian Jung <flo@windfisch.org>2011-04-15 16:37:42 +0000
commit84fdf802caa8a37cbbc3e8d2a4b33e7e89251604 (patch)
tree026aae084138f12c6496d1a41871c0825a51be2f /muse2
parent96903c974522e2ff67df92e57eb2c2db8d64fcf1 (diff)
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
Diffstat (limited to 'muse2')
-rw-r--r--muse2/muse/app.cpp126
-rw-r--r--muse2/muse/app.h16
-rw-r--r--muse2/muse/cobject.h2
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp108
-rw-r--r--muse2/muse/midiedit/scoreedit.h38
5 files changed, 199 insertions, 91 deletions
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<Track*> tracks;
+
+ for (ciPart it=pl->begin(); it!=pl->end(); it++)
+ tracks.insert(it->second->track());
+
+ for (set<Track*>::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<Track*> tracks;
-
- for (ciPart it=editor->parts()->begin(); it!=editor->parts()->end(); it++)
- tracks.insert(it->second->track());
-
- for (set<Track*>::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<staff_t>::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<staff_t>::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 <QPainter>
#include <QPixmap>
#include <QTimer>
+#include <QScrollBar>
#include <values.h>
#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<Part*>& parts);
void create_itemlist();
@@ -491,7 +469,7 @@ struct staff_t
clef=VIOLIN;
}
- staff_t (staff_type_t type_, clef_t clef_, set<Part*> parts_, unsigned split_note_=0)
+ staff_t (staff_type_t type_, clef_t clef_, set<Part*> 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<int>& nums, int denom);