mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
Show correct ghost hit for percussive tracks.
This commit is contained in:
parent
12b18da8f6
commit
606efb601c
5 changed files with 49 additions and 17 deletions
|
|
@ -125,3 +125,9 @@ Hit::y1 () const
|
||||||
/* bottom vertex */
|
/* bottom vertex */
|
||||||
return _polygon->position().y + _polygon->get()[3].y;
|
return _polygon->position().y + _polygon->get()[3].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Hit::set_ignore_events (bool ignore)
|
||||||
|
{
|
||||||
|
_polygon->set_ignore_events (ignore);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,8 @@ public:
|
||||||
void set_outline_color (uint32_t);
|
void set_outline_color (uint32_t);
|
||||||
void set_fill_color (uint32_t);
|
void set_fill_color (uint32_t);
|
||||||
|
|
||||||
|
void set_ignore_events (bool);
|
||||||
|
|
||||||
void move_event (double, double);
|
void move_event (double, double);
|
||||||
|
|
||||||
/* no trimming of percussive hits */
|
/* no trimming of percussive hits */
|
||||||
|
|
|
||||||
|
|
@ -1144,15 +1144,7 @@ MidiRegionView::redisplay_model()
|
||||||
if (!empty_when_starting && (cne = find_canvas_note (note)) != 0) {
|
if (!empty_when_starting && (cne = find_canvas_note (note)) != 0) {
|
||||||
|
|
||||||
cne->validate ();
|
cne->validate ();
|
||||||
|
update_note (cne);
|
||||||
Note* cn;
|
|
||||||
Hit* ch;
|
|
||||||
|
|
||||||
if ((cn = dynamic_cast<Note*>(cne)) != 0) {
|
|
||||||
update_note (cn);
|
|
||||||
} else if ((ch = dynamic_cast<Hit*>(cne)) != 0) {
|
|
||||||
update_hit (ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
cne->show ();
|
cne->show ();
|
||||||
|
|
@ -1627,12 +1619,24 @@ MidiRegionView::note_in_region_range (const boost::shared_ptr<NoteType> note, bo
|
||||||
return !outside;
|
return !outside;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MidiRegionView::update_note (NoteBase* note, bool update_ghost_regions)
|
||||||
|
{
|
||||||
|
Note* sus = NULL;
|
||||||
|
Hit* hit = NULL;
|
||||||
|
if ((sus = dynamic_cast<Note*>(note))) {
|
||||||
|
update_sustained(sus, update_ghost_regions);
|
||||||
|
} else if ((hit = dynamic_cast<Hit*>(note))) {
|
||||||
|
update_hit(hit, update_ghost_regions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Update a canvas note's size from its model note.
|
/** Update a canvas note's size from its model note.
|
||||||
* @param ev Canvas note to update.
|
* @param ev Canvas note to update.
|
||||||
* @param update_ghost_regions true to update the note in any ghost regions that we have, otherwise false.
|
* @param update_ghost_regions true to update the note in any ghost regions that we have, otherwise false.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
MidiRegionView::update_note (Note* ev, bool update_ghost_regions)
|
MidiRegionView::update_sustained (Note* ev, bool update_ghost_regions)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NoteType> note = ev->note();
|
boost::shared_ptr<NoteType> note = ev->note();
|
||||||
const double x = trackview.editor().sample_to_pixel (source_beats_to_region_frames (note->time()));
|
const double x = trackview.editor().sample_to_pixel (source_beats_to_region_frames (note->time()));
|
||||||
|
|
@ -1689,7 +1693,7 @@ MidiRegionView::update_note (Note* ev, bool update_ghost_regions)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MidiRegionView::update_hit (Hit* ev)
|
MidiRegionView::update_hit (Hit* ev, bool update_ghost_regions)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NoteType> note = ev->note();
|
boost::shared_ptr<NoteType> note = ev->note();
|
||||||
|
|
||||||
|
|
@ -1700,6 +1704,19 @@ MidiRegionView::update_hit (Hit* ev)
|
||||||
|
|
||||||
ev->set_position (ArdourCanvas::Duple (x, y));
|
ev->set_position (ArdourCanvas::Duple (x, y));
|
||||||
ev->set_height (diamond_size);
|
ev->set_height (diamond_size);
|
||||||
|
|
||||||
|
// Update color in case velocity has changed
|
||||||
|
ev->set_fill_color(ev->base_color());
|
||||||
|
ev->set_outline_color(ev->calculate_outline(ev->base_color(), ev->selected()));
|
||||||
|
|
||||||
|
if (update_ghost_regions) {
|
||||||
|
for (std::vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
|
||||||
|
MidiGhostRegion* gr = dynamic_cast<MidiGhostRegion*> (*i);
|
||||||
|
if (gr) {
|
||||||
|
gr->update_note (ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add a MIDI note to the view (with length).
|
/** Add a MIDI note to the view (with length).
|
||||||
|
|
@ -3555,7 +3572,11 @@ MidiRegionView::create_ghost_note (double x, double y)
|
||||||
remove_ghost_note ();
|
remove_ghost_note ();
|
||||||
|
|
||||||
boost::shared_ptr<NoteType> g (new NoteType);
|
boost::shared_ptr<NoteType> g (new NoteType);
|
||||||
_ghost_note = new Note (*this, _note_group, g);
|
if (midi_view()->note_mode() == Sustained) {
|
||||||
|
_ghost_note = new Note (*this, _note_group, g);
|
||||||
|
} else {
|
||||||
|
_ghost_note = new Hit (*this, _note_group, 10, g);
|
||||||
|
}
|
||||||
_ghost_note->set_ignore_events (true);
|
_ghost_note->set_ignore_events (true);
|
||||||
_ghost_note->set_outline_color (0x000000aa);
|
_ghost_note->set_outline_color (0x000000aa);
|
||||||
update_ghost_note (x, y);
|
update_ghost_note (x, y);
|
||||||
|
|
|
||||||
|
|
@ -410,7 +410,7 @@ private:
|
||||||
Note** _active_notes;
|
Note** _active_notes;
|
||||||
ArdourCanvas::Container* _note_group;
|
ArdourCanvas::Container* _note_group;
|
||||||
ARDOUR::MidiModel::NoteDiffCommand* _note_diff_command;
|
ARDOUR::MidiModel::NoteDiffCommand* _note_diff_command;
|
||||||
Note* _ghost_note;
|
NoteBase* _ghost_note;
|
||||||
double _last_ghost_x;
|
double _last_ghost_x;
|
||||||
double _last_ghost_y;
|
double _last_ghost_y;
|
||||||
ArdourCanvas::Rectangle* _step_edit_cursor;
|
ArdourCanvas::Rectangle* _step_edit_cursor;
|
||||||
|
|
@ -450,8 +450,10 @@ private:
|
||||||
NoteBase* find_canvas_note (boost::shared_ptr<NoteType>);
|
NoteBase* find_canvas_note (boost::shared_ptr<NoteType>);
|
||||||
Events::iterator _optimization_iterator;
|
Events::iterator _optimization_iterator;
|
||||||
|
|
||||||
void update_note (Note *, bool update_ghost_regions = true);
|
void update_note (NoteBase*, bool update_ghost_regions = true);
|
||||||
void update_hit (Hit *);
|
void update_sustained (Note *, bool update_ghost_regions = true);
|
||||||
|
void update_hit (Hit *, bool update_ghost_regions = true);
|
||||||
|
|
||||||
void create_ghost_note (double, double);
|
void create_ghost_note (double, double);
|
||||||
void update_ghost_note (double, double);
|
void update_ghost_note (double, double);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace ArdourCanvas {
|
||||||
class Text;
|
class Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This manages all the event handling for any MIDI event on the canvas.
|
/** Base class for canvas notes (sustained note rectangles and hit diamonds).
|
||||||
*
|
*
|
||||||
* This is not actually a canvas item itself to avoid the dreaded diamond
|
* This is not actually a canvas item itself to avoid the dreaded diamond
|
||||||
* inheritance pattern, since various types of canvas items (Note (rect), Hit
|
* inheritance pattern, since various types of canvas items (Note (rect), Hit
|
||||||
|
|
@ -51,7 +51,6 @@ namespace ArdourCanvas {
|
||||||
* Note: Because of this, derived classes need to manually bounce events to
|
* Note: Because of this, derived classes need to manually bounce events to
|
||||||
* on_event, it won't happen automatically.
|
* on_event, it won't happen automatically.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class NoteBase : public sigc::trackable
|
class NoteBase : public sigc::trackable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -91,6 +90,8 @@ class NoteBase : public sigc::trackable
|
||||||
virtual void set_outline_color(uint32_t c) = 0;
|
virtual void set_outline_color(uint32_t c) = 0;
|
||||||
virtual void set_fill_color(uint32_t c) = 0;
|
virtual void set_fill_color(uint32_t c) = 0;
|
||||||
|
|
||||||
|
virtual void set_ignore_events(bool ignore) = 0;
|
||||||
|
|
||||||
virtual ArdourCanvas::Coord x0 () const = 0;
|
virtual ArdourCanvas::Coord x0 () const = 0;
|
||||||
virtual ArdourCanvas::Coord y0 () const = 0;
|
virtual ArdourCanvas::Coord y0 () const = 0;
|
||||||
virtual ArdourCanvas::Coord x1 () const = 0;
|
virtual ArdourCanvas::Coord x1 () const = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue