Lomse library. API documentation  0.30.0
Interactor Class Reference

#include <lomse_interactor.h>

Inheritance diagram for Interactor:
EventHandler EventNotifier Observable

Detailed Description

The Interactor is the key object to interact with the document (here the name 'Interactor'). It is the interface between your application, the associated View and the Document (see The Lomse Model-View-Controller). It is responsible for translating your application requests into commands that manipulate the associated View and/or the Document, coordinating all the necessary actions. It also provides support for managing the user interaction with your application GUI (see Interaction with your application GUI).

The Interactor plays the role of the Controller in the MVC model. Each View has an associated Interactor (in fact the View is owned by the Interactor). The Interactor is owned by the Presenter.

The Interactor for a View is provided by the Presenter. It is best practice not to save pointers to the Interactor because when processing a Lomse event the Document (and thus, the Interactor) could have been deleted (e.g., because your application has closed the window displaying the document).

Lomse provides type SpInteractor, an smart pointer to the Interactor. The recommendation is to use always smart pointers when provided by Lomse instead of using raw pointers. The use of threads, document edition commands, and events processing can invalidate stored pointers in your application. So it is always recommended to get the pointer to the Interactor when needed, by accessing the smart pointer and checking that it is still valid:

if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
//safely use the Interactor
spInteractor->some_method();
...
}

See:

Public Types

enum  EInteractorOpMode
 
enum  ETimingTarget
 
- Public Types inherited from Observable
enum  EObservedChild
 

Public Member Functions

Modes of operation and related
void set_operating_mode (int mode)
 
int get_operating_mode ()
 
void enable_edition_restricted_to (ImoId id)
 
bool is_document_editable ()
 
void switch_task (int taskType)
 
Information about mouse clicked point
ClickPointData find_click_info_at (Pixels x, Pixels y)
 
Access to collaborators in MVC model
GraphicModelget_graphic_model ()
 
View * get_view ()
 
SelectionSet * get_selection_set ()
 
Interface to View
virtual void redraw_bitmap ()
 
virtual void force_redraw ()
 
bool view_needs_repaint ()
 
virtual void on_end_of_play_event (ImoScore *pScore, PlayerGui *pPlayCtrl)
 
void enable_forced_view_updates (bool value)
 
Interface to GraphicView. Rendering
virtual void set_rendering_buffer (unsigned char *buf, unsigned width, unsigned height)
 
virtual void set_view_area (unsigned width, unsigned height, unsigned xShift=0, unsigned yShift=0)
 
virtual void set_rendering_option (int option, bool value)
 
void set_view_background (Color color)
 
Interface to GraphicView. Coordinates conversion
virtual void screen_point_to_page_point (double *x, double *y)
 
virtual void model_point_to_device (double *x, double *y, int iPage)
 
virtual int page_at_screen_point (double x, double y)
 
virtual UPoint screen_point_to_model_point (Pixels x, Pixels y)
 
DiatonicPitch get_pitch_at (Pixels x, Pixels y)
 
Interface to GraphicView. Viewport (for scrolling)
virtual void new_viewport (Pixels x, Pixels y, bool fForceRedraw=true)
 
virtual void set_viewport_at_page_center (Pixels screenWidth)
 
virtual void get_viewport (Pixels *x, Pixels *y)
 
USize get_page_size (int page=0)
 
virtual void get_view_size (Pixels *xWidth, Pixels *yHeight)
 
virtual void scroll_to_measure_if_necessary (ImoId scoreId, int iMeasure, int iBeat=0, int iInstr=0)
 
virtual void scroll_to_measure_if_necessary (ImoId scoreId, int iMeasure, TimeUnits location=0.0, int iInstr=0)
 
virtual void scroll_to_measure (ImoId scoreId, int iMeasure, int iBeat=0, int iInstr=0)
 
virtual void scroll_to_measure (ImoId scoreId, int iMeasure, TimeUnits location=0.0, int iInstr=0)
 
Interface to GraphicView. Scale
virtual double get_scale ()
 
virtual void set_scale (double scale, Pixels x=0, Pixels y=0, bool fForceRedraw=true)
 
virtual void zoom_in (Pixels x=0, Pixels y=0, bool fForceRedraw=true)
 
virtual void zoom_out (Pixels x=0, Pixels y=0, bool fForceRedraw=true)
 
virtual void zoom_fit_full (Pixels width, Pixels height, bool fForceRedraw=true)
 
virtual void zoom_fit_width (Pixels width, bool fForceRedraw=true)
 
Interface to GraphicView. Selection rectangle
Todo:
Selection rectangle methods and explanation
virtual void start_selection_rectangle (Pixels x1, Pixels y1)
 
virtual void hide_selection_rectangle ()
 
Interface to GraphicView. Visual tracking effects during playback
virtual void set_visual_tracking_mode (int mode)
 
virtual VisualEffectget_tracking_effect (int effect)
 
virtual void move_tempo_line (ImoId scoreId, TimeUnits timepos)
 
virtual void move_tempo_line (ImoId scoreId, int iMeasure, int iBeat, int iInstr=0)
 
virtual void move_tempo_line (ImoId scoreId, int iMeasure, TimeUnits location, int iInstr=0)
 
virtual void move_tempo_line_and_scroll_if_necessary (ImoId scoreId, int iMeasure, int iBeat, int iInstr=0)
 
virtual void move_tempo_line_and_scroll_if_necessary (ImoId scoreId, int iMeasure, TimeUnits location, int iInstr=0)
 
virtual void highlight_object (ImoStaffObj *pSO)
 
virtual void remove_highlight_from_object (ImoStaffObj *pSO)
 
virtual void remove_all_visual_tracking ()
 
virtual void on_visual_tracking (SpEventVisualTracking pEvent)
 
Interface to GraphicView. Application markings on the score
FragmentMarkadd_fragment_mark_at_note_rest (ImoId scoreId, TimeUnits timepos)
 
FragmentMarkadd_fragment_mark_at_barline (ImoId scoreId, TimeUnits timepos)
 
FragmentMarkadd_fragment_mark_at_staffobj (ImoStaffObj *pSO)
 
MeasureHighlightadd_measure_highlight (ImoId scoreId, const MeasureLocator &ml)
 
void remove_mark (ApplicationMark *mark)
 
Interface to GraphicView. Print related
virtual void set_print_buffer (unsigned char *buf, unsigned width, unsigned height)
 
virtual void set_print_page_size (Pixels width, Pixels height)
 
virtual void print_page (int page, VPoint viewport=VPoint(0, 0))
 
virtual int get_num_pages ()
 
Interface to GraphicView. SVG drawing
void render_as_svg (std::ostream &svg, int page=0)
 
void set_svg_canvas_width (Pixels x)
 
void svg_indent (int value)
 
void svg_add_newlines (bool value)
 
void svg_add_id (bool value)
 
void svg_add_class (bool value)
 
Cursor and caret related methods
DocCursor * get_cursor ()
 
void blink_caret ()
 
string get_caret_timecode ()
 
