Lomse library. API documentation
0.30.0
|
#include <lomse_interactor.h>
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:
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 | |
GraphicModel * | get_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 | |
| |
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 VisualEffect * | get_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 | |
FragmentMark * | add_fragment_mark_at_note_rest (ImoId scoreId, TimeUnits timepos) |
FragmentMark * | add_fragment_mark_at_barline (ImoId scoreId, TimeUnits timepos) |
FragmentMark * | add_fragment_mark_at_staffobj (ImoStaffObj *pSO) |
MeasureHighlight * | add_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 | |
| |
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) |
Observer * | add_observer_for (Observable *target) |
Observer * | add_observer_for_child (Observable *parent, int childType, ImoId childId) |
Public Member Functions inherited from Observable | |
virtual | ~Observable () |
virtual EventNotifier * | get_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 Observable * | get_observable_child (int UNUSED(childType), ImoId UNUSED(childId)) |
Valid operating modes for the Interactor:
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:
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.
scoreId | Id. of the score on which the mark will be added. |
timepos | The position for the mark, in Time Units from the start of the score. |
See add_fragment_mark_at_note_rest() for more details.
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.
scoreId | Id. of the score on which the mark will be added. |
timepos | The 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:
k_mark_line
, that is, a vertical line.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:
FragmentMark* Interactor::add_fragment_mark_at_staffobj | ( | ImoStaffObj * | pSO | ) |
Create a new FragmentMark on the score at the given staff object position.
pSO | Pointer to the staff object defining the position for the mark. |
See add_fragment_mark_at_note_rest() for more details.
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.
scoreId | Id. of the score on which the mark will be added. |
ml | The 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.
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
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:
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:
string Interactor::dump_cursor | ( | ) |
Returns an string with the content of current Cursor.
string Interactor::dump_selection | ( | ) |
Returns an string with the content of current Selection Set.
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.
id | The ID of the only object that will be editable after invoking this method. |
|
inline |
Invoking this method controls the behavior of method force_redraw(). If disabled, Lomse will ignore any invocation to force_redraw().
value | true for enabling method force_redraw(). false for ignoring invocations to this method. |
By default, force_redraw() method is enabled.
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.
pCmd | The command to execute. |
Example:
void Interactor::exec_redo | ( | ) |
Redo the last edition command undone via exec_undo().
void Interactor::exec_undo | ( | ) |
Undo the last edition command executed via exec_command().
Example:
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.
x | The x coordinate (pixels) of the point. |
y | The y coordinate (pixels) of the point. |
|
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.
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:
|
inline |
Returns the cursor associated to the View of this Interactor.
|
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:
GraphicModel* Interactor::get_graphic_model | ( | ) |
Returns the graphic model object associated to the View of this Interactor.
|
virtual |
Returns the number of pages in current document.
|
inline |
Returns current operation mode for this Interactor. Returned value is one of the values from enum EInteractorOpMode.
Example:
USize Interactor::get_page_size | ( | int | page = 0 | ) |
Returns the size (logical units) of a page of the rendered document.
page | The 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. |
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.
|
virtual |
Returns the current scale factor.
See Scaling
|
inline |
Returns the selection set associated to the View of this Interactor.
|
virtual |
Returns the specified visual tracking effect (derived from VisualEffect).
effect | It is a value from enum EVisualTrackingMode. If k_tracking_none is specified it will return nullptr. |
Example:
|
inline |
Returns the View associated to this Interactor.
|
virtual |
Returns the total size (pixels) of the whole rendered document (the whole visual space, all pages).
xWidth | Receives the width of the whole rendered document, in pixels. |
yHeight | Receives the height of the whole rendered document, in pixels. |
|
virtual |
Returns the current coordinates (pixels) of viewport origin.
x,y | The variables in which the viewport origin will be returned. |
|
virtual |
pSO | This note or rest will be highlighted |
bool Interactor::is_document_editable | ( | ) |
Returns true if the document is editable.
|
virtual |
Converts logical coordinates relative to the start of a page to absolute coordinates in device units (pixels, relative to view origin).
Example:
|
virtual |
Move the tempo line to the given time position.
scoreId | Id. of the score to which all other parameters refer. |
timepos | Time units from the start of the score. |
|
virtual |
Move the tempo line to the given measure and beat.
scoreId | Id. of the score to which all other parameters refer. |
iMeasure | Measure number (0..n) in instrument iInstr. |
iBeat | Beat number (0..m) relative to the measure. |
iInstr | Number 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. |
|
virtual |
Move the tempo line to the given measure and relative location inside the measure.
scoreId | Id. of the score to which all other parameters refer. |
iMeasure | Measure number (0..n) in instrument iInstr. |
location | Time units from the start of the measure. |
iInstr | Number 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. |
|
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.
scoreId | Id. of the score to which all other parameters refer. |
iMeasure | Measure number (0..n) in instrument iInstr. |
iBeat | Beat number (0..m) relative to the measure. |
iInstr | Number 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. |
|
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.
scoreId | Id. of the score to which all other parameters refer. |
iMeasure | Measure number (0..n) in instrument iInstr. |
location | Time units from the start of the measure. |
iInstr | Number 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. |
|
virtual |
Sets a new origin for the viewport.
x,y | new coordinates (in pixels) for the viewport. |
fForceRedraw | If 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. |
|
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.
|
virtual |
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!!!! ?????????
|
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.
x,y | Current mouse position, as reported by the mouse event received by your application. |
flags | Flags 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. |
|
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.
x,y | Current mouse position, as reported by the mouse event received by your application. |
flags | Flags 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. |
|
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.
x,y | Current mouse position, as reported by the mouse event received by your application. |
flags | Flags 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. |
|
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.
x,y | Current mouse position, as reported by the mouse event received by your application. |
flags | Flags 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. |
|
virtual |
Inform Lomse that a mouse move event received by your application has to be handled by Lomse in accordance to current selected Task.
x,y | Current mouse position, as reported by the mouse event received by your application. |
flags | Flags 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. |
|
virtual |
pEvent | The Highlight event to be processed. |
|
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:
|
virtual |
Request Lomse to render a page on current print buffer.
page | The page to print (0..num_pages - 1) |
viewport | The 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. |
|
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.
|
virtual |
Remove all visual tracking visual effects.
|
virtual |
pSO | Highlight will be removed from this note or rest. |
void Interactor::remove_mark | ( | ApplicationMark * | mark | ) |
Hide a marker and delete it.
mark | Pointer to the marker to remove. After executing this method the pointer will no longer be valid. |
void Interactor::render_as_svg | ( | std::ostream & | svg, |
int | page = 0 |
||
) |
Request Lomse to render a document as SVG stream.
svg | The std::ostream in which SVG code will be written. |
page | The 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. |
|
virtual |
Instructs Lomse renderer to not render surrounding rectangles around any element.
See: set_box_to_draw().
|
virtual |
Converts absolute device coordinates (pixels, relative to view origin) to absolute logical units.
Example:
|
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:
|
virtual |
This method forces to set a new origin for the viewport so that requested score location is visible in the viewport.
scoreId | ID of the score to which all other parameters refer to. |
iMeasure | The index to the desired measure. First measure in the instrument, including a possible anacrusis start measure, is always measure 0. |
iBeat | The index to the desired beat in the measure. First beat is 0. |
iInstr | The 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. |
|
virtual |
This method forces to set a new origin for the viewport so that requested score location is visible in the viewport.
scoreId | ID of the score to which all other parameters refer to. |
iMeasure | The index to the desired measure. First measure in the instrument, including a possible anacrusis start measure, is always measure 0. |
location | Time units from the start of the measure. |
iInstr | The 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. |
|
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.
scoreId | ID of the score to which all other parameters refer to. |
iMeasure | The index to the desired measure. First measure in the instrument, including a possible anacrusis start measure, is always measure 0. |
iBeat | The index to the desired beat in the measure. First beat is 0. |
iInstr | The 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. |
|
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.
scoreId | ID of the score to which all other parameters refer to. |
iMeasure | The index to the desired measure. First measure in the instrument, including a possible anacrusis start measure, is always measure 0. |
location | Time units from the start of the measure. |
iInstr | The 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. |
void Interactor::select_voice | ( | int | voice | ) |
Restrict document cursor so that it only moves to positions occupied by the selected voice.
voice | The new voice to be tracked (0 ... num_voices - 1) |
|
virtual |
Instructs Lomse renderer to draw a rectangle around the area occupied by elements of type boxType.
boxType | The 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().
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:
|
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.
buf | Pointer to the memory area to be used as rendering buffer |
width | Rendering buffer width, in pixels |
height | Rendering buffer height, in pixels |
|
virtual |
Sets the resolution to use for printing.
width | Paper width, in pixels |
height | Paper height, in pixels |
|
virtual |
Associate a rendering buffer to the View related to this Interactor. This function takes three parameters:
buf | A ptr to the memory to be used as rendering buffer. |
width | The width of the buffer in pixels. |
height | The 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:
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.
|
virtual |
Set/reset a rendering option for the view associated to this Interactor.
option | The option to set or reset. Valid values for this param are defined by enum ERenderOptions |
value | true for enabling the option or false for disabling it. |
Example:
|
virtual |
Sets the scaling factor, useful for applications which require 'zooming'.
scale | Is the new scale factor, e.g. 2.0 |
x,y | Are the coordinates for the point that will remain fixed (unmoved) when applying the new scale (the center point for the zooming operation). |
fForceRedraw | If false prevents Lomse from sending a paint event. This is useful to avoid repaints when some consecutive operations will affect the View. |
See Scaling
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.
x | The 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. |
|
virtual |
Define a sub-region of the rendering bitmap for the View. This function takes four parameters:
width | The width of the view area in pixels. |
height | The height of the view area in pixels. |
xShift | Horizontal shift, in pixels, for view area origin. |
yShift | Vertical 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:
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:
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:
|
virtual |
Sets a new x origin for the viewport so that the viewport is centered on document page.
screenWidth | is the desired viewport width (in pixels) for computing the the new x origin. |
|
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.
mode | It is a value from enum EVisualTrackingMode. Several visual effects can be en effect simultaneously by combining values with the OR ('|') operator. Example: |
bool Interactor::should_enable_edit_redo | ( | ) |
Returns true if there are commands in the redo queue.
bool Interactor::should_enable_edit_undo | ( | ) |
Returns true if there are commands in the undo queue.
|
inline |
Enable / disable the generation of 'class' attribute in SVG elements.
value | true for enabling the generation of 'class' attributes. false for disabling it. |
By default, generation of 'class' attributes is disabled.
|
inline |
Enable / disable the generation of 'id' attribute in SVG elements.
value | true for enabling the generation of 'id' attributes. false for disabling it. |
By default, generation of 'id' attributes is disabled.
|
inline |
Enable or disable the generation of a line break after each SVG element.
value | true 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.
|
inline |
Set the number of spaces for indenting SVG elements.
value | The 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.
void Interactor::switch_task | ( | int | taskType | ) |
Switch the Task used by the Interactor for interpreting mouse events.
See Interaction with your application GUI.
Example:
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.
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.
|
virtual |
Adjusts the scaling factor so that current document page will fit on the specified rectangle.
width,height | Are the dimensions (in Pixels) of the rectangle in which the page should fit (usually the window size). |
fForceRedraw | If false prevents Lomse from sending a paint event. This is useful to avoid repaints when some consecutive operations will affect the View. |
See Scaling
|
virtual |
Adjusts the scaling factor so that current document page width will fit on the specified screen dimension.
width | The dimension (in Pixels) in which the page width should fit (usually the window width). |
fForceRedraw | If false prevents Lomse from sending a paint event. This is useful to avoid repaints when some consecutive operations will affect the View. |
See Scaling
|
virtual |
Increments the scaling factor by 5%.
x,y | Are the coordinates for the point that will remain fixed (unmoved) when applying the new scale (the center point for the zooming operation). |
fForceRedraw | If false prevents Lomse from sending a paint event. This is useful to avoid repaints when some consecutive operations will affect the View. |
See Scaling
|
virtual |
Decrements the scaling factor (near 5%) so that a subsequent zoom in operation will cancel the zoom out.
x,y | Are the coordinates for the point that will remain fixed (unmoved) when applying the new scale (the center point for the zooming operation). |
fForceRedraw | If false prevents Lomse from sending a paint event. This is useful to avoid repaints when some consecutive operations will affect the View. |
See Scaling