mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-30 17:03:06 +01:00
introduce concept of timeline origin to EditingContext
For the main editor, the timeline starts at the left edge of the editor canvas. But for MidiCueEditor, we place a canvas-ified piano roll header on the left of the canvas, so the timeline starts at some position right of that. Note that this means that converting global canvas coordinates to timeline coordinates is no longer guaranteed to be a 1:1 transform (it will be for Editor, but in general for EditingContext).
This commit is contained in:
parent
d550292f8f
commit
060d8c82d7
2 changed files with 24 additions and 3 deletions
|
|
@ -104,6 +104,7 @@ EditingContext::EditingContext (std::string const & name)
|
|||
, _draw_length (GridTypeNone)
|
||||
, _draw_velocity (DRAW_VEL_AUTO)
|
||||
, _draw_channel (DRAW_CHAN_AUTO)
|
||||
, _timeline_origin (0.)
|
||||
, _drags (new DragManager (this))
|
||||
, _leftmost_sample (0)
|
||||
, _playhead_cursor (nullptr)
|
||||
|
|
|
|||
|
|
@ -176,6 +176,8 @@ public:
|
|||
|
||||
samplecnt_t get_current_zoom () const { return samples_per_pixel; }
|
||||
|
||||
double timeline_origin() const { return _timeline_origin; }
|
||||
|
||||
/* NOTE: these functions assume that the "pixel" coordinate is
|
||||
in canvas coordinates. These coordinates already take into
|
||||
account any scrolling offsets.
|
||||
|
|
@ -191,13 +193,18 @@ public:
|
|||
is "before the start".
|
||||
*/
|
||||
|
||||
if (pixel >= 0) {
|
||||
return pixel * samples_per_pixel;
|
||||
if (pixel >= _timeline_origin) {
|
||||
return (pixel - _timeline_origin) * samples_per_pixel;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* It makes no sense to ever call these functions to convert to or from a
|
||||
* non-timeline relative pixel position, so they all assume that is
|
||||
* what they are being asked to do.
|
||||
*/
|
||||
|
||||
samplepos_t pixel_to_sample (double pixel) const {
|
||||
return pixel * samples_per_pixel;
|
||||
}
|
||||
|
|
@ -207,13 +214,24 @@ public:
|
|||
}
|
||||
|
||||
double sample_to_pixel_unrounded (samplepos_t sample) const {
|
||||
return sample / (double) samples_per_pixel;
|
||||
return (sample / (double) samples_per_pixel);
|
||||
}
|
||||
|
||||
double time_to_pixel (Temporal::timepos_t const & pos) const;
|
||||
double time_to_pixel_unrounded (Temporal::timepos_t const & pos) const;
|
||||
|
||||
double duration_to_pixels (Temporal::timecnt_t const & pos) const;
|
||||
double duration_to_pixels_unrounded (Temporal::timecnt_t const & pos) const;
|
||||
samplecnt_t pixel_duration_to_samples (double pixels) const {
|
||||
return pixels * samples_per_pixel;
|
||||
}
|
||||
|
||||
/* These two convert between timeline-relative x-axis pixel positions and
|
||||
* global canvas ones.
|
||||
*/
|
||||
|
||||
double timeline_to_canvas (double p) const { return p + _timeline_origin; }
|
||||
double canvas_to_timeline (double p) const { return p - _timeline_origin; }
|
||||
|
||||
/** computes the timeline position for an event whose coordinates
|
||||
* are in canvas units (pixels, scroll offset included). The time
|
||||
|
|
@ -390,6 +408,8 @@ public:
|
|||
int _draw_velocity;
|
||||
int _draw_channel;
|
||||
|
||||
double _timeline_origin;
|
||||
|
||||
ArdourWidgets::ArdourDropdown grid_type_selector;
|
||||
void build_grid_type_menu ();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue