mixer
[goodguy/history.git] / cinelerra-5.1 / cinelerra / assetpopup.C
index 14a538bbffd9a7543f57b4c159cd897d54fde92e..f5a3be2a37627b7b27cded03c82eb14b2a59b416 100644 (file)
@@ -44,6 +44,7 @@
 #include "tracks.h"
 #include "vwindow.h"
 #include "vwindowgui.h"
+#include "zwindow.h"
 
 
 AssetPopup::AssetPopup(MWindow *mwindow, AWindowGUI *gui)
@@ -62,11 +63,12 @@ void AssetPopup::create_objects()
        BC_MenuItem *menu_item;
        BC_SubMenu *submenu;
        add_item(info = new AssetPopupInfo(mwindow, this));
-       add_item(format = new AWindowListFormat(mwindow));
+       add_item(format = new AWindowListFormat(mwindow, gui));
        add_item(new AssetPopupSort(mwindow, this));
        add_item(index = new AssetPopupBuildIndex(mwindow, this));
        add_item(view = new AssetPopupView(mwindow, this));
        add_item(view_window = new AssetPopupViewWindow(mwindow, this));
+       add_item(mixer = new AssetPopupMixer(mwindow, this));
        add_item(new AssetPopupPaste(mwindow, this));
        add_item(menu_item = new BC_MenuItem(_("Match...")));
        menu_item->add_submenu(submenu = new BC_SubMenu());
@@ -144,16 +146,16 @@ AssetPopupInfo::~AssetPopupInfo()
 
 int AssetPopupInfo::handle_event()
 {
-       if(mwindow->session->drag_assets->total)
-       {
-               mwindow->awindow->asset_edit->edit_asset(
-                       mwindow->session->drag_assets->values[0]);
+       int cur_x, cur_y;
+       popup->gui->get_abs_cursor(cur_x, cur_y);
+       if( mwindow->session->drag_assets->size() ) {
+               AssetEdit *asset_edit = mwindow->awindow->get_asset_editor();
+               asset_edit->edit_asset(
+                       mwindow->session->drag_assets->values[0], cur_x, cur_y);
        }
-       else
-       if(mwindow->session->drag_clips->total)
-       {
+       else if( mwindow->session->drag_clips->size() ) {
                popup->gui->awindow->clip_edit->edit_clip(
-                       mwindow->session->drag_clips->values[0]);
+                       mwindow->session->drag_clips->values[0], cur_x, cur_y);
        }
        return 1;
 }
@@ -212,11 +214,11 @@ int AssetPopupView::handle_event()
        VWindow *vwindow = mwindow->get_viewer(1, DEFAULT_VWINDOW);
        vwindow->gui->lock_window("AssetPopupView::handle_event");
 
-       if(mwindow->session->drag_assets->total)
+       if( mwindow->session->drag_assets->total )
                vwindow->change_source(
                        mwindow->session->drag_assets->values[0]);
        else
-       if(mwindow->session->drag_clips->total)
+       if( mwindow->session->drag_clips->total )
                vwindow->change_source(
                        mwindow->session->drag_clips->values[0]);
 
@@ -244,11 +246,11 @@ int AssetPopupViewWindow::handle_event()
 // TODO: create new vwindow or change current vwindow
        vwindow->gui->lock_window("AssetPopupView::handle_event");
 
-       if(mwindow->session->drag_assets->total)
+       if( mwindow->session->drag_assets->total )
                vwindow->change_source(
                        mwindow->session->drag_assets->values[0]);
        else
-       if(mwindow->session->drag_clips->total)
+       if( mwindow->session->drag_clips->total )
                vwindow->change_source(
                        mwindow->session->drag_clips->values[0]);
 
@@ -256,6 +258,44 @@ int AssetPopupViewWindow::handle_event()
        return 1;
 }
 
+AssetPopupMixer::AssetPopupMixer(MWindow *mwindow, AssetPopup *popup)
+ : BC_MenuItem(_("Open Mixers"))
+{
+       this->mwindow = mwindow;
+       this->popup = popup;
+}
+
+AssetPopupMixer::~AssetPopupMixer()
+{
+}
+
+int AssetPopupMixer::handle_event()
+{
+       mwindow->select_zwindow(0);
+       for( int i=0; i<mwindow->session->drag_assets->total; ++i ) {
+               Indexable *indexable = mwindow->session->drag_assets->values[i];
+               ArrayList<Indexable*> new_assets;
+               new_assets.append(indexable);
+               Track *track = mwindow->edl->tracks->last;
+               mwindow->load_assets(&new_assets, -1, LOADMODE_NEW_TRACKS, 0, 0, 0, 0, 0, 0);
+               track = !track ? mwindow->edl->tracks->first : track->next;
+               Mixer *mixer = 0;
+               ZWindow *zwindow = mwindow->get_mixer(mixer);
+               while( track ) {
+                       track->play = track->record = 0;
+                       mixer->mixer_ids.append(track->get_mixer_id());
+                       track = track->next;
+               }
+               char *path = indexable->path;
+               char *tp = strrchr(path, '/');
+               if( !tp ) tp = path; else ++tp;
+               zwindow->set_title(tp);
+               zwindow->start();
+       }
+        mwindow->queue_mixers(mwindow->edl,CURRENT_FRAME,0,0,1,0);
+       mwindow->resync_guis();
+       return 1;
+}
 
 AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup)
  : BC_MenuItem(_("Paste"))
