switch samples_per_pixel to integer type
This commit is contained in:
parent
691be68ac2
commit
aaaeb958c1
|
@ -912,7 +912,7 @@ Editor::zoom_adjustment_changed ()
|
|||
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);
|
||||
|
||||
if (clamped) {
|
||||
|
@ -1123,7 +1123,7 @@ Editor::map_position_change (framepos_t frame)
|
|||
void
|
||||
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.
|
||||
*/
|
||||
|
@ -2263,7 +2263,10 @@ Editor::set_state (const XMLNode& node, int /*version*/)
|
|||
}
|
||||
|
||||
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 {
|
||||
reset_zoom (samples_per_pixel);
|
||||
}
|
||||
|
@ -2485,7 +2488,8 @@ Editor::get_state ()
|
|||
maybe_add_mixer_strip_width (*node);
|
||||
|
||||
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 ("snap-to", enum_2_string (_snap_type));
|
||||
node->add_property ("snap-mode", enum_2_string (_snap_mode));
|
||||
|
@ -4115,16 +4119,16 @@ Editor::reset_y_origin (double y)
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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 ();
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
*/
|
||||
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) {
|
||||
tempo_lines->tempo_map_changed();
|
||||
}
|
||||
|
||||
samples_per_pixel = fpp;
|
||||
|
||||
/* 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()) {
|
||||
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; }
|
||||
|
||||
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 {
|
||||
|
@ -216,18 +216,18 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
*/
|
||||
|
||||
if (pixel >= 0) {
|
||||
return (framepos_t) rint (pixel * samples_per_pixel);
|
||||
return pixel * samples_per_pixel;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
double sample_to_pixel (framepos_t sample) const {
|
||||
return rint (sample / samples_per_pixel);
|
||||
double sample_to_pixel (framepos_t sample) const {
|
||||
return sample / samples_per_pixel;
|
||||
}
|
||||
|
||||
double sample_to_pixel_unrounded (framepos_t sample) const {
|
||||
return sample / samples_per_pixel;
|
||||
return sample / (double) samples_per_pixel;
|
||||
}
|
||||
|
||||
/* selection */
|
||||
|
@ -274,7 +274,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
|
||||
void set_zoom_focus (Editing::ZoomFocus);
|
||||
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 temporal_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_to_follow_playhead ();
|
||||
void reset_y_origin (double);
|
||||
void reset_zoom (double);
|
||||
void reset_zoom (framecnt_t);
|
||||
void reposition_and_zoom (framepos_t, double);
|
||||
|
||||
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 ();
|
||||
double y_position;
|
||||
double samples_per_pixel;
|
||||
framecnt_t samples_per_pixel;
|
||||
framepos_t leftmost_frame;
|
||||
Editing::ZoomFocus zoom_focus;
|
||||
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 cancel_visual_state_op (uint32_t n);
|
||||
|
||||
framepos_t leftmost_frame;
|
||||
double samples_per_pixel;
|
||||
framepos_t leftmost_frame;
|
||||
framecnt_t samples_per_pixel;
|
||||
Editing::ZoomFocus zoom_focus;
|
||||
|
||||
void set_samples_per_pixel (double);
|
||||
bool clamp_samples_per_pixel (double &) const;
|
||||
void set_samples_per_pixel (framecnt_t);
|
||||
bool clamp_samples_per_pixel (framecnt_t &) const;
|
||||
|
||||
Editing::MouseMode mouse_mode;
|
||||
Editing::MouseMode pre_internal_mouse_mode;
|
||||
|
@ -1003,10 +1003,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
YOrigin = 0x4
|
||||
};
|
||||
|
||||
Type pending;
|
||||
Type pending;
|
||||
framepos_t time_origin;
|
||||
double samples_per_pixel;
|
||||
double y_origin;
|
||||
framecnt_t samples_per_pixel;
|
||||
double y_origin;
|
||||
|
||||
int idle_handler_id;
|
||||
/** 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 zoom_to_region (bool both_axes);
|
||||
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_to_frame (bool coarser, framepos_t frame);
|
||||
|
||||
|
|
|
@ -1331,17 +1331,17 @@ Editor::tav_zoom_smooth (bool coarser, bool force_all)
|
|||
}
|
||||
|
||||
bool
|
||||
Editor::clamp_samples_per_pixel (double& fpp) const
|
||||
Editor::clamp_samples_per_pixel (framecnt_t& fpp) const
|
||||
{
|
||||
bool clamped = false;
|
||||
|
||||
if (fpp < 1.0) {
|
||||
fpp = 1.0;
|
||||
if (fpp < 1) {
|
||||
fpp = 1;
|
||||
clamped = true;
|
||||
}
|
||||
|
||||
if (max_framepos / fpp < 800) {
|
||||
fpp = max_framepos / 800.0;
|
||||
fpp = max_framepos / 800;
|
||||
clamped = true;
|
||||
}
|
||||
|
||||
|
@ -1353,19 +1353,19 @@ Editor::temporal_zoom_step (bool coarser)
|
|||
{
|
||||
ENSURE_GUI_THREAD (*this, &Editor::temporal_zoom_step, coarser)
|
||||
|
||||
double nfpp = samples_per_pixel;
|
||||
framecnt_t nspp = samples_per_pixel;
|
||||
|
||||
if (coarser) {
|
||||
nfpp = min (9e6, nfpp * 1.61803399);
|
||||
nspp *= 2;
|
||||
} else {
|
||||
nfpp = max (1.0, nfpp / 1.61803399);
|
||||
nspp /= 2;
|
||||
}
|
||||
|
||||
temporal_zoom (nfpp);
|
||||
temporal_zoom (nspp);
|
||||
}
|
||||
|
||||
void
|
||||
Editor::temporal_zoom (double fpp)
|
||||
Editor::temporal_zoom (framecnt_t fpp)
|
||||
{
|
||||
if (!_session) {
|
||||
return;
|
||||
|
@ -1380,7 +1380,7 @@ Editor::temporal_zoom (double fpp)
|
|||
framepos_t leftmost_after_zoom = 0;
|
||||
framepos_t where;
|
||||
bool in_track_canvas;
|
||||
double nfpp;
|
||||
framecnt_t nfpp;
|
||||
double l;
|
||||
|
||||
clamp_samples_per_pixel (fpp);
|
||||
|
@ -1388,16 +1388,14 @@ Editor::temporal_zoom (double fpp)
|
|||
return;
|
||||
}
|
||||
|
||||
nfpp = fpp;
|
||||
|
||||
// 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
|
||||
// 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;
|
||||
|
||||
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 set_zoom_focus (Editing::ZoomFocus) = 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 void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>) = 0;
|
||||
virtual void new_playlists (TimeAxisView*) = 0;
|
||||
|
|
Loading…
Reference in New Issue