Lomse library. API documentation  0.30.0
EventUpdateViewport Class Reference

#include <lomse_events.h>

Inheritance diagram for EventUpdateViewport:
EventPlayback EventInfo

Detailed Description

An event to inform user application about the need to change the viewport during score playback, so that current played notes are visible.

Warning
This event is sent to your application from the Lomse sound thread. For processing it, do not retain control: generate an application event, place it on the application events loop, and return control to Lomse.

During playback Lomse could generate this event when auto-scroll mode is on. The event is generated when Lomse detects that the viewport has to be changed for ensuring that the notes being played are visible in the viewport. The event provides information about the new proposed viewport origin.

For processing this event the user application should create an application "viewport update" event, place it on the application events loop, and return control to Lomse. Later, when the application event is processed, the user application should invoke method Interactor.new_viewport(xPos, yPos) and, if necessary, update any GUI objects, such as scrollbars or other.

Example

For instance, in an application written using the wxWidgets framework you could have a global method for receiving all Lomse events, convert them in application events, and return control to Lomse:

void MainFrame::on_lomse_event(SpEventInfo pEvent)
{
DocumentWindow* pCanvas = get_active_document_window();
switch (pEvent->get_event_type())
{
...
{
if (pCanvas)
{
//generate update viewport event
static_pointer_cast<EventUpdateViewport>(pEvent) );
MyUpdateViewportEvent event(pEv);
::wxPostEvent(pCanvas, event);
}
break;
}
...

Later, your application should just process the application event as convenient. The recommended action is to use the Interactor for requesting to change the viewport to the new origin provided by the Lomse event. This will generate later an EventPaint for updating the View. In addition your application should to update scrollbars and other information or widgets used by the application. For instance:

void DocumentWindow::on_update_viewport(MyUpdateViewportEvent& event)
{
SpEventUpdateViewport pEv = event.get_lomse_event();
WpInteractor wpInteractor = pEv->get_interactor();
int xPos = pEv->get_new_viewport_x();
int yPos = pEv->get_new_viewport_y();
WpInteractor wpInteractor = pEv->get_interactor();
if (SpInteractor sp = wpInteractor.lock())
{
sp->new_viewport(xPos, yPos);
//reposition scroll thumb
SetScrollPos(wxVERTICAL, yPos);
}
}

Public Member Functions

 EventUpdateViewport (WpInteractor wpInteractor, Pixels x, Pixels y)
 
virtual ~EventUpdateViewport ()
 
Pixels get_new_viewport_x ()
 
Pixels get_new_viewport_y ()
 
void get_new_viewport (Pixels *x, Pixels *y)
 
- Public Member Functions inherited from EventPlayback
virtual ~EventPlayback ()
 
WpInteractor get_interactor ()
 
- Public Member Functions inherited from EventInfo
virtual ~EventInfo ()
 
virtual Observableget_source ()
 
EEventType get_event_type ()
 
bool is_doc_modified_event ()
 
bool is_update_window_event ()
 
bool is_mouse_in_event ()
 
bool is_mouse_out_event ()
 
bool is_on_click_event ()
 
bool is_link_clicked_event ()
 
bool is_show_contextual_menu_event ()
 
bool is_control_point_moved_event ()
 
bool is_selection_set_change ()
 
bool is_pointed_object_change ()
 
bool is_do_play_score_event ()
 
bool is_pause_score_event ()
 
bool is_stop_playback_event ()
 
bool is_tracking_event ()
 
bool is_update_viewport_event ()
 
bool is_end_of_playback_event ()
 

Constructor & Destructor Documentation

◆ EventUpdateViewport()

EventUpdateViewport::EventUpdateViewport ( WpInteractor  wpInteractor,
Pixels  x,
Pixels  y 
)
inline

Constructor.

◆ ~EventUpdateViewport()

virtual EventUpdateViewport::~EventUpdateViewport ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ get_new_viewport()

void EventUpdateViewport::get_new_viewport ( Pixels *  x,
Pixels *  y 
)
inline

Updates parameters x, y with the values for the new viewport origin.

◆ get_new_viewport_x()

Pixels EventUpdateViewport::get_new_viewport_x ( )
inline

Returns the x coordinate (pixels) for the new viewport origin.

◆ get_new_viewport_y()

Pixels EventUpdateViewport::get_new_viewport_y ( )
inline

Returns the y coordinate (pixels) for the new viewport origin.