summaryrefslogtreecommitdiff
path: root/muse2/muse
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-04-15 17:12:51 +0000
committerFlorian Jung <flo@windfisch.org>2011-04-15 17:12:51 +0000
commitd7e222752028fd0bed037c06806d252a66c5db88 (patch)
treeaf9ef20113c14560f41bf0a28783a0a6878c691d /muse2/muse
parent84fdf802caa8a37cbbc3e8d2a4b33e7e89251604 (diff)
scores now have names; the user can't change them yet,
but implementing this will be no problem
Diffstat (limited to 'muse2/muse')
-rw-r--r--muse2/muse/app.cpp9
-rw-r--r--muse2/muse/app.h5
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp59
-rw-r--r--muse2/muse/midiedit/scoreedit.h10
4 files changed, 70 insertions, 13 deletions
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<len;i++)
+ result+=char((rand() % 26) + 'A');
+
+ return result;
+}
+KeyList keymap;
+
+
KeyList::KeyList()
{
clear();
@@ -150,7 +164,8 @@ bool pixmaps_loaded=false;
-
+int ScoreEdit::serial=1;
+set<string> 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<staff_t>::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<staff_t>::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 <map>
#include <list>
#include <vector>
+#include <string>
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<string> 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; }
};