diff options
Diffstat (limited to 'muse2/muse/midiedit/scoreedit.cpp')
-rw-r--r-- | muse2/muse/midiedit/scoreedit.cpp | 180 |
1 files changed, 97 insertions, 83 deletions
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 8847c105..39f2f389 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -45,6 +45,7 @@ #include <QImage> #include <QInputDialog> #include <QMessageBox> +#include <QSpinBox> #include <stdio.h> #include <math.h> @@ -161,9 +162,6 @@ QColor* mycolors; // array [NUM_MYCOLORS] set<QString> ScoreEdit::names; -int ScoreEdit::width_init = 600; -int ScoreEdit::height_init = 400; -QByteArray ScoreEdit::default_toolbar_state; //--------------------------------------------------------- @@ -171,13 +169,11 @@ QByteArray ScoreEdit::default_toolbar_state; //--------------------------------------------------------- ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) - : TopWin(parent, name) + : TopWin(TopWin::SCORE, parent, name) { setAttribute(Qt::WA_DeleteOnClose); setFocusPolicy(Qt::StrongFocus); - resize(width_init, height_init); - mainw = new QWidget(this); mainGrid = new QGridLayout(); @@ -404,7 +400,31 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) connect(select_oloop_action, SIGNAL(triggered()), menu_mapper, SLOT(map())); - QMenu* settings_menu = menuBar()->addMenu(tr("&Settings")); + QMenu* functions_menu = menuBar()->addMenu(tr("Fu&nctions")); + + func_quantize_action = functions_menu->addAction(tr("&Quantize"), menu_mapper, SLOT(map())); + func_notelen_action = functions_menu->addAction(tr("Change note &length"), menu_mapper, SLOT(map())); + func_velocity_action = functions_menu->addAction(tr("Change note &velocity"), menu_mapper, SLOT(map())); + func_cresc_action = functions_menu->addAction(tr("Crescendo/Decrescendo"), menu_mapper, SLOT(map())); + func_transpose_action = functions_menu->addAction(tr("Transpose"), menu_mapper, SLOT(map())); + func_erase_action = functions_menu->addAction(tr("Erase Events"), menu_mapper, SLOT(map())); + func_move_action = functions_menu->addAction(tr("Move Notes"), menu_mapper, SLOT(map())); + func_fixed_len_action = functions_menu->addAction(tr("Set Fixed Length"), menu_mapper, SLOT(map())); + func_del_overlaps_action = functions_menu->addAction(tr("Delete Overlaps"), menu_mapper, SLOT(map())); + func_legato_action = functions_menu->addAction(tr("Legato"), menu_mapper, SLOT(map())); + menu_mapper->setMapping(func_quantize_action, CMD_QUANTIZE); + menu_mapper->setMapping(func_notelen_action, CMD_NOTELEN); + menu_mapper->setMapping(func_velocity_action, CMD_VELOCITY); + menu_mapper->setMapping(func_cresc_action, CMD_CRESCENDO); + menu_mapper->setMapping(func_transpose_action, CMD_TRANSPOSE); + menu_mapper->setMapping(func_erase_action, CMD_ERASE); + menu_mapper->setMapping(func_move_action, CMD_MOVE); + menu_mapper->setMapping(func_fixed_len_action, CMD_FIXED_LEN); + menu_mapper->setMapping(func_del_overlaps_action, CMD_DELETE_OVERLAPS); + menu_mapper->setMapping(func_legato_action, CMD_LEGATO); + + + QMenu* settings_menu = menuBar()->addMenu(tr("Window &Config")); color_menu = settings_menu->addMenu(tr("Note head &colors")); color_actions = new QActionGroup(this); @@ -423,7 +443,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) color_black_action->setChecked(true); menu_command(CMD_COLOR_BLACK); - + QMenu* preamble_menu = settings_menu->addMenu(tr("Set up &preamble")); preamble_keysig_action = preamble_menu->addAction(tr("Display &key signature")); preamble_timesig_action = preamble_menu->addAction(tr("Display &time signature")); @@ -438,31 +458,13 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) QAction* set_name_action = settings_menu->addAction(tr("Set Score &name"), menu_mapper, SLOT(map())); menu_mapper->setMapping(set_name_action, CMD_SET_NAME); + + settings_menu->addSeparator(); + settings_menu->addAction(subwinAction); + settings_menu->addAction(shareAction); + settings_menu->addAction(fullscreenAction); - QMenu* functions_menu = menuBar()->addMenu(tr("Fu&nctions")); - - func_quantize_action = functions_menu->addAction(tr("&Quantize"), menu_mapper, SLOT(map())); - func_notelen_action = functions_menu->addAction(tr("Change note &length"), menu_mapper, SLOT(map())); - func_velocity_action = functions_menu->addAction(tr("Change note &velocity"), menu_mapper, SLOT(map())); - func_cresc_action = functions_menu->addAction(tr("Crescendo/Decrescendo"), menu_mapper, SLOT(map())); - func_transpose_action = functions_menu->addAction(tr("Transpose"), menu_mapper, SLOT(map())); - func_erase_action = functions_menu->addAction(tr("Erase Events"), menu_mapper, SLOT(map())); - func_move_action = functions_menu->addAction(tr("Move Notes"), menu_mapper, SLOT(map())); - func_fixed_len_action = functions_menu->addAction(tr("Set Fixed Length"), menu_mapper, SLOT(map())); - func_del_overlaps_action = functions_menu->addAction(tr("Delete Overlaps"), menu_mapper, SLOT(map())); - func_legato_action = functions_menu->addAction(tr("Legato"), menu_mapper, SLOT(map())); - menu_mapper->setMapping(func_quantize_action, CMD_QUANTIZE); - menu_mapper->setMapping(func_notelen_action, CMD_NOTELEN); - menu_mapper->setMapping(func_velocity_action, CMD_VELOCITY); - menu_mapper->setMapping(func_cresc_action, CMD_CRESCENDO); - menu_mapper->setMapping(func_transpose_action, CMD_TRANSPOSE); - menu_mapper->setMapping(func_erase_action, CMD_ERASE); - menu_mapper->setMapping(func_move_action, CMD_MOVE); - menu_mapper->setMapping(func_fixed_len_action, CMD_FIXED_LEN); - menu_mapper->setMapping(func_del_overlaps_action, CMD_DELETE_OVERLAPS); - menu_mapper->setMapping(func_legato_action, CMD_LEGATO); - init_shortcuts(); connect(MusEGlobal::muse, SIGNAL(configChanged()), SLOT(init_shortcuts())); @@ -473,9 +475,6 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) clipboard_changed(); selection_changed(); - if (!default_toolbar_state.isEmpty()) - restoreState(default_toolbar_state); - connect(song, SIGNAL(songChanged(int)), SLOT(song_changed(int))); score_canvas->fully_recalculate(); @@ -488,6 +487,9 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) apply_velo=true; + + initTopwinState(); + initalizing=false; } void ScoreEdit::init_shortcuts() @@ -656,30 +658,10 @@ void ScoreEdit::closeEvent(QCloseEvent* e) //settings.setValue("ScoreEdit/geometry", saveGeometry()); settings.setValue("ScoreEdit/windowState", saveState()); - emit deleted((unsigned long)this); + emit deleted(static_cast<TopWin*>(this)); e->accept(); } -void ScoreEdit::resizeEvent(QResizeEvent* ev) -{ - QWidget::resizeEvent(ev); - - store_initial_state(); -} - -void ScoreEdit::focusOutEvent(QFocusEvent* ev) -{ - QMainWindow::focusOutEvent(ev); - - store_initial_state(); -} - -void ScoreEdit::store_initial_state() -{ - width_init=width(); - height_init=height(); - default_toolbar_state=saveState(); -} void ScoreEdit::menu_command(int cmd) { @@ -712,7 +694,7 @@ void ScoreEdit::menu_command(int cmd) case CMD_COPY: copy_notes(score_canvas->get_all_parts(), 1); break; case CMD_PASTE: menu_command(CMD_SELECT_NONE); - paste_notes(score_canvas->get_selected_part()); + paste_notes(); //(score_canvas->get_selected_part()); TODO FINDMICHJETZT break; case CMD_QUANTIZE: quantize_notes(score_canvas->get_all_parts()); break; case CMD_VELOCITY: modify_velocity(score_canvas->get_all_parts()); break; @@ -733,7 +715,7 @@ void ScoreEdit::menu_command(int cmd) void ScoreEdit::clipboard_changed() { - paste_action->setEnabled(QApplication::clipboard()->mimeData()->hasFormat(QString("text/x-muse-eventlist"))); + paste_action->setEnabled(QApplication::clipboard()->mimeData()->hasFormat(QString("text/x-muse-groupedeventlists"))); } void ScoreEdit::selection_changed() @@ -1050,12 +1032,8 @@ void ScoreEdit::read_configuration(Xml& xml) switch (token) { case Xml::TagStart: - if (tag == "height") - height_init = xml.parseInt(); - else if (tag == "width") - width_init = xml.parseInt(); - else if (tag == "toolbars") - default_toolbar_state = QByteArray::fromHex(xml.parse1().toAscii()); + if (tag == "topwin") + TopWin::readConfiguration(SCORE, xml); else xml.unknown("ScoreEdit"); break; @@ -1074,9 +1052,7 @@ void ScoreEdit::read_configuration(Xml& xml) void ScoreEdit::write_configuration(int level, Xml& xml) { xml.tag(level++, "scoreedit"); - xml.intTag(level, "width", width_init); - xml.intTag(level, "height", height_init); - xml.strTag(level, "toolbars", default_toolbar_state.toHex().data()); + TopWin::writeConfiguration(SCORE, level, xml); xml.etag(level, "scoreedit"); } @@ -3952,7 +3928,7 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) unsigned newpartlen=dragged_event_part->lenTick(); if (tmp.endTick() > dragged_event_part->lenTick()) { - if (dragged_event_part->hasHiddenEvents()) // do not allow autoexpand + if (dragged_event_part->hasHiddenEvents()) // do not allow autoexpand { tmp.setLenTick(dragged_event_part->lenTick() - tmp.tick()); if (MusEGlobal::debugMsg) cout << "resized note would exceed its part; limiting length to " << tmp.lenTick() << endl; @@ -4463,6 +4439,39 @@ void staff_t::update_part_indices() part_indices.insert((*it)->sn()); } + +void ScoreEdit::keyPressEvent(QKeyEvent* event) +{ + int key = event->key(); + + if (key == Qt::Key_Escape) + { + close(); + return; + } + else if (key == shortcuts[SHRT_TOOL_POINTER].key) + { + edit_tools->set(MusEWidget::PointerTool); + return; + } + else if (key == shortcuts[SHRT_TOOL_PENCIL].key) + { + edit_tools->set(MusEWidget::PencilTool); + return; + } + else if (key == shortcuts[SHRT_TOOL_RUBBER].key) + { + edit_tools->set(MusEWidget::RubberTool); + return; + } + else //Default: + { + event->ignore(); + return; + } +} + + //the following assertions are made: // pix_quarter.width() == pix_half.width() @@ -4488,33 +4497,41 @@ void staff_t::update_part_indices() * and both A and B get scheduled to be expanded (because we * have one event from A and one event from B), this causes a bug, * because after A (and B) got resized, the B-resize is invalid! + * o when changing toolbarstate when sharing and immediately after that + * changing "share" status, the changed state isn't stored * * CURRENT TODO + * o when pasting and creating new parts, inform the editors about that! + * o TEST pasting in editors! + * o pasting in editors: add dialogs + * + * ! o fix sigedit boxes + * M o remove that ugly "bool initalizing" stuff. it's probably unneeded (watch out for the FINDMICH message) + * o mirror most menus to an additional right-click context menu to avoid the long mouse pointer + * journey to the menu bar. try to find a way which does not involve duplicate code! + * o sane defaults for toolbars + * o paste in midi editors + * o implement borland-style maximize: free windows do not cover the main menu, even when maximized + * o smart range selection: if range markers have been used recently (that is, a dialog with + * "range" setting, or they've been modified), default to "in range" or "selected in range" + * + * IMPORTANT TODO + * o add "dotted quarter" quantize option (for 6/8 beat) + * + * o rename stuff with F2 key * o redo transport menu: offer "one beat" and "one bar" steps * maybe also offer scrollbar * o quick "set left/right marker", "select between markers" * or even "set marker and select between immediately" * o support partially selected parts. when moving, automatically split * - * o speed up structural operations - * o maybe remove "insert empty measure"? - * o structural OPs: don't erase note which begins at "end of cut" - * o add "move other notes" or "overwrite notes" or "mix with notes" to paste - * - * IMPORTANT TODO - * o add "dotted quarter" quantize option (for 6/8 beat) - * o draw the edge of parts hiding notes "jagged" (hasHiddenEvents() is interesting for this) - Done. Tim. * o shrink a part from its beginning as well! watch out for clones! - * o insert empty measure should also work inside parts, that is, - * move notes _within_ parts * * o canvas editor: create clone via "alt+drag" moves window instead * o investigate with valgrind * o controller view in score editor - * o fix sigedit boxes * o solo button * o grand staff brace - * o mastertrack editor: key-combobox is buggy * o drum editor: channel-stuff * o do partial recalculating; recalculating can take pretty long * (0,5 sec) when displaying a whole song in scores @@ -4537,7 +4554,6 @@ void staff_t::update_part_indices() * keeping its own pos_add variable (which is only an optimisation) * o support edge-scrolling when opening a lasso * o save more configuration stuff (quant, color) - * o drum list: scroll while dragging (not important due to "reorder list") * * really unimportant nice-to-haves * o support in-song clef-changes @@ -4545,7 +4561,7 @@ void staff_t::update_part_indices() * o use timesig_t in all timesig-stuff * o refuse to resize so that width gets smaller or equal than x_left * o draw a margin around notes which are in a bright color - * o support drum tracks (x-note-heads etc.) + * o support drum tracks in the score editor (x-note-heads etc.) * o drum list: scroll while dragging: probably unneccessary with the "reorder list" function * * @@ -4556,8 +4572,6 @@ void staff_t::update_part_indices() * * o process accurate timesignatures from muse's list (has to be implemented first in muse) * ( (2+2+3)/4 or (3+2+2)/4 instead of 7/4 ) - * o maybe do expanding parts inside the msgChangeEvent or - * msgNewEvent functions (see my e-mail) */ |