DocCursorState click_event_to_cursor_state (SpEventMouse event)
 
void select_voice (int voice)
 
Drag image associated to mouse cursor
Todo:
Drag images explanation and methods for dragging images
void show_drag_image (bool value)
 
void set_drag_image (GmoShape *pShape, bool fGetOwnership, UPoint offset)
 
void enable_drag_image (bool fEnabled)
 
Document edition
void exec_command (DocCommand *pCmd)
 
void exec_undo ()
 
void exec_redo ()
 
bool should_enable_edit_undo ()
 
bool should_enable_edit_redo ()
 
User application: to inform Lomse about certain events
virtual void on_document_updated ()
 
virtual void on_mouse_move (Pixels x, Pixels y, unsigned flags)
 
virtual void on_mouse_button_down (Pixels x, Pixels y, unsigned flags)
 
virtual void on_mouse_button_up (Pixels x, Pixels y, unsigned flags)
 
virtual void on_mouse_enter_window (Pixels x, Pixels y, unsigned flags)
 
virtual void on_mouse_leave_window (Pixels x, Pixels y, unsigned flags)
 
For performance measurements
void timing_repaint_done ()
 
double * get_elapsed_times ()
 
Debugging

These methods are oriented to debug Lomse and should not be in the public API. If you use them be aware that they might be removed from public API in future.

virtual void set_box_to_draw (int boxType)
 
virtual void reset_boxes_to_draw ()
 
string dump_cursor ()
 
string dump_selection ()
 
- Public Member Functions inherited from EventHandler
virtual ~EventHandler ()
 
virtual void handle_event (SpEventInfo pEvent)=0
 
- Public Member Functions inherited from EventNotifier
 EventNotifier (EventsDispatcher *dispatcher)
 
virtual ~EventNotifier ()
 
bool notify_observers (SpEventInfo pEvent, Observable *target)
 
void remove_observer (Observer *observer)
 
Observeradd_observer_for (Observable *target)
 
Observeradd_observer_for_child (Observable *parent, int childType, ImoId childId)
 
- Public Member Functions inherited from Observable
virtual ~Observable ()
 
virtual EventNotifierget_event_notifier ()=0
 
virtual void add_event_handler (int eventType, EventHandler *pHandler)
 
virtual void add_event_handler (int eventType, void *pThis, void(*pt2Func)(void *pObj, SpEventInfo event))
 
virtual void add_event_handler (int eventType, void(*pt2Func)(SpEventInfo event))
 
void add_event_handler (int childType, ImoId childId, int eventType, EventHandler *pHandler)
 
void add_event_handler (int childType, ImoId childId, int eventType, void *pThis, void(*pt2Func)(void *pObj, SpEventInfo event))
 
void add_event_handler (int childType, ImoId childId, int eventType, void(*pt2Func)(SpEventInfo event))
 
virtual Observableget_observable_child (int UNUSED(childType), ImoId UNUSED(childId))
 

Member Enumeration Documentation

◆ EInteractorOpMode

Valid operating modes for the Interactor:

  • k_mode_read_only - Read only mode: no changes allowed in the document.
  • k_mode_edition - Edition mode: changes allowed in the document.
  • k_mode_playback - Playback mode: disabled any action that could affect playback in any way. Edition is disabled in this mode.
Enumerator
k_mode_read_only 

Read only mode: no changes allowed in the document.

k_mode_edition 

Edition mode: changes allowed in the document.

k_mode_playback 

Playback mode: disabled any action that could affect playback in any way. Edition is disabled in this mode.

◆ ETimingTarget

Method Interactor::get_elapsed_times() returns a vector of elapsed times. This enum is used as index on that vector for identifying the operation to which each vector element refers. So, for instance, times[0] is the time for building the graphic model (0 = k_timing_gmodel_build_time), times[1] is the time for rendering the graphic model (1 = k_timing_gmodel_draw_time), etc, according to this:

  • k_timing_gmodel_build_time = 0 - elapsed time for building the graphic model.
  • k_timing_gmodel_draw_time = 1 - elapsed time for rendering the graphic model
  • k_timing_visual_effects_draw_time = 2 - elapsed time for rendering the visual effects
  • k_timing_total_render_time = 3 - total elapsed time for renderization
  • k_timing_repaint_time = 4 - elapsed time for repainting the view
  • k_timing_max_value - Not used as index. This value is for knowing how many items you should expect in the returned vector, for allocating space.

Member Function Documentation

◆ add_fragment_mark_at_barline()

FragmentMark* Interactor::add_fragment_mark_at_barline ( ImoId  scoreId,
TimeUnits  timepos 
)

Create a new FragmentMark on the score at the barline at the given time position. Take into account that barlines have the same timepos than the first note/rest after the barline. If there is no a barline at the given timepos, this method will place the mark on the note/rest position for the passed timepos.

Parameters
scoreIdId. of the score on which the mark will be added.
timeposThe position for the mark, in Time Units from the start of the score.

See add_fragment_mark_at_note_rest() for more details.

◆ add_fragment_mark_at_note_rest()

FragmentMark* Interactor::add_fragment_mark_at_note_rest ( ImoId  scoreId,
TimeUnits  timepos 
)

Create a new FragmentMark on the score at the given time position for notes and rest. If no note/rest exists in the given timepos, the mark will be placed at the estimated position at which the note would be placed.

Parameters
scoreIdId. of the score on which the mark will be added.
timeposThe position for the mark, in Time Units from the start of the score.

The mark will cover all staves of the system and its height will be that of the system box. After creation you can use methods FragmentMark::top() and FragmentMark::bottom() to define the instruments and staves range to cover, as well as to change the extra height with method FragmentMark::extra_height().

By default, the properties of the created mark are as follows:

  • Marker type is k_mark_line, that is, a vertical line.
  • Line color is transparent red (Color(255,0,0,128)).
  • Line thickness is six tenths, referred to the first staff of the system at which the mark is placed.
  • Line style solid.

The mark properties (type, color, position, length, etc.) can later be changed. See methods: FragmentMark::type(), FragmentMark::color(), FragmentMark::top(), FragmentMark::bottom(), FragmentMark::x_shift(), FragmentMark:: line_style() and FragmentMark::extra_height().

Example of use:

ImoId scoreId = ...
TimeUnits timepos = ...
FragmentMark* mark = pInteractor->add_fragment_mark(scoreId, timepos);
//customize the mark: magenta solid color, covering second and third instruments
mark->color(Color(255,0,255))->thickness(5)->top(1)->bottom(2);
...
//change its appearance: rounded open bracket, cyan transparent color
mark->type(k_mark_open_rounded)->color(Color(0,255,255,128));
...
//when no longer needed remove it
pInteractor->remove_mark(mark);
Lomse will retain the ownership of returned pointer to the marker, and will be
automatically deleted when the score model is deleted. Nevertheless you can
remove a marker at any moment by invoking Interactor::remove_mark() and passing
the marker to remove.
Markers cannot be repositioned. If this is needed, just remove current mark (by
invoking Interactor::remove_mark() ) and create a new one at the new desired
position.

