mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-11 09:06:33 +01:00
switch samples_per_pixel to integer type
This commit is contained in:
parent
691be68ac2
commit
aaaeb958c1
4 changed files with 48 additions and 45 deletions
|
|
@ -912,7 +912,7 @@ Editor::zoom_adjustment_changed ()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double fpu = zoom_range_clock->current_duration() / _visible_canvas_width;
|
framecnt_t fpu = llrintf (zoom_range_clock->current_duration() / _visible_canvas_width);
|
||||||
bool clamped = clamp_samples_per_pixel (fpu);
|
bool clamped = clamp_samples_per_pixel (fpu);
|
||||||
|
|
||||||
if (clamped) {
|
if (clamped) {
|
||||||
|
|
@ -1123,7 +1123,7 @@ Editor::map_position_change (framepos_t frame)
|
||||||
void
|
void
|
||||||
Editor::center_screen (framepos_t frame)
|
Editor::center_screen (framepos_t frame)
|
||||||
{
|
{
|
||||||
double const page = _visible_canvas_width * samples_per_pixel;
|
framecnt_t const page = _visible_canvas_width * samples_per_pixel;
|
||||||
|
|
||||||
/* if we're off the page, then scroll.
|
/* if we're off the page, then scroll.
|
||||||
*/
|
*/
|
||||||
|
|
@ -2263,7 +2263,10 @@ Editor::set_state (const XMLNode& node, int /*version*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prop = node.property ("zoom"))) {
|
if ((prop = node.property ("zoom"))) {
|
||||||
reset_zoom (PBD::atof (prop->value()));
|
/* older versions of ardour used floating point samples_per_pixel */
|
||||||
|
double f = PBD::atof (prop->value());
|
||||||
|
cerr << "LOADED ZOOM from " << prop->value() << " as " << f << endl;
|
||||||
|
reset_zoom (llrintf (f));
|
||||||
} else {
|
} else {
|
||||||
reset_zoom (samples_per_pixel);
|
reset_zoom (samples_per_pixel);
|
||||||
}
|
}
|
||||||
|
|
@ -2485,7 +2488,8 @@ Editor::get_state ()
|
||||||
maybe_add_mixer_strip_width (*node);
|
maybe_add_mixer_strip_width (*node);
|
||||||
|
|
||||||
node->add_property ("zoom-focus", enum_2_string (zoom_focus));
|
node->add_property ("zoom-focus", enum_2_string (zoom_focus));
|
||||||
snprintf (buf, sizeof(buf), "%f", samples_per_pixel);
|
|
||||||
|
snprintf (buf, sizeof(buf), "%" PRId64, samples_per_pixel);
|
||||||
node->add_property ("zoom", buf);
|
node->add_property ("zoom", buf);
|
||||||
node->add_property ("snap-to", enum_2_string (_snap_type));
|
node->add_property ("snap-to", enum_2_string (_snap_type));
|
||||||
node->add_property ("snap-mode", enum_2_string (_snap_mode));
|
node->add_property ("snap-mode", enum_2_string (_snap_mode));
|
||||||
|
|
@ -4115,16 +4119,16 @@ Editor::reset_y_origin (double y)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Editor::reset_zoom (double fpp)
|
Editor::reset_zoom (framecnt_t spp)
|
||||||
{
|
{
|
||||||
clamp_samples_per_pixel (fpp);
|
clamp_samples_per_pixel (spp);
|
||||||
|
|
||||||
if (fpp == samples_per_pixel) {
|
if (spp == samples_per_pixel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pending_visual_change.add (VisualChange::ZoomLevel);
|
pending_visual_change.add (VisualChange::ZoomLevel);
|
||||||
pending_visual_change.samples_per_pixel = fpp;
|
pending_visual_change.samples_per_pixel = spp;
|
||||||
ensure_visual_change_idle_handler ();
|
ensure_visual_change_idle_handler ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4235,17 +4239,18 @@ Editor::use_visual_state (VisualState& vs)
|
||||||
* @param fpu New frames per unit; should already have been clamped so that it is sensible.
|
* @param fpu New frames per unit; should already have been clamped so that it is sensible.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Editor::set_samples_per_pixel (double fpp)
|
Editor::set_samples_per_pixel (framecnt_t spp)
|
||||||
{
|
{
|
||||||
|
clamp_samples_per_pixel (spp);
|
||||||
|
samples_per_pixel = spp;
|
||||||
|
|
||||||
if (tempo_lines) {
|
if (tempo_lines) {
|
||||||
tempo_lines->tempo_map_changed();
|
tempo_lines->tempo_map_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
samples_per_pixel = fpp;
|
|
||||||
|
|
||||||
/* convert fpu to frame count */
|
/* convert fpu to frame count */
|
||||||
|
|
||||||
framepos_t frames = (framepos_t) floor (samples_per_pixel * _visible_canvas_width);
|
framepos_t frames = samples_per_pixel * _visible_canvas_width;
|
||||||
|
|
||||||
if (samples_per_pixel != zoom_range_clock->current_duration()) {
|
if (samples_per_pixel != zoom_range_clock->current_duration()) {
|
||||||
zoom_range_clock->set (frames);
|
zoom_range_clock->set (frames);
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||||
framepos_t leftmost_sample() const { return leftmost_frame; }
|
framepos_t leftmost_sample() const { return leftmost_frame; }
|
||||||
|
|
||||||
framecnt_t current_page_samples() const {
|
framecnt_t current_page_samples() const {
|
||||||
return (framecnt_t) floor (_visible_canvas_width * samples_per_pixel);
|
return (framecnt_t) _visible_canvas_width * samples_per_pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
double visible_canvas_height () const {
|
double visible_canvas_height () const {
|
||||||
|
|
@ -216,18 +216,18 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (pixel >= 0) {
|
if (pixel >= 0) {
|
||||||
return (framepos_t) rint (pixel * samples_per_pixel);
|
return pixel * samples_per_pixel;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double sample_to_pixel (framepos_t sample) const {
|
double sample_to_pixel (framepos_t sample) const {
|
||||||
return rint (sample / samples_per_pixel);
|
return sample / samples_per_pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
double sample_to_pixel_unrounded (framepos_t sample) const {
|
double sample_to_pixel_unrounded (framepos_t sample) const {
|
||||||
return sample / samples_per_pixel;
|
return sample / (double) samples_per_pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* selection */
|
/* selection */
|
||||||
|
|
@ -274,7 +274,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||||
|
|
||||||
void set_zoom_focus (Editing::ZoomFocus);
|
void set_zoom_focus (Editing::ZoomFocus);
|
||||||
Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
|
Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
|
||||||
double get_current_zoom () const { return samples_per_pixel; }
|
framecnt_t get_current_zoom () const { return samples_per_pixel; }
|
||||||
void cycle_zoom_focus ();
|
void cycle_zoom_focus ();
|
||||||
void temporal_zoom_step (bool coarser);
|
void temporal_zoom_step (bool coarser);
|
||||||
void tav_zoom_step (bool coarser);
|
void tav_zoom_step (bool coarser);
|
||||||
|
|
@ -360,7 +360,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||||
void reset_x_origin (framepos_t);
|
void reset_x_origin (framepos_t);
|
||||||
void reset_x_origin_to_follow_playhead ();
|
void reset_x_origin_to_follow_playhead ();
|
||||||
void reset_y_origin (double);
|
void reset_y_origin (double);
|
||||||
void reset_zoom (double);
|
void reset_zoom (framecnt_t);
|
||||||
void reposition_and_zoom (framepos_t, double);
|
void reposition_and_zoom (framepos_t, double);
|
||||||
|
|
||||||
framepos_t get_preferred_edit_position (bool ignore_playhead = false, bool use_context_click = false);
|
framepos_t get_preferred_edit_position (bool ignore_playhead = false, bool use_context_click = false);
|
||||||
|
|
@ -466,7 +466,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||||
VisualState (bool with_tracks);
|
VisualState (bool with_tracks);
|
||||||
~VisualState ();
|
~VisualState ();
|
||||||
double y_position;
|
double y_position;
|
||||||
double samples_per_pixel;
|
framecnt_t samples_per_pixel;
|
||||||
framepos_t leftmost_frame;
|
framepos_t leftmost_frame;
|
||||||
Editing::ZoomFocus zoom_focus;
|
Editing::ZoomFocus zoom_focus;
|
||||||
GUIObjectState* gui_state;
|
GUIObjectState* gui_state;
|
||||||
|
|
@ -485,12 +485,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||||
void start_visual_state_op (uint32_t n);
|
void start_visual_state_op (uint32_t n);
|
||||||
void cancel_visual_state_op (uint32_t n);
|
void cancel_visual_state_op (uint32_t n);
|
||||||
|
|
||||||
framepos_t leftmost_frame;
|
framepos_t leftmost_frame;
|
||||||
double samples_per_pixel;
|
framecnt_t samples_per_pixel;
|
||||||
Editing::ZoomFocus zoom_focus;
|
Editing::ZoomFocus zoom_focus;
|
||||||
|
|
||||||
void set_samples_per_pixel (double);
|
void set_samples_per_pixel (framecnt_t);
|
||||||
bool clamp_samples_per_pixel (double &) const;
|
bool clamp_samples_per_pixel (framecnt_t &) const;
|
||||||
|
|
||||||
Editing::MouseMode mouse_mode;
|
Editing::MouseMode mouse_mode;
|
||||||
Editing::MouseMode pre_internal_mouse_mode;
|
Editing::MouseMode pre_internal_mouse_mode;
|
||||||
|
|
@ -1003,10 +1003,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||||
YOrigin = 0x4
|
YOrigin = 0x4
|
||||||
};
|
};
|
||||||
|
|
||||||
Type pending;
|
Type pending;
|
||||||
framepos_t time_origin;
|
framepos_t time_origin;
|
||||||
double samples_per_pixel;
|
framecnt_t samples_per_pixel;
|
||||||
double y_origin;
|
double y_origin;
|
||||||
|
|
||||||
int idle_handler_id;
|
int idle_handler_id;
|
||||||
/** true if we are currently in the idle handler */
|
/** true if we are currently in the idle handler */
|
||||||
|
|
@ -1190,7 +1190,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||||
void temporal_zoom_region (bool both_axes);
|
void temporal_zoom_region (bool both_axes);
|
||||||
void zoom_to_region (bool both_axes);
|
void zoom_to_region (bool both_axes);
|
||||||
void temporal_zoom_session ();
|
void temporal_zoom_session ();
|
||||||
void temporal_zoom (double scale);
|
void temporal_zoom (framecnt_t samples_per_pixel);
|
||||||
void temporal_zoom_by_frame (framepos_t start, framepos_t end);
|
void temporal_zoom_by_frame (framepos_t start, framepos_t end);
|
||||||
void temporal_zoom_to_frame (bool coarser, framepos_t frame);
|
void temporal_zoom_to_frame (bool coarser, framepos_t frame);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1331,17 +1331,17 @@ Editor::tav_zoom_smooth (bool coarser, bool force_all)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Editor::clamp_samples_per_pixel (double& fpp) const
|
Editor::clamp_samples_per_pixel (framecnt_t& fpp) const
|
||||||
{
|
{
|
||||||
bool clamped = false;
|
bool clamped = false;
|
||||||
|
|
||||||
if (fpp < 1.0) {
|
if (fpp < 1) {
|
||||||
fpp = 1.0;
|
fpp = 1;
|
||||||
clamped = true;
|
clamped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_framepos / fpp < 800) {
|
if (max_framepos / fpp < 800) {
|
||||||
fpp = max_framepos / 800.0;
|
fpp = max_framepos / 800;
|
||||||
clamped = true;
|
clamped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1353,19 +1353,19 @@ Editor::temporal_zoom_step (bool coarser)
|
||||||
{
|
{
|
||||||
ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step, coarser)
|
ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step, coarser)
|
||||||
|
|
||||||
double nfpp = samples_per_pixel;
|
framecnt_t nspp = samples_per_pixel;
|
||||||
|
|
||||||
if (coarser) {
|
if (coarser) {
|
||||||
nfpp = min (9e6, nfpp * 1.61803399);
|
nspp *= 2;
|
||||||
} else {
|
} else {
|
||||||
nfpp = max (1.0, nfpp / 1.61803399);
|
nspp /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
temporal_zoom (nfpp);
|
temporal_zoom (nspp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Editor::temporal_zoom (double fpp)
|
Editor::temporal_zoom (framecnt_t fpp)
|
||||||
{
|
{
|
||||||
if (!_session) {
|
if (!_session) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1380,7 +1380,7 @@ Editor::temporal_zoom (double fpp)
|
||||||
framepos_t leftmost_after_zoom = 0;
|
framepos_t leftmost_after_zoom = 0;
|
||||||
framepos_t where;
|
framepos_t where;
|
||||||
bool in_track_canvas;
|
bool in_track_canvas;
|
||||||
double nfpp;
|
framecnt_t nfpp;
|
||||||
double l;
|
double l;
|
||||||
|
|
||||||
clamp_samples_per_pixel (fpp);
|
clamp_samples_per_pixel (fpp);
|
||||||
|
|
@ -1388,16 +1388,14 @@ Editor::temporal_zoom (double fpp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nfpp = fpp;
|
|
||||||
|
|
||||||
// Imposing an arbitrary limit to zoom out as too much zoom out produces
|
// Imposing an arbitrary limit to zoom out as too much zoom out produces
|
||||||
// segfaults for lack of memory. If somebody decides this is not high enough I
|
// segfaults for lack of memory. If somebody decides this is not high enough I
|
||||||
// believe it can be raisen to higher values but some limit must be in place.
|
// believe it can be raisen to higher values but some limit must be in place.
|
||||||
if (nfpp > 8e+08) {
|
|
||||||
nfpp = 8e+08;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_page_size = (framepos_t) floor (_visible_canvas_width * nfpp);
|
nfpp = min (fpp, 8589934592);
|
||||||
|
nfpp = max ((framecnt_t) 1, fpp);
|
||||||
|
|
||||||
|
new_page_size = _visible_canvas_width;
|
||||||
half_page_size = new_page_size / 2;
|
half_page_size = new_page_size / 2;
|
||||||
|
|
||||||
switch (zoom_focus) {
|
switch (zoom_focus) {
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
|
||||||
virtual void add_toplevel_controls (Gtk::Container&) = 0;
|
virtual void add_toplevel_controls (Gtk::Container&) = 0;
|
||||||
virtual void set_zoom_focus (Editing::ZoomFocus) = 0;
|
virtual void set_zoom_focus (Editing::ZoomFocus) = 0;
|
||||||
virtual Editing::ZoomFocus get_zoom_focus () const = 0;
|
virtual Editing::ZoomFocus get_zoom_focus () const = 0;
|
||||||
virtual gdouble get_current_zoom () const = 0;
|
virtual framecnt_t get_current_zoom () const = 0;
|
||||||
virtual PlaylistSelector& playlist_selector() const = 0;
|
virtual PlaylistSelector& playlist_selector() const = 0;
|
||||||
virtual void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>) = 0;
|
virtual void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>) = 0;
|
||||||
virtual void new_playlists (TimeAxisView*) = 0;
|
virtual void new_playlists (TimeAxisView*) = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue