5 #include "mwindowgui.h"
8 #include "mainsession.h"
12 Patch::Patch(MWindow *mwindow, PatchBay *patchbay, int data_type) : ListItem<Patch>()
14 this->mwindow = mwindow;
15 this->patches = patchbay;
16 this->data_type = data_type;
17 record = play = automate = draw = 1;
33 int Patch::create_objects(char *text, int pixel)
41 if(mwindow->session->tracks_vertical)
43 //x = patches->gui->w - pixel - mwindow->zoom_track;
53 patches->add_subwindow(recordpatch = new RecordPatchOld(mwindow, this, x, y));
54 patches->add_subwindow(playpatch = new PlayPatchOld(mwindow, this, x, y));
55 patches->add_subwindow(title_text = new TitlePatchOld(mwindow, this, text, x, y));
56 //patches->add_subwindow(autotitle = new BC_Title(x + PATCH_AUTO_TITLE, y + PATCH_ROW2, "A", SMALLFONT));
57 //patches->add_subwindow(autopatch = new AutoPatchOld(mwindow, this, x, y));
58 //patches->add_subwindow(drawtitle = new BC_Title(x + PATCH_DRAW_TITLE, y + PATCH_ROW2, "D", SMALLFONT));
59 patches->add_subwindow(drawpatch = new DrawPatchOld(mwindow, this, x, y));
64 int Patch::save(FileXML *xml)
66 xml->tag.set_title("PATCH");
71 xml->tag.set_title("PLAY");
73 xml->tag.set_title("/PLAY");
79 xml->tag.set_title("RECORD");
81 xml->tag.set_title("/RECORD");
87 xml->tag.set_title("AUTO");
89 xml->tag.set_title("/AUTO");
95 xml->tag.set_title("DRAW");
97 xml->tag.set_title("/DRAW");
101 xml->tag.set_title("TITLE");
103 xml->append_text(title);
104 xml->tag.set_title("/TITLE");
108 xml->tag.set_title("/PATCH");
110 xml->append_newline();
114 int Patch::load(FileXML *xml)
117 play = record = automate = draw = 0; // defaults
120 result = xml->read_tag();
124 if(xml->tag.title_is("/PATCH"))
129 if(xml->tag.title_is("PLAY"))
134 if(xml->tag.title_is("RECORD"))
139 if(xml->tag.title_is("AUTO"))
144 if(xml->tag.title_is("DRAW"))
149 if(xml->tag.title_is("TITLE"))
151 strcpy(title, xml->read_text());
158 playpatch->update(play);
159 recordpatch->update(record);
160 autopatch->update(automate);
161 drawpatch->update(draw);
162 title_text->update(title);
167 int Patch::set_pixel(int pixel)
168 { // must be top of track for track zoom
172 if(mwindow->session->tracks_vertical)
175 playpatch->reposition_window(pixel + PATCH_PLAY, playpatch->get_y());
176 recordpatch->reposition_window(pixel + PATCH_REC, recordpatch->get_y());
177 autopatch->reposition_window(pixel + PATCH_AUTO, autopatch->get_y());
178 title_text->reposition_window(pixel, title_text->get_y());
179 drawpatch->reposition_window(pixel + PATCH_DRAW, drawpatch->get_y());
183 playpatch->reposition_window(playpatch->get_x(), pixel + PATCH_ROW2);
184 recordpatch->reposition_window(recordpatch->get_x(), pixel + PATCH_ROW2);
185 autopatch->reposition_window(autopatch->get_x(), pixel + PATCH_ROW2);
186 drawpatch->reposition_window(drawpatch->get_x(), pixel + PATCH_ROW2);
187 title_text->reposition_window(title_text->get_x(), pixel + 3);
193 int Patch::set_title(char *new_title)
195 strcpy(title, new_title);
196 title_text->update(new_title);
200 int Patch::flip_vertical()
204 if(mwindow->session->tracks_vertical)
206 playpatch->reposition_window(playpatch->get_x(), PATCH_ROW2);
207 recordpatch->reposition_window(recordpatch->get_x(), PATCH_ROW2);
208 autopatch->reposition_window(autopatch->get_x(), PATCH_ROW2);
209 drawpatch->reposition_window(drawpatch->get_x(), PATCH_ROW2);
210 title_text->reposition_window(title_text->get_x(), 3);
214 playpatch->reposition_window(PATCH_PLAY, playpatch->get_y());
215 recordpatch->reposition_window(PATCH_REC, recordpatch->get_y());
216 autopatch->reposition_window(PATCH_AUTO, autopatch->get_y());
217 drawpatch->reposition_window(PATCH_DRAW, drawpatch->get_y());
218 title_text->reposition_window(PATCH_TITLE, title_text->get_y());
226 int Patch::pixelmovement(int distance)
236 Module* Patch::get_module() // return corresponding module from console
238 // return mwindow->console->modules->module_number(patches->number_of(this));
241 PlayPatchOld::PlayPatchOld(MWindow *mwindow, Patch *patch, int x, int y)
242 : BC_Toggle(x + PATCH_PLAY,
244 mwindow->theme->playpatch_data,
252 patches = patch->patches;
256 int PlayPatchOld::handle_event()
258 // get the total selected before this event
261 int total_selected = patches->plays_selected();
263 if(total_selected == 0)
265 // nothing previously selected
266 patches->select_all_play();
269 if(total_selected == 1)
273 // this patch was previously the only one on
274 patches->select_all_play();
278 // another patch was previously the only one on
279 patches->deselect_all_play();
284 if(total_selected > 1)
286 patches->deselect_all_play();
294 patch->play = get_value();
296 patches->button_down = 1;
297 patches->reconfigure_trigger = 1;
298 patches->new_status = get_value();
302 int PlayPatchOld::button_release()
307 int PlayPatchOld::cursor_moved_over()
309 if(patches->button_down && patches->new_status != get_value())
311 update(patches->new_status);
312 patch->play = get_value();
318 RecordPatchOld::RecordPatchOld(MWindow *mwindow, Patch *patch, int x, int y)
319 : BC_Toggle(x + PATCH_REC,
321 mwindow->theme->recordpatch_data,
329 patches = patch->patches;
332 int RecordPatchOld::handle_event()
334 // get the total selected before this event
337 int total_selected = patches->records_selected();
339 if(total_selected == 0)
341 // nothing previously selected
342 patches->select_all_record();
345 if(total_selected == 1)
349 // this patch was previously the only one on
350 patches->select_all_record();
354 // another patch was previously the only one on
355 patches->deselect_all_record();
360 if(total_selected > 1)
362 patches->deselect_all_record();
366 update(patch->record);
370 patch->record = get_value();
372 patches->button_down = 1;
373 patches->new_status = get_value();
377 int RecordPatchOld::button_release()
379 //if(patches->button_down)
381 // patches->button_down = 0;
382 // restart the playback
383 //patches->mwindow->start_reconfigure(1);
384 //patches->mwindow->stop_reconfigure(1);
389 int RecordPatchOld::cursor_moved_over()
391 if(patches->button_down && patches->new_status != get_value())
393 update(patches->new_status);
394 patch->record = get_value();
400 TitlePatchOld::TitlePatchOld(MWindow *mwindow, Patch *patch, char *text, int x, int y)
401 : BC_TextBox(x, y + PATCH_TITLE, 124, 1, text, 0)
404 patches = patch->patches;
408 int TitlePatchOld::handle_event()
410 if(!module) module = patch->get_module();
411 module->set_title(get_text());
412 strcpy(patch->title, get_text());
416 DrawPatchOld::DrawPatchOld(MWindow *mwindow, Patch *patch, int x, int y)
417 : BC_Toggle(x + PATCH_DRAW,
419 mwindow->theme->drawpatch_data,
427 this->patches = patch->patches;
430 int DrawPatchOld::handle_event()
432 // get the total selected before this event
435 int total_selected = patches->draws_selected();
437 if(total_selected == 0)
439 // nothing previously selected
440 patches->select_all_draw();
443 if(total_selected == 1)
447 // this patch was previously the only one on
448 patches->select_all_draw();
452 // another patch was previously the only one on
453 patches->deselect_all_draw();
458 if(total_selected > 1)
460 patches->deselect_all_draw();
468 patch->draw = get_value();
470 patches->button_down = 1;
471 patches->new_status = get_value();
475 int DrawPatchOld::cursor_moved_over()
477 if(patches->button_down && patches->new_status != get_value())
479 update(patches->new_status);
480 patch->draw = get_value();