13
0

add Editor::canvas_event_time()

See comments in header for more
This commit is contained in:
Paul Davis 2021-01-18 20:13:13 -07:00
parent 0114059c9d
commit 6a44dcbdad
2 changed files with 21 additions and 0 deletions

View File

@ -2121,6 +2121,13 @@ private:
*/
samplepos_t canvas_event_sample (GdkEvent const*, double* px = 0, double* py = 0) const;
/** computes the timeline position for an event whose coordinates
* are in canvas units (pixels, scroll offset included). The time
* domain used by the return value will match ::default_time_domain()
* at the time of calling.
*/
Temporal::timepos_t canvas_event_time (GdkEvent const*, double* px = 0, double* py = 0) const;
/** computes the timeline sample (sample) of an event whose coordinates
* are in window units (pixels, no scroll offset).
*/

View File

@ -169,6 +169,20 @@ Editor::window_event_sample (GdkEvent const * event, double* pcx, double* pcy) c
return pixel_to_sample (d.x);
}
timepos_t
Editor::canvas_event_time (GdkEvent const * event, double* pcx, double* pcy) const
{
timepos_t pos (canvas_event_sample (event, pcx, pcy));
if (default_time_domain() == Temporal::AudioTime) {
cerr << "E::cet returns audio\n";
return pos;
}
cerr << "E::cet returns beats\n";
return timepos_t (pos.beats());
}
samplepos_t
Editor::canvas_event_sample (GdkEvent const * event, double* pcx, double* pcy) const
{