add x10tv ati remote rework, android remote rework, wintv remote tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / assetedit.C
index 4df0f70a40ec52b27e363ae182d35b87146060a2..6222f1c6913a05a6b686fa36f15f196c77e41abd 100644 (file)
@@ -133,7 +133,7 @@ void AssetEdit::handle_close_event(int result)
 // 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 ) {
-                               mwindow->remove_asset_from_caches(asset);
+                               mwindow->remove_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);
@@ -146,7 +146,7 @@ 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, FORCE_REDRAW, 0, 0, 0, 0, 0);
 //printf("AssetEdit::handle_close_event %d\n", __LINE__);
 
 // Start index rebuilding
@@ -159,7 +159,7 @@ void AssetEdit::handle_close_event(int result)
                                        indexable->path);
                                remove_file(index_filename);
                                indexable->index_state->index_status = INDEX_NOTTESTED;
-                               mwindow->mainindexes->add_next_asset(0, indexable);
+                               mwindow->mainindexes->add_indexable(indexable);
                                mwindow->mainindexes->start_build();
                        }
                        mwindow->gui->unlock_window();
@@ -190,20 +190,22 @@ int AssetEdit::window_height()
        int h = 128 + 64;
        if( indexable->have_audio() ) h += 200;
        if( indexable->have_video() ) {
-               h += 210;
+               h += 160;
                if( indexable->is_asset ) {
                        Asset *asset = (Asset *)indexable;
                        if( File::can_scale_input(asset) )
                                h += 42;
                }
        }
-       return h;
+       return yS(h);
 }
 
+#define AEW_W xS(450)
+
 AssetEditWindow::AssetEditWindow(MWindow *mwindow, AssetEdit *asset_edit)
  : BC_Window(_(PROGRAM_NAME ": Asset Info"),
-       asset_edit->x - 450/2, asset_edit->y - asset_edit->window_height()/2,
-       450, asset_edit->window_height(), 0, 0, 1)
+       asset_edit->x - AEW_W/2, asset_edit->y - asset_edit->window_height()/2,
+       AEW_W, asset_edit->window_height(), 0, 0, 1)
 {
        this->mwindow = mwindow;
        this->asset_edit = asset_edit;
@@ -235,14 +237,12 @@ AssetEditWindow::~AssetEditWindow()
 
 void AssetEditWindow::create_objects()
 {
-       int y = 10, x = 10, x1 = 10, x2 = 190;
+       int xpad10 = xS(10);
+       int ypad5 = yS(5), ypad10 = yS(10), ypad20 = yS(20), ypad30 = yS(30);
+       int y = ypad10, x = xpad10, x1 = xpad10, x2 = xS(190);
        char string[BCTEXTLEN];
-       int vmargin;
        FileSystem fs;
        BC_Title *title;
-       BC_TextBox  *textboxw;
-       BC_ListBox  *listboxw;
-       Interlaceautofix *ilacefixoption_chkboxw;
        Asset *asset = 0;
        EDL *nested_edl = 0;
 
@@ -251,23 +251,16 @@ void AssetEditWindow::create_objects()
        else
                nested_edl = (EDL*)asset_edit->indexable;
 
-       if( asset && asset->format == FILE_PCM )
-               allow_edits = 1;
-       else
-               allow_edits = 0;
-
+       allow_edits = asset && asset->format == FILE_PCM ? 1 : 0;
+       int vmargin = yS(allow_edits ? 30 : 20);
        lock_window("AssetEditWindow::create_objects");
-       if( allow_edits )
-               vmargin = 30;
-       else
-               vmargin = 20;
 
        add_subwindow(path_text = new AssetEditPathText(this, y));
        add_subwindow(path_button = new AssetEditPath(mwindow, this,
                path_text, y, asset_edit->indexable->path,
                _(PROGRAM_NAME ": Asset path"),
                _("Select a file for this asset:")));
-       y += 30;
+       y += yS(30);
 
        if( asset ) {
                add_subwindow(new BC_Title(x, y, _("File format:")));
@@ -276,7 +269,7 @@ void AssetEditWindow::create_objects()
                        MEDIUMFONT,
                        mwindow->theme->assetedit_color));
                x = x1;
-               y += 20;
+               y += ypad20;
 
                int64_t bytes = fs.get_size(asset->path);
                add_subwindow(new BC_Title(x, y, _("Bytes:")));
@@ -287,15 +280,15 @@ void AssetEditWindow::create_objects()
                add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
                if( asset->format == FILE_MPEG || asset->format == FILE_FFMPEG ) {
                        detail_dialog = new DetailAssetDialog(mwindow);
-                       BC_GenericButton *detail = new DetailAssetButton(this, x2+120, y);
+                       BC_GenericButton *detail = new DetailAssetButton(this, x2+xS(120), y);
                        add_subwindow(detail);
                }
 
-               y += 20;
+               y += ypad20;
                x = x1;
 
                double length = 0.;
-               y += 20;
+               y += ypad20;
                x = x1;
 
                if( asset->audio_length > 0 )
@@ -313,17 +306,17 @@ void AssetEditWindow::create_objects()
                Units::punctuate(string);
                add_subwindow(new BC_Title(x2, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
 
-               y += 30;
+               y += ypad30;
                x = x1;
        }
 
        if( (asset && asset->audio_data) || nested_edl ) {
                add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
-               y += 5;
+               y += ypad5;
 
                add_subwindow(new BC_Title(x, y, _("Audio:"), LARGEFONT, RED));
 
-               y += 30;
+               y += ypad30;
 
                if( asset ) {
                        if( asset->get_compression_text(1, 0) ) {
@@ -353,7 +346,7 @@ void AssetEditWindow::create_objects()
                }
                else {
                        add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
-                       y += 20;
+                       y += ypad20;
                }
 
                x = x1;
@@ -371,7 +364,7 @@ void AssetEditWindow::create_objects()
                        add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
                }
 
-               y += 30;
+               y += ypad30;
                x = x1;
 
                if( asset ) {
@@ -408,14 +401,10 @@ void AssetEditWindow::create_objects()
                                x = x2;
 
                                add_subwindow(lohi = new AssetEditByteOrderLOHI(this,
-                                       asset->byte_order,
-                                       x,
-                                       y));
-                               x += 70;
+                                       asset->byte_order, x, y));
+                               x += xS(70);
                                add_subwindow(hilo = new AssetEditByteOrderHILO(this,
-                                       !asset->byte_order,
-                                       x,
-                                       y));
+                                       !asset->byte_order, x, y));
                                y += vmargin;
                        }
                        else {
@@ -440,17 +429,17 @@ void AssetEditWindow::create_objects()
                                        add_subwindow(new BC_Title(x, y, _("Values are signed")));
                        }
 
