lenmus / lomse

A C++ library for rendering, editing and playing back music scores.
MIT License
117 stars 28 forks source link

Interactor: API method to get info about mouse click point #355

Closed cecilios closed 2 years ago

cecilios commented 2 years ago

This PR adds a method to get info about the score object at mouse click point position. It returns a struct ClickPointData that describes the content of the point on current bitmap rendition.

The struct provides a ptr. to the clicked object, and if the clicked point is on a score, it also provides:

Otherwise, if clicked point is not on a score, the MeasureLocator is invalid and the staff index is -1.

Example:

//get mouse click point
Pixels x = Pixels( mouse_x );
Pixels y = Pixels( mouse_y );

//get information about that point
ClickPointData data = spInteractor->find_click_info_at(x, y);

ImoObj* pClickedObj = data.pImo;
MeasureLocator ml = data.ml;
if (ml.is_valid())
{
    //clicked point is a valid location on an score 
    int iMeasure = ml.iMeasure;
    int iInstr = ml.iInstr
    int iStaff = data.iStaff

    //do whatever you like with this information
    ...
}

Other changes