tempo mappoing: use actual mouse cursors not canvas item cursors
Also some changes to attempt to do "half-twist" that will be removed soon.
This commit is contained in:
parent
f3e13848fa
commit
57398b1e5e
|
@ -1060,8 +1060,6 @@ private:
|
|||
ArdourCanvas::Rectangle* cue_marker_bar;
|
||||
ArdourCanvas::Line* ruler_separator;
|
||||
|
||||
ArdourCanvas::Arc* mapping_cursor;
|
||||
|
||||
void toggle_cue_behavior ();
|
||||
|
||||
Gtk::Label minsec_label;
|
||||
|
|
|
@ -189,17 +189,6 @@ Editor::initialize_canvas ()
|
|||
mapping_bar->set_outline(false);
|
||||
mapping_bar->set_outline_what(ArdourCanvas::Rectangle::BOTTOM);
|
||||
|
||||
mapping_cursor = new ArdourCanvas::Arc (mapping_group);
|
||||
CANVAS_DEBUG_NAME (mapping_cursor, "Mapping Cursor");
|
||||
mapping_cursor->set_fill (false);
|
||||
mapping_cursor->set_outline (true);
|
||||
mapping_cursor->set_outline_color (0xff0000ff);
|
||||
mapping_cursor->set_outline_width (3. * UIConfiguration::instance().get_ui_scale());
|
||||
mapping_cursor->set_radius ((timebar_height-5.)/2);
|
||||
mapping_cursor->set_arc (360);
|
||||
mapping_cursor->set_position (ArdourCanvas::Duple (35., (timebar_height-5.)/2.0)); // x is arbitrary at this time
|
||||
mapping_cursor->hide ();
|
||||
|
||||
range_marker_bar = new ArdourCanvas::Rectangle (range_marker_group, ArdourCanvas::Rect (0.0, timebar_top, ArdourCanvas::COORD_MAX, timebar_btm));
|
||||
CANVAS_DEBUG_NAME (range_marker_bar, "Range Marker Bar");
|
||||
|
||||
|
@ -261,7 +250,6 @@ Editor::initialize_canvas ()
|
|||
|
||||
tempo_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_bar_event), tempo_bar, TempoBarItem, "tempo bar"));
|
||||
mapping_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_bar_event), mapping_bar, MappingBarItem, "mapping bar"));
|
||||
mapping_cursor->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_bar_event), mapping_cursor, MappingCursorItem, "mapping cursor"));
|
||||
meter_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_bar_event), meter_bar, MeterBarItem, "meter bar"));
|
||||
marker_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_bar_event), marker_bar, MarkerBarItem, "marker bar"));
|
||||
cd_marker_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_ruler_bar_event), cd_marker_bar, CdMarkerBarItem, "cd marker bar"));
|
||||
|
@ -1367,6 +1355,9 @@ Editor::which_canvas_cursor(ItemType type) const
|
|||
case AutomationTrackItem:
|
||||
cursor = which_track_cursor ();
|
||||
break;
|
||||
case MappingBarItem:
|
||||
cursor = _cursors->trimmer;
|
||||
break;
|
||||
case PlayheadCursorItem:
|
||||
cursor = _cursors->grabber;
|
||||
break;
|
||||
|
@ -1523,8 +1514,8 @@ Editor::choose_canvas_cursor_on_entry (ItemType type)
|
|||
void
|
||||
Editor::update_all_enter_cursors ()
|
||||
{
|
||||
for (std::vector<EnterContext>::iterator i = _enter_stack.begin(); i != _enter_stack.end(); ++i) {
|
||||
i->cursor_ctx->change(which_canvas_cursor(i->item_type));
|
||||
for (auto & ec : _enter_stack) {
|
||||
ec.cursor_ctx->change(which_canvas_cursor (ec.item_type));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3592,15 +3592,16 @@ MappingLinearDrag::aborted (bool moved)
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
MappingStretchDrag::MappingStretchDrag (Editor* e, ArdourCanvas::Item* i, Temporal::TempoMap::WritableSharedPtr& wmap)
|
||||
MappingStretchDrag::MappingStretchDrag (Editor* e, ArdourCanvas::Item* i, Temporal::TempoMap::WritableSharedPtr& wmap, Temporal::TempoPoint& focus, XMLNode& before)
|
||||
: Drag (e, i, Temporal::BeatTime)
|
||||
, _tempo (0)
|
||||
, _focus (focus)
|
||||
, map (wmap)
|
||||
, _before_state (0)
|
||||
, direction (0.)
|
||||
, delta (0.)
|
||||
, _before_state (before)
|
||||
, _drag_valid (true)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::Drags, "New MappingStretchDrag\n");
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3608,33 +3609,17 @@ MappingStretchDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
|||
{
|
||||
Drag::start_grab (event, cursor);
|
||||
|
||||
_tempo = const_cast<TempoPoint*> (&map->metric_at (raw_grab_time().beats()).tempo());
|
||||
stringstream sstr;
|
||||
|
||||
if (adjusted_current_time (event, false) <= _tempo->time()) {
|
||||
std::cerr << "too early for " << *_tempo << std::endl;
|
||||
_drag_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
ostringstream sstr;
|
||||
if (_tempo->continuing()) {
|
||||
TempoPoint const * prev = map->previous_tempo (*_tempo);
|
||||
if (prev) {
|
||||
sstr << "end: " << fixed << setprecision(3) << prev->end_note_types_per_minute() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
sstr << "start: " << fixed << setprecision(3) << _tempo->note_types_per_minute();
|
||||
sstr << "start: " << fixed << setprecision(3) << _focus.note_types_per_minute();
|
||||
show_verbose_cursor_text (sstr.str());
|
||||
initial_npm = _focus.note_types_per_minute();
|
||||
}
|
||||
|
||||
void
|
||||
MappingStretchDrag::setup_pointer_offset ()
|
||||
{
|
||||
/* get current state */
|
||||
_before_state = &map->get_state();
|
||||
|
||||
_grab_qn = max (Beats(), raw_grab_time().beats());
|
||||
Beats grab_qn = max (Beats(), raw_grab_time().beats());
|
||||
|
||||
uint32_t divisions = _editor->get_grid_beat_divisions (_editor->grid_type());
|
||||
|
||||
|
@ -3642,8 +3627,8 @@ MappingStretchDrag::setup_pointer_offset ()
|
|||
divisions = 4;
|
||||
}
|
||||
|
||||
_grab_qn = _grab_qn.round_to_subdivision (divisions, Temporal::RoundDownAlways);
|
||||
_pointer_offset = timepos_t (_grab_qn).distance (raw_grab_time());
|
||||
grab_qn = grab_qn.round_to_subdivision (divisions, Temporal::RoundDownAlways);
|
||||
_pointer_offset = timepos_t (grab_qn).distance (raw_grab_time());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3653,20 +3638,49 @@ MappingStretchDrag::motion (GdkEvent* event, bool first_move)
|
|||
return;
|
||||
}
|
||||
|
||||
if (first_move) {
|
||||
_editor->begin_reversible_command (_("map tempo w/stretch"));
|
||||
}
|
||||
|
||||
timepos_t pf;
|
||||
|
||||
if (_editor->grid_musical()) {
|
||||
pf = adjusted_current_time (event, false);
|
||||
if (_drags->current_pointer_x() < last_pointer_x()) {
|
||||
if (direction < 0.) {
|
||||
direction = 1.;
|
||||
initial_npm += delta;
|
||||
std::cerr << "!!!!! RESET INTIIAL to " << initial_npm << std::endl;
|
||||
delta = 0.;
|
||||
}
|
||||
} else {
|
||||
pf = adjusted_current_time (event);
|
||||
if (direction >= 0.) {
|
||||
direction = -1.;
|
||||
initial_npm += delta;
|
||||
std::cerr << "!!!!! RESET INTIIAL 2 to " << initial_npm << std::endl;
|
||||
delta = 0.;
|
||||
}
|
||||
}
|
||||
|
||||
map->stretch_tempo (_tempo, timepos_t (_grab_qn).samples(), pf.samples(), _grab_qn, pf.beats());
|
||||
_editor->mapping_cursor->set_position (Duple (_editor->time_to_pixel_unrounded (pf), _editor->mapping_cursor->position().y));
|
||||
|
||||
if (_drags->current_pointer_time() >= timepos_t::from_superclock (_focus.sclock())) {
|
||||
std::cerr << "nope\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// if (_drags->current_pointer_time() <= timepos_t::from_superclock (prev.sclock())) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
/* XXX needs to scale somehow with zoom level */
|
||||
|
||||
delta += 0.5 * (last_pointer_x() - _drags->current_pointer_x());
|
||||
|
||||
double new_npm = initial_npm + delta;
|
||||
|
||||
if (new_npm < 8 || new_npm > 300) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (new_npm < 8 || new_npm > 300) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << "new tempo value will be " << initial_npm << " + " << delta << " = " << new_npm << std::endl;
|
||||
|
||||
map->stretch_tempo (_focus, new_npm);
|
||||
_editor->mid_tempo_change (Editor::MappingChanged);
|
||||
}
|
||||
|
||||
|
@ -3689,7 +3703,7 @@ MappingStretchDrag::finished (GdkEvent* event, bool movement_occurred)
|
|||
|
||||
XMLNode &after = map->get_state();
|
||||
|
||||
_editor->session()->add_command (new Temporal::TempoCommand (_("move BBT point"), _before_state, &after));
|
||||
_editor->session()->add_command (new Temporal::TempoCommand (_("tempo conform/stretch"), &_before_state, &after));
|
||||
_editor->commit_reversible_command ();
|
||||
|
||||
/* 2nd argument means "update tempo map display after the new map is
|
||||
|
@ -3778,8 +3792,6 @@ MappingTwistDrag::motion (GdkEvent* event, bool first_move)
|
|||
delta += 0.75 * (last_pointer_x() - _drags->current_pointer_x());
|
||||
|
||||
map->twist_tempi (prev, focus, next, initial_npm + delta);
|
||||
|
||||
_editor->mapping_cursor->set_position (Duple (_editor->sample_to_pixel_unrounded (superclock_to_samples (focus.sclock(), TEMPORAL_SAMPLE_RATE)), _editor->mapping_cursor->position().y));
|
||||
_editor->mid_tempo_change (Editor::MappingChanged);
|
||||
}
|
||||
|
||||
|
@ -3988,7 +4000,7 @@ TempoEndDrag::motion (GdkEvent* event, bool first_move)
|
|||
}
|
||||
|
||||
timepos_t const pos = adjusted_current_time (event, false);
|
||||
map->stretch_tempo_end (_tempo, timepos_t (_grab_qn).samples(), pos.samples());
|
||||
// map->stretch_tempo_end (_tempo, timepos_t (_grab_qn).samples(), pos.samples());
|
||||
_editor->mid_tempo_change (Editor::TempoChanged);
|
||||
|
||||
ostringstream sstr;
|
||||
|
|
|
@ -944,7 +944,7 @@ private:
|
|||
class MappingStretchDrag : public Drag
|
||||
{
|
||||
public:
|
||||
MappingStretchDrag (Editor *, ArdourCanvas::Item *, Temporal::TempoMap::WritableSharedPtr&);
|
||||
MappingStretchDrag (Editor *, ArdourCanvas::Item *, Temporal::TempoMap::WritableSharedPtr&, Temporal::TempoPoint&, XMLNode&);
|
||||
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
|
@ -962,11 +962,14 @@ public:
|
|||
void setup_pointer_offset ();
|
||||
|
||||
private:
|
||||
Temporal::TempoPoint* _tempo;
|
||||
Temporal::TempoPoint& _focus;
|
||||
Temporal::TempoMap::WritableSharedPtr map;
|
||||
Temporal::Beats _grab_qn;
|
||||
|
||||
XMLNode* _before_state;
|
||||
double direction;
|
||||
double delta;
|
||||
double initial_npm;
|
||||
|
||||
XMLNode& _before_state;
|
||||
bool _drag_valid;
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ enum ItemType {
|
|||
MeterBarItem,
|
||||
TempoBarItem,
|
||||
MappingBarItem,
|
||||
MappingCursorItem,
|
||||
RegionViewNameHighlight,
|
||||
RegionViewName,
|
||||
StartSelectionTrimItem,
|
||||
|
|
|
@ -817,7 +817,6 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
break;
|
||||
|
||||
case MappingBarItem:
|
||||
case MappingCursorItem:
|
||||
choose_mapping_drag (item, event);
|
||||
return true;
|
||||
|
||||
|
@ -1692,7 +1691,6 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
case CdMarkerBarItem:
|
||||
case TempoBarItem:
|
||||
case MappingBarItem:
|
||||
case MappingCursorItem:
|
||||
case TempoCurveItem:
|
||||
case MeterBarItem:
|
||||
case VideoBarItem:
|
||||
|
@ -1820,7 +1818,6 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
return true;
|
||||
|
||||
case MappingBarItem:
|
||||
case MappingCursorItem:
|
||||
return true;
|
||||
|
||||
case TempoBarItem:
|
||||
|
@ -1984,13 +1981,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
|
|||
choose_canvas_cursor_on_entry (item_type);
|
||||
|
||||
switch (item_type) {
|
||||
case MappingCursorItem:
|
||||
/* nothing to do ??? */
|
||||
break;
|
||||
|
||||
case MappingBarItem:
|
||||
mapping_cursor->show ();
|
||||
mapping_cursor->raise_to_top ();
|
||||
break;
|
||||
|
||||
case ControlPointItem:
|
||||
|
@ -2138,12 +2129,7 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent*, ItemType item_type)
|
|||
}
|
||||
|
||||
switch (item_type) {
|
||||
case MappingCursorItem:
|
||||
/* ignore */
|
||||
break;
|
||||
|
||||
case MappingBarItem:
|
||||
mapping_cursor->hide ();
|
||||
break;
|
||||
|
||||
case ControlPointItem:
|
||||
|
@ -2349,39 +2335,30 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, bool from_aut
|
|||
timepos_t t (where);
|
||||
bool move_snapped_cursor = true;
|
||||
|
||||
if (item == mapping_bar || item == mapping_cursor) {
|
||||
if (item == mapping_bar) {
|
||||
|
||||
/* Snap to the nearest beat, and figure out how
|
||||
* many pixels from the pointer cursor that is.
|
||||
*/
|
||||
|
||||
timepos_t snapped = _snap_to_bbt (t, RoundNearest, SnapToGrid_Unscaled, GridTypeBeat);
|
||||
const double unsnapped_pos = time_to_pixel_unrounded (t);
|
||||
const double snapped_pos = time_to_pixel_unrounded (snapped);
|
||||
Editor::EnterContext* ctx = get_enter_context (MappingBarItem);
|
||||
|
||||
if (std::abs (snapped_pos - unsnapped_pos) < 10 * UIConfiguration::instance().get_ui_scale()) {
|
||||
if (ctx) {
|
||||
timepos_t snapped = _snap_to_bbt (t, RoundNearest, SnapToGrid_Unscaled, GridTypeBeat);
|
||||
const double unsnapped_pos = time_to_pixel_unrounded (t);
|
||||
const double snapped_pos = time_to_pixel_unrounded (snapped);
|
||||
|
||||
/* Close to a beat, so snap the mapping
|
||||
* cursor *and* the snapped cursor to
|
||||
* the beat.
|
||||
*/
|
||||
if (std::abs (snapped_pos - unsnapped_pos) < 10 * UIConfiguration::instance().get_ui_scale()) {
|
||||
|
||||
mapping_cursor->show ();
|
||||
mapping_cursor->raise_to_top ();
|
||||
/* Close to a beat, so snap the mapping
|
||||
* cursor *and* the snapped cursor to
|
||||
* the beat.
|
||||
*/
|
||||
|
||||
mapping_cursor->set_position (ArdourCanvas::Duple (snapped_pos, mapping_cursor->position().y));
|
||||
set_snapped_cursor_position (snapped);
|
||||
|
||||
move_snapped_cursor = false;
|
||||
|
||||
} else {
|
||||
|
||||
/* Not close to a beat, hide the
|
||||
* mapping cursor, then move the
|
||||
* snapped cursor as normal.
|
||||
*/
|
||||
|
||||
mapping_cursor->hide ();
|
||||
ctx->cursor_ctx->change (cursors()->time_fx);
|
||||
} else {
|
||||
ctx->cursor_ctx->change (cursors()->trimmer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2947,21 +2924,12 @@ Editor::get_pointer_position (double& x, double& y) const
|
|||
void
|
||||
Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event)
|
||||
{
|
||||
if (item != mapping_cursor && item != mapping_bar) {
|
||||
if (item != mapping_bar) {
|
||||
return;
|
||||
}
|
||||
|
||||
Temporal::TempoMap::WritableSharedPtr map = begin_tempo_mapping ();
|
||||
|
||||
if (item == mapping_bar) {
|
||||
/* Drag on the bar, not the cursor: just adjust tempo up or
|
||||
* down.
|
||||
*/
|
||||
_drags->set (new MappingLinearDrag (this, item, map), event);
|
||||
std::cerr << ":Linear\n";
|
||||
return;
|
||||
}
|
||||
|
||||
/* Decide between a tempo twist drag, which we do if the
|
||||
* pointer is between two tempo markers, and a tempo stretch
|
||||
* drag, which we do if the pointer is after the last tempo
|
||||
|
@ -2973,12 +2941,27 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event)
|
|||
|
||||
TempoPoint* after = const_cast<TempoPoint*> (map->next_tempo (tempo));
|
||||
|
||||
std::cerr << "is there an after ? " << after << " for " << tempo <<std::endl;
|
||||
|
||||
if (!after || dynamic_cast<MusicTimePoint*>(after)) {
|
||||
/* Drag on the bar, not the cursor: just adjust tempo up or
|
||||
* down.
|
||||
*/
|
||||
_drags->set (new MappingLinearDrag (this, item, map), event);
|
||||
std::cerr << ":Linear\n";
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << " cursor stack: " << _cursor_stack.size() << std::endl;
|
||||
|
||||
if (_cursor_stack.empty() || _cursor_stack.back() != cursors()->grabber) {
|
||||
/* This is the final tempo, or the next one is a BBT marker.
|
||||
* No twisting, just stretch this one.
|
||||
*/
|
||||
std::cerr << "stretch!\n";
|
||||
_drags->set (new MappingStretchDrag (this, item, map), event);
|
||||
begin_reversible_command (_("map tempo/stretch"));
|
||||
XMLNode* before_state = &map->get_state();
|
||||
_drags->set (new MappingStretchDrag (this, item, map, *after, *before_state), event);
|
||||
std::cerr << ":Stretch\n";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -255,7 +255,6 @@ Editor::popup_ruler_menu (timepos_t const & where, ItemType t)
|
|||
break;
|
||||
|
||||
case MappingBarItem:
|
||||
case MappingCursorItem:
|
||||
#warning paul fix mapping bar context menu
|
||||
ruler_items.push_back (MenuElem (_("New BBT Marker"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_add_new_tempo_event), where)));
|
||||
ruler_items.push_back (MenuElem (_("New Tempo Marker"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_add_new_tempo_event), where)));
|
||||
|
|
|
@ -162,7 +162,6 @@ setup_gtk_ardour_enums ()
|
|||
REGISTER_ENUM (MeterBarItem);
|
||||
REGISTER_ENUM (TempoBarItem);
|
||||
REGISTER_ENUM (MappingBarItem);
|
||||
REGISTER_ENUM (MappingCursorItem);
|
||||
REGISTER_ENUM (RegionViewNameHighlight);
|
||||
REGISTER_ENUM (RegionViewName);
|
||||
REGISTER_ENUM (StartSelectionTrimItem);
|
||||
|
|
Loading…
Reference in New Issue