Lomse library. API documentation  0.30.0
CmdAddChordNote Class Reference

#include <lomse_command.h>

Inheritance diagram for CmdAddChordNote:
DocCmdSimple DocCommand

Detailed Description

A command for adding a note to an existing note and thus to create a chord, or for adding a note to an existing chord.

See constructor for details.

Public Member Functions

 CmdAddChordNote (const std::string &pitch, const std::string &name="Add chord note")
 
int get_cursor_update_policy () override
 
int get_undo_policy () override
 
int get_selection_update_policy () override
 
- Public Member Functions inherited from DocCmdSimple
virtual ~DocCmdSimple ()
 
bool is_composite () override
 
- Public Member Functions inherited from DocCommand
virtual ~DocCommand ()
 
std::string get_name ()
 
bool is_reversible ()
 
bool is_recordable ()
 
std::string get_error ()
 

Additional Inherited Members

- Public Types inherited from DocCommand
enum  ECmdCursorPolicy
 
enum  ECmdUndoPolicy
 
enum  ECmdSelectionPolicy
 

Constructor & Destructor Documentation

◆ CmdAddChordNote()

CmdAddChordNote::CmdAddChordNote ( const std::string &  pitch,
const std::string &  name = "Add chord note" 
)

This command adds a new note to an existing note or chord. If the selected note prior to executing this command is not in a chord, a new chord will be created by combining this new note with the existing one. Otherwise, if the selected note is part of a chord, the new note is also added to the existing chord.

Parameters
pitchA string with the pitch for the note to insert. The pitch must be in LDP format (step letter followed by octave, e.g. "c4", "b6", "f3"). Octave numbers are the same than in MIDI format, that is, octave 4 is the central one (a4 is 440Hz).
nameThe displayable name for the command. If not specified will default to "Add chord note".

Remarks

  • The target for this command must be a selected note. The selection must contain only the target note, otherwise the command will not be executed and will return an error.
  • Only note pitch is needed as all other attributes (duration, voice, etc.) will be taken from the target note.
  • After executing the command:
    • the selection will be cleared and the added note will be selected. That is, the selection will contain only the new added note.
    • the cursor will be pointing to added note.

Example

Consider an edition application in which the expected user interaction pattern is as follows:

  • First, user selects a note.
  • As a consequence, the application enables and disables allowed tools for the new context. In this example, as the user has selected a note the tool "add chord note" is enabled (among other tools).
  • The user then clicks on the "add chord note" tool and execution arrives to the following method:
void CommandHandler::add_chord_note(const string& stepLetter, int octave)
{
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
stringstream src;
src << stepLetter << octave;
string pitch = src.str();
string name = gettext("Add chord note") + "(" + pitch + ")";
SpInteractor->exec_command( new CmdAddChordNote(pitch, name) );
}
}

Member Function Documentation

◆ get_cursor_update_policy()

int CmdAddChordNote::get_cursor_update_policy ( )
inlineoverridevirtual

Returns a value from ECmdCursorPolicy that indicates the update policy followed by this command.

Implements DocCommand.

◆ get_selection_update_policy()

int CmdAddChordNote::get_selection_update_policy ( )
inlineoverridevirtual

Returns a value from ECmdSelectionPolicy that indicates the undo policy followed by this command.

Implements DocCommand.

◆ get_undo_policy()

int CmdAddChordNote::get_undo_policy ( )
inlineoverridevirtual

Returns a value from ECmdUndoPolicy that indicates the undo policy followed by this command.

Implements DocCommand.