awindowgui / mwindowedit / label rework
[goodguy/history.git] / cinelerra-5.1 / cinelerra / assetedit.C
index 27a5a8db5ed72defb95f0d5a34dde1c391df099f..eebc32af0fbf49f5b5e19388f9628e799f6a9a78 100644 (file)
@@ -78,11 +78,7 @@ AssetEdit::~AssetEdit()
 
 void AssetEdit::edit_asset(Indexable *indexable)
 {
-       if(this->indexable)
-       {
-               close_window();
-       }
-
+       close_window();
        this->indexable = indexable;
        this->indexable->add_user();
 
@@ -110,57 +106,41 @@ void AssetEdit::edit_asset(Indexable *indexable)
 
 void AssetEdit::handle_done_event(int result)
 {
-       if( !result ) {
-               changed_params->tcstart = ceil(indexable->get_frame_rate() *
-                       (atoi(window->tc_hours_textbox->get_text()) * 3600 +
-                        atoi(window->tc_minutes_textbox->get_text()) * 60 +
-                        atoi(window->tc_seconds_textbox->get_text()))) +
-                        atoi(window->tc_rest_textbox->get_text());
-       }
 }
 
 void AssetEdit::handle_close_event(int result)
 {
-       if(!result)
-       {
+       if(!result) {
                int changed = 0;
                Asset *asset = 0;
                EDL *nested_edl = 0;
 
-               if(indexable->is_asset)
-               {
+               if(indexable->is_asset) {
                        asset = (Asset*)indexable;
-                       if(!changed_params->equivalent(*asset, 1, 1, mwindow->edl))
+                       if( !changed_params->equivalent(*asset, 1, 1, mwindow->edl) )
                                changed = 1;
                }
-               else
-               {
+               else {
                        nested_edl = (EDL*)indexable;
-                       if(strcmp(changed_params->path, nested_edl->path)
-//                ||
-//                changed_params->sample_rate != nested_edl->session->sample_rate ||
-//                             !EQUIV(changed_params->frame_rate, nested_edl->session->frame_rate)
-                )
+                       if( strcmp(changed_params->path, nested_edl->path)
+//                          || changed_params->sample_rate != nested_edl->session->sample_rate
+//                          || !EQUIV(changed_params->frame_rate, nested_edl->session->frame_rate
+                       )
                                changed = 1;
                }
-//printf("AssetEdit::handle_close_event %d\n", __LINE__);
-
-               if(changed)
-               {
+               if(changed) {
                        mwindow->gui->lock_window();
 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
 
 // Omit index status from copy since an index rebuild may have been
 // happening when new_asset was created but not be happening anymore.
-                       if(asset)
-                       {
+                       if(asset) {
                                mwindow->remove_asset_from_caches(asset);
 //printf("AssetEdit::handle_close_event %d %f\n", __LINE__, asset->get_frame_rate());
                                asset->copy_from(changed_params, 0);
 //printf("AssetEdit::handle_close_event %d %d %d\n", __LINE__, changed_params->bits, asset->bits);
                        }
-                       else
-                       {
+                       else {
                                strcpy(nested_edl->path, changed_params->path);
 // Other parameters can't be changed because they're defined in the other EDL
 //                nested_edl->session->frame_rate = changed_params->frame_rate;
@@ -168,18 +148,11 @@ void AssetEdit::handle_close_event(int result)
                        }
 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
 
-                       mwindow->gui->update(0,
-                               2,
-                               0,
-                               0,
-                               0,
-                               0,
-                               0);
+                       mwindow->gui->update(0, 2, 0, 0, 0, 0, 0);
 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
 
 // Start index rebuilding
-                       if( (asset && asset->audio_data) || nested_edl)
-                       {
+                       if( (asset && asset->audio_data) || nested_edl) {
                                char source_filename[BCTEXTLEN];
                                char index_filename[BCTEXTLEN];
                                IndexFile::get_index_filename(source_filename,
@@ -193,6 +166,7 @@ void AssetEdit::handle_close_event(int result)
                        }
                        mwindow->gui->unlock_window();
 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
+                       mwindow->awindow->gui->update_picon(indexable);
                        mwindow->awindow->gui->async_update_assets();
 
                        mwindow->restart_brender();
@@ -213,23 +187,29 @@ BC_Window* AssetEdit::new_gui()
        return window;
 }
 
-
-
-
-
-
-
-
+int AssetEdit::window_height()
+{
+       int h = 128 + 64;
+       if( indexable->have_audio() )
+               h += 180;
+       if( indexable->have_video() ) {
+               h += 200;
+               if( indexable->is_asset ) {
+                       Asset *asset = (Asset *)indexable;
+                       if( asset->format == FILE_MPEG ||
+                           asset->format == FILE_FFMPEG ) {
+                               h += 40;
+                       }
+               }
+       }
+       return h;
+}
 
 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
  : BC_Window(_(PROGRAM_NAME ": Asset Info"),
        mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
-       mwindow->gui->get_abs_cursor_y(1) - (128 + 64 +
-               (!asset_edit->indexable->have_audio() ? 0 : 180) +
-               (!asset_edit->indexable->have_video() ? 0 : 350)) / 2,
-       450, (128 + 64 +
-               (!asset_edit->indexable->have_audio() ? 0 : 180) +
-               (!asset_edit->indexable->have_video() ? 0 : 350)), 0, 0, 1)
+       mwindow->gui->get_abs_cursor_y(1) - asset_edit->window_height() / 2,
+       450, asset_edit->window_height(), 0, 0, 1)
 {
        this->mwindow = mwindow;
        this->asset_edit = asset_edit;
@@ -240,6 +220,8 @@ AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
        lohi = 0;
        allow_edits = 0;
        detail_thread = 0;
+       win_width = 0;
+       win_height = 0;
 }
 
 
@@ -602,47 +584,6 @@ void AssetEditWindow::create_objects()
                ilacefixoption_chkboxw->ilacefixmethod_listbox = listboxw;
                ilacefixoption_chkboxw->showhideotherwidgets();
                y += textboxw->get_h() + 5;
-
-               x = x1;
-               add_subwindow(new BC_Title(x, y, _("Reel Name:")));
-               x = x2;
-               add_subwindow(new AssetEditReelName(this, x, y));
-               y += 30;
-
-               x = x1;
-               add_subwindow(new BC_Title(x, y, _("Reel Number:")));
-               x = x2;
-               add_subwindow(new AssetEditReelNumber(this, x, y));
-               y += 30;
-
-               x = x1;
-               add_subwindow(new BC_Title(x, y, _("Time Code Start:")));
-               x = x2;
-
-// Calculate values to enter into textboxes
-               char text[32], *tc = text;
-               if( asset )
-                       Units::totext(tc, asset->tcstart / asset->frame_rate,
-                               TIME_HMSF, asset->sample_rate, asset->frame_rate);
-               else
-                       strcpy(tc, "0:00:00:00");
-
-               const char *tc_hours = tc, *tc_minutes, *tc_seconds, *tc_rest;
-               tc = strchr(tc, ':');  *tc++ = 0;  tc_minutes = tc;
-               tc = strchr(tc, ':');  *tc++ = 0;  tc_seconds = tc;
-               tc = strchr(tc, ':');  *tc++ = 0;  tc_rest = tc;
-
-               int padw = BC_Title::calculate_w(this, ":", MEDIUMFONT);
-               int fldw = BC_Title::calculate_w(this, "00", MEDIUMFONT) + 5;
-               add_subwindow(tc_hours_textbox = new BC_TextBox(x, y, fldw, 1, tc_hours));
-               add_subwindow(new BC_Title(x += tc_hours_textbox->get_w(), y, ":"));
-               add_subwindow(tc_minutes_textbox = new BC_TextBox(x += padw, y, fldw, 1, tc_minutes));
-               add_subwindow(new BC_Title(x += tc_minutes_textbox->get_w(), y, ":"));
-               add_subwindow(tc_seconds_textbox = new BC_TextBox(x += padw, y , fldw, 1, tc_seconds));
-               add_subwindow(new BC_Title(x += tc_seconds_textbox->get_w(), y, ":"));
-               add_subwindow(tc_rest_textbox = new BC_TextBox(x += 10, y, fldw, 1, tc_rest));
-
-               y += 30;
        }
 
        add_subwindow(new BC_OKButton(this));
@@ -1084,44 +1025,3 @@ void DetailAssetThread::run()
        dwindow = 0;
 }
 
-
-
-
-
-AssetEditReelName::AssetEditReelName(AssetEditWindow *fwindow, int x, int y)
- : BC_TextBox(x, y, 220, 1, fwindow->asset_edit->changed_params->reel_name,
-       1, MEDIUMFONT, 1)
-{
-       this->fwindow = fwindow;
-}
-AssetEditReelName::~AssetEditReelName()
-{
-}
-int AssetEditReelName::handle_event()
-{
-       Asset *asset = fwindow->asset_edit->changed_params;
-       strcpy(asset->reel_name, get_text());
-       return 1;
-}
-
-
-
-
-
-AssetEditReelNumber::AssetEditReelNumber(AssetEditWindow *fwindow, int x, int y)
- : BC_TextBox(x, y, 200, 1, fwindow->asset_edit->changed_params->reel_number)
-{
-       this->fwindow = fwindow;
-}
-AssetEditReelNumber::~AssetEditReelNumber()
-{
-}
-int AssetEditReelNumber::handle_event()
-{
-       Asset *asset = fwindow->asset_edit->changed_params;
-       asset->reel_number = atoi(get_text());
-       return 1;
-}
-
-
-