/*
- 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 <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"
class MidiTimeAxisView;
class GhostRegion;
class AutomationTimeAxisView;
+class AutomationRegionView;
class MidiRegionView : public RegionView
{
{ 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 ARDOUR::MidiModel::Note& note);
+ 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();
/* This stuff is a bit boilerplatey ATM. Work in progress. */
inline void start_remove_command() {
- _command_mode = Remove;
if (!_delta_command)
_delta_command = _model->new_delta_command();
}
inline void start_delta_command() {
- _command_mode = Delta;
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());
+ _delta_command->remove(ev->note());
ev->selected(true);
}
}
-
- void command_add_note(ARDOUR::MidiModel::Note& note) {
- if (_delta_command) {
- _delta_command->add(note);
- }
- }
-
- void note_entered(ArdourCanvas::CanvasMidiEvent* ev) {
- if (_command_mode == Remove && _delta_command && ev->note())
- _delta_command->remove(*ev->note());
- }
-
- //ARDOUR::MidiModel::DeltaCommand* delta_command() { return _delta_command; }
void abort_command() {
delete _delta_command;
_delta_command = NULL;
- _command_mode = None;
+ clear_selection();
}
void apply_command() {
_model->apply_command(_delta_command);
_delta_command = NULL;
}
- _command_mode = None;
+ 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 redisplay_model();
void clear_events();
+ void switch_source(boost::shared_ptr<ARDOUR::Source> src);
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::Item*> _events;
- ArdourCanvas::CanvasNote** _active_notes;
- ARDOUR::MidiModel::DeltaCommand* _delta_command;
+ 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;
-
- enum CommandMode { None, Remove, Delta };
- CommandMode _command_mode;
};
#endif /* __gtk_ardour_midi_region_view_h__ */