Lomse library. API documentation  0.30.0
MeasureHighlight Class Reference

#include <lomse_measure_highlight.h>

Inheritance diagram for MeasureHighlight:
ApplicationMark VisualEffect

Detailed Description

MeasureHighlight is an ApplicationMark to display a colored background on any score measure.

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

See: Interactor::add_measure_highlight().

MeasureHighlight-1.png
Image: Example of MeasureHighlight marker.

Marker: vertical position and height

By default, the highlight will cover the whole staff from top line of first staff to bottom line of bottom staff, plus an additional height above and below (the added space is the spacing between systems, half is added on top and half on bottom. This additional height 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 highlight. 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 highlight can be changed at any moment. See top(), bottom() and extra_height() methods.

Example of use:

Previous image was created with the following code, when clicking on third measure:

ImoId scoreId = pScore->get_id();
MeasureHighlight* mark = spInteractor->add_measure_highlight(scoreId, data.ml);
mark->color(Color(0,255,0,64));

Observe that the marker is overlayed on top of the score image. Thus, you should use transparent colours.

The marker can be trimmed to occupy just some instruments or staves. For instance, the next code trims the marker to the clicked instrument:

ImoId scoreId = pScore->get_id();
MeasureHighlight* mark = spInteractor->add_measure_highlight(scoreId, data.ml);
mark->top(data.ml.iInstr)->bottom(data.ml.iInstr);

And this is the result:

MeasureHighlight-2.png
Image: Trimming the marker to the clicked instrument.


Public Member Functions

Customizable properties
MeasureHighlighttop (int instr, int staff=0)
 
MeasureHighlightbottom (int instr, int staff=-1)
 
MeasureHighlightextra_height (Tenths value=0)
 
MeasureHighlightcolor (Color value)
 
Access to current values
Color get_color () const
 

Member Function Documentation

◆ bottom()

MeasureHighlight* MeasureHighlight::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()

MeasureHighlight* MeasureHighlight::color ( Color  value)
inline

Set the color of the mark.

◆ extra_height()

MeasureHighlight* MeasureHighlight::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 MeasureHighlight::get_color ( ) const
inline

Return the current mark color.

◆ top()

MeasureHighlight* MeasureHighlight::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().