MuseScore/libmscore/input.cpp

95 lines
2.4 KiB
C++
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2011 Werner Schweer and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENSE.GPL
//=============================================================================
#include "input.h"
#include "segment.h"
#include "part.h"
#include "staff.h"
#include "score.h"
#include "chordrest.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
class DrumSet;
//---------------------------------------------------------
// InputState
//---------------------------------------------------------
InputState::InputState() :
_duration(TDuration::V_INVALID),
_drumNote(-1),
_drumset(0),
_track(0),
_segment(0),
_string(VISUAL_STRING_NONE),
2012-05-26 14:26:10 +02:00
_repitchMode(false),
rest(false),
noteType(NOTE_NORMAL),
beamMode(BeamMode::AUTO),
2012-05-26 14:26:10 +02:00
noteEntryMode(false),
slur(0)
{
}
//---------------------------------------------------------
// drumset
//---------------------------------------------------------
Drumset* InputState::drumset() const
{
if (_segment == 0 || _track == -1)
return 0;
return _segment->score()->staff(_track/VOICES)->part()->instr(_segment->tick())->drumset();
}
//---------------------------------------------------------
// staffGroup
//---------------------------------------------------------
StaffGroup InputState::staffGroup() const
{
if (_segment == 0 || _track == -1)
Re-factor presets and staff types. 1) Built-in staff types have been removed. 2) Presets are internally used as source for the staff types of a new score, to match data in Instruments.xml and as reference to check for modifications. 3) Each new score is given by default one staff type for each preset with the same name. 4) The Instrument page of the New Score Wizard lists (under the name of "Staff types") the default staff types applicable to the instrument (actually it lists the preset, as the score does not have any staff type yet). 5) The "Add | Instruments" dlg box lists all the staff types applicable to the instrument: = to the list of 4) + any user-created staff type. 6) The Staff Properties dlg box lists all the staff types applicable to the instrument: = list in 5) 7) The Staff Type Editor lists all the staff types This should ensure consistency among the several lists of staff types and avoid duplication of similar items Terminology: 7) A new staff type created in the editor is named by default with the group name ("Standard-", "Perc-", "Tab-") + the index of the new type in its group + the suffix "[*]" marking a user customisation. The user is anyway able to rename it, if he want. 8) The pitched staff type has been renamed everywhere (hopefully!) to "Standard" 9) The term 'preset' have been removed from the UI, except from the Staff Type Editor where it keeps its meaning of ready-made collections of parameters The commit affects many files, but a fair number of them have only changes in names of literals. The files with significant code changes are: libmscore/score.cpp libmscore/stafftype.cpp/.h mscore/editstafftype.cpp (code for naming a new staff type) mscore/instrdialog.cpp (building type list) Note: as score files store staff type indications as integer indices and the number and order of new default staff types is different from the old built-in types, there is a compatibility issue with old 2.0 score which use percussion and tab staves. In Score::read() (libmscore/scorefile.cpp), there is a rudimentary attempt to cope with this.Old scores will need manual fix anyway. There should not be any (new) compatibility issue with 1.x scores, as they did not use staff types.
2013-08-18 11:55:31 +02:00
return STANDARD_STAFF_GROUP;
return _segment->score()->staff(_track/VOICES)->staffType()->group();
}
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// tick
//---------------------------------------------------------
int InputState::tick() const
{
return _segment ? _segment->tick() : 0;
}
//---------------------------------------------------------
// cr
//---------------------------------------------------------
ChordRest* InputState::cr() const
{
return _segment ? static_cast<ChordRest*>(_segment->element(_track)) : 0;
}
//---------------------------------------------------------
// setTrack
//---------------------------------------------------------
void InputState::setTrack(int v)
{
_track = v;
}
2012-05-26 14:26:10 +02:00
2013-05-13 18:49:17 +02:00
}