summaryrefslogtreecommitdiff
path: root/muse2/muse/midiedit/scoreedit.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2012-03-15 18:21:23 +0000
committerFlorian Jung <flo@windfisch.org>2012-03-15 18:21:23 +0000
commit27b7bf6815cda7abb67026c37b3e44daee1803cb (patch)
tree0b9d1c0bc84ac7ff8032e707f2b5fb4e0aaabb5c /muse2/muse/midiedit/scoreedit.cpp
parent2d6f113a10eb485694e20a78500f650776d701e3 (diff)
merged with trunk
Diffstat (limited to 'muse2/muse/midiedit/scoreedit.cpp')
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp142
1 files changed, 96 insertions, 46 deletions
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index 955a73d0..5722a275 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -45,7 +45,6 @@
#include <QImage>
#include <QInputDialog>
#include <QMessageBox>
-#include <QSpinBox>
#include <stdio.h>
#include <math.h>
@@ -69,12 +68,9 @@ using namespace std;
#include "functions.h"
#include "helper.h"
#include "cmd.h"
-#include "sig.h"
#include "song.h"
#include "shortcuts.h"
-//#include "../ctrl/ctrledit.h"
-
using MusEGlobal::debugMsg;
using MusEGlobal::heavyDebugMsg;
@@ -108,7 +104,8 @@ QString IntToQStr(int i);
-//do NOT put parentheses around this!
+//do NOT put parentheses around this! and always right-multiply it,
+//that is: foo * PAGESTEP, never PAGESTEP * foo!
#define PAGESTEP 3/4
@@ -184,7 +181,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
: TopWin(TopWin::SCORE, parent, name)
{
setAttribute(Qt::WA_DeleteOnClose);
- setFocusPolicy(Qt::StrongFocus);
+ setFocusPolicy(Qt::NoFocus);
mainw = new QWidget(this);
@@ -243,6 +240,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
srec->setToolTip(tr("Step Record"));
srec->setIcon(*steprecIcon);
srec->setCheckable(true);
+ srec->setFocusPolicy(Qt::NoFocus);
steprec_tools->addWidget(srec);
connect(srec, SIGNAL(toggled(bool)), score_canvas, SLOT(set_steprec(bool)));
@@ -318,24 +316,34 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
note_settings_toolbar->addWidget(apply_velo_to_label);
note_settings_toolbar->addWidget(new QLabel(tr("Velocity:"), note_settings_toolbar));
- velo_spinbox = new QSpinBox(this);
+ velo_spinbox = new SpinBox(this);
velo_spinbox->setRange(0, 127);
velo_spinbox->setSingleStep(1);
//we do not use the valueChanged signal, because that would generate
//many many undos when using the spin buttons.
connect(velo_spinbox, SIGNAL(editingFinished()), SLOT(velo_box_changed()));
connect(this,SIGNAL(velo_changed(int)), score_canvas, SLOT(set_velo(int)));
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(velo_spinbox, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(velo_spinbox, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
note_settings_toolbar->addWidget(velo_spinbox);
velo_spinbox->setValue(ScoreCanvas::note_velo_init);
note_settings_toolbar->addWidget(new QLabel(tr("Off-Velocity:"), note_settings_toolbar));
- velo_off_spinbox = new QSpinBox(this);
+ velo_off_spinbox = new SpinBox(this);
velo_off_spinbox->setRange(0, 127);
velo_off_spinbox->setSingleStep(1);
//we do not use the valueChanged signal, because that would generate
//many many undos when using the spin buttons.
connect(velo_off_spinbox, SIGNAL(editingFinished()), SLOT(velo_off_box_changed()));
connect(this,SIGNAL(velo_off_changed(int)), score_canvas, SLOT(set_velo_off(int)));
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(velo_off_spinbox, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(velo_off_spinbox, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
note_settings_toolbar->addWidget(velo_off_spinbox);
velo_off_spinbox->setValue(ScoreCanvas::note_velo_off_init);
@@ -350,25 +358,33 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
quant_combobox->addItem("8"); // _quant_power2 and _quant_power2_init
quant_combobox->addItem("16"); // and MAX_QUANT_POWER (must be log2(largest_value))
quant_combobox->addItem("32");
+ quant_combobox->setFocusPolicy(Qt::TabFocus);
quant_combobox->setCurrentIndex(score_canvas->quant_power2()-1);
// the above is intendedly executed BEFORE connecting. otherwise this would
// destroy pixels_per_whole_init!
- connect(quant_combobox, SIGNAL(currentIndexChanged(int)), score_canvas, SLOT(set_quant(int)));
+ //connect(quant_combobox, SIGNAL(currentIndexChanged(int)), score_canvas, SLOT(set_quant(int)));
+ connect(quant_combobox, SIGNAL(activated(int)), SLOT(quant_combobox_changed(int))); // Tim
quant_toolbar->addWidget(quant_combobox);
quant_toolbar->addSeparator();
quant_toolbar->addWidget(new QLabel(tr("Pixels per whole:"), quant_toolbar));
- px_per_whole_spinbox = new QSpinBox(this);
+ px_per_whole_spinbox = new SpinBox(this);
+ px_per_whole_spinbox->setFocusPolicy(Qt::StrongFocus);
px_per_whole_spinbox->setRange(10, 1200);
px_per_whole_spinbox->setSingleStep(50);
connect(px_per_whole_spinbox, SIGNAL(valueChanged(int)), score_canvas, SLOT(set_pixels_per_whole(int)));
connect(score_canvas, SIGNAL(pixels_per_whole_changed(int)), px_per_whole_spinbox, SLOT(setValue(int)));
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(px_per_whole_spinbox, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(px_per_whole_spinbox, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
quant_toolbar->addWidget(px_per_whole_spinbox);
px_per_whole_spinbox->setValue(ScoreCanvas::_pixels_per_whole_init);
- QMenu* edit_menu = menuBar()->addMenu(tr("&Edit"));
+ QMenu* edit_menu = menuBar()->addMenu(tr("&Edit"));
edit_menu->addActions(MusEGlobal::undoRedo->actions());
edit_menu->addSeparator();
@@ -426,7 +442,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
connect(select_oloop_action, SIGNAL(triggered()), menu_mapper, SLOT(map()));
- QMenu* functions_menu = menuBar()->addMenu(tr("Fu&nctions"));
+ 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()));
@@ -450,7 +466,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
menu_mapper->setMapping(func_legato_action, CMD_LEGATO);
- QMenu* settings_menu = menuBar()->addMenu(tr("Window &Config"));
+ QMenu* settings_menu = menuBar()->addMenu(tr("Window &Config"));
color_menu = settings_menu->addMenu(tr("Note head &colors"));
color_actions = new QActionGroup(this);
@@ -491,7 +507,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
preamble_keysig_action->setChecked(ScoreCanvas::preamble_contains_keysig_init);
preamble_timesig_action->setChecked(ScoreCanvas::preamble_contains_timesig_init);
-
+
QAction* set_name_action = settings_menu->addAction(tr("Set Score &name"), menu_mapper, SLOT(map()));
menu_mapper->setMapping(set_name_action, CMD_SET_NAME);
@@ -499,7 +515,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
settings_menu->addAction(subwinAction);
settings_menu->addAction(shareAction);
settings_menu->addAction(fullscreenAction);
-
+
init_shortcuts();
@@ -614,6 +630,12 @@ ScoreEdit::~ScoreEdit()
names.erase(name);
}
+void ScoreEdit::focusCanvas()
+{
+ score_canvas->setFocus();
+ score_canvas->activateWindow();
+}
+
void ScoreEdit::velo_box_changed()
{
emit velo_changed(velo_spinbox->value());
@@ -624,11 +646,18 @@ void ScoreEdit::velo_off_box_changed()
emit velo_off_changed(velo_off_spinbox->value());
}
+void ScoreEdit::quant_combobox_changed(int idx)
+{
+ score_canvas->set_quant(idx);
+ if(MusEGlobal::config.smartFocus)
+ focusCanvas();
+}
+
void ScoreEdit::song_changed(int flags)
{
if(_isDeleting) // Ignore while while deleting to prevent crash.
return;
-
+
if (flags & (SC_SELECTION | SC_EVENT_MODIFIED | SC_EVENT_REMOVED))
{
map<MusECore::Event*, MusECore::Part*> selection=get_events(score_canvas->get_all_parts(),1);
@@ -699,7 +728,7 @@ void ScoreEdit::closeEvent(QCloseEvent* e)
{
_isDeleting = true; // Set flag so certain signals like songChanged, which may cause crash during delete, can be ignored.
names.erase(name);
-
+
QSettings settings("MusE", "MusE-qt");
//settings.setValue("ScoreEdit/geometry", saveGeometry());
settings.setValue("ScoreEdit/windowState", saveState());
@@ -976,6 +1005,10 @@ void ScoreCanvas::write_staves(int level, MusECore::Xml& xml) const
void ScoreEdit::readStatus(MusECore::Xml& xml)
{
+ // never "return;" inside that function.
+ // instead, goto end_of_scoreedit_read_status;
+ // (there is a command which must be executed!)
+
bool apply_velo_temp=apply_velo;
apply_velo=false;
@@ -1063,12 +1096,15 @@ void ScoreEdit::readStatus(MusECore::Xml& xml)
case MusECore::Xml::TagEnd:
if (tag == "scoreedit")
- return;
+ goto end_of_scoreedit_read_status;
default:
break;
}
}
+
+end_of_scoreedit_read_status:
+
apply_velo=apply_velo_temp;
}
@@ -1510,7 +1546,7 @@ void ScoreCanvas::song_changed(int flags)
{
if(parent && parent->deleting()) // Ignore while while deleting to prevent crash.
return;
-
+
if (flags & (SC_PART_MODIFIED | SC_PART_REMOVED | SC_PART_INSERTED | SC_TRACK_REMOVED))
{
update_parts();
@@ -2132,12 +2168,19 @@ list<note_len_t> parse_note_len(int len_ticks, int begin_tick, vector<int>& foo,
#define NUMBER_HEIGHT (pix_num[0].height())
-//kann 0 oder 1 sein:
-//bei notenkollisionen mit ungerader anzahl von kollidierenden
-//wird immer so ausgewichen, dass möglichst wenige ausweichen müssen
-//wenn die anzahl aber gerade ist, gibt es keine "bessere" lösung
-//in dem fall werden immer die geraden (0) bzw. ungeraden (1)
-//ausweichen.
+// kann 0 oder 1 sein:
+// bei notenkollisionen mit ungerader anzahl von kollidierenden
+// wird immer so ausgewichen, dass möglichst wenige ausweichen müssen
+// wenn die anzahl aber gerade ist, gibt es keine "bessere" lösung
+// in dem fall werden immer die geraden (0) bzw. ungeraden (1)
+// ausweichen.
+// ROUGH TRANSLATION:
+// can be 0 or 1:
+// when there are note head collisions with an odd number of colliding
+// heads there's an unique solution for "stepping aside", so that
+// fewer notes must "step aside". but when the number of colliding
+// heads is even, there is no "better" solution. this constant
+// specifies whether the "odd" (1) or the "even" (0) heads will move.
#define AUSWEICHEN_BEVORZUGT 0
#define STEM_LEN 30
@@ -2861,9 +2904,11 @@ void ScoreCanvas::draw_note_lines(QPainter& p, int y, bool reserve_akkolade_spac
void staff_t::calc_item_pos()
{
- MusECore::key_enum curr_key=MusECore::KEY_C; //this has to be KEY_C or KEY_C_B and nothing else,
- //because only with these two keys the next (initial)
- //key signature is properly drawn.
+ //this has to be KEY_C or KEY_C_B and nothing else,
+ //because only with these two keys the next (initial)
+ //key signature is properly drawn.
+ MusECore::key_enum curr_key=MusECore::KEY_C;
+
int pos_add=0;
max_y_coord=0;
@@ -2974,9 +3019,13 @@ void ScoreCanvas::calc_pos_add_list()
//process key changes
- MusECore::key_enum curr_key=MusECore::KEY_C; //this has to be KEY_C or KEY_C_B and nothing else,
- //because only with these two keys the next (initial)
- //key signature is properly calculated.
+
+ //this has to be KEY_C or KEY_C_B and nothing else,
+ //because only with these two keys the next (initial)
+ //key signature is properly calculated.
+ MusECore::key_enum curr_key=MusECore::KEY_C;
+
+
for (MusECore::iKeyEvent it=MusEGlobal::keymap.begin(); it!=MusEGlobal::keymap.end(); it++)
{
MusECore::key_enum new_key=it->second.key;
@@ -3252,10 +3301,10 @@ void ScoreCanvas::draw_items(QPainter& p, int y_offset, staff_t& staff, ScoreIte
list<int> aufloes_list=calc_accidentials(curr_key, staff.clef, new_key);
list<int> new_acc_list=calc_accidentials(new_key, staff.clef);
- // vorzeichen aus curr_key auflösen
+ // cancel accidentials from curr_key
draw_accidentials(p, it->x + KEYCHANGE_ACC_LEFTDIST - x_pos+x_left, y_offset, aufloes_list, pix_noacc[BLACK_PIXMAP]);
- // alle vorzeichen aus new_key zeichnen
+ // draw all accidentials from new_key
QPixmap* pix = is_sharp_key(new_key) ? &pix_sharp[BLACK_PIXMAP] : &pix_b[BLACK_PIXMAP];
vorzeichen_t new_accidential = is_sharp_key(new_key) ? SHARP : B;
@@ -3650,9 +3699,9 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event)
keystate=event->modifiers();
bool ctrl=keystate & Qt::ControlModifier;
- // den errechneten tick immer ABrunden!
- // denn der "bereich" eines schlags geht von schlag_begin bis nächsterschlag_begin-1
- // noten werden aber genau in die mitte dieses bereiches gezeichnet
+ // always round DOWN.
+ // because the "area" of a beat goes from "beat_begin" to "nextbeat_begin-1",
+ // but notes are drawn in the middle of that area!
list<staff_t>::iterator staff_it=staff_at_y(event->y() + y_pos);
@@ -4644,7 +4693,8 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo
/* BUGS and potential bugs
* 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
+ * between, for example, when a cis is tied to a des [ will not fix ]
+ * (reason: this actually never happens if dealing with a sane piece)
* > o when changing toolbarstate when sharing and immediately after that
* changing "share" status, the changed state isn't stored
* (could be solved by storing the current window when quitting/saving whatever)
@@ -4689,6 +4739,15 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo
* o all places where i added doubleclick-edits: only react on left-click double clicks!
* o support "new style" reordering with old style drum tracks as well
* (not swapping but inserting!)
+ *
+ * o canvas editor: create clone via "alt+drag" moves window instead
+ * o controller view in score editor
+ * o solo button
+ * o do partial recalculating; recalculating can take pretty long
+ * (0,5 sec) when displaying a whole song in scores
+ * o transpose etc. must also transpose key-pressure events
+ * o transpose: support in-key-transpose
+ * o thin out: remove unneeded ctrl messages
* o support edge-scrolling when opening a lasso
* o add "dotted quarter" quantize option (for 6/8 beat)
* o ticks-to-quarter spinboxes
@@ -4702,15 +4761,6 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo
*
* o shrink a part from its beginning as well! watch out for clones!
*
- * o canvas editor: create clone via "alt+drag" moves window instead
- * o controller view in score editor
- * o solo button
- * > o do partial recalculating; recalculating can take pretty long
- * (0,5 sec) when displaying a whole song in scores
- * o transpose etc. must also transpose key-pressure events
- * o transpose: support in-key-transpose
- * o thin out: remove unneeded ctrl messages
- *
* less important stuff
* o allow "fixating" toolbars?
* o quantize-templates (everything is forced into a specified