◆ add_fragment_mark_at_staffobj()

FragmentMark* Interactor::add_fragment_mark_at_staffobj ( ImoStaffObj *  pSO)

Create a new FragmentMark on the score at the given staff object position.

Parameters
pSOPointer to the staff object defining the position for the mark.

See add_fragment_mark_at_note_rest() for more details.

◆ add_measure_highlight()

MeasureHighlight* Interactor::add_measure_highlight ( ImoId  scoreId,
const MeasureLocator &  ml 
)

Create a new MeasureHighlight on the score at the barline at the given time position. Take into account that barlines have the same timepos than the first note/rest after the barline. If there is no a barline at the given timepos, this method will place the mark on the note/rest position for the passed timepos.

Parameters
scoreIdId. of the score on which the mark will be added.
mlThe position for the mark. Only measure and instrument will be used.

Lomse will retain the ownership of returned pointer to the marker, and will be automatically deleted when the score model is deleted. Nevertheless you can remove a marker at any moment by invoking Interactor::remove_mark() and passing the marker to remove.

Markers cannot be repositioned. If this is needed, just remove current mark (by invoking Interactor::remove_mark() ) and create a new one at the new desired position.

◆ blink_caret()

void Interactor::blink_caret ( )

Switch the state of the caret: if it is visible, hide it; if it is hidden, show it. Lomse caret does not blink and this method is oriented to implement a blinking caret in your application.

See Editing documents overview

Remarks
  • Caret is always shown when document edition is enabled. and it is hidden when edition is disabled.
  • This method has no effect when document edition is disabled. That is, if edition is not enabled, you cannot use this method for forcing to display the caret.
  • See set_operating_mode().

If your application would like a blinking caret, you will have to use a timer for the caret and switch the caret state on each timer event. This is an example:

void MainFrame::on_caret_timer_event()
{
Interactor* pInteractor = get_active_canvas_interactor();
if (pInteractor)
pInteractor->blink_caret();
}

◆ click_event_to_cursor_state()

DocCursorState Interactor::click_event_to_cursor_state ( SpEventMouse  event)

Returns a DocCursorState object pointing to the nearest valid position to the mouse click point.

This is a support method for applications wishing to get cursor related information from mouse clicks. For instance, to move the caret by pointing with the mouse and clicking:

void DocumentWindow::move_cursor_to_click_point(SpEventMouse event)
{
if (!m_pPresenter)
return;
if (SpInteractor spIntor = m_pPresenter->get_interactor(0).lock())
{
if (spIntor->get_operating_mode() == Interactor::k_mode_edition)
{
DocCursorState state = spIntor->click_event_to_cursor_state(event);
spIntor->exec_command(new CmdCursor(state));
}
}
}

◆ dump_cursor()

string Interactor::dump_cursor ( )

Returns an string with the content of current Cursor.

Attention
This method is oriented to debug Lomse. It might be removed from public API in future.

◆ dump_selection()

string Interactor::dump_selection ( )

Returns an string with the content of current Selection Set.

Attention
This method is oriented to debug Lomse. It might be removed from public API in future.

◆ enable_edition_restricted_to()

void Interactor::enable_edition_restricted_to ( ImoId  id)

When in edition mode, invoking this method disables edition in all the document with the exception of the object whose ID is passed. This method allows your application to restrict edition to a certain area of the document, such as an score, a paragraph, etc.

Parameters
idThe ID of the only object that will be editable after invoking this method.

◆ enable_forced_view_updates()

void Interactor::enable_forced_view_updates ( bool  value)
inline

Invoking this method controls the behavior of method force_redraw(). If disabled, Lomse will ignore any invocation to force_redraw().

Parameters
valuetrue for enabling method force_redraw(). false for ignoring invocations to this method.

By default, force_redraw() method is enabled.

◆ exec_command()

void Interactor::exec_command ( DocCommand pCmd)

Execute an edition command for modifying the document content, the current set of selected objects or the cursor position.

Parameters
pCmdThe command to execute.
Remarks
This method has no effect when document edition is disabled. See set_operating_mode().

Example:

void CommandGenerator::insert_rest(ENoteType noteType, int dots, int voice, int staff)
{
//insert a rest at current cursor position
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
stringstream src;
src << "(r "
" " << LdpExporter::notetype_to_string(noteType, dots)
<< " v" << voice
<< " p" << staff+1
<< ")";
string name = "Insert rest";
spInteractor->exec_command( new CmdInsertStaffObj(src.str(), name) );
}
}

See How to modify a document

See also
exec_undo(), exec_redo()

◆ exec_redo()

void Interactor::exec_redo ( )

Redo the last edition command undone via exec_undo().

Remarks
This method has no effect when document edition is disabled. See set_operating_mode().

See How to modify a document

See also
exec_command(), exec_undo(), should_enable_edit_redo(),

◆ exec_undo()

void Interactor::exec_undo ( )

Undo the last edition command executed via exec_command().

Remarks
This method has no effect when document edition is disabled. See set_operating_mode().

Example:

void DocumentWindow::on_edit_undo()
{
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
spInteractor->exec_undo();
}

See How to modify a document

See also
exec_command(), exec_redo(), should_enable_edit_undo()

◆ find_click_info_at()

ClickPointData Interactor::find_click_info_at ( Pixels  x,
Pixels  y 
)

Returns a ClickedDataInfo struct with information about object at x,y position on current bitmap rendition.

Parameters
xThe x coordinate (pixels) of the point.
yThe y coordinate (pixels) of the point.

◆ force_redraw()

virtual void Interactor::force_redraw ( )
virtual

Invoking this method forces Lomse to render again the View and, therefore, the rendering buffer gets updated. After doing it, Lomse will generate a EventPaint event.

Note
Lomse will ignore the request if forced updates are disabled. See enable_forced_view_updates().
Todo:
Clarify the need of methods force_redraw(), redraw_bitmap() and enable_forced_view_updates(). Probably This code has to be re-factored.
See also
redraw_bitmap().

◆ get_caret_timecode()

string Interactor::get_caret_timecode ( )

Returns a string with the timecode (measure, beat, part) for current position, when caret on a music score. If caret is not on a music score, the returned string is empty.

See Editing documents overview

This method can be useful for displaying the timecode of the caret. For example:

void DocumentWindow::update_status_bar_caret_timepos()
{
if (is_edition_enabled())
{
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
StatusReporter* pStatus = m_appScope.get_status_reporter();
pStatus->report_caret_time( spInteractor->get_caret_timecode() );
}
}
}
See also
blink_caret()

◆ get_cursor()

DocCursor* Interactor::get_cursor ( )
inline

Returns the cursor associated to the View of this Interactor.

See Editing documents overview

◆ get_elapsed_times()

double* Interactor::get_elapsed_times ( )
inline

Returns a vector of times, with the elapsed times for the different steps related to rendering a document. When a new rendering is necessary, Lomse resets all time counters and starts timing the different steps. Your application only has to inform Lomse when the rendering buffer has been copied onto the application window (do this by invoking method timing_repaint_done()). Then all times are available to be accessed by using this method.

Enum Interactor::ETimingTarget is used as index on the returned vector for identifying the operation to which each vector element refers.

Example:

void DocumentWindow::copy_buffer_on_dc(DC& dc)
{
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
// draw lomse buffer onto DC
...
//inform lomse that the buffer has been copied
spInteractor->timing_repaint_done();
//Display ellapsed times for the different renderization steps
double* pTimes = spInteractor->get_elapsed_times();
std::ostringstream msg;
msg << std::fixed << std::setprecision(2)
<< "Build graphic model = "
<< *(pTimes + Interactor::k_timing_gmodel_build_time) << "msecs." << endl
<< "Render gaphic model = "
<< *(pTimes + Interactor::k_timing_gmodel_draw_time) << "msecs." << endl
<< "Render visual effects = "
<< *(pTimes + Interactor::k_timing_visual_effects_draw_time) << "msecs." << endl
<< "Total Lomse render time = "
<< *(pTimes + Interactor::k_timing_total_render_time) << "msecs." << endl
<< "Paint buffer on DC = "
<< *(pTimes + Interactor::k_timing_repaint_time) << "msecs." << endl;
...
}
}

◆ get_graphic_model()

GraphicModel* Interactor::get_graphic_model ( )

Returns the graphic model object associated to the View of this Interactor.

◆ get_num_pages()

virtual int Interactor::get_num_pages ( )
virtual

Returns the number of pages in current document.

See Printing documents overview

◆ get_operating_mode()

int Interactor::get_operating_mode ( )
inline

Returns current operation mode for this Interactor. Returned value is one of the values from enum EInteractorOpMode.

Example:

bool DocumentWindow::is_edition_enabled()
{
if (!m_pPresenter)
return false;
if (SpInteractor spIntor = m_pPresenter->get_interactor(0).lock())
return spIntor->get_operating_mode() == Interactor::k_mode_edition;
else
return false;
}

◆ get_page_size()

USize Interactor::get_page_size ( int  page = 0)

Returns the size (logical units) of a page of the rendered document.

Parameters
pageThe page (0..num_pages - 1) whose size is requested. This parameter is only meaningful for View types that can generate several pages (k_view_vertical_book and k_view_horizontal_book). For all others there is only one page (page == 0) and the value of this parameter is ignored.

◆ get_pitch_at()

DiatonicPitch Interactor::get_pitch_at ( Pixels  x,
Pixels  y 
)

Returns the pitch (DiatonicPitch type) of the staff point pointed by coordinates x, y or value k_no_pitch if not pointing to a staff.

This helper method is useful in some scenarios. For instance, if in your application the user is allowed to insert notes on a staff by clicking with the mouse on the insertion point, you will need to determine the nearest staff line/space, and the applicable clef, in order to determine the pitch for the note to insert. This method performs all these operations and returns the diatonic pitch for the staff point.

DiatonicPitch DocumentWindow::get_pitch_at(Pixels x, Pixels y)
{
if (m_pPresenter)
{
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
return spInteractor->get_pitch_at(x, y);
}
}
return DiatonicPitch(k_no_pitch);
}

◆ get_scale()

virtual double Interactor::get_scale ( )
virtual

Returns the current scale factor.

See Scaling

◆ get_selection_set()

SelectionSet* Interactor::get_selection_set ( )
inline

Returns the selection set associated to the View of this Interactor.

See Editing documents overview

◆ get_tracking_effect()

virtual VisualEffect* Interactor::get_tracking_effect ( int  effect)
virtual

Returns the specified visual tracking effect (derived from VisualEffect).

Parameters
effectIt is a value from enum EVisualTrackingMode. If k_tracking_none is specified it will return nullptr.

Example:

VisualEffect* pVE = spInteractor->get_tracking_effect(k_tracking_tempo_line);
if (pVE)
{
TempoLine* pTL = static_cast<TempoLine*>(pVE);
pTL->set_color(Color(255,0,0,128)); //transparent red
pTL->set_width(200); //logical units: 2 mm
}

◆ get_view()

View* Interactor::get_view ( )
inline

Returns the View associated to this Interactor.

◆ get_view_size()

virtual void Interactor::get_view_size ( Pixels *  xWidth,
Pixels *  yHeight 
)
virtual

Returns the total size (pixels) of the whole rendered document (the whole visual space, all pages).

Parameters
xWidthReceives the width of the whole rendered document, in pixels.
yHeightReceives the height of the whole rendered document, in pixels.
See also
new_viewport(), set_viewport_at_page_center(), get_viewport()

◆ get_viewport()

virtual void Interactor::get_viewport ( Pixels *  x,
Pixels *  y 
)
virtual

Returns the current coordinates (pixels) of viewport origin.

Parameters
x,yThe variables in which the viewport origin will be returned.

See Scrolling: the Viewport

See also
new_viewport(), set_viewport_at_page_center(), get_view_size()

◆ highlight_object()

virtual void Interactor::highlight_object ( ImoStaffObj *  pSO)
virtual
Parameters
pSOThis note or rest will be highlighted
Todo:
Document Interactor::highlight_object

◆ is_document_editable()

bool Interactor::is_document_editable ( )

Returns true if the document is editable.

Note
Currently, LenMus documents are always editable. Therefore this method will always return true. But by invoking this method your application can be ready for disabling edition for future read-only documents.

◆ model_point_to_device()

virtual void Interactor::model_point_to_device ( double *  x,
double *  y,
int  iPage 
)
virtual

Converts logical coordinates relative to the start of a page to absolute coordinates in device units (pixels, relative to view origin).

Example:

int iPage = 4; //in fact page 5. Remember iPage = 0..num_pages-1
double x = 4500.0; //LUnits relative to page 5 origin
double y = 2700.0;
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
spInteractor->model_point_to_device(&x, &y, iPage);
//Here @a x and @a y contains pixels relative to
//view origin
}

◆ move_tempo_line() [1/3]

virtual void Interactor::move_tempo_line ( ImoId  scoreId,
TimeUnits  timepos 
)
virtual

Move the tempo line to the given time position.

Parameters
scoreIdId. of the score to which all other parameters refer.
timeposTime units from the start of the score.

◆ move_tempo_line() [2/3]

virtual void Interactor::move_tempo_line ( ImoId  scoreId,
int  iMeasure,
int  iBeat,
int  iInstr = 0 
)
virtual

Move the tempo line to the given measure and beat.

Parameters
scoreIdId. of the score to which all other parameters refer.
iMeasureMeasure number (0..n) in instrument iInstr.
iBeatBeat number (0..m) relative to the measure.
iInstrNumber of the instrument (0..m) to which the measures refer to. Take into account that for polymetric music (music in which not all instruments have the same time signature), the measure number is not an absolute value, common to all the score instruments (score parts), but it is relative to an instrument. For normal scores, just providing measure number and location will do the job.