@@ -328,8 +368,7 @@ AssetPopupProjectRemove::~AssetPopupProjectRemove()
 
 int AssetPopupProjectRemove::handle_event()
 {
-       mwindow->remove_assets_from_project(1,
-               1,
+       mwindow->remove_assets_from_project(1, 1,
                mwindow->session->drag_assets,
                mwindow->session->drag_clips);
        return 1;
@@ -368,10 +407,10 @@ AssetListMenu::~AssetListMenu()
 
 void AssetListMenu::create_objects()
 {
-       add_item(format = new AWindowListFormat(mwindow));
-       add_item(new AWindowListSort(mwindow));
-       add_item(new AssetListCopy(mwindow));
-       add_item(new AssetListPaste(mwindow));
+       add_item(format = new AWindowListFormat(mwindow, gui));
+       add_item(new AWindowListSort(mwindow, gui));
+       add_item(new AssetListCopy(mwindow, gui));
+       add_item(new AssetListPaste(mwindow, gui));
        update_titles();
 }
 
@@ -380,10 +419,11 @@ void AssetListMenu::update_titles()
        format->update();
 }
 
-AssetListCopy::AssetListCopy(MWindow *mwindow)
+AssetListCopy::AssetListCopy(MWindow *mwindow, AWindowGUI *gui)
  : BC_MenuItem(_("Copy file list"))
 {
        this->mwindow = mwindow;
+       this->gui = gui;
        copy_dialog = 0;
 }
 AssetListCopy::~AssetListCopy()
@@ -412,12 +452,14 @@ int AssetListCopy::handle_event()
                cp += sprintf(cp, "%s\n", path);
        }
        *cp = 0;
+       int cur_x, cur_y;
+       gui->get_abs_cursor(cur_x, cur_y, 0);
        gui->unlock_window(); 
 
        if( n ) {
                if( !copy_dialog )
                        copy_dialog = new AssetCopyDialog(this);
-               copy_dialog->start(text);
+               copy_dialog->start(text, cur_x, cur_y);
        }
        else {
                eprintf(_("Nothing selected"));
@@ -429,31 +471,30 @@ int AssetListCopy::handle_event()
 AssetCopyDialog::AssetCopyDialog(AssetListCopy *copy)
  : BC_DialogThread()
 {
-        this->copy = copy;
+       this->copy = copy;
        copy_window = 0;
 }
 
-void AssetCopyDialog::start(char *text)
+void AssetCopyDialog::start(char *text, int x, int y)
 {
-        close_window();
-        this->text = text;
+       close_window();
+       this->text = text;
+       this->x = x;  this->y = y;
        BC_DialogThread::start();
 }
 
 AssetCopyDialog::~AssetCopyDialog()
 {
-        close_window();
+       close_window();
 }
 
 BC_Window* AssetCopyDialog::new_gui()
 {
-        BC_DisplayInfo display_info;
-        int x = display_info.get_abs_cursor_x();
-        int y = display_info.get_abs_cursor_y();
+       BC_DisplayInfo display_info;
 
-        copy_window = new AssetCopyWindow(this, x, y);
-        copy_window->create_objects();
-        return copy_window;
+       copy_window = new AssetCopyWindow(this);
+       copy_window->create_objects();
+       return copy_window;
 }
 
 void AssetCopyDialog::handle_done_event(int result)
@@ -463,14 +504,16 @@ void AssetCopyDialog::handle_done_event(int result)
 
 void AssetCopyDialog::handle_close_event(int result)
 {
-        copy_window = 0;
+       copy_window = 0;
 }
 
 
-AssetCopyWindow::AssetCopyWindow(AssetCopyDialog *copy_dialog, int x, int y)
- : BC_Window(_(PROGRAM_NAME ": Copy File List"), x, y, 500, 200, 500, 200, 0, 0, 1)
+AssetCopyWindow::AssetCopyWindow(AssetCopyDialog *copy_dialog)
+ : BC_Window(_(PROGRAM_NAME ": Copy File List"),
+       copy_dialog->x - 500/2, copy_dialog->y - 200/2,
+       500, 200, 500, 200, 1, 0, 1)
 {
-        this->copy_dialog = copy_dialog;
+       this->copy_dialog = copy_dialog;
 }
 
 AssetCopyWindow::~AssetCopyWindow()
@@ -492,14 +535,24 @@ void AssetCopyWindow::create_objects()
        file_list->create_objects();
 
        add_subwindow(new BC_OKButton(this));
-        show_window();
+       show_window();
 }
 