-                       y += 30;
+                       y += ypad30;
                }
        }
 
        x = x1;
        if( (asset && asset->video_data) || nested_edl ) {
                add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
-               y += 5;
+               y += ypad5;
 
                add_subwindow(new BC_Title(x, y, _("Video:"), LARGEFONT, RED));
-               y += 30;
+               y += ypad30;
                x = x1;
 
 
@@ -474,14 +463,14 @@ void AssetEditWindow::create_objects()
                if( asset ) {
                        BC_TextBox *framerate;
                        add_subwindow(framerate = new AssetEditFRate(this, string, x, y));
-                       x += 105;
+                       x += framerate->get_w();
                        add_subwindow(new FrameRatePulldown(mwindow, framerate, x, y));
                }
                else {
                        add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
                }
 
-               y += 30;
+               y += ypad30;
                x = x1;
                add_subwindow(new BC_Title(x, y, _("Width:")));
                x = x2;
@@ -496,17 +485,17 @@ void AssetEditWindow::create_objects()
                sprintf(string, "%d", asset_edit->changed_params->height);
                win_height = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
                add_subwindow(win_height);
-               y += win_height->get_h() + 5;
+               y += win_height->get_h() + ypad5;
 
                if( asset && File::can_scale_input(asset) ) {
-                       y += 5;
+                       y += ypad5;
                        x = x1;
                        add_subwindow(new BC_Title(x, y, _("Actual width:")));
                        x = x2;
                        sprintf(string, "%d", asset->actual_width);
                        add_subwindow(new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color));
 
-                       BC_GenericButton *resize = new ResizeAssetButton(this, x+64, y);
+                       BC_GenericButton *resize = new ResizeAssetButton(this, x+xS(64), y);
                        add_subwindow(resize);
 
                        y += vmargin;
@@ -516,40 +505,18 @@ void AssetEditWindow::create_objects()
                        sprintf(string, "%d", asset->actual_height);
                        title = new BC_Title(x, y, string, MEDIUMFONT, mwindow->theme->assetedit_color);
                        add_subwindow(title);
-                       y += title->get_h() + 5;
+                       y += title->get_h() + ypad5;
+               }
+               if( asset ) {
+                       add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:")));
+                       ilacemode_to_text(string, asset->interlace_mode);
+                       AssetEditILacemode *edit_ilace_mode;
+                       add_subwindow(edit_ilace_mode = new AssetEditILacemode(this, string, x2, y, xS(160)));
+                       add_subwindow(new AssetEditInterlacemodePulldown(mwindow, edit_ilace_mode,
+                               &asset_edit->changed_params->interlace_mode,
+                               (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
+                               x2 + edit_ilace_mode->get_w(), y));
                }
-
-               // --------------------
-               add_subwindow(title = new BC_Title(x1, y, _("Fix interlacing:")));
-               add_subwindow(ilacefixoption_chkboxw = new Interlaceautofix(mwindow,this, x2, y));
-               y += ilacefixoption_chkboxw->get_h() + 5;
-               // --------------------
-               add_subwindow(title = new BC_Title(x1, y, _("Asset's interlacing:")));
-               add_subwindow(textboxw = new AssetEditILacemode(this, "", ILACE_ASSET_MODEDEFAULT, x2, y, 200));
-               ilacefixoption_chkboxw->ilacemode_textbox = textboxw;
-               add_subwindow(listboxw = new AssetEditInterlacemodePulldown(mwindow,
-                                                       textboxw,
-                                                       &asset_edit->changed_params->interlace_mode,
-                                                       (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_modes,
-                                                       ilacefixoption_chkboxw,
-                                                       x2 + textboxw->get_w(),
-                                                       y));
-               ilacefixoption_chkboxw->ilacemode_listbox = listboxw;
-               y += textboxw->get_h() + 5;
-
-               // --------------------
-               add_subwindow(title = new BC_Title(x1, y, _("Interlace correction:")));
-               add_subwindow(textboxw = new AssetEditILacefixmethod(this, "", ILACE_FIXDEFAULT, x2, y, 200));
-               ilacefixoption_chkboxw->ilacefixmethod_textbox = textboxw;
-               add_subwindow(listboxw = new InterlacefixmethodPulldown(mwindow,
-                                                       textboxw,
-                                                       &asset_edit->changed_params->interlace_fixmethod,
-                                                       (ArrayList<BC_ListBoxItem*>*)&mwindow->interlace_asset_fixmethods,
-                                                       x2 + textboxw->get_w(),
-                                                       y));
-               ilacefixoption_chkboxw->ilacefixmethod_listbox = listboxw;
-               ilacefixoption_chkboxw->showhideotherwidgets();
-               y += textboxw->get_h() + 5;
        }
 
        add_subwindow(new BC_OKButton(this));
@@ -570,13 +537,8 @@ AssetEditChannels::AssetEditChannels(AssetEditWindow *fwindow,
        char *text,
        int x,
        int y)
- : BC_TumbleTextBox(fwindow,
-               (int)atol(text),
-               (int)1,
-               (int)MAXCHANNELS,
-               x,
-               y,
-               50)
+ : BC_TumbleTextBox(fwindow, (int)atol(text), (int)1,
+               (int)MAXCHANNELS, x, y, xS(50))
 {
        this->fwindow = fwindow;
 }
@@ -589,7 +551,7 @@ int AssetEditChannels::handle_event()
 }
 
 AssetEditRate::AssetEditRate(AssetEditWindow *fwindow, char *text, int x, int y)
