Lomse library. API documentation  0.30.0
CmdAddTuplet Class Reference

#include <lomse_command.h>

Inheritance diagram for CmdAddTuplet:
DocCmdSimple DocCommand

Detailed Description

A command for creating a tuplet.

See constructor for details.

Public Member Functions

 CmdAddTuplet (const std::string &src, const std::string &name="Add tuplet")
 
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

◆ CmdAddTuplet()

CmdAddTuplet::CmdAddTuplet ( const std::string &  src,
const std::string &  name = "Add tuplet" 
)

This command adds a tuplet to the selected notes/rests.

Parameters
srcLDP source code for the tuplet to add.
nameThe displayable name for the command. If not specified will default to "Add tuplet".

Remarks

  • The notes/rest that will form the tuplet must be selected. There could be other objects selected between the notes and rests (e.g. a barline).
  • Before executing the command Lomse will check that the selection is not empty. Otherwise the command will not be executed and will return a failure code.
  • Before asking to execute this command your application should do more checks (e.g. all selected notes and rests are in the same voice and instrument; Lomse should do this but currently it does not (see issue #39).
  • After executing the command:
    • the selection will not be changed.
    • the cursor will not change its position.

Example

void CommandHandler::add_triplet()
{
// Add a triplet to the selected notes/rests (there could be other objects selected
// between the notes)
//
// Precondition:
// your application has checked that there are three notes/rest in the selection,
// that they are not in a tuplet, are consecutive, have the same duration and are
// in the same instrument and voice.
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
string name = gettext("Add triplet");
SpInteractor->exec_command( new CmdAddTuplet("(t + 2 3)", name) );
}
}

Member Function Documentation

◆ get_cursor_update_policy()

int CmdAddTuplet::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 CmdAddTuplet::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 CmdAddTuplet::get_undo_policy ( )
inlineoverridevirtual

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

Implements DocCommand.