_snap_mode = SnapOff;
set_snap_mode (_snap_mode);
set_mouse_mode (MouseObject, true);
- pre_internal_mouse_mode = MouseObject;
pre_internal_snap_type = _snap_type;
pre_internal_snap_mode = _snap_mode;
internal_snap_type = _snap_type;
edit_items.push_back (MenuElem (_("Select All in Range"), sigc::mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
edit_items.push_back (SeparatorElem());
- edit_items.push_back (MenuElem (_("Set Loop from Range"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_selection), false)));
- edit_items.push_back (MenuElem (_("Set Punch from Range"), sigc::mem_fun(*this, &Editor::set_punch_from_selection)));
- edit_items.push_back (MenuElem (_("Set Session Start/End from Range"), sigc::mem_fun(*this, &Editor::set_session_extents_from_selection)));
+ edit_items.push_back (MenuElem (_("Set Loop from Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_selection), false)));
+ edit_items.push_back (MenuElem (_("Set Punch from Selection"), sigc::mem_fun(*this, &Editor::set_punch_from_selection)));
+ edit_items.push_back (MenuElem (_("Set Session Start/End from Selection"), sigc::mem_fun(*this, &Editor::set_session_extents_from_selection)));
edit_items.push_back (SeparatorElem());
edit_items.push_back (MenuElem (_("Add Range Markers"), sigc::mem_fun (*this, &Editor::add_location_from_selection)));
{
unsigned int snap_ind = (unsigned int)st;
+ if (internal_editing()) {
+ internal_snap_type = st;
+ } else {
+ pre_internal_snap_type = st;
+ }
+
_snap_type = st;
if (snap_ind > snap_type_strings.size() - 1) {
break;
}
+ redisplay_tempo (false);
+
SnapChanged (); /* EMIT SIGNAL */
}
return offset;
}
-Evoral::MusicalTime
+unsigned
+Editor::get_grid_beat_divisions(framepos_t position)
+{
+ switch (_snap_type) {
+ case SnapToBeatDiv128: return 128;
+ case SnapToBeatDiv64: return 64;
+ case SnapToBeatDiv32: return 32;
+ case SnapToBeatDiv28: return 28;
+ case SnapToBeatDiv24: return 24;
+ case SnapToBeatDiv20: return 20;
+ case SnapToBeatDiv16: return 16;
+ case SnapToBeatDiv14: return 14;
+ case SnapToBeatDiv12: return 12;
+ case SnapToBeatDiv10: return 10;
+ case SnapToBeatDiv8: return 8;
+ case SnapToBeatDiv7: return 7;
+ case SnapToBeatDiv6: return 6;
+ case SnapToBeatDiv5: return 5;
+ case SnapToBeatDiv4: return 4;
+ case SnapToBeatDiv3: return 3;
+ case SnapToBeatDiv2: return 2;
+ default: return 0;
+ }
+ return 0;
+}
+
+Evoral::Beats
Editor::get_grid_type_as_beats (bool& success, framepos_t position)
{
success = true;
+ const unsigned divisions = get_grid_beat_divisions(position);
+ if (divisions) {
+ return Evoral::Beats(1.0 / (double)get_grid_beat_divisions(position));
+ }
+
switch (_snap_type) {
case SnapToBeat:
- return Evoral::MusicalTime(1.0);
- break;
-
- case SnapToBeatDiv128:
- return Evoral::MusicalTime(1.0/128.0);
- break;
- case SnapToBeatDiv64:
- return Evoral::MusicalTime(1.0/64.0);
- break;
- case SnapToBeatDiv32:
- return Evoral::MusicalTime(1.0/32.0);
- break;
- case SnapToBeatDiv28:
- return Evoral::MusicalTime(1.0/28.0);
- break;
- case SnapToBeatDiv24:
- return Evoral::MusicalTime(1.0/24.0);
- break;
- case SnapToBeatDiv20:
- return Evoral::MusicalTime(1.0/20.0);
- break;
- case SnapToBeatDiv16:
- return Evoral::MusicalTime(1.0/16.0);
- break;
- case SnapToBeatDiv14:
- return Evoral::MusicalTime(1.0/14.0);
- break;
- case SnapToBeatDiv12:
- return Evoral::MusicalTime(1.0/12.0);
- break;
- case SnapToBeatDiv10:
- return Evoral::MusicalTime(1.0/10.0);
- break;
- case SnapToBeatDiv8:
- return Evoral::MusicalTime(1.0/8.0);
- break;
- case SnapToBeatDiv7:
- return Evoral::MusicalTime(1.0/7.0);
- break;
- case SnapToBeatDiv6:
- return Evoral::MusicalTime(1.0/6.0);
- break;
- case SnapToBeatDiv5:
- return Evoral::MusicalTime(1.0/5.0);
- break;
- case SnapToBeatDiv4:
- return Evoral::MusicalTime(1.0/4.0);
- break;
- case SnapToBeatDiv3:
- return Evoral::MusicalTime(1.0/3.0);
- break;
- case SnapToBeatDiv2:
- return Evoral::MusicalTime(1.0/2.0);
- break;
-
+ return Evoral::Beats(1.0);
case SnapToBar:
if (_session) {
- return Evoral::MusicalTime(_session->tempo_map().meter_at (position).divisions_per_bar());
+ return Evoral::Beats(_session->tempo_map().meter_at (position).divisions_per_bar());
}
break;
-
- case SnapToCDFrame:
- case SnapToTimecodeFrame:
- case SnapToTimecodeSeconds:
- case SnapToTimecodeMinutes:
- case SnapToSeconds:
- case SnapToMinutes:
- case SnapToRegionStart:
- case SnapToRegionEnd:
- case SnapToRegionSync:
- case SnapToRegionBoundary:
default:
success = false;
break;
}
- return Evoral::MusicalTime();
+ return Evoral::Beats();
}
framecnt_t
}
framepos_t
-Editor::get_preferred_edit_position (bool ignore_playhead, bool from_context_menu)
+Editor::get_preferred_edit_position (bool ignore_playhead, bool from_context_menu, bool from_outside_canvas)
{
bool ignored;
framepos_t where = 0;
if(Profile->get_mixbus())
if (ep == EditAtSelectedMarker)
ep=EditAtPlayhead;
-
- if (from_context_menu && (ep == EditAtMouse)) {
+
+ if (from_outside_canvas && (ep == EditAtMouse)) {
+ ep = EditAtPlayhead;
+ } else if (from_context_menu && (ep == EditAtMouse)) {
return canvas_event_sample (&context_click_event, 0, 0);
}