- : BC_TextBox(x, y, 100, 1, text)
+ : BC_TextBox(x, y, xS(100), 1, text)
 {
        this->fwindow = fwindow;
 }
@@ -602,7 +564,7 @@ int AssetEditRate::handle_event()
 }
 
 AssetEditFRate::AssetEditFRate(AssetEditWindow *fwindow, char *text, int x, int y)
- : BC_TextBox(x, y, 100, 1, text)
+ : BC_TextBox(x, y, xS(100), 1, text)
 {
        this->fwindow = fwindow;
 }
@@ -614,130 +576,25 @@ int AssetEditFRate::handle_event()
        return 1;
 }
 
-Interlaceautofix::Interlaceautofix(MWindow *mwindow,AssetEditWindow *fwindow, int x, int y)
- : BC_CheckBox(x, y,
-       fwindow->asset_edit->changed_params->interlace_autofixoption,
-       _("Automatically Fix Interlacing"))
-{
-       this->fwindow = fwindow;
-       this->mwindow = mwindow;
-}
-
-Interlaceautofix::~Interlaceautofix()
-{
-}
-
-int Interlaceautofix::handle_event()
-{
-       Asset *asset = fwindow->asset_edit->changed_params;
-       asset->interlace_autofixoption = get_value();
-       showhideotherwidgets();
-       return 1;
-}
-
-void Interlaceautofix::showhideotherwidgets()
-{
-  int thevalue = get_value();
-
-       Asset *asset = fwindow->asset_edit->changed_params;
-       if( thevalue == ILACE_AUTOFIXOPTION_AUTO ) {
-               this->ilacemode_textbox->enable();
-               this->ilacemode_listbox->enable();
-               this->ilacefixmethod_textbox->disable();
-               this->ilacefixmethod_listbox->disable();
-               int xx = ilaceautofixmethod(mwindow->edl->session->interlace_mode,asset->interlace_mode);
-               ilacefixmethod_to_text(string, xx);
-               this->ilacefixmethod_textbox->update(string);
-       }
-       if( thevalue == ILACE_AUTOFIXOPTION_MANUAL ) {
-               this->ilacemode_textbox->disable();
-               this->ilacemode_listbox->disable();
-               this->ilacefixmethod_textbox->enable();
-               this->ilacefixmethod_listbox->enable();
-               ilacefixmethod_to_text(string, asset->interlace_fixmethod);
-               this->ilacefixmethod_textbox->update(string);
-         }
-}
-
-InterlacefixmethodItem::InterlacefixmethodItem(const char *text, int value)
- : BC_ListBoxItem(text)
-{
-       this->value = value;
-}
-
-InterlacefixmethodPulldown::InterlacefixmethodPulldown(MWindow *mwindow,
-               BC_TextBox *output_text, int *output_value,
-               ArrayList<BC_ListBoxItem*> *data, int x, int y)
- : BC_ListBox(x, y, 200, 150, LISTBOX_TEXT, data, 0, 0, 1, 0, 1)
-{
-       this->mwindow = mwindow;
-       this->output_text = output_text;
-       this->output_value = output_value;
-       output_text->update(interlacefixmethod_to_text());
-}
-
-int InterlacefixmethodPulldown::handle_event()
-{
-       output_text->update(get_selection(0, 0)->get_text());
-       *output_value = ((InterlacefixmethodItem*)get_selection(0, 0))->value;
-       return 1;
-}
-
-const char* InterlacefixmethodPulldown::interlacefixmethod_to_text()
-{
-       ilacefixmethod_to_text(this->string,*output_value);
-       return (this->string);
-}
 
