/*
- Copyright (C) 2001-2006 Paul Davis
+ Copyright (C) 2001-2007 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <libgnomecanvasmm.h>
#include <libgnomecanvasmm/polygon.h>
-#include <sigc++/signal.h>
+#include <ardour/midi_track.h>
#include <ardour/midi_region.h>
+#include <ardour/midi_model.h>
+#include <ardour/diskstream.h>
#include <ardour/types.h>
#include "region_view.h"
-#include "route_time_axis.h"
+#include "midi_time_axis.h"
#include "time_axis_view_item.h"
#include "automation_line.h"
#include "enums.h"
#include "canvas.h"
-#include "color.h"
+#include "canvas-note.h"
+#include "canvas-midi-event.h"
namespace ARDOUR {
class MidiRegion;
+ class MidiModel;
};
class MidiTimeAxisView;
class GhostRegion;
class AutomationTimeAxisView;
+class AutomationRegionView;
class MidiRegionView : public RegionView
{
~MidiRegionView ();
- virtual void init (Gdk::Color& base_color, bool wait_for_data = false);
+ virtual void init (Gdk::Color& basic_color, bool wfd);
- boost::shared_ptr<ARDOUR::MidiRegion> midi_region() const;
+ inline const boost::shared_ptr<ARDOUR::MidiRegion> midi_region() const
+ { return boost::dynamic_pointer_cast<ARDOUR::MidiRegion>(_region); }
+
+ inline MidiTimeAxisView* midi_view() const
+ { return dynamic_cast<MidiTimeAxisView*>(&trackview); }
+
+ inline MidiStreamView* midi_stream_view() const
+ { return midi_view()->midi_view(); }
void set_y_position_and_height (double, double);
-
- void show_region_editor ();
+
+ void set_frame_color();
+
+ void redisplay_model();
GhostRegion* add_ghost (AutomationTimeAxisView&);
- void add_event(const ARDOUR::MidiEvent& ev);
+ void add_note(const boost::shared_ptr<ARDOUR::Note> note);
+ void resolve_note(uint8_t note_num, double end_time);
void begin_write();
void end_write();
void extend_active_notes();
+ void create_note_at(double x, double y, double dur);
+
+ void display_model(boost::shared_ptr<ARDOUR::MidiModel> model);
+
+ /* This stuff is a bit boilerplatey ATM. Work in progress. */
+
+ inline void start_remove_command() {
+ if (!_delta_command)
+ _delta_command = _model->new_delta_command();
+ }
+
+ inline void start_delta_command() {
+ if (!_delta_command)
+ _delta_command = _model->new_delta_command();
+ }
+
+ void command_add_note(const boost::shared_ptr<ARDOUR::Note> note) {
+ if (_delta_command)
+ _delta_command->add(note);
+ }
+
+ void command_remove_note(ArdourCanvas::CanvasMidiEvent* ev) {
+ if (_delta_command && ev->note()) {
+ _delta_command->remove(ev->note());
+ ev->selected(true);
+ }
+ }
+
+ void abort_command() {
+ delete _delta_command;
+ _delta_command = NULL;
+ clear_selection();
+ }
+
+ void apply_command() {
+ if (_delta_command) {
+ _model->apply_command(_delta_command);
+ _delta_command = NULL;
+ }
+ midi_view()->midi_track()->diskstream()->playlist_modified();
+ }
+
+ void note_entered(ArdourCanvas::CanvasMidiEvent* ev);
+ void unique_select(ArdourCanvas::CanvasMidiEvent* ev);
+ void note_selected(ArdourCanvas::CanvasMidiEvent* ev, bool add);
+ void note_deselected(ArdourCanvas::CanvasMidiEvent* ev, bool add);
+ void delete_selection();
+ size_t selection_size() { return _selection.size(); }
+
+ void move_selection(double dx, double dy);
+ void note_dropped(ArdourCanvas::CanvasMidiEvent* ev, double dt, uint8_t dnote);
+
+ enum MouseState { None, Pressed, SelectTouchDragging, SelectRectDragging, AddDragging, EraseTouchDragging };
+ MouseState mouse_state() const { return _mouse_state; }
+
protected:
/* this constructor allows derived types
private:
- void display_events();
+ void clear_events();
+ void switch_source(boost::shared_ptr<ARDOUR::Source> src);
- std::vector<ArdourCanvas::Item*> _events;
- ArdourCanvas::SimpleRect** _active_notes;
+ bool canvas_event(GdkEvent* ev);
+ bool note_canvas_event(GdkEvent* ev);
+
+ void clear_selection_except(ArdourCanvas::CanvasMidiEvent* ev);
+ void clear_selection() { clear_selection_except(NULL); }
+ void update_drag_selection(double last_x, double x, double last_y, double y);
+
+ double _default_note_length;
+
+ boost::shared_ptr<ARDOUR::MidiModel> _model;
+ std::vector<ArdourCanvas::CanvasMidiEvent*> _events;
+ ArdourCanvas::CanvasNote** _active_notes;
+ ArdourCanvas::Group* _note_group;
+ ARDOUR::MidiModel::DeltaCommand* _delta_command;
+
+ MouseState _mouse_state;
+ int _pressed_button;
+
+ typedef std::set<ArdourCanvas::CanvasMidiEvent*> Selection;
+ Selection _selection;
};
#endif /* __gtk_ardour_midi_region_view_h__ */