mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 07:14:56 +01:00
lollipop drag: move all selected notes
This commit is contained in:
parent
279e648a43
commit
f7130f5c02
4 changed files with 27 additions and 9 deletions
|
|
@ -7183,6 +7183,7 @@ RegionMarkerDrag::setup_pointer_sample_offset ()
|
||||||
LollipopDrag::LollipopDrag (Editor* ed, ArdourCanvas::Item* l)
|
LollipopDrag::LollipopDrag (Editor* ed, ArdourCanvas::Item* l)
|
||||||
: Drag (ed, l, Temporal::BeatTime)
|
: Drag (ed, l, Temporal::BeatTime)
|
||||||
, _primary (dynamic_cast<ArdourCanvas::Lollipop*> (l))
|
, _primary (dynamic_cast<ArdourCanvas::Lollipop*> (l))
|
||||||
|
, cumulative_delta (0.)
|
||||||
{
|
{
|
||||||
_region = reinterpret_cast<VelocityGhostRegion*> (_item->get_data ("ghostregionview"));
|
_region = reinterpret_cast<VelocityGhostRegion*> (_item->get_data ("ghostregionview"));
|
||||||
}
|
}
|
||||||
|
|
@ -7203,7 +7204,9 @@ LollipopDrag::start_grab (GdkEvent *ev, Gdk::Cursor* c)
|
||||||
bool add = Keyboard::modifier_state_equals (ev->button.state, Keyboard::PrimaryModifier);
|
bool add = Keyboard::modifier_state_equals (ev->button.state, Keyboard::PrimaryModifier);
|
||||||
bool extend = Keyboard::modifier_state_equals (ev->button.state, Keyboard::TertiaryModifier);
|
bool extend = Keyboard::modifier_state_equals (ev->button.state, Keyboard::TertiaryModifier);
|
||||||
|
|
||||||
mrv->note_selected (note, add, extend);
|
if (mrv->selection().find (note) == mrv->selection().end()) {
|
||||||
|
mrv->note_selected (note, add, extend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -7224,6 +7227,9 @@ LollipopDrag::finished (GdkEvent *ev, bool did_move)
|
||||||
MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (&_region->parent_rv);
|
MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (&_region->parent_rv);
|
||||||
assert (mrv);
|
assert (mrv);
|
||||||
|
|
||||||
|
double this_delta = velocity - note->note()->velocity();
|
||||||
|
cumulative_delta += this_delta;
|
||||||
|
|
||||||
mrv->set_velocity (note, velocity);
|
mrv->set_velocity (note, velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1577,6 +1577,7 @@ class LollipopDrag : public Drag
|
||||||
private:
|
private:
|
||||||
VelocityGhostRegion* _region;
|
VelocityGhostRegion* _region;
|
||||||
ArdourCanvas::Lollipop* _primary;
|
ArdourCanvas::Lollipop* _primary;
|
||||||
|
double cumulative_delta;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __gtk2_ardour_editor_drag_h_ */
|
#endif /* __gtk2_ardour_editor_drag_h_ */
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,7 @@ public:
|
||||||
void show_list_editor ();
|
void show_list_editor ();
|
||||||
|
|
||||||
typedef std::set<NoteBase*> Selection;
|
typedef std::set<NoteBase*> Selection;
|
||||||
Selection selection () const {
|
Selection const & selection () const {
|
||||||
return _selection;
|
return _selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
#include "editor_drag.h"
|
#include "editor_drag.h"
|
||||||
#include "gui_thread.h"
|
#include "gui_thread.h"
|
||||||
#include "midi_automation_line.h"
|
#include "midi_automation_line.h"
|
||||||
|
#include "midi_region_view.h"
|
||||||
#include "note_base.h"
|
#include "note_base.h"
|
||||||
#include "public_editor.h"
|
#include "public_editor.h"
|
||||||
#include "ui_config.h"
|
#include "ui_config.h"
|
||||||
|
|
@ -133,20 +134,32 @@ VelocityGhostRegion::drag_lolli (ArdourCanvas::Lollipop* l, GdkEventMotion* ev)
|
||||||
{
|
{
|
||||||
ArdourCanvas::Rect r (base_rect->item_to_window (base_rect->get()));
|
ArdourCanvas::Rect r (base_rect->item_to_window (base_rect->get()));
|
||||||
|
|
||||||
/* translate event y-coord so that zero matches the top of base_rect */
|
/* translate event y-coord so that zero matches the top of base_rect
|
||||||
|
* (event coordinates use window coordinate space)
|
||||||
|
*/
|
||||||
|
|
||||||
ev->y -= r.y0;
|
ev->y -= r.y0;
|
||||||
|
|
||||||
/* clamp y to be within the range defined by the base_rect height minus
|
/* clamp y to be within the range defined by the base_rect height minus
|
||||||
* the lollipop radius at top and bottom
|
* the lollipop radius at top and bottom
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const double effective_y = std::max (lollipop_radius, std::min (r.height() - (2.0 * lollipop_radius), ev->y));
|
const double effective_y = std::max (lollipop_radius, std::min (r.height() - (2.0 * lollipop_radius), ev->y));
|
||||||
|
const double newlen = r.height() - effective_y - lollipop_radius;
|
||||||
|
const double delta = newlen - l->length();
|
||||||
|
|
||||||
std::cerr << "new y " << effective_y << std::endl;
|
MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (&parent_rv);
|
||||||
|
assert (mrv);
|
||||||
|
MidiRegionView::Selection const & sel (mrv->selection());
|
||||||
|
|
||||||
l->set (ArdourCanvas::Duple (l->x(), effective_y), r.height() - effective_y - lollipop_radius, lollipop_radius);
|
for (auto & s : sel) {
|
||||||
|
GhostEvent* x = find_event (s->note());
|
||||||
|
|
||||||
|
if (x) {
|
||||||
|
ArdourCanvas::Lollipop* l = dynamic_cast<ArdourCanvas::Lollipop*> (x->item);
|
||||||
|
l->set (ArdourCanvas::Duple (l->x(), l->y0() - delta), l->length() + delta, lollipop_radius);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -155,14 +168,12 @@ VelocityGhostRegion::y_position_to_velocity (double y) const
|
||||||
const ArdourCanvas::Rect r (base_rect->get());
|
const ArdourCanvas::Rect r (base_rect->get());
|
||||||
int velocity;
|
int velocity;
|
||||||
|
|
||||||
std::cerr << "y = " << y << " h = " << r.height() << std::endl;
|
|
||||||
|
|
||||||
if (y >= r.height() - (2.0 * lollipop_radius)) {
|
if (y >= r.height() - (2.0 * lollipop_radius)) {
|
||||||
velocity = 0;
|
velocity = 0;
|
||||||
} else if (y <= lollipop_radius) {
|
} else if (y <= lollipop_radius) {
|
||||||
velocity = 127;
|
velocity = 127;
|
||||||
} else {
|
} else {
|
||||||
velocity = floor (127. * ((r.height() - y) / r.height()));
|
velocity = floor (127. * (((r.height() - 2.0 * lollipop_radius)- y) / r.height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr << " y = " << y << " vel = " << velocity << std::endl;
|
std::cerr << " y = " << y << " vel = " << velocity << std::endl;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue