diff options
author | Florian Jung <flo@windfisch.org> | 2011-04-10 15:42:21 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-04-10 15:42:21 +0000 |
commit | cb193f62e79ae5f2ba75d8c7435ac10dc85499ee (patch) | |
tree | 0d83c272102ee6bc5293a68ab1c3c0e2f38a183c /muse2 | |
parent | 07f850ab11651dd62cbfc2177bba8e88a7ee5b44 (diff) |
added some scrolling stuff and fixed segfault when closing
Diffstat (limited to 'muse2')
-rw-r--r-- | muse2/muse/app.cpp | 2 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.cpp | 80 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.h | 15 |
3 files changed, 77 insertions, 20 deletions
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))); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index aff9198d..5405bf24 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -3,14 +3,6 @@ //the trailing slash is necessary #define FONT_PATH "/home/flo/muse-glyphs/" -//========================================================= -// MusE -// Linux Music Editor -// scoreedit.cpp -// (C) Copyright 2011 Florian Jung (florian.a.jung@web.de) -//========================================================= - - #include <QLayout> #include <QSizeGrip> #include <QLabel> @@ -67,6 +59,10 @@ using namespace std; #include "sig.h" +#define PAGESTEP 3/4 +//do NOT put parentheses around this! + + //--------------------------------------------------------- // ScoreEdit //--------------------------------------------------------- @@ -74,7 +70,6 @@ using namespace std; ScoreEdit::ScoreEdit(PartList* pl, QWidget* parent, const char* name, unsigned initPos) : MidiEditor(0, 0, pl, parent, name) { - // Splitter* hsplitter; QPushButton* ctrl; /* @@ -100,19 +95,22 @@ ScoreEdit::ScoreEdit(PartList* pl, QWidget* parent, const char* name, unsigned i */ ScoreCanvas* test=new ScoreCanvas(this, mainw, 1, 1); - QScrollBar* hscroll = new QScrollBar(Qt::Horizontal, mainw); + hscroll = new QScrollBar(Qt::Horizontal, mainw); 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->setRowStretch(0, 100); // mainGrid->setColumnStretch(1, 100); mainGrid->addWidget(test, 0, 0); mainGrid->addWidget(hscroll,1,0); hscroll->setMinimum(0); -hscroll->setMaximum(1000); -hscroll->setPageStep(100); +test->song_changed(0); +test->goto_tick(initPos,true); // gridS1->addWidget(test,0,0); // gridS1->addWidget(canvas, 0, 0); @@ -130,6 +128,27 @@ ScoreEdit::~ScoreEdit() } +void ScoreEdit::canvas_width_changed(int width) +{ + hscroll->setMaximum(width); +} +void ScoreEdit::viewport_width_changed(int width) +{ + hscroll->setPageStep(width * PAGESTEP); +} + +void ScoreEdit::closeEvent(QCloseEvent* e) +{ + QSettings settings("MusE", "MusE-qt"); + //settings.setValue("ScoreEdit/geometry", saveGeometry()); + settings.setValue("ScoreEdit/windowState", saveState()); + + emit deleted((unsigned long)this); + e->accept(); +} + + + ScoreCanvas::ScoreCanvas(MidiEditor* pr, QWidget* parent, int sx, int sy) : View(parent, sx, sy) { @@ -153,10 +172,9 @@ ScoreCanvas::ScoreCanvas(MidiEditor* pr, QWidget* parent, last_len=384; new_len=-1; - song_changed(0); //fertig mit aufbereiten cout << "---------------- CALCULATING DONE ------------------" << endl; - + } void ScoreCanvas::song_changed(int) @@ -169,6 +187,8 @@ void ScoreCanvas::song_changed(int) calc_item_pos(itemlist); redraw(); cout << "song had changed, recalculation complete" << endl; + + emit canvas_width_changed(tick_to_x(itemlist.rbegin()->first)); } //flo code starting here @@ -1777,6 +1797,7 @@ int ScoreCanvas::clef_height(clef_t clef) void ScoreCanvas::draw_preamble(QPainter& p) { + int x_left_old=x_left; int tick=x_to_tick(x_pos); // draw clef -------------------------------------------------------- @@ -1809,6 +1830,9 @@ void ScoreCanvas::draw_preamble(QPainter& p) p.setPen(Qt::black); //Y_MARKER p.drawLine(x_left,YDIST,x_left,YDIST+4*YLEN); + + if (x_left_old!=x_left) + emit viewport_width_changed(width() - x_left); } @@ -2253,6 +2277,31 @@ void ScoreCanvas::scroll_event(int x) } +//if force is true, it will always happen something +//if force is false, it will only happen something, if +//tick isn't visible at all. if it's visible, but not at +//the position goto would set it to, nothing happens +void ScoreCanvas::goto_tick(int tick, bool force) +{ + //TODO FINDMICH: implement force + + x_pos=tick_to_x(tick); + redraw(); + + emit xpos_changed(x_pos); +} + +//--------------------------------------------------------- +// resizeEvent +//--------------------------------------------------------- + +void ScoreCanvas::resizeEvent(QResizeEvent* ev) +{ + QWidget::resizeEvent(ev); //TODO is this really neccessary? + + emit viewport_width_changed( ev->size().width() - x_left ); +} + // TODO: testen: kommen die segfaults von muse oder von mir? [ von mir ] // TODO: testen, ob das noten-splitten korrekt arbeitet [ scheint zu klappen ] // TODO: testen, ob shift immer korrekt gesetzt wird [ scheint zu klappen ] @@ -2291,10 +2340,10 @@ void ScoreCanvas::scroll_event(int x) * operator/ rounds towards zero. (-5)/7=0, but should be -1 * * IMPORTANT TODO + * o refuse to resize so that width gets smaller or equal than x_left * o support violin and bass clefs at one time * o support multiple note systems * o let the user select which clef to use - * o use correct scrolling bounds * 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", @@ -2303,6 +2352,7 @@ void ScoreCanvas::scroll_event(int x) * o support selections * * less important stuff + * 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 diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h index 58c5ea18..bb091e6a 100644 --- a/muse2/muse/midiedit/scoreedit.h +++ b/muse2/muse/midiedit/scoreedit.h @@ -73,7 +73,9 @@ class ScoreEdit : public MidiEditor Q_OBJECT private: + virtual void closeEvent(QCloseEvent*); + QScrollBar* hscroll; private slots: @@ -82,7 +84,8 @@ class ScoreEdit : public MidiEditor void deleted(unsigned long); public slots: - CtrlEdit* addCtrl() {return NULL;}; //TODO does nothing + void canvas_width_changed(int); + void viewport_width_changed(int); public: ScoreEdit(PartList*, QWidget* parent = 0, const char* name = 0, unsigned initPos = MAXINT); @@ -498,8 +501,13 @@ class ScoreCanvas : public View public slots: void scroll_event(int); void song_changed(int); - - + void goto_tick(int,bool); + + signals: + void xpos_changed(int); + void viewport_width_changed(int); + void canvas_width_changed(int); + protected: virtual void draw(QPainter& p, const QRect& rect); MidiEditor* editor; @@ -507,6 +515,7 @@ class ScoreCanvas : public View virtual void mousePressEvent (QMouseEvent* event); virtual void mouseMoveEvent (QMouseEvent* event); virtual void mouseReleaseEvent (QMouseEvent* event); + virtual void resizeEvent(QResizeEvent*); public: ScoreCanvas(MidiEditor*, QWidget*, int, int); |