-AssetEditILaceautofixoption::AssetEditILaceautofixoption(AssetEditWindow *fwindow, char *text, int thedefault, int x, int y, int w)
+AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, const char *text, int x, int y, int w)
  : BC_TextBox(x, y, w, 1, text)
 {
        this->fwindow = fwindow;
-       this->thedefault = thedefault;
-}
-
-int AssetEditILaceautofixoption::handle_event()
-{
-       Asset *asset = fwindow->asset_edit->changed_params;
-       asset->interlace_autofixoption = ilaceautofixoption_from_text(get_text(), this->thedefault);
-       return 1;
-}
-
-
-AssetEditILacemode::AssetEditILacemode(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w)
- : BC_TextBox(x, y, w, 1, text)
-{
-       this->fwindow = fwindow;
-       this->thedefault = thedefault;
 }
 
 int AssetEditILacemode::handle_event()
 {
        Asset *asset = fwindow->asset_edit->changed_params;
-       asset->interlace_mode = ilacemode_from_text(get_text(),this->thedefault);
+       asset->interlace_mode = ilacemode_from_text(get_text(), ILACE_ASSET_MODEDEFAULT);
        return 1;
 }
 
 AssetEditInterlacemodePulldown::AssetEditInterlacemodePulldown(MWindow *mwindow,
-               BC_TextBox *output_text,
-               int *output_value,
-               ArrayList<BC_ListBoxItem*> *data,
-               Interlaceautofix *fixoption_chkboxw,
-               int x,
-               int y)
- : BC_ListBox(x,
-       y,
-       200,
-       150,
-       LISTBOX_TEXT,
-       data,
-       0,
-       0,
-       1,
-       0,
-       1)
-{
-       this->fixoption_chkbox = fixoption_chkboxw;
+               BC_TextBox *output_text, int *output_value,
+               ArrayList<BC_ListBoxItem*> *data, int x, int y)
+ : BC_ListBox(x, y, xS(160), yS(80), LISTBOX_TEXT, data, 0, 0, 1, 0, 1)
+{
        this->mwindow = mwindow;
        this->output_text = output_text;
        this->output_value = output_value;
@@ -748,7 +605,6 @@ int AssetEditInterlacemodePulldown::handle_event()
 {
        output_text->update(get_selection(0, 0)->get_text());
        *output_value = ((InterlacemodeItem*)get_selection(0, 0))->value;
-       fixoption_chkbox->showhideotherwidgets();
        return 1;
 }
 
@@ -758,22 +614,8 @@ char* AssetEditInterlacemodePulldown::interlacemode_to_text()
        return (this->string);
 }
 
