lollis: also adjust velocity bars during the drag
This commit is contained in:
parent
96c9f2ee19
commit
2d9a2ad668
|
@ -145,3 +145,10 @@ Hit::set_ignore_events (bool ignore)
|
|||
{
|
||||
_polygon->set_ignore_events (ignore);
|
||||
}
|
||||
|
||||
double
|
||||
Hit::visual_velocity() const
|
||||
{
|
||||
/* We don't display velocity in any explicit way */
|
||||
return 0.0;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,8 @@ public:
|
|||
|
||||
static ArdourCanvas::Points points(ArdourCanvas::Distance height);
|
||||
|
||||
double visual_velocity() const;
|
||||
|
||||
private:
|
||||
ArdourCanvas::Polygon* _polygon;
|
||||
};
|
||||
|
|
|
@ -1859,7 +1859,6 @@ MidiRegionView::update_sustained (Note* ev, bool update_ghost_regions)
|
|||
const uint32_t base_col = ev->base_color();
|
||||
ev->set_fill_color(base_col);
|
||||
ev->set_outline_color(ev->calculate_outline(base_col, ev->selected()));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3378,8 +3377,6 @@ MidiRegionView::set_velocity (NoteBase* note, int velocity)
|
|||
|
||||
int delta = velocity - note->note()->velocity();
|
||||
|
||||
std::cerr << "vel delta = " << delta << std::endl;
|
||||
|
||||
start_note_diff_command (_("set velocities"));
|
||||
|
||||
for (Selection::iterator i = _selection.begin(); i != _selection.end();) {
|
||||
|
@ -4660,3 +4657,11 @@ MidiRegionView::quantize_selected_notes ()
|
|||
|
||||
trackview.editor().apply_midi_note_edit_op (quant, rs);
|
||||
}
|
||||
|
||||
void
|
||||
MidiRegionView::sync_velocity_drag (double factor)
|
||||
{
|
||||
for (auto & s : _selection) {
|
||||
s->set_velocity (s->visual_velocity() * factor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -505,6 +505,8 @@ public:
|
|||
std::shared_ptr<SysEx> find_canvas_sys_ex (ARDOUR::MidiModel::SysExPtr s);
|
||||
|
||||
friend class VelocityGhostRegion;
|
||||
void sync_velocity_drag (double factor);
|
||||
|
||||
void update_note (NoteBase*, bool update_ghost_regions = true);
|
||||
void update_sustained (Note *, bool update_ghost_regions = true);
|
||||
void update_hit (Hit *, bool update_ghost_regions = true);
|
||||
|
|
|
@ -32,122 +32,128 @@ using ArdourCanvas::Duple;
|
|||
Note::Note (
|
||||
MidiRegionView& region, ArdourCanvas::Item* parent, const std::shared_ptr<NoteType> note, bool with_events)
|
||||
: NoteBase (region, with_events, note)
|
||||
, _note (new ArdourCanvas::Note (parent))
|
||||
, _visual_note (new ArdourCanvas::Note (parent))
|
||||
{
|
||||
CANVAS_DEBUG_NAME (_note, "note");
|
||||
set_item (_note);
|
||||
CANVAS_DEBUG_NAME (_visual_note, "note");
|
||||
set_item (_visual_note);
|
||||
}
|
||||
|
||||
Note::~Note ()
|
||||
{
|
||||
delete _note;
|
||||
delete _visual_note;
|
||||
}
|
||||
|
||||
void
|
||||
Note::move_event (double dx, double dy)
|
||||
{
|
||||
_note->set (_note->get().translate (Duple (dx, dy)));
|
||||
_visual_note->set (_visual_note->get().translate (Duple (dx, dy)));
|
||||
}
|
||||
|
||||
Coord
|
||||
Note::x0 () const
|
||||
{
|
||||
return _note->x0 ();
|
||||
return _visual_note->x0 ();
|
||||
}
|
||||
|
||||
Coord
|
||||
Note::x1 () const
|
||||
{
|
||||
return _note->x1 ();
|
||||
return _visual_note->x1 ();
|
||||
}
|
||||
|
||||
Coord
|
||||
Note::y0 () const
|
||||
{
|
||||
return _note->y0 ();
|
||||
return _visual_note->y0 ();
|
||||
}
|
||||
|
||||
Coord
|
||||
Note::y1 () const
|
||||
{
|
||||
return _note->y1 ();
|
||||
return _visual_note->y1 ();
|
||||
}
|
||||
|
||||
void
|
||||
Note::set_outline_color (uint32_t color)
|
||||
{
|
||||
_note->set_outline_color (color);
|
||||
_visual_note->set_outline_color (color);
|
||||
}
|
||||
|
||||
void
|
||||
Note::set_fill_color (uint32_t color)
|
||||
{
|
||||
_note->set_fill_color (color);
|
||||
_visual_note->set_fill_color (color);
|
||||
}
|
||||
|
||||
void
|
||||
Note::show ()
|
||||
{
|
||||
_note->show ();
|
||||
_visual_note->show ();
|
||||
}
|
||||
|
||||
void
|
||||
Note::hide ()
|
||||
{
|
||||
_note->hide ();
|
||||
_visual_note->hide ();
|
||||
}
|
||||
|
||||
void
|
||||
Note::set (ArdourCanvas::Rect rect)
|
||||
{
|
||||
_note->set (rect);
|
||||
_visual_note->set (rect);
|
||||
}
|
||||
|
||||
void
|
||||
Note::set_x0 (Coord x0)
|
||||
{
|
||||
_note->set_x0 (x0);
|
||||
_visual_note->set_x0 (x0);
|
||||
}
|
||||
|
||||
void
|
||||
Note::set_y0 (Coord y0)
|
||||
{
|
||||
_note->set_y0 (y0);
|
||||
_visual_note->set_y0 (y0);
|
||||
}
|
||||
|
||||
void
|
||||
Note::set_x1 (Coord x1)
|
||||
{
|
||||
_note->set_x1 (x1);
|
||||
_visual_note->set_x1 (x1);
|
||||
}
|
||||
|
||||
void
|
||||
Note::set_y1 (Coord y1)
|
||||
{
|
||||
_note->set_y1 (y1);
|
||||
_visual_note->set_y1 (y1);
|
||||
}
|
||||
|
||||
void
|
||||
Note::set_outline_what (ArdourCanvas::Rectangle::What what)
|
||||
{
|
||||
_note->set_outline_what (what);
|
||||
_visual_note->set_outline_what (what);
|
||||
}
|
||||
|
||||
void
|
||||
Note::set_outline_all ()
|
||||
{
|
||||
_note->set_outline_all ();
|
||||
_visual_note->set_outline_all ();
|
||||
}
|
||||
|
||||
void
|
||||
Note::set_ignore_events (bool ignore)
|
||||
{
|
||||
_note->set_ignore_events (ignore);
|
||||
_visual_note->set_ignore_events (ignore);
|
||||
}
|
||||
|
||||
void
|
||||
Note::set_velocity (double fract)
|
||||
{
|
||||
_note->set_velocity (fract);
|
||||
/* This just changes the way velocity is drawn */
|
||||
_visual_note->set_velocity (fract);
|
||||
}
|
||||
|
||||
double
|
||||
Note::visual_velocity () const
|
||||
{
|
||||
return _visual_note->velocity();
|
||||
}
|
||||
|
|
|
@ -62,11 +62,13 @@ public:
|
|||
|
||||
void set_ignore_events (bool);
|
||||
|
||||
/* Just changes the visual display of velocity during a drag */
|
||||
void set_velocity (double);
|
||||
double visual_velocity () const;
|
||||
void move_event (double dx, double dy);
|
||||
|
||||
private:
|
||||
ArdourCanvas::Note* _note;
|
||||
ArdourCanvas::Note* _visual_note;
|
||||
};
|
||||
|
||||
#endif /* __gtk_ardour_note_h__ */
|
||||
|
|
|
@ -105,6 +105,9 @@ class NoteBase : public sigc::trackable
|
|||
virtual ArdourCanvas::Coord x1 () const = 0;
|
||||
virtual ArdourCanvas::Coord y1 () const = 0;
|
||||
|
||||
virtual void set_velocity (double) {}
|
||||
virtual double visual_velocity() const = 0;
|
||||
|
||||
float mouse_x_fraction() const { return _mouse_x_fraction; }
|
||||
float mouse_y_fraction() const { return _mouse_y_fraction; }
|
||||
|
||||
|
@ -137,7 +140,7 @@ protected:
|
|||
ArdourCanvas::Item* _item;
|
||||
ArdourCanvas::Text* _text;
|
||||
State _state;
|
||||
const std::shared_ptr<NoteType> _note;
|
||||
const std::shared_ptr<NoteType> _note;
|
||||
bool _with_events;
|
||||
bool _own_note;
|
||||
Flags _flags;
|
||||
|
|
|
@ -150,6 +150,14 @@ VelocityGhostRegion::drag_lolli (ArdourCanvas::Lollipop* l, GdkEventMotion* ev)
|
|||
|
||||
MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (&parent_rv);
|
||||
assert (mrv);
|
||||
|
||||
/* This will redraw the velocity bars for the selected notes, without
|
||||
* changing the note velocities.
|
||||
*/
|
||||
|
||||
const double factor = newlen / l->length();
|
||||
mrv->sync_velocity_drag (factor);
|
||||
|
||||
MidiRegionView::Selection const & sel (mrv->selection());
|
||||
|
||||
for (auto & s : sel) {
|
||||
|
@ -176,7 +184,5 @@ VelocityGhostRegion::y_position_to_velocity (double y) const
|
|||
velocity = floor (127. * (((r.height() - 2.0 * lollipop_radius)- y) / r.height()));
|
||||
}
|
||||
|
||||
std::cerr << " y = " << y << " vel = " << velocity << std::endl;
|
||||
|
||||
return velocity;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue