1 #include "automation.h"
5 #include "edlsession.h"
8 #include "localsession.h"
11 #include "mwindowgui.h"
14 #include "playbackengine.h"
17 #include "trackcanvas.h"
19 #include "transportque.h"
23 #define _(String) gettext(String)
24 #define gettext_noop(String) String
25 #define N_(String) gettext_noop (String)
28 PatchGUI::PatchGUI(MWindow *mwindow,
34 this->mwindow = mwindow;
35 this->patchbay = patchbay;
49 if(track) track_id = track->get_id();
54 if(title) delete title;
55 if(record) delete record;
57 // if(automate) delete automate;
61 if(expand) delete expand;
64 int PatchGUI::create_objects()
69 int PatchGUI::reposition(int x, int y)
75 if(x != this->x || y != this->y)
82 title->reposition_window(x1, y1 + y);
84 y1 += mwindow->theme->title_h;
88 play->reposition_window(x1, y1 + y);
90 record->reposition_window(x1, y1 + y);
91 x1 += record->get_w();
92 // automate->reposition_window(x1, y1 + y);
93 // x1 += automate->get_w();
94 gang->reposition_window(x1, y1 + y);
96 draw->reposition_window(x1, y1 + y);
98 mute->reposition_window(x1, y1 + y);
101 expand->reposition_window(
102 patchbay->get_w() - 10 - mwindow->theme->expandpatch_data[0]->get_w(),
104 x1 += expand->get_w();
106 y1 += mwindow->theme->play_h;
110 y1 += mwindow->theme->title_h;
111 y1 += mwindow->theme->play_h;
117 int PatchGUI::update(int x, int y)
121 int h = track->vertical_span(mwindow->theme);
134 title->update(track->title);
140 patchbay->add_subwindow(title = new TitlePatch(mwindow, this, x1 + x, y1 + y));
142 y1 += mwindow->theme->title_h;
146 if(h - y1 < mwindow->theme->play_h)
162 play->update(track->play);
163 record->update(track->record);
164 gang->update(track->gang);
165 draw->update(track->draw);
166 mute->update(mute->get_keyframe(mwindow, this)->value);
167 expand->update(track->expand_view);
171 if(h - y1 >= mwindow->theme->play_h)
173 patchbay->add_subwindow(play = new PlayPatch(mwindow, this, x1 + x, y1 + y));
175 patchbay->add_subwindow(record = new RecordPatch(mwindow, this, x1 + x, y1 + y));
176 x1 += record->get_w();
177 patchbay->add_subwindow(gang = new GangPatch(mwindow, this, x1 + x, y1 + y));
179 patchbay->add_subwindow(draw = new DrawPatch(mwindow, this, x1 + x, y1 + y));
181 patchbay->add_subwindow(mute = new MutePatch(mwindow, this, x1 + x, y1 + y));
185 patchbay->add_subwindow(expand = new ExpandPatch(mwindow,
187 patchbay->get_w() - 10 - mwindow->theme->expandpatch_data[0]->get_w(),
189 x1 += expand->get_w();
191 y1 += mwindow->theme->play_h;
197 void PatchGUI::toggle_behavior(int type,
202 if(toggle->shift_down())
204 int total_selected = mwindow->edl->tracks->total_of(type);
206 // nothing previously selected
207 if(total_selected == 0)
209 mwindow->edl->tracks->select_all(type,
213 if(total_selected == 1)
215 // this patch was previously the only one on
218 mwindow->edl->tracks->select_all(type,
221 // another patch was previously the only one on
224 mwindow->edl->tracks->select_all(type,
230 if(total_selected > 1)
232 mwindow->edl->tracks->select_all(type,
236 toggle->set_value(*output);
242 // Select + drag behavior
243 patchbay->drag_operation = type;
244 patchbay->new_status = value;
245 patchbay->button_down = 1;
248 if(type == Tracks::PLAY)
250 mwindow->gui->unlock_window();
251 mwindow->restart_brender();
252 mwindow->sync_parameters(CHANGE_EDL);
253 mwindow->gui->lock_window();
256 if(type == Tracks::MUTE)
258 mwindow->gui->unlock_window();
259 mwindow->restart_brender();
260 mwindow->sync_parameters(CHANGE_PARAMS);
261 mwindow->gui->lock_window();
264 // Update affected tracks in cwindow
265 if(type == Tracks::RECORD)
266 mwindow->cwindow->update(0, 1, 1);
280 PlayPatch::PlayPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
283 mwindow->theme->playpatch_data,
290 this->mwindow = mwindow;
292 set_tooltip(_("Play track"));
296 int PlayPatch::button_press_event()
298 if(is_event_win() && get_buttonpress() == 1)
300 update(!get_value());
301 patch->toggle_behavior(Tracks::PLAY,
304 &patch->track->play);
310 int PlayPatch::button_release_event()
312 if(patch->patchbay->drag_operation != Tracks::NONE)
314 patch->patchbay->drag_operation = Tracks::NONE;
330 RecordPatch::RecordPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
333 mwindow->theme->recordpatch_data,
334 patch->track->record,
340 this->mwindow = mwindow;
342 set_tooltip(_("Arm track"));
346 int RecordPatch::button_press_event()
348 if(is_event_win() && get_buttonpress() == 1)
350 update(!get_value());
351 patch->toggle_behavior(Tracks::RECORD,
354 &patch->track->record);
360 int RecordPatch::button_release_event()
362 if(patch->patchbay->drag_operation != Tracks::NONE)
364 patch->patchbay->drag_operation = Tracks::NONE;
379 TitlePatch::TitlePatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
382 patch->patchbay->get_w() - 10,
386 this->mwindow = mwindow;
390 int TitlePatch::handle_event()
392 strcpy(patch->track->title, get_text());
393 mwindow->update_plugin_titles();
394 mwindow->gui->canvas->draw_overlays();
395 mwindow->gui->canvas->flash();
409 GangPatch::GangPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
411 mwindow->theme->gangpatch_data,
418 this->mwindow = mwindow;
420 set_tooltip(_("Gang faders"));
424 int GangPatch::button_press_event()
426 if(is_event_win() && get_buttonpress() == 1)
428 update(!get_value());
429 patch->toggle_behavior(Tracks::GANG,
432 &patch->track->gang);
438 int GangPatch::button_release_event()
440 if(patch->patchbay->drag_operation != Tracks::NONE)
442 patch->patchbay->drag_operation = Tracks::NONE;
458 DrawPatch::DrawPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
460 mwindow->theme->drawpatch_data,
467 this->mwindow = mwindow;
469 set_tooltip(_("Draw media"));
473 int DrawPatch::button_press_event()
475 if(is_event_win() && get_buttonpress() == 1)
477 update(!get_value());
478 patch->toggle_behavior(Tracks::DRAW,
481 &patch->track->draw);
487 int DrawPatch::button_release_event()
489 if(patch->patchbay->drag_operation != Tracks::NONE)
491 patch->patchbay->drag_operation = Tracks::NONE;
506 MutePatch::MutePatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
508 mwindow->theme->mutepatch_data,
509 get_keyframe(mwindow, patch)->value,
515 this->mwindow = mwindow;
517 set_tooltip(_("Don't send to output"));
521 int MutePatch::button_press_event()
523 if(is_event_win() && get_buttonpress() == 1)
525 update(!get_value());
527 double position = mwindow->edl->local_session->selectionstart;
528 Autos *mute_autos = patch->track->automation->mute_autos;
530 mwindow->undo->update_undo_before(_("keyframe"), LOAD_AUTOMATION);
532 current = (IntAuto*)mute_autos->get_auto_for_editing(position);
533 current->value = get_value();
535 patch->toggle_behavior(Tracks::MUTE,
541 mwindow->undo->update_undo_after();
543 if(mwindow->edl->session->auto_conf->mute)
545 mwindow->gui->canvas->draw_overlays();
546 mwindow->gui->canvas->flash();
553 int MutePatch::button_release_event()
555 if(patch->patchbay->drag_operation != Tracks::NONE)
557 patch->patchbay->drag_operation = Tracks::NONE;
563 IntAuto* MutePatch::get_keyframe(MWindow *mwindow, PatchGUI *patch)
566 double unit_position = mwindow->edl->local_session->selectionstart;
567 unit_position = mwindow->edl->align_to_frame(unit_position, 0);
568 unit_position = patch->track->to_units(unit_position, 0);
569 return (IntAuto*)patch->track->automation->mute_autos->get_prev_auto(
586 ExpandPatch::ExpandPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
589 mwindow->theme->expandpatch_data,
590 patch->track->expand_view,
596 this->mwindow = mwindow;
601 int ExpandPatch::button_press_event()
603 if(is_event_win() && get_buttonpress() == 1)
605 update(!get_value());
606 patch->toggle_behavior(Tracks::EXPAND,
609 &patch->track->expand_view);
610 mwindow->trackmovement(mwindow->edl->local_session->track_start);
616 int ExpandPatch::button_release_event()
618 if(patch->patchbay->drag_operation != Tracks::NONE)
620 patch->patchbay->drag_operation = Tracks::NONE;