-AssetEditILacefixmethod::AssetEditILacefixmethod(AssetEditWindow *fwindow, const char *text, int thedefault, int x, int y, int w)
- : BC_TextBox(x, y, w, 1, text)
-{
-       this->fwindow = fwindow;
-       this->thedefault = thedefault;
-}
-
-int AssetEditILacefixmethod::handle_event()
-{
-       Asset *asset = fwindow->asset_edit->changed_params;
-       asset->interlace_fixmethod = ilacefixmethod_from_text(get_text(),this->thedefault);
-       return 1;
-}
-
 AssetEditHeader::AssetEditHeader(AssetEditWindow *fwindow, char *text, int x, int y)
- : BC_TextBox(x, y, 100, 1, text)
+ : BC_TextBox(x, y, xS(100), 1, text)
 {
        this->fwindow = fwindow;
 }
@@ -844,7 +686,7 @@ int AssetEditSigned::handle_event()
 
 
 AssetEditPathText::AssetEditPathText(AssetEditWindow *fwindow, int y)
- : BC_TextBox(5, y, 300, 1, fwindow->asset_edit->changed_params->path)
+ : BC_TextBox(5, y, xS(300), 1, fwindow->asset_edit->changed_params->path)
 {
        this->fwindow = fwindow;
 }
@@ -860,7 +702,7 @@ int AssetEditPathText::handle_event()
 AssetEditPath::AssetEditPath(MWindow *mwindow, AssetEditWindow *fwindow,
        BC_TextBox *textbox, int y, const char *text,
        const char *window_title, const char *window_caption)
- : BrowseButton(mwindow->theme, fwindow, textbox, 310, y, text,
+ : BrowseButton(mwindow->theme, fwindow, textbox, yS(310), y, text,
        window_title, window_caption, 0)
 {
        this->fwindow = fwindow;
@@ -887,10 +729,13 @@ int DetailAssetButton::handle_event()
        return 1;
 }
 
+#define DTL_W xS(600)
+#define DTL_H yS(500)
+
 DetailAssetWindow::DetailAssetWindow(MWindow *mwindow,
        DetailAssetDialog *detail_dialog, Asset *asset)
  : BC_Window(_("Asset Detail"),
-       detail_dialog->x - 600/2, detail_dialog->y - 500/2, 600, 500)
+       detail_dialog->x - DTL_W/2, detail_dialog->y - DTL_H/2, DTL_W, DTL_H)
 {
        this->mwindow = mwindow;
        this->detail_dialog = detail_dialog;
@@ -920,7 +765,7 @@ DetailAssetDialog::~DetailAssetDialog()
 
 void DetailAssetWindow::create_objects()
 {
-       int y = 10, x = 10;
+       int y = yS(10), x = xS(10);
        char file_name[BCTEXTLEN];
        int len = sizeof(info);
        strncpy(info,_("no info available"),len);
@@ -937,7 +782,9 @@ void DetailAssetWindow::create_objects()
                }
        }
        lock_window("DetailAssetWindow::create_objects");
-       text = new BC_ScrollTextBox(this, x, y, get_w()-32, 23, info, -len);
+       int text_h = get_h()-y - BC_OKButton::calculate_h() - yS(15);
+       int lines = BC_TextBox::pixels_to_rows(this, MEDIUMFONT, text_h);
+       text = new BC_ScrollTextBox(this, x, y, get_w()-xS(32), lines, info, -len);
        text->create_objects();  text->set_text_row(0);
        add_subwindow(new BC_OKButton(this));
        show_window();