olaf neophyte and de.po updates, valgrind tweaks, delete green lady, inkscape dpi=96
[goodguy/history.git] / cinelerra-5.1 / cinelerra / patchgui.C
index 72211d1ac4c1036713e34aff0079caeb9827dd0b..f7f4c7e25846ee9b49cadb1783e3d0532a59b3dc 100644 (file)
@@ -42,7 +42,7 @@
 #include "tracks.h"
 #include "transportque.h"
 #include "vframe.h"
-
+#include "zwindow.h"
 
 
 PatchGUI::PatchGUI(MWindow *mwindow,
@@ -65,22 +65,24 @@ PatchGUI::PatchGUI(MWindow *mwindow,
        mute = 0;
        expand = 0;
        nudge = 0;
+       mix = 0;
        change_source = 0;
-       track_id = -1;
-       if(track) track_id = track->get_id();
+       track_id = track ? track->get_id() : -1;
+       mixer = 0;
 }
 
 PatchGUI::~PatchGUI()
 {
-       if(title) delete title;
-       if(record) delete record;
-       if(play) delete play;
-//     if(automate) delete automate;
-       if(gang) delete gang;
-       if(draw) delete draw;
-       if(mute) delete mute;
-       if(expand) delete expand;
-       if(nudge) delete nudge;
+       delete title;
+       delete record;
+       delete play;
+//     delete automate;
+       delete gang;
+       delete draw;
+       delete mute;
+       delete expand;
+       delete nudge;
+       delete mix;
 }
 
 void PatchGUI::create_objects()
@@ -94,59 +96,36 @@ int PatchGUI::reposition(int x, int y)
        int y1 = 0;
 
 
-       if(x != this->x || y != this->y)
-       {
-               this->x = x;
-               this->y = y;
+       if( x != this->x || y != this->y ) {
+               this->x = x;  this->y = y;
 
-               if(title)
-               {
-TRACE("PatchGUI::reposition 1\n");
+               if( title )
                        title->reposition_window(title->get_x(), y1 + y, 0);
-TRACE("PatchGUI::reposition 2\n");
-               }
+               if( expand )
+                       expand->reposition_window(expand->get_x(), y1 + y);
                y1 += mwindow->theme->title_h;
 
-               if(play)
-               {
-TRACE("PatchGUI::reposition 3\n");
+               if( play ) {
                        play->reposition_window(play->get_x(), y1 + y);
                        x1 += play->get_w();
-TRACE("PatchGUI::reposition 4\n");
                        record->reposition_window(record->get_x(), y1 + y);
                        x1 += record->get_w();
-TRACE("PatchGUI::reposition 5\n");
 //                     automate->reposition_window(x1, y1 + y);
 //                     x1 += automate->get_w();
                        gang->reposition_window(gang->get_x(), y1 + y);
                        x1 += gang->get_w();
-TRACE("PatchGUI::reposition 6\n");
                        draw->reposition_window(draw->get_x(), y1 + y);
                        x1 += draw->get_w();
-TRACE("PatchGUI::reposition 7\n");
                        mute->reposition_window(mute->get_x(), y1 + y);
                        x1 += mute->get_w();
-TRACE("PatchGUI::reposition 8\n");
-
-                       if(expand)
-                       {
-TRACE("PatchGUI::reposition 9\n");
-//     VFrame **expandpatch_data = mwindow->theme->get_image_set("expandpatch_data");
-//     int x = patchbay->get_w() - 10 - expandpatch_data[0]->get_w();
-                               expand->reposition_window(
-                                       expand->get_x(),
-                                       y1 + y);
-TRACE("PatchGUI::reposition 10\n");
-                               x1 += expand->get_w();
-TRACE("PatchGUI::reposition 11\n");
-                       }
                }
                y1 += mwindow->theme->play_h;
        }
-       else
-       {
-               y1 += mwindow->theme->title_h;
-               y1 += mwindow->theme->play_h;
+       else {
+               if( title )
+                       y1 += mwindow->theme->title_h;
+               if( play )
+                       y1 += mwindow->theme->play_h;
        }
 
        return y1;
@@ -163,49 +142,45 @@ int PatchGUI::update(int x, int y)
        int x1 = 0;
 //printf("PatchGUI::update 10\n");
 
-       if(title)
-       {
-               if(h - y1 < 0)
-               {
-                       delete title;
-                       title = 0;
+       int y2 = y1 + mwindow->theme->title_h;
+       if( title ) {
+               if( h < y2 ) {
+                       delete title;   title = 0;
+                       delete expand;  expand = 0;
                }
-               else
-               {
+               else {
                        title->update(track->title);
+                       expand->update(track->expand_view);
                }
        }
-       else
-       if(h - y1 >= 0)
-       {
-               patchbay->add_subwindow(title = new TitlePatch(mwindow, this, x1 + x, y1 + y));
+       else if( h >= y2 ) {
+               VFrame **expandpatch_data = mwindow->theme->get_image_set("expandpatch_data");
+               int x2 = patchbay->get_w() - expandpatch_data[0]->get_w() - 5;
+               patchbay->add_subwindow(title = new TitlePatch(mwindow, this, x1 + x, y1 + y, x2-x1-5));
+               patchbay->add_subwindow(expand = new ExpandPatch(mwindow, this, x2, y1 + y));
        }
-       y1 += mwindow->theme->title_h;
 
-       if(play)
-       {
-               if(h - y1 < mwindow->theme->play_h)
-               {
+       if( title )
+               y1 = y2;
+
+       y2 = y1 + mwindow->theme->play_h;
+       if( play ) {
+               if( h < y2 ) {
                        delete play;    play = 0;
                        delete record;  record = 0;
                        delete gang;    gang = 0;
                        delete draw;    draw = 0;
                        delete mute;    mute = 0;
-                       delete expand;  expand = 0;
                }
-               else
-               {
+               else {
                        play->update(track->play);
                        record->update(track->record);
                        gang->update(track->gang);
                        draw->update(track->draw);
                        mute->update(mwindow->get_int_auto(this, AUTOMATION_MUTE)->value);
-                       expand->update(track->expand_view);
                }
        }
-       else
-       if(h - y1 >= mwindow->theme->play_h)
-       {
+       else if( h >= y2 ) {
                patchbay->add_subwindow(play = new PlayPatch(mwindow, this, x1 + x, y1 + y));
 //printf("PatchGUI::update %d %d\n", __LINE__, play->get_h());
                x1 += play->get_w();
@@ -217,15 +192,9 @@ int PatchGUI::update(int x, int y)
                x1 += draw->get_w();
                patchbay->add_subwindow(mute = new MutePatch(mwindow, this, x1 + x, y1 + y));
                x1 += mute->get_w();
-
-               VFrame **expandpatch_data = mwindow->theme->get_image_set("expandpatch_data");
-               patchbay->add_subwindow(expand = new ExpandPatch(mwindow,
-                       this,
-                       patchbay->get_w() - 10 - expandpatch_data[0]->get_w(),
-                       y1 + y));
-               x1 += expand->get_w();
        }
-       y1 += mwindow->theme->play_h;
+       if( play )
+               y1 = y2;
 
 //UNTRACE
        return y1;
@@ -333,16 +302,6 @@ int64_t PatchGUI::calculate_nudge(const char *string)
 }
 
 
-
-
-
-
-
-
-
-
-
-
 PlayPatch::PlayPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
  : BC_Toggle(x,
                y,
@@ -423,6 +382,10 @@ int RecordPatch::button_press_event()
                        get_value(),
                        this,
                        &patch->track->record);
+               patch->title->set_back_color(patch->track->record ?
+                       get_resources()->text_background :
+                       get_resources()->text_background_disarmed);
+               patch->title->set_text_row(0);
                return 1;
        }
        return 0;
@@ -656,19 +619,22 @@ int ExpandPatch::button_release_event()
 }
 
 
-
-
-
-TitlePatch::TitlePatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
- : BC_TextBox(x,
-               y,
-               patch->patchbay->get_w() - 10,
-               1,
-               patch->track->title,
-               1, MEDIUMFONT, 1)
+TitlePatch::TitlePatch(MWindow *mwindow, PatchGUI *patch, int x, int y, int w)
+ : BC_TextBox(x, y, w, 1, patch->track->title, 1, MEDIUMFONT, 1)
 {
        this->mwindow = mwindow;
        this->patch = patch;
+       set_back_color(patch->track->record ?
+                       get_resources()->text_background :
+                       get_resources()->text_background_disarmed);
+}
+
+void TitlePatch::update(const char *text)
+{
+       set_back_color(patch->track->record ?
+                       get_resources()->text_background :
+                       get_resources()->text_background_disarmed);
+       BC_TextBox::update(text);
 }
 
 int TitlePatch::handle_event()
@@ -682,13 +648,6 @@ int TitlePatch::handle_event()
 }
 
 
-
-
-
-
-
-
-
 NudgePatch::NudgePatch(MWindow *mwindow,
        PatchGUI *patch,
        int x,
@@ -713,13 +672,13 @@ int NudgePatch::handle_event()
 
 void NudgePatch::set_value(int64_t value)
 {
-       mwindow->undo->update_undo_before(_("nudge"), this);
+       mwindow->undo->update_undo_before(_("nudge."), this);
        patch->track->nudge = value;
 
        if(patch->track->gang && patch->track->record)
                patch->patchbay->synchronize_nudge(patch->track->nudge, patch->track);
 
-       mwindow->undo->update_undo_after(_("nudge"), LOAD_PATCHES);
+       mwindow->undo->update_undo_after(_("nudge."), LOAD_PATCHES);
 
        mwindow->gui->unlock_window();
        if(patch->track->data_type == TRACK_VIDEO)
@@ -789,5 +748,34 @@ void NudgePatch::update()
 }
 
 
+MixPatch::MixPatch(MWindow *mwindow, PatchGUI *patch, int x, int y)
+ : BC_Toggle(x, y, mwindow->theme->get_image_set("mixpatch_data"),
+       patch->mixer, "", 0, 0, 0)
+{
+       this->mwindow = mwindow;
+       this->patch = patch;
+}
+
+MixPatch::~MixPatch()
+{
+}
 
+int MixPatch::handle_event()
+{
+       int v = patch->track ? get_value() : 0;
+       if( patch->mixer != v ) {
+               if( patch->track )
+                       mwindow->gui->update_mixers(patch->track, v);
+               else
+                       update(v);
+               mwindow->update_mixer_tracks();
+       }
+       return 1;
+}
+
+void MixPatch::update(int v)
+{
+       patch->mixer = v;
+       BC_Toggle::update(v);
+}