Lomse library. API documentation  0.30.0
EventUpdateUI Class Reference

#include <lomse_events.h>

Inheritance diagram for EventUpdateUI:
EventAction EventInfo

Detailed Description

EventUpdateUI events are generated to inform about actions related to the Document that could require changes on the user application GUI, such as enabling or disabling tools, menu items and buttons.

EventUpdateUI events of type k_selection_set_change are generated when Document objects are selected or deselected. The rationale is that some application tools should be enabled or disabled depending on the kind of selected objects.

EventUpdateUI events of type k_pointed_object_change are generated when the document cursor is updated, as the object pointed by the cursor has changed. Again, the rationale is that some application tools should be enabled or disabled depending on the nature of the pointed object.

EventUpdateUI events are sent directly to the application global handler (the one set by invoking LomseDoorway::set_notify_callback() ). For handling these events you should generate application events, place them in the application events loop and return control to Lomse.

Example

For instance, in an application written using the wxWidgets framework you could handle the EventUpdateUI as follows:

void MainFrame::on_lomse_event(SpEventInfo pEvent)
{
DocumentWindow* pCanvas = get_active_document_window();
switch (pEvent->get_event_type())
{
...
{
if (is_toolbox_visible())
{
SpEventUpdateUI pEv( static_pointer_cast<EventUpdateUI>(pEvent) );
MyUpdateUIEvent event(pEv);
::wxPostEvent(m_pToolBox, event);
}
break;
}
...

Later, your application event will be processed by the appropriate objects (i.e., a ToolBox object) for synchronizing the state of tools, menu items and buttons:

void ToolBox::on_update_UI(MyUpdateUIEvent& event)
{
SpEventUpdateUI pEv = event.get_lomse_event();
WpInteractor wpInteractor = pEv->get_interactor();
if (SpInteractor sp = wpInteractor.lock())
{
SelectionSet* pSelection = pEv->get_selection();
DocCursor* pCursor = pEv->get_cursor();
synchronize_tools(pSelection, pCursor);
}
}
void ToolBox::synchronize_tools(SelectionSet* pSelection, DocCursor* pCursor)
{
//synchronize toolbox selected options with current selection and cursor object
if (!pSelection->empty())
{
//there is a selection. Disable options related to cursor
synchronize_with_cursor(false);
synchronize_with_selection(true, pSelection);
}
else
{
//No selection. Disable options related to selections
synchronize_with_cursor(true, pCursor);
synchronize_with_selection(false);
}
}

Public Member Functions

 EventUpdateUI (EEventType type, WpInteractor wpInteractor, WpDocument wpDoc, SelectionSet *pSelection, DocCursor *pCursor)
 
SelectionSet * get_selection ()
 
DocCursor * get_cursor ()
 
- Public Member Functions inherited from EventAction
virtual ~EventAction ()
 
WpInteractor get_interactor ()
 
WpDocument get_document ()
 
bool is_still_valid ()
 
- 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

◆ EventUpdateUI()

EventUpdateUI::EventUpdateUI ( EEventType  type,
WpInteractor  wpInteractor,
WpDocument  wpDoc,
SelectionSet *  pSelection,
DocCursor *  pCursor 
)
inline

Constructor.

Member Function Documentation

◆ get_cursor()

DocCursor* EventUpdateUI::get_cursor ( )
inline

Returns a ptr to current DocCursor object, so that user application can determine where is the cursor pointing.

◆ get_selection()

SelectionSet* EventUpdateUI::get_selection ( )
inline

Returns a ptr to current SelectionSet object, containg the information for currently selected objects.