#include "evoral/midi_util.h"
#include "canvas/debug.h"
+#include "canvas/text.h"
#include "automation_region_view.h"
#include "automation_time_axis.h"
#include "rgb_macros.h"
#include "selection.h"
#include "streamview.h"
-#include "utils.h"
#include "patch_change_dialog.h"
#include "verbose_cursor.h"
#include "ardour_ui.h"
#define MIDI_BP_ZERO ((Config->get_first_midi_bank_is_zero())?0:1)
-MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv,
- boost::shared_ptr<MidiRegion> r, double spu, Gdk::Color const & basic_color)
+MidiRegionView::MidiRegionView (ArdourCanvas::Container *parent, RouteTimeAxisView &tv,
+ boost::shared_ptr<MidiRegion> r, double spu, uint32_t basic_color)
: RegionView (parent, tv, r, spu, basic_color)
, _current_range_min(0)
, _current_range_max(0)
, _active_notes(0)
- , _note_group (new ArdourCanvas::Group (group))
+ , _note_group (new ArdourCanvas::Container (group))
, _note_diff_command (0)
, _ghost_note(0)
, _step_edit_cursor (0)
SelectionCleared.connect (_selection_cleared_connection, invalidator (*this), boost::bind (&MidiRegionView::selection_cleared, this, _1), gui_context ());
}
-MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv,
- boost::shared_ptr<MidiRegion> r, double spu, Gdk::Color& basic_color,
+MidiRegionView::MidiRegionView (ArdourCanvas::Container *parent, RouteTimeAxisView &tv,
+ boost::shared_ptr<MidiRegion> r, double spu, uint32_t basic_color,
TimeAxisViewItem::Visibility visibility)
: RegionView (parent, tv, r, spu, basic_color, false, visibility)
, _current_range_min(0)
, _current_range_max(0)
, _active_notes(0)
- , _note_group (new ArdourCanvas::Group (parent))
+ , _note_group (new ArdourCanvas::Container (parent))
, _note_diff_command (0)
, _ghost_note(0)
, _step_edit_cursor (0)
void
MidiRegionView::parameter_changed (std::string const & p)
{
- if (p == "diplay-first-midi-bank-as-zero") {
+ if (p == "display-first-midi-bank-as-zero") {
if (_enable_display) {
redisplay_model();
}
, _current_range_min(0)
, _current_range_max(0)
, _active_notes(0)
- , _note_group (new ArdourCanvas::Group (get_canvas_group()))
+ , _note_group (new ArdourCanvas::Container (get_canvas_group()))
, _note_diff_command (0)
, _ghost_note(0)
, _step_edit_cursor (0)
, pre_press_cursor (0)
, _note_player (0)
{
- Gdk::Color c;
- int r,g,b,a;
-
- UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
- c.set_rgb_p (r/255.0, g/255.0, b/255.0);
-
- init (c, false);
+ init (false);
}
MidiRegionView::MidiRegionView (const MidiRegionView& other, boost::shared_ptr<MidiRegion> region)
, _current_range_min(0)
, _current_range_max(0)
, _active_notes(0)
- , _note_group (new ArdourCanvas::Group (get_canvas_group()))
+ , _note_group (new ArdourCanvas::Container (get_canvas_group()))
, _note_diff_command (0)
, _ghost_note(0)
, _step_edit_cursor (0)
, pre_press_cursor (0)
, _note_player (0)
{
- Gdk::Color c;
- int r,g,b,a;
-
- UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
- c.set_rgb_p (r/255.0, g/255.0, b/255.0);
-
- init (c, true);
+ init (true);
}
void
-MidiRegionView::init (Gdk::Color const & basic_color, bool wfd)
+MidiRegionView::init (bool wfd)
{
PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
_model = midi_region()->midi_source(0)->model();
_enable_display = false;
- RegionView::init (basic_color, false);
-
- compute_colors (basic_color);
+ RegionView::init (false);
set_height (trackview.current_height());
if ((!trackview.editor().internal_editing() && trackview.editor().current_mouse_mode() != MouseGain) ||
(trackview.editor().current_mouse_mode() == MouseTimeFX) ||
(trackview.editor().current_mouse_mode() == MouseZoom)) {
- // handle non-draw modes elsewhere
- return false;
+ // handle non-internal-edit/non-draw modes elsewhere
+ return RegionView::canvas_group_event (ev);
}
switch (ev->type) {
return trackview.editor().canvas_region_view_event (ev, group, this);
}
-void
-MidiRegionView::remove_ghost_note ()
-{
- delete _ghost_note;
- _ghost_note = 0;
-}
-
bool
MidiRegionView::enter_notify (GdkEventCrossing* ev)
{
default:
break;
+
}
- return false;
+ /* we may be dragging some non-note object (eg. patch-change, sysex)
+ */
+
+ return editor.drags()->motion_handler ((GdkEvent *) ev, false);
}
MidiModel::Notes& notes (_model->notes());
_optimization_iterator = _events.begin();
- bool empty_when_starting = !_events.empty();
+ bool empty_when_starting = _events.empty();
for (MidiModel::Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
bool visible;
if (note_in_region_range (note, visible)) {
-
- if (empty_when_starting && (cne = find_canvas_note (note)) != 0) {
+
+ if (!empty_when_starting && (cne = find_canvas_note (note)) != 0) {
cne->validate ();
}
} else {
-
- if (empty_when_starting && (cne = find_canvas_note (note)) != 0) {
+
+ if (!empty_when_starting && (cne = find_canvas_note (note)) != 0) {
cne->validate ();
cne->hide ();
}
/* remove note items that are no longer valid */
- if (empty_when_starting) {
+ if (!empty_when_starting) {
for (Events::iterator i = _events.begin(); i != _events.end(); ) {
if (!(*i)->valid ()) {
void
MidiRegionView::set_height (double height)
{
- static const double FUDGE = 2.0;
- const double old_height = _height;
+ double old_height = _height;
RegionView::set_height(height);
- _height = height - FUDGE;
- apply_note_range(midi_stream_view()->lowest_note(),
- midi_stream_view()->highest_note(),
- height != old_height + FUDGE);
+ apply_note_range (midi_stream_view()->lowest_note(),
+ midi_stream_view()->highest_note(),
+ height != old_height);
if (name_text) {
name_text->raise_to_top();
cnote->set_y1 (y1);
} else if (Hit* chit = dynamic_cast<Hit*>(event)) {
-
- const double diamond_size = update_hit (chit);
-
- chit->set_height (diamond_size);
+ update_hit (chit);
}
}
}
const framepos_t end_time_frames = region_beats_to_region_frames(end_time);
_active_notes[note]->set_x1 (trackview.editor().sample_to_pixel(end_time_frames));
- _active_notes[note]->set_outline_what (0xf);
+ _active_notes[note]->set_outline_all ();
_active_notes[note] = 0;
+
}
}
Note* const old_rect = _active_notes[note->note()];
boost::shared_ptr<NoteType> old_note = old_rect->note();
old_rect->set_x1 (x);
- old_rect->set_outline_what (0xF);
+ old_rect->set_outline_all ();
}
_active_notes[note->note()] = ev;
}
/* outline all but right edge */
- ev->set_outline_what (0x1 & 0x4 & 0x8);
+ ev->set_outline_what (ArdourCanvas::Rectangle::What (
+ ArdourCanvas::Rectangle::TOP|
+ ArdourCanvas::Rectangle::LEFT|
+ ArdourCanvas::Rectangle::BOTTOM));
} else {
/* outline all edges */
- ev->set_outline_what (0xF);
+ ev->set_outline_all ();
}
if (update_ghost_regions) {
}
}
-double
+void
MidiRegionView::update_hit (Hit* ev)
{
boost::shared_ptr<NoteType> note = ev->note();
const framepos_t note_start_frames = source_beats_to_region_frames(note->time());
const double x = trackview.editor().sample_to_pixel(note_start_frames);
- const double diamond_size = midi_stream_view()->note_height() / 2.0;
- const double y = midi_stream_view()->note_to_y(note->note()) + ((diamond_size-2) / 4.0);
+ const double diamond_size = midi_stream_view()->note_height();
+ const double y = midi_stream_view()->note_to_y(note->note()) + (diamond_size/2.0);
ev->set_position (ArdourCanvas::Duple (x, y));
-
- return diamond_size;
+ ev->set_height (diamond_size);
}
/** Add a MIDI note to the view (with length).
{
NoteBase* event = 0;
- //ArdourCanvas::Group* const group = (ArdourCanvas::Group*) get_canvas_group();
-
if (midi_view()->note_mode() == Sustained) {
Note* ev_rect = new Note (*this, _note_group, note);
show_verbose_cursor (_ghost_note->note ());
}
+void
+MidiRegionView::remove_ghost_note ()
+{
+ delete _ghost_note;
+ _ghost_note = 0;
+}
+
void
MidiRegionView::snap_changed ()
{
MidiRegionView::show_step_edit_cursor (Evoral::MusicalTime pos)
{
if (_step_edit_cursor == 0) {
- ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group();
+ ArdourCanvas::Item* const group = get_canvas_group();
_step_edit_cursor = new ArdourCanvas::Rectangle (group);
_step_edit_cursor->set_y0 (0);
/* Reparent the note group to the region view's parent, so that it doesn't change
when the region view is trimmed.
*/
- _temporary_note_group = new ArdourCanvas::Group (group->parent ());
+ _temporary_note_group = new ArdourCanvas::Container (group->parent ());
_temporary_note_group->move (group->position ());
_note_group->reparent (_temporary_note_group);
}
void
MidiRegionView::show_verbose_cursor (string const & text, double xoffset, double yoffset) const
{
- double wx, wy;
-
- trackview.editor().verbose_cursor()->set_text (text);
- trackview.editor().get_pointer_position (wx, wy);
-
- wx += xoffset;
- wy += yoffset;
-
- /* Flip the cursor above the mouse pointer if it would overlap the bottom of the canvas */
-
- boost::optional<ArdourCanvas::Rect> bbo = trackview.editor().verbose_cursor()->item().bounding_box();
-
- assert (bbo);
-
- ArdourCanvas::Rect bb = bbo.get();
-
- if ((wy + bb.y1 - bb.y0) > trackview.editor().visible_canvas_height()) {
- wy -= (bb.y1 - bb.y0) + 2 * yoffset;
- }
-
- trackview.editor().verbose_cursor()->set_position (wx, wy);
+ trackview.editor().verbose_cursor()->set (text);
trackview.editor().verbose_cursor()->show ();
+ trackview.editor().verbose_cursor()->set_offset (ArdourCanvas::Duple (xoffset, yoffset));
}
/** @param p A session framepos.