4 bt fixes, xft unrefd font fix, add: find in resources, add: user title, filebox...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / editpopup.C
index 9dccdd06a85c70df923ea29b5029ac8e5401f578..5fcd8152485f90d156c90d0d3a25b8790055c9d4 100644 (file)
  *
  */
 
+#include "asset.h"
+#include "assets.h"
+#include "awindow.h"
+#include "awindowgui.h"
 #include "edit.h"
 #include "editpopup.h"
+#include "edl.h"
+#include "edlsession.h"
+#include "file.h"
+#include "keys.h"
 #include "language.h"
+#include "localsession.h"
+#include "mainerror.h"
 #include "mainsession.h"
 #include "mwindow.h"
 #include "mwindowgui.h"
 #include "tracks.h"
 #include "trackcanvas.h"
 
-
 #include <string.h>
 
 EditPopup::EditPopup(MWindow *mwindow, MWindowGUI *gui)
- : BC_PopupMenu(0,
-               0,
-               0,
-               "",
-               0)
+ : BC_PopupMenu(0, 0, 0, "", 0)
 {
        this->mwindow = mwindow;
        this->gui = gui;
@@ -56,8 +61,10 @@ void EditPopup::create_objects()
        add_item(new EditMoveTrackDown(mwindow, this));
        add_item(new EditPopupDeleteTrack(mwindow, this));
        add_item(new EditPopupAddTrack(mwindow, this));
-//     add_item(new EditPopupTitle(mwindow, this));
+       add_item(new EditPopupFindAsset(mwindow, this));
+       add_item(new EditPopupTitle(mwindow, this));
        resize_option = 0;
+       matchsize_option = 0;
 }
 
 int EditPopup::update(Track *track, Edit *edit)
@@ -80,13 +87,6 @@ int EditPopup::update(Track *track, Edit *edit)
 }
 
 
-
-
-
-
-
-
-
 EditAttachEffect::EditAttachEffect(MWindow *mwindow, EditPopup *popup)
  : BC_MenuItem(_("Attach effect..."))
 {
@@ -103,10 +103,8 @@ EditAttachEffect::~EditAttachEffect()
 int EditAttachEffect::handle_event()
 {
        dialog_thread->start_window(popup->track,
-               0,
-               _(PROGRAM_NAME ": Attach Effect"),
-               0,
-               popup->track->data_type);
+               0, _(PROGRAM_NAME ": Attach Effect"),
+               0, popup->track->data_type);
        return 1;
 }
 
@@ -144,8 +142,6 @@ int EditMoveTrackDown::handle_event()
 }
 
 
-
-
 EditPopupResize::EditPopupResize(MWindow *mwindow, EditPopup *popup)
  : BC_MenuItem(_("Resize track..."))
 {
@@ -165,10 +161,6 @@ int EditPopupResize::handle_event()
 }
 
 
-
-
-
-
 EditPopupMatchSize::EditPopupMatchSize(MWindow *mwindow, EditPopup *popup)
  : BC_MenuItem(_("Match output size"))
 {
@@ -186,11 +178,6 @@ int EditPopupMatchSize::handle_event()
 }
 
 
-
-
-
-
-
 EditPopupDeleteTrack::EditPopupDeleteTrack(MWindow *mwindow, EditPopup *popup)
  : BC_MenuItem(_("Delete track"))
 {
@@ -204,10 +191,6 @@ int EditPopupDeleteTrack::handle_event()
 }
 
 
-
-
-
-
 EditPopupAddTrack::EditPopupAddTrack(MWindow *mwindow, EditPopup *popup)
  : BC_MenuItem(_("Add track"))
 {
@@ -231,9 +214,45 @@ int EditPopupAddTrack::handle_event()
        return 1;
 }
 
+EditPopupFindAsset::EditPopupFindAsset(MWindow *mwindow, EditPopup *popup)
+ : BC_MenuItem(_("Find in Resources"))
+{
+       this->mwindow = mwindow;
+       this->popup = popup;
+}
 
-
-
+int EditPopupFindAsset::handle_event()
+{
+       Edit *edit = popup->edit;
+       if( edit ) {
+               Indexable *idxbl = (Indexable *)edit->asset;
+               if( !idxbl ) idxbl = (Indexable *)edit->nested_edl;
+               if( idxbl ) {
+                       AWindowGUI *agui = mwindow->awindow->gui;
+                       agui->lock_window("EditPopupFindAsset::handle_event");
+                       AssetPicon *picon = 0;
+                       for( int i=0, n=agui->assets.size(); i<n; ++i ) {
+                               AssetPicon *ap = (AssetPicon *)agui->assets[i];
+                               int found = ap->indexable && ( idxbl == ap->indexable ||
+                                       !strcmp(idxbl->path, ap->indexable->path) );
+                               if( found && !picon ) picon = ap;
+                               ap->set_selected(found);
+                       }
+                       if( picon ) {
+                               int selected_folder = picon->indexable->awindow_folder;
+                               mwindow->edl->session->awindow_folder = selected_folder;
+                               for( int i=0,n=agui->folders.size(); i<n; ++i ) {
+                                       AssetPicon *folder_item = (AssetPicon *)agui->folders[i];
+                                       int selected = folder_item->foldernum == selected_folder ? 1 : 0;
+                                       folder_item->set_selected(selected);
+                               }
+                       }
+                       agui->unlock_window();
+                       agui->async_update_assets();
+               }
+       }
+       return 1;
+}
 
 
 EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup)
@@ -246,32 +265,21 @@ EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup)
 
 EditPopupTitle::~EditPopupTitle()
 {
-       delete popup;
 }
 
 int EditPopupTitle::handle_event()
 {
        int result;
-
-       Track *trc = mwindow->session->track_highlighted;
-
-       if (trc && trc->record)
-       {
-               Edit *edt = mwindow->session->edit_highlighted;
-               if(!edt) return 1;
-
+       if( popup->edit ) {
                window = new EditPopupTitleWindow (mwindow, popup);
                window->create_objects();
                result = window->run_window();
-
-
-               if(!result && edt)
-               {
-                       strcpy(edt->user_title, window->title_text->get_text());
+               if( !result && popup->edit ) {
+                       strcpy(popup->edit->user_title, window->title_text->get_text());
+                       mwindow->gui->draw_canvas(1, 0);
+                       mwindow->gui->flash_canvas(1);
                }
-
-               delete window;
-               window = 0;
+               delete window;  window = 0;
        }
 
        return 1;
@@ -282,20 +290,12 @@ EditPopupTitleWindow::EditPopupTitleWindow (MWindow *mwindow, EditPopup *popup)
  : BC_Window (_(PROGRAM_NAME ": Set edit title"),
        mwindow->gui->get_abs_cursor_x(0) - 400 / 2,
        mwindow->gui->get_abs_cursor_y(0) - 500 / 2,
-       300,
-       100,
-       300,
-       100,
-       0,
-       0,
-       1)
+       300, 130, 300, 130, 0, 0, 1)
 {
        this->mwindow = mwindow;
        this->popup = popup;
-       this->edt = this->mwindow->session->edit_highlighted;
-       if(this->edt)
-       {
-               strcpy(new_text, this->edt->user_title);
+       if( popup->edit ) {
+               strcpy(new_text, popup->edit->user_title);
        }
 }
 
@@ -311,24 +311,26 @@ int EditPopupTitleWindow::close_event()
 
 void EditPopupTitleWindow::create_objects()
 {
-       int x = 5;
+       lock_window("EditPopupTitleWindow::create_objects");
+       int x = 10;
        int y = 10;
-
-       add_subwindow (new BC_Title (x, y, _("User title")));
-       add_subwindow (title_text = new EditPopupTitleText (this,
-               mwindow, x, y + 20));
+       add_subwindow (new BC_Title (x, y, _("User title:")));
+       title_text = new EditPopupTitleText (this, mwindow, x+15, y+20,
+               popup->edit ? popup->edit->user_title : "");
+       add_subwindow(title_text);
        add_tool(new BC_OKButton(this));
        add_tool(new BC_CancelButton(this));
 
 
        show_window();
        flush();
+       unlock_window();
 }
 
 
 EditPopupTitleText::EditPopupTitleText (EditPopupTitleWindow *window,
-       MWindow *mwindow, int x, int y)
- : BC_TextBox(x, y, 250, 1, (char*)(window->edt ? window->edt->user_title : ""))
+       MWindow *mwindow, int x, int y, const char *text)
+ : BC_TextBox(x, y, 250, 1, text)
 {
        this->window = window;
        this->mwindow = mwindow;
@@ -340,12 +342,8 @@ EditPopupTitleText::~EditPopupTitleText()
 
 int EditPopupTitleText::handle_event()
 {
+       if( get_keypress() == RETURN )
+               window->set_done(0);
        return 1;
 }
 
-
-
-
-
-
-