13
0

snap-revisited: replace hardcoded ruler-density with a configgable value

This commit is contained in:
Ben Loftis 2021-02-20 10:25:10 -06:00
parent 4a5b355d3d
commit 21a66c01ea
3 changed files with 16 additions and 2 deletions

View File

@ -1073,8 +1073,11 @@ Editor::compute_bbt_ruler_scale (samplepos_t lower, samplepos_t upper)
bbt_bars = _session->tempo_map().bbt_at_beat (ceil_upper_beat).bars - _session->tempo_map().bbt_at_beat (floor_lower_beat).bars;
beats = (ceil_upper_beat - floor_lower_beat);// - bbt_bars; possible thinko; this fixes the problem (for me) where measure lines alternately appear&disappear while playing at certain zoom scales
double beat_density = ((beats + 1) * ((double) (upper - lower) / (double) (1 + beat_after_upper_pos - beat_before_lower_pos))) / 5.0;
double ruler_line_granularity = UIConfiguration::instance().get_ruler_granularity (); //in pixels
ruler_line_granularity = _visible_canvas_width / (ruler_line_granularity*5); //fudge factor '5' probably related to (4+1 beats)/measure, I think
beats = (ceil_upper_beat - floor_lower_beat);
double beat_density = ((beats + 1) * ((double) (upper - lower) / (double) (1 + beat_after_upper_pos - beat_before_lower_pos))) / (float)ruler_line_granularity;
/* Only show the bar helper if there aren't many bars on the screen */
if ((bbt_bars < 2) || (beats < 5)) {

View File

@ -2687,6 +2687,16 @@ RCOptionEditor::RCOptionEditor ()
1, 10
));
add_option (_("Editor/Snap"),
new SpinOption<uint32_t> (
"ruler-granularity",
_("Approximate Grid/Ruler granularity (pixels)"),
sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_ruler_granularity),
sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_ruler_granularity),
1, 100,
1, 10
));
add_option (_("Editor/Snap"),
new BoolOption (
"show-snapped-cursor",

View File

@ -116,6 +116,7 @@ UI_CONFIG_VARIABLE (bool, use_note_bars_for_velocity, "use-note-bars-for-velocit
UI_CONFIG_VARIABLE (bool, use_note_color_for_velocity, "use-note-color-for-velocity", true)
UI_CONFIG_VARIABLE (bool, show_snapped_cursor, "show-snapped-cursor", true)
UI_CONFIG_VARIABLE (uint32_t, snap_threshold, "snap-threshold", 25)
UI_CONFIG_VARIABLE (uint32_t, ruler_granularity, "ruler-granularity", 25)
UI_CONFIG_VARIABLE (bool, snap_to_marks, "snap-to-marks", true)
UI_CONFIG_VARIABLE (bool, snap_to_region_sync, "snap-to-region-sync", true)
UI_CONFIG_VARIABLE (bool, snap_to_region_start, "snap-to-region-start", true)