Lomse library. API documentation  0.30.0
FragmentMark Class Reference

#include <lomse_fragment_mark.h>

Inheritance diagram for FragmentMark:
ApplicationMark VisualEffect

Detailed Description

FragmentMark is an ApplicationMark to display on any score brackets and vertical lines, spanning one or several staves, to define the start and end points of a score section or fragment.

FragmentMark objects are created by the Interactor associated to the View on which the mark is going to be displayed.

See:

The following picture displays the different types of FragmentMark markers that can be created. The markers were created with the code shown at the end of this description.

FragmentMark-types.png
Image: Different types of FragmentMark markers.

Marks' horizontal position

Marks of type k_mark_line are positioned centered on the reference timepos vertical line.

For all other types:

  • When created using method Interactor::add_fragment_mark_at_barline() the marks are also positioned centered on the reference timepos vertical line, that is the barline left border.
  • When created by any other Interactor methods:
    • Type open are displayed with the inner bracket vertical border aligned with the timepos vertical line.
    • Type close are displayed with the outside bracket vertical border aligned with the timepos vertical line.

It is possible to add an horizontal shift to the mark default position. See x_shift(). The horizontal shift can be modified when necessary.

But marks cannot be repositioned, that is, its reference timepos can not be changed. If this is needed, just delete current mark (by invoking Interactor::remove_mark() ) and create a new one at the new desired position.

Marks' vertical position and height

By default, the mark will cover the whole staff from top line of first staff to bottom line of bottom staff, plus an additional height of the spacing between systems (half is added on top and half on bottom). This additional height to add can be chaged by method extra_height().

Methods top() and bottom() allows to define the vertical position and height of the mark by defining the reference instruments and staves that will be covered by the mark. When using any of these methods, the additional height will be changed to be the staves margin. You can later change this value by using method extra_height().

The height and vertical position of the mark can be changed at any moment. See top(), bottom() and extra_height() methods.

Example of use:

The marks in previous image were created with this code:

ImoId scoreId = pScore->get_id();
//green mark: open rounded at staffobj (key signature).
//From second instrument to last one
ScoreCursor cursor(pDoc, pScore); //cursor points to clef
cursor.move_next(); //now points to key signature
ImoStaffObj* pSO = dynamic_cast<ImoStaffObj*>(*(cursor));
FragmentMark* mark = spInteractor->add_fragment_mark_at_staffobj(pSO);
mark->color(Color(0,255,0))->top(1);
cursor.move_next(); //now points to time signature
pSO = dynamic_cast<ImoStaffObj*>(*(cursor));
mark = spInteractor->add_fragment_mark_at_staffobj(pSO);
mark->color(Color(0,255,0))->top(1);
//blue curly marks: at first barline (measure 1, beat 0) and second
//barline (measure 2, beat 0). The whole system
TimeUnits timepos = ScoreAlgorithms::get_timepos_for(pScore, 1, 0);
mark = spInteractor->add_fragment_mark_at_barline(scoreId, timepos);
mark->color(Color(0,0,255,128))->type(k_mark_open_curly);
timepos = ScoreAlgorithms::get_timepos_for(pScore, 2, 0);
mark = spInteractor->add_fragment_mark_at_barline(scoreId, timepos);
mark->color(Color(0,0,255,128))->type(k_mark_close_curly);
//red line mark: first note after first barline (measure 1, beat 0)
timepos = ScoreAlgorithms::get_timepos_for(pScore, 1, 0);
spInteractor->add_fragment_mark_at_note_rest(scoreId, timepos);
//magenta line mark: at interpolated timepos. Only third instrument
timepos += k_duration_eighth; //at first quarter dotted note position
mark = spInteractor->add_fragment_mark_at_note_rest(scoreId, timepos);
mark->color(Color(255,0,255,128))->type(k_mark_line)->top(2);
//solid blue curly mark: instruments 2,3 & 4
timepos = ScoreAlgorithms::get_timepos_for(pScore, 1, 1);
mark = spInteractor->add_fragment_mark_at_note_rest(scoreId, timepos);
mark->color(Color(0,0,255))->top(1,0)->bottom(3);
mark->type(k_mark_open_curly)->x_shift(-5.0); //some space before
timepos = ScoreAlgorithms::get_timepos_for(pScore, 1, 2);
mark = spInteractor->add_fragment_mark_at_note_rest(scoreId, timepos);
mark->color(Color(0,0,255))->top(1,0)->bottom(3);
mark->type(k_mark_close_curly)->x_shift(25.0); //some space to skip noteheads
//magenta squared mark: instruments 2,3 & 4
timepos = ScoreAlgorithms::get_timepos_for(pScore, 2,1);
mark = spInteractor->add_fragment_mark_at_note_rest(scoreId, timepos);
mark->color(Color(255,0,255,128))->top(1,0)->bottom(3);
timepos = ScoreAlgorithms::get_timepos_for(pScore, 2,2);
mark = spInteractor->add_fragment_mark_at_note_rest(scoreId, timepos);
mark->color(Color(255,0,255,128))->top(1,0)->bottom(3);
//green line mark: instruments 2,3 & 4
timepos = ScoreAlgorithms::get_timepos_for(pScore, 3,0);
mark = spInteractor->add_fragment_mark_at_note_rest(scoreId, timepos);
mark->color(Color(0, 255,0))->top(1,0)->bottom(3);
//red rounded mark: instruments 2,3 & 4
timepos = ScoreAlgorithms::get_timepos_for(pScore, 4,0);
mark = spInteractor->add_fragment_mark_at_note_rest(scoreId, timepos);
mark->color(Color(255,0,0))->top(1,0)->bottom(3);
timepos = ScoreAlgorithms::get_timepos_for(pScore, 4,1);
mark = spInteractor->add_fragment_mark_at_note_rest(scoreId, timepos);
mark->color(Color(255,0,0))->top(1,0)->bottom(3);


Public Member Functions

Customizable properties
FragmentMarkx_shift (Tenths dx)
 
FragmentMarktop (int instr, int staff=0)
 
FragmentMarkbottom (int instr, int staff=-1)
 
FragmentMarkextra_height (Tenths value=0)
 
FragmentMarkcolor (Color value)
 
FragmentMarktype (EFragmentMark value)
 
FragmentMarkthickness (Tenths value)
 
FragmentMarkline_style (ELineStyle value)
 
Access to current values
Color get_color () const
 
EFragmentMark get_type () const
 
ELineStyle get_line_style () const
 

Member Function Documentation

◆ bottom()

FragmentMark* FragmentMark::bottom ( int  instr,
int  staff = -1 
)

Place the bottom of the mark at first line of the specified staff of an instrument.

Parameters
instrThe instrument number (0..n-1) of the instrument.
staffThe staff number (0..m-1), relative to the number of staves in the instrument. Special value -1 means "the last staff of the instrument".

When invoking this method, the extra height for the mark will be changed to be the staves margin. You can later change this value by using method extra_height().

◆ color()

FragmentMark* FragmentMark::color ( Color  value)
inline

Set the color of the mark.

◆ extra_height()

FragmentMark* FragmentMark::extra_height ( Tenths  value = 0)

Define the additional height to add, at top and bottom of the mark line. Please note that the line heigth will be incremented in twice the passed value, as the extra height value will be added at top and also at bottom.

This extra lenght is specified in tenths, referred to the first staff in the system on which the mark is placed.

◆ get_color()

Color FragmentMark::get_color ( ) const
inline

Return the current mark color.

◆ get_line_style()

ELineStyle FragmentMark::get_line_style ( ) const
inline

Return the current line style in use for drawing the mark.

◆ get_type()

EFragmentMark FragmentMark::get_type ( ) const
inline

Return the current mark type.

◆ line_style()

FragmentMark* FragmentMark::line_style ( ELineStyle  value)
inline

Set the line style.

◆ thickness()

FragmentMark* FragmentMark::thickness ( Tenths  value)

Change the thickness of the mark vertical line. When the mark is created, it has a default thickness of six tenths.

The thickness is specified in tenths, referred to the first staff in the system on which the mark is placed.

◆ top()

FragmentMark* FragmentMark::top ( int  instr,
int  staff = 0 
)

Place the start of the mark at top line of the specified staff of an instrument.

Parameters
instrThe instrument number (0..n-1) of the instrument.
staffThe staff number (0..m-1), relative to the number of staves in the instrument. Special value -1 means "the last staff of the instrument".

When invoking this method, the extra height for the mark will be changed to be the staves margin. You can later change this value by using method extra_height().

◆ type()

FragmentMark* FragmentMark::type ( EFragmentMark  value)
inline

Set the type of the mark.

◆ x_shift()

FragmentMark* FragmentMark::x_shift ( Tenths  dx)

Define the horizontal shift to add to the default place for the mark.

Parameters
dxThe shift to add. The shift is specified in tenths, referred to the first staff in the system on which the mark is placed.