+int AssetCopyWindow::resize_event(int w, int h)
+{
+       int fx = file_list->get_x(), fy = file_list->get_y(), pad = 5;
+       int text_w = w - fx - 10;
+       int text_h = h - fy - BC_OKButton::calculate_h() - pad;
+       int text_rows = BC_TextBox::pixels_to_rows(this, MEDIUMFONT, text_h);
+       file_list->reposition_window(fx, fy, text_w, text_rows);
+       return 0;
+}
 
-AssetListPaste::AssetListPaste(MWindow *mwindow)
+AssetListPaste::AssetListPaste(MWindow *mwindow, AWindowGUI *gui)
  : BC_MenuItem(_("Paste file list"))
 {
        this->mwindow = mwindow;
+       this->gui = gui;
        paste_dialog = 0;
 }
 AssetListPaste::~AssetListPaste()
@@ -511,31 +564,31 @@ int AssetListPaste::handle_event()
 {
        if( !paste_dialog )
                paste_dialog = new AssetPasteDialog(this);
-       paste_dialog->start();
+       else
+               paste_dialog->close_window();
+       int cur_x, cur_y;
+       gui->get_abs_cursor(cur_x, cur_y, 0);
+       paste_dialog->start(cur_x, cur_y);
        return 1;
 }
 
 AssetPasteDialog::AssetPasteDialog(AssetListPaste *paste)
  : BC_DialogThread()
 {
-        this->paste = paste;
+       this->paste = paste;
        paste_window = 0;
 }
 
 AssetPasteDialog::~AssetPasteDialog()
 {
-        close_window();
+       close_window();
 }
 
 BC_Window* AssetPasteDialog::new_gui()
 {
-        BC_DisplayInfo display_info;
-        int x = display_info.get_abs_cursor_x();
-        int y = display_info.get_abs_cursor_y();
-
-        paste_window = new AssetPasteWindow(this, x, y);
-        paste_window->create_objects();
-        return paste_window;
+       paste_window = new AssetPasteWindow(this);
+       paste_window->create_objects();
+       return paste_window;
 }
 
 void AssetPasteDialog::handle_done_event(int result)
@@ -564,21 +617,28 @@ void AssetPasteDialog::handle_done_event(int result)
        result = mwindow->load_filenames(&path_list, LOADMODE_RESOURCESONLY, 0);
        mwindow->gui->unlock_window();
        path_list.remove_all_objects();
-        mwindow->save_backup();
-        mwindow->restart_brender();
+       mwindow->save_backup();
+       mwindow->restart_brender();
        mwindow->session->changes_made = 1;
 }
 
 void AssetPasteDialog::handle_close_event(int result)
 {
-        paste_window = 0;
+       paste_window = 0;
 }
 
+void AssetPasteDialog::start(int x, int y)
+{
+       this->x = x;  this->y = y;
+       BC_DialogThread::start();
+}
 
-AssetPasteWindow::AssetPasteWindow(AssetPasteDialog *paste_dialog, int x, int y)
- : BC_Window(_(PROGRAM_NAME ": Paste File List"), x, y, 500, 200, 500, 200, 0, 0, 1)
+AssetPasteWindow::AssetPasteWindow(AssetPasteDialog *paste_dialog)
+ : BC_Window(_(PROGRAM_NAME ": Paste File List"),
+       paste_dialog->x - 500/2, paste_dialog->y - 200/2,
+       500, 200, 500, 200, 1, 0, 1)
 {
-        this->paste_dialog = paste_dialog;
+       this->paste_dialog = paste_dialog;
 }
 
 AssetPasteWindow::~AssetPasteWindow()
@@ -598,6 +658,16 @@ void AssetPasteWindow::create_objects()
        file_list->create_objects();
        add_subwindow(new BC_OKButton(this));
        add_subwindow(new BC_CancelButton(this));
-        show_window();
+       show_window();
+}
+
+int AssetPasteWindow::resize_event(int w, int h)
+{
+       int fx = file_list->get_x(), fy = file_list->get_y(), pad = 5;
+       int text_w = w - fx - 10;
+       int text_h = h - fy - BC_OKButton::calculate_h() - pad;
+       int text_rows = BC_TextBox::pixels_to_rows(this, MEDIUMFONT, text_h);
+       file_list->reposition_window(fx, fy, text_w, text_rows);
+       return 0;
 }