add bump floatautos, add time_references for align timecodes, add menuitem create_key...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / patchgui.C
index f7f4c7e25846ee9b49cadb1783e3d0532a59b3dc..fa471477af7e1eb25338f6311be9e2374a252483 100644 (file)
@@ -60,15 +60,19 @@ PatchGUI::PatchGUI(MWindow *mwindow,
        record = 0;
        play = 0;
 //     automate = 0;
-       gang = 0;
        draw = 0;
        mute = 0;
+       gang = 0;
+       master = 0;
+       zoom = 0;
        expand = 0;
        nudge = 0;
        mix = 0;
        change_source = 0;
        track_id = track ? track->get_id() : -1;
        mixer = 0;
+       edge = 0;
+       span = 1;
 }
 
 PatchGUI::~PatchGUI()
@@ -77,9 +81,11 @@ PatchGUI::~PatchGUI()
        delete record;
        delete play;
 //     delete automate;
-       delete gang;
        delete draw;
        delete mute;
+       delete gang;
+       delete master;
+       delete zoom;
        delete expand;
        delete nudge;
        delete mix;
@@ -92,6 +98,7 @@ void PatchGUI::create_objects()
 
 int PatchGUI::reposition(int x, int y)
 {
+       if( track->is_hidden() ) return 0;
        int x1 = 0;
        int y1 = 0;
 
@@ -112,12 +119,16 @@ int PatchGUI::reposition(int x, int y)
                        x1 += record->get_w();
 //                     automate->reposition_window(x1, y1 + y);
 //                     x1 += automate->get_w();
-                       gang->reposition_window(gang->get_x(), y1 + y);
-                       x1 += gang->get_w();
                        draw->reposition_window(draw->get_x(), y1 + y);
                        x1 += draw->get_w();
                        mute->reposition_window(mute->get_x(), y1 + y);
                        x1 += mute->get_w();
+                       gang->reposition_window(gang->get_x(), y1 + y);
+                       x1 += gang->get_w();
+                       master->reposition_window(master->get_x(), y1 + y);
+                       x1 += master->get_w();
+                       zoom->reposition_window(zoom->get_x(), y1 + y);
+//                     x1 += zoom->get_w();
                }
                y1 += mwindow->theme->play_h;
        }
@@ -133,6 +144,7 @@ int PatchGUI::reposition(int x, int y)
 
 int PatchGUI::update(int x, int y)
 {
+       if( track->is_hidden() ) return 0;
 //TRACE("PatchGUI::update 1");
        reposition(x, y);
 //TRACE("PatchGUI::update 10");
@@ -168,16 +180,19 @@ int PatchGUI::update(int x, int y)
                if( h < y2 ) {
                        delete play;    play = 0;
                        delete record;  record = 0;
-                       delete gang;    gang = 0;
                        delete draw;    draw = 0;
                        delete mute;    mute = 0;
+                       delete gang;    gang = 0;
+                       delete master;  master = 0;
+                       delete zoom;    zoom = 0;
                }
                else {
                        play->update(track->play);
-                       record->update(track->record);
-                       gang->update(track->gang);
+                       record->update(track->armed);
                        draw->update(track->draw);
                        mute->update(mwindow->get_int_auto(this, AUTOMATION_MUTE)->value);
+                       gang->update(track->ganged);
+                       master->update(track->master);
                }
        }
        else if( h >= y2 ) {
@@ -186,12 +201,16 @@ int PatchGUI::update(int x, int y)
                x1 += play->get_w();
                patchbay->add_subwindow(record = new RecordPatch(mwindow, this, x1 + x, y1 + y));
                x1 += record->get_w();
-               patchbay->add_subwindow(gang = new GangPatch(mwindow, this, x1 + x, y1 + y));
-               x1 += gang->get_w();
                patchbay->add_subwindow(draw = new DrawPatch(mwindow, this, x1 + x, y1 + y));
                x1 += draw->get_w();
                patchbay->add_subwindow(mute = new MutePatch(mwindow, this, x1 + x, y1 + y));
                x1 += mute->get_w();
+               patchbay->add_subwindow(gang = new GangPatch(mwindow, this, x1 + x, y1 + y));
+               x1 += gang->get_w();
+               patchbay->add_subwindow(master = new MasterPatch(mwindow, this, x1 + x, y1 + y));
+               x1 += master->get_w();
+               patchbay->add_subwindow(zoom = new ZoomPatch(mwindow, this, x1 + x, y1 + y));
+//             x1 += zoom->get_w();
        }
        if( play )
                y1 = y2;