◆ move_tempo_line() [3/3]

virtual void Interactor::move_tempo_line ( ImoId  scoreId,
int  iMeasure,
TimeUnits  location,
int  iInstr = 0 
)
virtual

Move the tempo line to the given measure and relative location inside the measure.

Parameters
scoreIdId. of the score to which all other parameters refer.
iMeasureMeasure number (0..n) in instrument iInstr.
locationTime units from the start of the measure.
iInstrNumber of the instrument (0..m) to which the measures refer to. Take into account that for polymetric music (music in which not all instruments have the same time signature), the measure number is not an absolute value, common to all the score instruments (score parts), but it is relative to an instrument. For normal scores, just providing measure number and location will do the job.

◆ move_tempo_line_and_scroll_if_necessary() [1/2]

virtual void Interactor::move_tempo_line_and_scroll_if_necessary ( ImoId  scoreId,
int  iMeasure,
int  iBeat,
int  iInstr = 0 
)
virtual

Move the tempo line to the given measure and beat and change the viewport, if necessary, for ensuring that the requested measure/beat is visible.

Parameters
scoreIdId. of the score to which all other parameters refer.
iMeasureMeasure number (0..n) in instrument iInstr.
iBeatBeat number (0..m) relative to the measure.
iInstrNumber of the instrument (0..m) to which the measures refer to. Take into account that for polymetric music (music in which not all instruments have the same time signature), the measure number is not an absolute value, common to all the score instruments (score parts), but it is relative to an instrument. For normal scores, just providing measure number and location will do the job.

◆ move_tempo_line_and_scroll_if_necessary() [2/2]

virtual void Interactor::move_tempo_line_and_scroll_if_necessary ( ImoId  scoreId,
int  iMeasure,
TimeUnits  location,
int  iInstr = 0 
)
virtual

Move the tempo line to the given measure and relative location inside the measure, and change the viewport, if necessary, for ensuring that the requested measure/beat is visible.

Parameters
scoreIdId. of the score to which all other parameters refer.
iMeasureMeasure number (0..n) in instrument iInstr.
locationTime units from the start of the measure.
iInstrNumber of the instrument (0..m) to which the measures refer to. Take into account that for polymetric music (music in which not all instruments have the same time signature), the measure number is not an absolute value, common to all the score instruments (score parts), but it is relative to an instrument. For normal scores, just providing measure number and location will do the job.

◆ new_viewport()

virtual void Interactor::new_viewport ( Pixels  x,
Pixels  y,
bool  fForceRedraw = true 
)
virtual

Sets a new origin for the viewport.

Parameters
x,ynew coordinates (in pixels) for the viewport.
fForceRedrawIf false prevents redrawing the new viewport into the rendering buffer; this is useful for saving time when several consecutive changes are going to be done. If not specified true is assumed.
Remarks
The size of viewport (height, width) is always determined by rendering buffer size.

See Scrolling: the Viewport

See also
set_viewport_at_page_center(), get_viewport(), get_view_size()

◆ on_document_updated()

virtual void Interactor::on_document_updated ( )
virtual

Inform Lomse that the Document associated to this Interactor has been modified. This forces Lomse to rebuild all the internal data associated to the document (e.g. the graphic model) and to refresh all the views.

Remarks
Normally you don't have to use this method. But in some applications that don't use edition commands but modify the Document by direct manipulation of its internal data structures, this method it is needed for informing Lomse and forcing to render again all the views associated to the document.

◆ on_end_of_play_event()

virtual void Interactor::on_end_of_play_event ( ImoScore *  pScore,
PlayerGui *  pPlayCtrl 
)
virtual
Todo:
This method should be for internal use. Analyse and refactor or document.

This method should be invoked when processing a EventPlayCtrl of type k_end_of_playback_event. But this method generates a k_end_of_playback_event, this will create a loop!!!! ?????????

◆ on_mouse_button_down()

virtual void Interactor::on_mouse_button_down ( Pixels  x,
Pixels  y,
unsigned  flags 
)
virtual

Inform Lomse that a mouse button down event received by your application has to be handled by Lomse in accordance to current selected Task.

Parameters
x,yCurrent mouse position, as reported by the mouse event received by your application.
flagsFlags for keys pressed in the keyboard while the mouse button was pressed, as reported by the mouse event received by your application. Values for these flas are described by enum EEventFlag.
See also

◆ on_mouse_button_up()

virtual void Interactor::on_mouse_button_up ( Pixels  x,
Pixels  y,
unsigned  flags 
)
virtual

Inform Lomse that a mouse button up event received by your application has to be handled by Lomse in accordance to current selected Task.

Parameters
x,yCurrent mouse position, as reported by the mouse event received by your application.
flagsFlags for keys pressed in the keyboard while the mouse button was released, as reported by the mouse event received by your application. Values for these flags are described by enum EEventFlag.
See also

◆ on_mouse_enter_window()

virtual void Interactor::on_mouse_enter_window ( Pixels  x,
Pixels  y,
unsigned  flags 
)
virtual

Inform Lomse that a mouse enter window event received by your application has to be handled by Lomse in accordance to current selected Task.

Parameters
x,yCurrent mouse position, as reported by the mouse event received by your application.
flagsFlags for keys pressed in the keyboard while the mouse entered the window, as reported by the mouse event received by your application. Values for these flags are described by enum EEventFlag.
See also

◆ on_mouse_leave_window()

virtual void Interactor::on_mouse_leave_window ( Pixels  x,
Pixels  y,
unsigned  flags 
)
virtual

Inform Lomse that a mouse leave window event received by your application has to be handled by Lomse in accordance to current selected Task.

Parameters
x,yCurrent mouse position, as reported by the mouse event received by your application.
flagsFlags for keys pressed in the keyboard while the mouse moved out of the window, as reported by the mouse event received by your application. Values for these flags are described by enum EEventFlag.
See also

◆ on_mouse_move()

virtual void Interactor::on_mouse_move ( Pixels  x,
Pixels  y,
unsigned  flags 
)
virtual

Inform Lomse that a mouse move event received by your application has to be handled by Lomse in accordance to current selected Task.

Parameters
x,yCurrent mouse position, as reported by the mouse event received by your application.
flagsFlags for keys pressed in the keyboard while moving the mouse, as reported by the mouse event received by your application. Values for these flags are described by enum EEventFlag.
See also

◆ on_visual_tracking()

virtual void Interactor::on_visual_tracking ( SpEventVisualTracking  pEvent)
virtual
Parameters
pEventThe Highlight event to be processed.
Todo:
Document Interactor::on_visual_tracking

◆ page_at_screen_point()

virtual int Interactor::page_at_screen_point ( double  x,
double  y 
)
virtual

Returns the page number (0 .. num_pages - 1) that contains the point (x, y) or -1 if point is out of page. Variables x and y are in absolute device units (pixels, relative to view origin).

Example:

double x = 4500.0; //pixels relative to view origin
double y = 2700.0; //pixels
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
int iPage = spInteractor->page_at_screen_point(x, y);
//Here @a iPage is the page number (0 .. num_pages - 1)
}

◆ print_page()

virtual void Interactor::print_page ( int  page,
VPoint  viewport = VPoint(0, 0) 
)
virtual

Request Lomse to render a page on current print buffer.

Parameters
pageThe page to print (0..num_pages - 1)
viewportThe desired viewport. By changing the viewport in a loop of calls to this method your application can split the page in tiles, so that printing in large paper formats will not require huge buffer sizes.

See Printing documents overview

◆ redraw_bitmap()

virtual void Interactor::redraw_bitmap ( )
virtual

Invoking this method forces Lomse to render again the View and, therefore, the rendering buffer gets updated. After doing it, Lomse does not generate a EventPaint event, as invoking this method implies that your application is aware of the rendering buffer change.

See also
force_redraw().

◆ remove_all_visual_tracking()

virtual void Interactor::remove_all_visual_tracking ( )
virtual

Remove all visual tracking visual effects.

◆ remove_highlight_from_object()

virtual void Interactor::remove_highlight_from_object ( ImoStaffObj *  pSO)
virtual
Parameters
pSOHighlight will be removed from this note or rest.
Todo:
Document Interactor::remove_highlight_from_object

◆ remove_mark()

void Interactor::remove_mark ( ApplicationMark mark)

Hide a marker and delete it.

Parameters
markPointer to the marker to remove. After executing this method the pointer will no longer be valid.

◆ render_as_svg()

void Interactor::render_as_svg ( std::ostream &  svg,
int  page = 0 
)

Request Lomse to render a document as SVG stream.

Parameters
svgThe std::ostream in which SVG code will be written.
pageThe page to render (0..num_pages - 1). This parameter is only meaningful for View types that can generate several pages (k_view_vertical_book and k_view_horizontal_book). For all others there is only one page (page == 0) and the value of this parameter is ignored.

See Render in SVG format

◆ reset_boxes_to_draw()

virtual void Interactor::reset_boxes_to_draw ( )
virtual

Instructs Lomse renderer to not render surrounding rectangles around any element.

See: set_box_to_draw().

Attention
This method is oriented to debug Lomse. It might be removed from public API in future.

◆ screen_point_to_model_point()

virtual UPoint Interactor::screen_point_to_model_point ( Pixels  x,
Pixels  y 
)
virtual

Converts absolute device coordinates (pixels, relative to view origin) to absolute logical units.

Example:

void DocumentWindow::on_mouse_move_event(MouseEvent& event)
{
if (!m_pPresenter)
return;
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
Interactor* pInteractor = spInteractor.get();
if (!pInteractor) return;
Point pos = event.GetPosition();
unsigned flags = event.GetFlags(event);
UPoint uPos = pInteractor->screen_point_to_model_point(pos.x, pos.y);
//inform Lomse
pInteractor->on_mouse_move(pos.x, pos.y, flags);
}
}

◆ screen_point_to_page_point()

virtual void Interactor::screen_point_to_page_point ( double *  x,
double *  y 
)
virtual

Converts device coordinates (pixels) to coordinates in logical units. The returned values are not absolute but relative to the start of the page at which the device point is pointing.

Once invoked, variables x and y should be statically cast to logical units (LUnits type).

Example:

double x = 4500.0; //pixels relative to view origin
double y = 2700.0; //pixels
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
int iPage = spInteractor->page_at_screen_point(x, y);
spInteractor->screen_point_to_page_point(&x, &y);
//Here @a x and @a y contains logical units relative to
//page iPage origin
}

◆ scroll_to_measure() [1/2]

virtual void Interactor::scroll_to_measure ( ImoId  scoreId,
int  iMeasure,
int  iBeat = 0,
int  iInstr = 0 
)
virtual

This method forces to set a new origin for the viewport so that requested score location is visible in the viewport.

Parameters
scoreIdID of the score to which all other parameters refer to.
iMeasureThe index to the desired measure. First measure in the instrument, including a possible anacrusis start measure, is always measure 0.
iBeatThe index to the desired beat in the measure. First beat is 0.
iInstrThe index to the instrument to which the measure refers. If not specified, iInstr 0 is assumed. Normally, all instruments in the score use the same time signature. In these cases all score parts have the same number of measures and iInstr is not needed. But in polymetric music not all instruments use the same time signature and this implies that the instruments have different number of measures; in these cases the measure number alone is not enough for determining the location.

See Scrolling: the Viewport

◆ scroll_to_measure() [2/2]

virtual void Interactor::scroll_to_measure ( ImoId  scoreId,
int  iMeasure,
TimeUnits  location = 0.0,
int  iInstr = 0 
)
virtual

This method forces to set a new origin for the viewport so that requested score location is visible in the viewport.

Parameters
scoreIdID of the score to which all other parameters refer to.
iMeasureThe index to the desired measure. First measure in the instrument, including a possible anacrusis start measure, is always measure 0.
locationTime units from the start of the measure.
iInstrThe index to the instrument to which the measure refers. If not specified, iInstr 0 is assumed. Normally, all instruments in the score use the same time signature. In these cases all score parts have the same number of measures and iInstr is not needed. But in polymetric music not all instruments use the same time signature and this implies that the instruments have different number of measures; in these cases the measure number alone is not enough for determining the location.

See Scrolling: the Viewport

◆ scroll_to_measure_if_necessary() [1/2]

virtual void Interactor::scroll_to_measure_if_necessary ( ImoId  scoreId,
int  iMeasure,
int  iBeat = 0,
int  iInstr = 0 
)
virtual

This method invokes Lomse auto-scrolling algorithm to determine if scroll is necessary, and if that is the case, it will set a new origin for the viewport so that requested score location is visible in the viewport.

Parameters
scoreIdID of the score to which all other parameters refer to.
iMeasureThe index to the desired measure. First measure in the instrument, including a possible anacrusis start measure, is always measure 0.
iBeatThe index to the desired beat in the measure. First beat is 0.
iInstrThe index to the instrument to which the measure refers. If not specified, iInstr 0 is assumed. Normally, all instruments in the score use the same time signature. In these cases all score parts have the same number of measures and iInstr is not needed. But in polymetric music not all instruments use the same time signature and this implies that the instruments have different number of measures; in these cases the measure number alone is not enough for determining the location.

See Scrolling: the Viewport

◆ scroll_to_measure_if_necessary() [2/2]

virtual void Interactor::scroll_to_measure_if_necessary ( ImoId  scoreId,
int  iMeasure,
TimeUnits  location = 0.0,
int  iInstr = 0 
)
virtual

This method invokes Lomse auto-scrolling algorithm to determine if scroll is necessary, and if that is the case, it will set a new origin for the viewport so that requested score location is visible in the viewport.

Parameters
scoreIdID of the score to which all other parameters refer to.
iMeasureThe index to the desired measure. First measure in the instrument, including a possible anacrusis start measure, is always measure 0.
locationTime units from the start of the measure.
iInstrThe index to the instrument to which the measure refers. If not specified, iInstr 0 is assumed. Normally, all instruments in the score use the same time signature. In these cases all score parts have the same number of measures and iInstr is not needed. But in polymetric music not all instruments use the same time signature and this implies that the instruments have different number of measures; in these cases the measure number alone is not enough for determining the location.

See Scrolling: the Viewport

◆ select_voice()

void Interactor::select_voice ( int  voice)

Restrict document cursor so that it only moves to positions occupied by the selected voice.

Parameters
voiceThe new voice to be tracked (0 ... num_voices - 1)
Remarks
  • As a consequence of this operation the selected voice will be rendered highlighted.
  • This method only has effects is the object being edited is a music score. For other top level objects this method does nothing.

◆ set_box_to_draw()

virtual void Interactor::set_box_to_draw ( int  boxType)
virtual

Instructs Lomse renderer to draw a rectangle around the area occupied by elements of type boxType.

Parameters
boxTypeThe elements for which it is requested to draw a surrounding rectangle. Valid values are given by enum constants GmoObj::k_box_xxxxxxx defined in GmoObj class.

See: reset_boxes_to_draw().

Attention
This method is oriented to debug Lomse. It might be removed from public API in future.

◆ set_operating_mode()

void Interactor::set_operating_mode ( int  mode)

Set current operation mode. An operation mode defines valid actions and commands on the Document. For instance, in 'read only' mode all actions that could alter Document content will be ignored. Valid operation modes are defined by enum EInteractorOpMode. Look there for an explanation of the different operating modes.

Example:

void DocumentWindow::play_score(SpEventInfo pEvent)
{
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
spInteractor->set_operating_mode(Interactor::k_mode_playback);
SpEventPlayCtrl pEv = static_pointer_cast<EventPlayCtrl>(pEvent);
ImoScore* pScore = pEv->get_score();
ScorePlayer* pPlayer = m_appScope.get_score_player();
PlayerGui* pPlayerGui = pEv->get_player();
pPlayer->load_score(pScore, pEv->get_player());
//initialize with default options
bool fVisualTracking = true;
long nMM = pPlayerGui->get_metronome_mm();
pPlayer->play(fVisualTracking, nMM, spInteractor.get());
}
}

◆ set_print_buffer()

virtual void Interactor::set_print_buffer ( unsigned char *  buf,
unsigned  width,
unsigned  height 
)
virtual

Sets the memory area to be used as buffer for printing operations.

In order to not interfere with screen display, a different rendering buffer is used for printing.

Parameters
bufPointer to the memory area to be used as rendering buffer
widthRendering buffer width, in pixels
heightRendering buffer height, in pixels

See Printing documents overview

◆ set_print_page_size()

virtual void Interactor::set_print_page_size ( Pixels  width,
Pixels  height 
)
virtual

Sets the resolution to use for printing.

Parameters
widthPaper width, in pixels
heightPaper height, in pixels

See Printing documents overview

◆ set_rendering_buffer()

virtual void Interactor::set_rendering_buffer ( unsigned char *  buf,
unsigned  width,
unsigned  height 
)
virtual

Associate a rendering buffer to the View related to this Interactor. This function takes three parameters:

Parameters
bufA ptr to the memory to be used as rendering buffer.
widthThe width of the buffer in pixels.
heightThe height of the buffer in pixels.

Invoking this method is mandatory before doing any operation that would require to render the view, and the view area will be the whole rendering bitmap.

Once invoked, it is not necessary to allocate a new buffer and invoke again this method, unless the application window is resized. So, normally, the creation of the rendering buffer is done in the window resize event handler. Example:

if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
wxImage* buffer = new wxImage(width, height);
unsigned char* pdata = buffer->GetData(); //ptr to the real bytes buffer
spInteractor->set_print_buffer(pdata, width, height);
}

For applications having special requirements, it is possible to restrict Lomse to use only a sub-area of the rendering buffer. See set_view_area() method.

◆ set_rendering_option()

virtual void Interactor::set_rendering_option ( int  option,
bool  value 
)
virtual

Set/reset a rendering option for the view associated to this Interactor.

Parameters
optionThe option to set or reset. Valid values for this param are defined by enum ERenderOptions
valuetrue for enabling the option or false for disabling it.

Example:

void DocumentWindow::display_voices_in_colours(bool value)
{
if (!m_pPresenter)
return;
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
spInteractor->set_rendering_option(k_option_display_voices_in_colours, value);
Refresh(); //force to repaint this window
}
}

◆ set_scale()

virtual void Interactor::set_scale ( double  scale,
Pixels  x = 0,
Pixels  y = 0,
bool  fForceRedraw = true 
)
virtual

Sets the scaling factor, useful for applications which require 'zooming'.

Parameters
scaleIs the new scale factor, e.g. 2.0
x,yAre the coordinates for the point that will remain fixed (unmoved) when applying the new scale (the center point for the zooming operation).
fForceRedrawIf false prevents Lomse from sending a paint event. This is useful to avoid repaints when some consecutive operations will affect the View.

See Scaling

See also
zoom_in(), zoom_out(), zoom_fit_full(), zoom_fit_width(), get_scale()

◆ set_svg_canvas_width()

void Interactor::set_svg_canvas_width ( Pixels  x)

Lomse normally layouts the score to fit in the page width specified in the document. But when View type k_view_free_flow is selected, it is necessary specify the desired width for the rendered score, and this is the purpose of this method.

The width must be set before invoking render_as_svg() but this is only needed when using the k_view_free_flow View type. For all other view types any value set using this method will be overriden by the document page width so it is useless to invoke it but does not harm.

Parameters
xThe desired width for the score in pixels. For most applications, this value should be the width of the HTML element in which the generated SVG code will be inserted.

See Render in SVG format

◆ set_view_area()

virtual void Interactor::set_view_area ( unsigned  width,
unsigned  height,
unsigned  xShift = 0,
unsigned  yShift = 0 
)
virtual

Define a sub-region of the rendering bitmap for the View. This function takes four parameters:

Parameters
widthThe width of the view area in pixels.
heightThe height of the view area in pixels.
xShiftHorizontal shift, in pixels, for view area origin.
yShiftVertical shift, in pixels, for view area origin.

Invoking this method is optional. If not invoked, the view area will be the whole rendering bitmap.

The view area cannot be redefined, so once this method is invoked, if your application would like to use a different sub-region, it is necessary to invoke again the set_rendering_buffer() method.

For instance, if you have a 200x100 bitmap and you want to draw only on the 80x50 top-right corner:

if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
wxImage* buffer = LENMUS_NEW wxImage(200, 100);
unsigned char* pdata = buffer->GetData(); //ptr to the real bytes buffer
spInteractor->set_rendering_buffer(pdata, 200, 100);
spInteractor->set_view_area(80, 50);
}

Parameters xShift and yShift allows to change the origin of the view area. For example, if you have a 200x100 bitmap and you want to draw only an area of 100x50 pixels in the center, you can shift the view area top corner:

if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
wxImage* buffer = LENMUS_NEW wxImage(200, 100);
unsigned char* pdata = buffer->GetData(); //ptr to the real bytes buffer
spInteractor->set_rendering_buffer(pdata, 200, 100);
spInteractor->set_view_area(100, 50, 50, 25);
}

◆ set_view_background()

void Interactor::set_view_background ( Color  color)

Changes the background color for the View. By default all Views have a gray background and the paper is white. Example, for suppressing the background:

m_pPresenter = lomse.open_document(k_view_single_system, filename);
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
spInteractor->set_view_background( Color(255,255,255) ); //white
...

◆ set_viewport_at_page_center()

virtual void Interactor::set_viewport_at_page_center ( Pixels  screenWidth)
virtual

Sets a new x origin for the viewport so that the viewport is centered on document page.

Parameters
screenWidthis the desired viewport width (in pixels) for computing the the new x origin.
Remarks
This method computes the new origin as (pageWidth - screenWidth) / 2;

See Scrolling: the Viewport

See also
new_viewport(), get_viewport(), get_view_size()

◆ set_visual_tracking_mode()

virtual void Interactor::set_visual_tracking_mode ( int  mode)
virtual

Select the visual effect to use for visual tracking during playback. By default, if this method is not invoked, k_tracking_highlight_notes is used.

Parameters
modeIt is a value from enum EVisualTrackingMode. Several visual effects can be en effect simultaneously by combining values with the OR ('|') operator. Example:
spInteractor->set_visual_tracking_mode(k_tracking_tempo_line | k_tracking_highlight_notes);

◆ should_enable_edit_redo()

bool Interactor::should_enable_edit_redo ( )

Returns true if there are commands in the redo queue.

Remarks
This method is oriented for applications wishing to validate that exec_redo() can be invoked.

See How to modify a document

See also
exec_command(), exec_undo(), exec_redo(), should_enable_edit_undo(),

◆ should_enable_edit_undo()

bool Interactor::should_enable_edit_undo ( )

Returns true if there are commands in the undo queue.

Remarks
This method is oriented for applications wishing to validate that exec_undo() can be invoked.

See How to modify a document

See also
exec_command(), exec_undo(), exec_redo(), should_enable_edit_redo(),

◆ svg_add_class()

void Interactor::svg_add_class ( bool  value)
inline

Enable / disable the generation of 'class' attribute in SVG elements.

Parameters
valuetrue for enabling the generation of 'class' attributes. false for disabling it.

By default, generation of 'class' attributes is disabled.

See Render in SVG format

◆ svg_add_id()

void Interactor::svg_add_id ( bool  value)
inline

Enable / disable the generation of 'id' attribute in SVG elements.

Parameters
valuetrue for enabling the generation of 'id' attributes. false for disabling it.

By default, generation of 'id' attributes is disabled.

See Render in SVG format

◆ svg_add_newlines()

void Interactor::svg_add_newlines ( bool  value)
inline

Enable or disable the generation of a line break after each SVG element.

Parameters
valuetrue for enabling the generation of line breaks. false for disabling it.

By default, Lomse generates the SVG code to be as compact as possible and, thus, it does not include line breaks.

See Render in SVG format

◆ svg_indent()

void Interactor::svg_indent ( int  value)
inline

Set the number of spaces for indenting SVG elements.

Parameters
valueThe number of spaces for an indentation. Note that a value of zero supress indentation.

By default, Lomse generates the SVG code to be as compact as possible and, thus, it does not include indentation spaces. So default value is 0.

See Render in SVG format

◆ switch_task()

void Interactor::switch_task ( int  taskType)

Switch the Task used by the Interactor for interpreting mouse events.

Remarks
When the Interactor is created it is initialized with an instace of TaskSelection class.

See Interaction with your application GUI.

Example:

void DocumentWindow::switch_mode_for_current_tool(int toolType)
{
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
switch(toolType)
{
case k_tool_data_entry:
spInteractor->switch_task(TaskFactory::k_task_data_entry);
break;
case k_tool_selection:
default:
spInteractor->switch_task(TaskFactory::k_task_selection);
}
}
}

◆ timing_repaint_done()

void Interactor::timing_repaint_done ( )

Invoke this method for informing Lomse when the rendering buffer has been copied onto the application window. See get_elapsed_times() for more information.

This method is oriented to performance measurements.

◆ view_needs_repaint()

bool Interactor::view_needs_repaint ( )

Returns true if the document, the graphic model, or any View option have been changed since last view rendering.

Your application rarely will need to invoke this method as Lomse automatically triggers updates when anything is changed.

◆ zoom_fit_full()

virtual void Interactor::zoom_fit_full ( Pixels  width,
Pixels  height,
bool  fForceRedraw = true 
)
virtual

Adjusts the scaling factor so that current document page will fit on the specified rectangle.

Parameters
width,heightAre the dimensions (in Pixels) of the rectangle in which the page should fit (usually the window size).
fForceRedrawIf false prevents Lomse from sending a paint event. This is useful to avoid repaints when some consecutive operations will affect the View.

See Scaling

See also
set_scale(), zoom_in(), zoom_out(), zoom_fit_width(), get_scale()

◆ zoom_fit_width()

virtual void Interactor::zoom_fit_width ( Pixels  width,
bool  fForceRedraw = true 
)
virtual

Adjusts the scaling factor so that current document page width will fit on the specified screen dimension.

Parameters
widthThe dimension (in Pixels) in which the page width should fit (usually the window width).
fForceRedrawIf false prevents Lomse from sending a paint event. This is useful to avoid repaints when some consecutive operations will affect the View.

See Scaling

See also
set_scale(), zoom_in(), zoom_out(), zoom_fit_full(), get_scale()

◆ zoom_in()

virtual void Interactor::zoom_in ( Pixels  x = 0,
Pixels  y = 0,
bool  fForceRedraw = true 
)
virtual

Increments the scaling factor by 5%.

Parameters
x,yAre the coordinates for the point that will remain fixed (unmoved) when applying the new scale (the center point for the zooming operation).
fForceRedrawIf false prevents Lomse from sending a paint event. This is useful to avoid repaints when some consecutive operations will affect the View.

See Scaling

See also
set_scale(), zoom_out(), zoom_fit_full(), zoom_fit_width(), get_scale()

◆ zoom_out()

virtual void Interactor::zoom_out ( Pixels  x = 0,
Pixels  y = 0,
bool  fForceRedraw = true 
)
virtual

Decrements the scaling factor (near 5%) so that a subsequent zoom in operation will cancel the zoom out.

Parameters
x,yAre the coordinates for the point that will remain fixed (unmoved) when applying the new scale (the center point for the zooming operation).
fForceRedrawIf false prevents Lomse from sending a paint event. This is useful to avoid repaints when some consecutive operations will affect the View.

See Scaling

See also
set_scale(), zoom_in(), zoom_fit_full(), zoom_fit_width(), get_scale()