add new tracks as master, update msg txt
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / trackpopup.C
index f6f0e315190d845d13c9641835e88db40329dc0e..077fa9cb23cd208ea90fe20feb77f9a35257f0c4 100644 (file)
@@ -216,10 +216,10 @@ int TrackPopupAddTrack::handle_event()
                mwindow->add_audio_track_entry(1, popup->track);
                break;
        case TRACK_VIDEO:
-               mwindow->add_video_track_entry(popup->track);
+               mwindow->add_video_track_entry(1, popup->track);
                break;
        case TRACK_SUBTITLE:
-               mwindow->add_subttl_track_entry(popup->track);
+               mwindow->add_subttl_track_entry(1, popup->track);
                break;
        }
        return 1;
@@ -279,12 +279,15 @@ TrackPopupUserTitle::~TrackPopupUserTitle()
        delete dialog_thread;
 }
 
+#define TTW_W xS(300)
+#define TTW_H yS(130)
+
 int TrackPopupUserTitle::handle_event()
 {
        if( popup->edit ) {
                dialog_thread->close_window();
-               int wx = mwindow->gui->get_abs_cursor_x(0) - 400 / 2;
-               int wy = mwindow->gui->get_abs_cursor_y(0) - 500 / 2;
+               int wx = mwindow->gui->get_abs_cursor_x(0) - TTW_W / 2;
+               int wy = mwindow->gui->get_abs_cursor_y(0) - TTW_H / 2;
                dialog_thread->start(wx, wy);
        }
        return 1;
@@ -329,7 +332,7 @@ void TrackUserTitleDialogThread::handle_done_event(int result)
        const char *text = window->title_text->get_text();
        int count = 0;
        for( Track *track=edl->tracks->first; track; track=track->next ) {
-               if( !track->record ) continue;
+               if( !track->is_armed() ) continue;
                for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
                        if( !edit->is_selected ) continue;
                        strcpy(edit->user_title, text);
@@ -350,7 +353,7 @@ void TrackUserTitleDialogThread::handle_done_event(int result)
 TrackPopupUserTitleWindow::TrackPopupUserTitleWindow(MWindow *mwindow,
                TrackPopup *popup, int wx, int wy)
  : BC_Window(_(PROGRAM_NAME ": Set edit title"), wx, wy,
-       300, 130, 300, 130, 0, 0, 1)
+       TTW_W, TTW_H, TTW_W, TTW_H, 0, 0, 1)
 {
        this->mwindow = mwindow;
        this->popup = popup;
@@ -364,9 +367,9 @@ TrackPopupUserTitleWindow::~TrackPopupUserTitleWindow()
 void TrackPopupUserTitleWindow::create_objects()
 {
        lock_window("TrackPopupUserTitleWindow::create_objects");
-       int x = 10, y = 10, x1;
+       int x = xS(10), y = yS(10), x1;
        BC_Title *title = new BC_Title(x1=x, y, _("User title:"));
-       add_subwindow(title);  x1 += title->get_w() + 10;
+       add_subwindow(title);  x1 += title->get_w() + xS(10);
        title_text = new TrackPopupUserTitleText(this, mwindow, x1, y, new_text);
        add_subwindow(title_text);
 
@@ -382,7 +385,7 @@ void TrackPopupUserTitleWindow::create_objects()
 
 TrackPopupUserTitleText::TrackPopupUserTitleText(TrackPopupUserTitleWindow *window,
        MWindow *mwindow, int x, int y, const char *text)
- : BC_TextBox(x, y, window->get_w()-x-15, 1, text)
+ : BC_TextBox(x, y, window->get_w()-x-xS(15), 1, text)
 {
        this->window = window;
        this->mwindow = mwindow;
@@ -451,10 +454,12 @@ TrackTitleColorPicker::~TrackTitleColorPicker()
 }
 void TrackTitleColorPicker::create_objects(ColorWindow *gui)
 {
-       int y = gui->get_h() - BC_CancelButton::calculate_h() + 10;
-       int x = gui->get_w() - BC_CancelButton::calculate_w() - 10;
-       x -= BC_GenericButton::calculate_w(gui, _("default")) + 15;
+       gui->lock_window("TrackTitleColorPicker::create_objects");
+       int y = gui->get_h() - BC_CancelButton::calculate_h() + yS(10);
+       int x = gui->get_w() - BC_CancelButton::calculate_w() - xS(10);
+       x -= BC_GenericButton::calculate_w(gui, _("default")) + xS(15);
        gui->add_subwindow(new TrackTitleColorDefault(this, x, y));
+       gui->unlock_window();
 }
 
 int TrackTitleColorPicker::handle_new_color(int color, int alpha)
@@ -469,7 +474,7 @@ void TrackTitleColorPicker::handle_done_event(int result)
                EDL *edl = popup->mwindow->edl;
                int count = 0;
                for( Track *track=edl->tracks->first; track; track=track->next ) {
-                       if( !track->record ) continue;
+                       if( !track->is_armed() ) continue;
                        for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
                                if( !edit->is_selected ) continue;
                                edit->color = color;
@@ -488,6 +493,9 @@ void TrackTitleColorPicker::handle_done_event(int result)
 }
 
 
+#define TPW_W xS(300)
+#define TPW_H yS(220)
+
 TrackPopupShow::TrackPopupShow(MWindow *mwindow, TrackPopup *popup)
  : BC_MenuItem(_("Show edit"))
 {
@@ -505,8 +513,8 @@ int TrackPopupShow::handle_event()
 {
        if( popup->edit ) {
                dialog_thread->close_window();
-               int wx = mwindow->gui->get_abs_cursor_x(0) - 400 / 2;
-               int wy = mwindow->gui->get_abs_cursor_y(0) - 500 / 2;
+               int wx = mwindow->gui->get_abs_cursor_x(0) - TPW_W / 2;
+               int wy = mwindow->gui->get_abs_cursor_y(0) - TPW_H / 2;
                dialog_thread->start(wx, wy);
        }
        return 1;
@@ -545,7 +553,7 @@ void TrackShowDialogThread::handle_close_event(int result)
 TrackPopupShowWindow::TrackPopupShowWindow(MWindow *mwindow,
                TrackPopup *popup, int wx, int wy)
  : BC_Window(_(PROGRAM_NAME ": Show edit"), wx, wy,
-       300, 220, 300, 220, 0, 0, 1)
+       TPW_W, TPW_H, TPW_W, TPW_H, 0, 0, 1)
 {
        this->mwindow = mwindow;
        this->popup = popup;
@@ -558,24 +566,25 @@ TrackPopupShowWindow::~TrackPopupShowWindow()
 void TrackPopupShowWindow::create_objects()
 {
        lock_window("TrackPopupShowWindow::create_objects");
-       int x = 10, y = 10;
+       int x = xS(10), y = yS(10);
        BC_Title *title;
        char text[BCTEXTLEN];
        Edit *edit = popup->edit;
        Track *track = edit->track;
        sprintf(text, _("Track %d:"), mwindow->edl->tracks->number_of(track)+1);
        add_subwindow(title = new BC_Title(x, y, text));
-       int x1 = x + title->get_w() + 10;
-       int tw = get_w() - x1 - 20;
-       truncate_text(text, track->title, tw);
-       add_subwindow(new BC_Title(x1, y, text));
+       int x1 = x + title->get_w() + xS(10);
+       int tw = get_w() - x1 - xS(20);
+       char *track_title = get_truncated_text(MEDIUMFONT, track->title, tw);
+       add_subwindow(new BC_Title(x1, y, track_title));
+       delete [] track_title;
        y += title->get_h() + 5;
        sprintf(text, _("Edit %d:"), track->edits->number_of(edit)+1);
        add_subwindow(title = new BC_Title(x, y, text));
-       char edit_title[BCTEXTLEN];
-       edit->get_title(edit_title);
-       truncate_text(text, edit_title, tw);
-       add_subwindow(new BC_Title(x1, y, text));
+       edit->get_title(text);
+       char *edit_title = get_truncated_text(MEDIUMFONT, text, tw);
+       add_subwindow(new BC_Title(x1, y, edit_title));
+       delete [] edit_title;
        y += title->get_h() + 5;
 
        EDLSession *session = mwindow->edl->session;
@@ -598,7 +607,7 @@ void TrackPopupShowWindow::create_objects()
                        time_format, sample_rate, frame_rate, frames_per_foot),
                Units::totext(text_length, length,
                        time_format, sample_rate, frame_rate, frames_per_foot));
-       show_text = new TrackPopupShowText(this, mwindow, x+15, y+10, text);
+       show_text = new TrackPopupShowText(this, mwindow, x+xS(15), y+yS(10), text);
        add_subwindow(show_text);
        add_tool(new BC_OKButton(this));
 
@@ -610,7 +619,7 @@ void TrackPopupShowWindow::create_objects()
 
 TrackPopupShowText::TrackPopupShowText(TrackPopupShowWindow *window,
        MWindow *mwindow, int x, int y, const char *text)
- : BC_TextBox(x, y, 250, 4, text)
+ : BC_TextBox(x, y, xS(250), 4, text)
 {
        this->window = window;
        this->mwindow = mwindow;