@@ -254,7 +273,7 @@ void PatchGUI::toggle_behavior(int type,
                        break;
 
                case Tracks::DRAW:
-                       mwindow->gui->update(0, 1, 0, 0, 0, 0, 0);
+                       mwindow->gui->update(0, NORMAL_DRAW, 0, 0, 0, 0, 0);
                        break;
 
                case Tracks::EXPAND:
@@ -359,7 +378,7 @@ RecordPatch::RecordPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
  : BC_Toggle(x,
                y,
                mwindow->theme->get_image_set("recordpatch_data"),
-               patch->track->record,
+               patch->track->armed,
                "",
                0,
                0,
@@ -381,11 +400,12 @@ int RecordPatch::button_press_event()
                patch->toggle_behavior(Tracks::RECORD,
                        get_value(),
                        this,
-                       &patch->track->record);
-               patch->title->set_back_color(patch->track->record ?
+                       &patch->track->armed);
+               patch->title->set_back_color(patch->track->armed ?
                        get_resources()->text_background :
                        get_resources()->text_background_disarmed);
                patch->title->set_text_row(0);
+               mwindow->gui->draw_overlays(1);
                return 1;
        }
        return 0;
@@ -415,7 +435,7 @@ int RecordPatch::button_release_event()
 GangPatch::GangPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
  : BC_Toggle(x, y,
                mwindow->theme->get_image_set("gangpatch_data"),
-               patch->track->gang,
+               patch->track->ganged,
                "",
                0,
                0,
@@ -437,7 +457,7 @@ int GangPatch::button_press_event()
                patch->toggle_behavior(Tracks::GANG,
                        get_value(),
                        this,
-                       &patch->track->gang);
+                       &patch->track->ganged);
                return 1;
        }
        return 0;
@@ -573,16 +593,52 @@ int MutePatch::button_release_event()
 }
 
 
+ZoomPatch::ZoomPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
+ : BC_Tumbler(x, y, mwindow->theme->get_image_set("tumblepatch_data"))
+{
+       this->mwindow = mwindow;
+       this->patch = patch;
+       set_tooltip(_("Track Data Height"));
+}
+
+int ZoomPatch::handle_up_event()
+{
+       patch->track->data_h *= 2;
+       bclamp(patch->track->data_h,  MIN_TRACK_ZOOM, MAX_TRACK_ZOOM);
+       mwindow->edl->tracks->update_y_pixels(mwindow->theme);
+       mwindow->gui->draw_trackmovement();
+       return 1;
+}
+int ZoomPatch::handle_down_event()
+{
+       patch->track->data_h /= 2;
+       bclamp(patch->track->data_h,  MIN_TRACK_ZOOM, MAX_TRACK_ZOOM);
+       mwindow->edl->tracks->update_y_pixels(mwindow->theme);
+       mwindow->gui->draw_trackmovement();
+       return 1;
+}
+
+
+MasterPatch::MasterPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
+ : BC_Toggle(x, y, mwindow->theme->get_image_set("masterpatch_data"),
+               patch->track->master, "", 0, 0, 0)
+{
+       this->mwindow = mwindow;
+       this->patch = patch;
+       set_tooltip(_("Master Track"));
+}
+
+int MasterPatch::handle_event()
+{
+       patch->track->master = patch->track->master ? 0 : 1;
+       mwindow->draw_trackmovement();  // delayed, can delete *this
+       return 1;
+}
+
 
 ExpandPatch::ExpandPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
- : BC_Toggle(x,
-               y,
-               mwindow->theme->get_image_set("expandpatch_data"),
-               patch->track->expand_view,
-               "",
-               0,
-               0,
-               0)
+ : BC_Toggle(x, y, mwindow->theme->get_image_set("expandpatch_data"),
+               patch->track->expand_view, "", 0, 0, 0)
 {
        this->mwindow = mwindow;
        this->patch = patch;
@@ -624,14 +680,14 @@ TitlePatch::TitlePatch(MWindow *mwindow, PatchGUI *patch, int x, int y, int w)
 {
        this->mwindow = mwindow;
        this->patch = patch;
-       set_back_color(patch->track->record ?
+       set_back_color(patch->track->armed ?
                        get_resources()->text_background :
                        get_resources()->text_background_disarmed);
 }
 
 void TitlePatch::update(const char *text)
 {
-       set_back_color(patch->track->record ?
+       set_back_color(patch->track->armed ?
                        get_resources()->text_background :
                        get_resources()->text_background_disarmed);
        BC_TextBox::update(text);
@@ -675,7 +731,7 @@ void NudgePatch::set_value(int64_t value)
        mwindow->undo->update_undo_before(_("nudge."), this);
        patch->track->nudge = value;
 
-       if(patch->track->gang && patch->track->record)
+       if(patch->track->is_ganged() && patch->track->is_armed())
                patch->patchbay->synchronize_nudge(patch->track->nudge, patch->track);
 
        mwindow->undo->update_undo_after(_("nudge."), LOAD_PATCHES);