commit
This commit is contained in:
commit
e979ca976d
25
model.cpp
25
model.cpp
|
@ -215,6 +215,17 @@ void Pattern::update_keys() {
|
|||
}
|
||||
}
|
||||
|
||||
void Pattern::copy_from(const Pattern &pattern) {
|
||||
name = pattern.name;
|
||||
length = pattern.length;
|
||||
channel_count = pattern.channel_count;
|
||||
|
||||
const_iterator iter;
|
||||
for (iter = pattern.begin(); iter != pattern.end(); ++iter) {
|
||||
add_event(iter->second);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
SongEvent::SongEvent() {
|
||||
|
@ -368,12 +379,16 @@ void Model::reset() {
|
|||
song.clear();
|
||||
}
|
||||
|
||||
Pattern &Model::new_pattern() {
|
||||
Pattern &Model::new_pattern(const Pattern *template_pattern) {
|
||||
Pattern *pattern = new Pattern();
|
||||
char text[64];
|
||||
sprintf(text, "Pattern %i", patterns.size()+1);
|
||||
pattern->name = text;
|
||||
pattern->set_length(frames_per_beat * beats_per_bar);
|
||||
if (template_pattern) {
|
||||
pattern->copy_from(*template_pattern);
|
||||
} else {
|
||||
char text[64];
|
||||
sprintf(text, "Pattern %i", patterns.size()+1);
|
||||
pattern->name = text;
|
||||
pattern->set_length(frames_per_beat * beats_per_bar);
|
||||
}
|
||||
patterns.push_back(pattern);
|
||||
return *pattern;
|
||||
}
|
||||
|
|
|
@ -151,6 +151,7 @@ public:
|
|||
iterator get_event(int frame, int channel, int param);
|
||||
|
||||
void update_keys();
|
||||
void copy_from(const Pattern &pattern);
|
||||
protected:
|
||||
Pattern();
|
||||
|
||||
|
@ -250,7 +251,7 @@ public:
|
|||
void reset();
|
||||
|
||||
Model();
|
||||
Pattern &new_pattern();
|
||||
Pattern &new_pattern(const Pattern *template_pattern=NULL);
|
||||
|
||||
int get_track_count() const;
|
||||
|
||||
|
|
|
@ -510,12 +510,15 @@ void TrackView::select_from_box() {
|
|||
}
|
||||
}
|
||||
|
||||
void TrackView::clone_selection() {
|
||||
void TrackView::clone_selection(bool references/*=false*/) {
|
||||
Song::IterList new_selection;
|
||||
|
||||
Song::IterList::iterator iter;
|
||||
for (iter = selection.begin(); iter != selection.end(); ++iter) {
|
||||
Song::Event event = (*iter)->second;
|
||||
if (!references) {
|
||||
event.pattern = &model->new_pattern(event.pattern);
|
||||
}
|
||||
new_selection.push_back(model->song.add_event(event));
|
||||
}
|
||||
|
||||
|
@ -524,6 +527,7 @@ void TrackView::clone_selection() {
|
|||
|
||||
bool TrackView::on_motion_notify_event(GdkEventMotion *event) {
|
||||
bool shift_down = event->state & Gdk::SHIFT_MASK;
|
||||
bool ctrl_down = event->state & Gdk::CONTROL_MASK;
|
||||
|
||||
if (interact_mode == InteractNone) {
|
||||
TrackCursor cur(*this);
|
||||
|
@ -550,7 +554,7 @@ bool TrackView::on_motion_notify_event(GdkEventMotion *event) {
|
|||
} else {
|
||||
if (shift_down) {
|
||||
invalidate_selection();
|
||||
clone_selection();
|
||||
clone_selection(ctrl_down);
|
||||
}
|
||||
interact_mode = InteractMove;
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ protected:
|
|||
void update_adjustments();
|
||||
void on_adjustment_value_changed();
|
||||
|
||||
void clone_selection();
|
||||
void clone_selection(bool references=false);
|
||||
|
||||
// zoomlevel (0=1:1, 1=1:2, 2=1:4, etc.)
|
||||
int zoomlevel;
|
||||
|
|
Loading…
Reference in New Issue