Lomse library. API documentation  0.30.0
EventControlPointMoved Class Reference

#include <lomse_events.h>

Inheritance diagram for EventControlPointMoved:
EventAction EventInfo

Detailed Description

EventControlPointMoved event is generated when a mouse action has been interpreted by Lomse as a command for moving an object control point (handler).

Operating system raw mouse events can be passed to Lomse to be processed by the currently selected Task object (see Task objects). Once done, Lomse will generate relevant events of different types (normally EventMouse, EventControlPointMoved and EventUpdateUI events) with relevant information about affected Document objects or other.

In particular, an EventControlPointMoved event is generated when TaskMoveHandler is selected and the user releases the mouse button. For having a full view of the event generation process, imagine that your application has selected TaskSelection behavior; this is the default task when no specific task is assigned. This task is oriented to initiate actions related to selecting objects: drawing a section rectangle, displaying a contextual menu, generating on-click events, and initiating a 'move object' action. In this situation a mouse left click down generates an EventMouse of type k_on_click_event. Your application receives this event and having determined that the pointed object is a handle, decides to select the clicked object and switch to TaskMoveObject. Now, Lomse will take care of moving the handle while the mouse moves, and when the mouse button is released, Lomse will generate the EventControlPointMoved to inform your application about the event and the final destination point of the handle.

For processing this event, probably your application will issue an edition command for changing the object owning the moved handle. All relevant information for this is provided by the event. For example:

class DocumentWindow : public wxWindow
{
public:
...
//callback wrappers
static void wrapper_on_command_event(void* pThis, SpEventInfo pEvent);
...
};
void DocumentWindow::display_document(const string& filename, ostringstream& reporter)
{
...
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
//register to receive desired events
spInteractor->add_event_handler(k_control_point_moved_event, this, wrapper_on_action_event);
...
}
void DocumentWindow::wrapper_on_action_event(void* pThis, SpEventInfo pEvent)
{
static_cast<DocumentWindow*>(pThis)->on_action_event(pEvent);
}
void DocumentWindow::on_action_event(SpEventInfo pEvent)
{
SpEventAction pEv( static_pointer_cast<EventAction>(pEvent) );
if (!pEv->is_still_valid())
return;
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
SelectionSet* selection = spInteractor->get_selection_set();
DocCursor* cursor = spInteractor->get_cursor();
CommandEventHandler handler(m_appScope, this, m_toolsInfo, selection, cursor);
handler.process_action_event(pEv);
}
}
void CommandEventHandler::process_action_event(SpEventAction event)
{
m_fEventProcessed = false;
if (m_pController->is_edition_enabled())
{
if (event->is_control_point_moved_event())
{
static_pointer_cast<EventControlPointMoved>(event) );
UPoint shift = pEv->get_shift();
int iPoint = pEv->get_handler_index();
m_executer.move_object_point(iPoint, shift);
m_fEventProcessed = true;
}
}
}
void CommandGenerator::move_object_point(int iPoint, UPoint shift)
{
string name = to_std_string(_("Move control point"));
m_pController->exec_lomse_command( new CmdMoveObjectPoint(iPoint, shift, name),
k_show_busy );
}
void DocumentWindow::exec_lomse_command(DocCommand* pCmd, bool fShowBusy)
{
if (!m_pPresenter)
return;
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
if (fShowBusy)
::wxBeginBusyCursor();
spInteractor->exec_command(pCmd);
update_status_bar_caret_timepos();
if (fShowBusy)
::wxEndBusyCursor();
}
}

Public Member Functions

 EventControlPointMoved (EEventType type, WpInteractor wpInteractor, GmoObj *pGmo, int iHandler, UPoint uShift, WpDocument wpDoc)
 
int get_handler_index ()
 
ShapeId get_shape_index ()
 
UPoint get_shift ()
 
int get_gmo_type ()
 
- 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

◆ EventControlPointMoved()

EventControlPointMoved::EventControlPointMoved ( EEventType  type,
WpInteractor  wpInteractor,
GmoObj pGmo,
int  iHandler,
UPoint  uShift,
WpDocument  wpDoc 
)

Constructor.

Member Function Documentation

◆ get_gmo_type()

int EventControlPointMoved::get_gmo_type ( )
inline

Returns the type of graphic object owning the handler.

◆ get_handler_index()

int EventControlPointMoved::get_handler_index ( )
inline

Returns the handler number (0...n-1) for the moved handler.

◆ get_shape_index()

ShapeId EventControlPointMoved::get_shape_index ( )
inline

Returns the shape ID of the object owning the handler or -1 if it is a box.

◆ get_shift()

UPoint EventControlPointMoved::get_shift ( )
inline

Returns the shift (in logical units) to apply to the object.