r954: Improve icons of the liveaudio and livevideo effects.
[cinelerra_cv.git] / cinelerra / assetpopup.C
blob1ceba78ecb61b4c6404c23a354bbed6d93b75b87
1 #include "assetedit.h"
2 #include "assetpopup.h"
3 #include "assetremove.h"
4 #include "awindow.h"
5 #include "awindowgui.h"
6 #include "awindowmenu.h"
7 #include "clipedit.h"
8 #include "cwindow.h"
9 #include "cwindowgui.h"
10 #include "edl.h"
11 #include "language.h"
12 #include "localsession.h"
13 #include "mainindexes.h"
14 #include "mainsession.h"
15 #include "mwindow.h"
16 #include "mwindowgui.h"
17 #include "tracks.h"
18 #include "vwindow.h"
19 #include "vwindowgui.h"
23 AssetPopup::AssetPopup(MWindow *mwindow, AWindowGUI *gui)
24  : BC_PopupMenu(0, 
25                 0, 
26                 0, 
27                 "", 
28                 0)
30         this->mwindow = mwindow;
31         this->gui = gui;
34 AssetPopup::~AssetPopup()
38 void AssetPopup::create_objects()
40         add_item(format = new AssetListFormat(mwindow));
41         add_item(info = new AssetPopupInfo(mwindow, this));
42         add_item(new AssetPopupSort(mwindow, this));
43         add_item(index = new AssetPopupBuildIndex(mwindow, this));
44         add_item(view = new AssetPopupView(mwindow, this));
45         add_item(new AssetPopupPaste(mwindow, this));
46         add_item(new AssetMatchSize(mwindow, this));
47         add_item(new AssetMatchRate(mwindow, this));
48         add_item(new AssetPopupProjectRemove(mwindow, this));
49         add_item(new AssetPopupDiskRemove(mwindow, this));
52 void AssetPopup::paste_assets()
54 // Collect items into the drag vectors for temporary storage
55         gui->lock_window("AssetPopup::paste_assets");
56         mwindow->gui->lock_window("AssetPopup::paste_assets");
57         mwindow->cwindow->gui->lock_window("AssetPopup::paste_assets");
59         gui->collect_assets();
60         mwindow->paste_assets(mwindow->edl->local_session->get_selectionstart(1), 
61                 mwindow->edl->tracks->first,
62                 0);   // do not overwrite
64         gui->unlock_window();
65         mwindow->gui->unlock_window();
66         mwindow->cwindow->gui->unlock_window();
69 void AssetPopup::match_size()
71 // Collect items into the drag vectors for temporary storage
72         gui->collect_assets();
73         mwindow->gui->lock_window("AssetPopup::match_size");
74         mwindow->asset_to_size();
75         mwindow->gui->unlock_window();
78 void AssetPopup::match_rate()
80 // Collect items into the drag vectors for temporary storage
81         gui->collect_assets();
82         mwindow->gui->lock_window("AssetPopup::match_rate");
83         mwindow->asset_to_rate();
84         mwindow->gui->unlock_window();
87 int AssetPopup::update()
89         format->update();
90         gui->collect_assets();
91         return 0;
102 AssetPopupInfo::AssetPopupInfo(MWindow *mwindow, AssetPopup *popup)
103  : BC_MenuItem(_("Info..."))
105         this->mwindow = mwindow;
106         this->popup = popup;
109 AssetPopupInfo::~AssetPopupInfo()
113 int AssetPopupInfo::handle_event()
115         if(mwindow->session->drag_assets->total)
116         {
117                 if(mwindow->awindow->asset_edit->running() && 
118                         mwindow->awindow->asset_edit->window)
119                 {
120                         mwindow->awindow->asset_edit->window->raise_window();
121                         mwindow->awindow->asset_edit->window->flush();
122                 }
123                 else
124                 {
125                         mwindow->awindow->asset_edit->edit_asset(
126                                 mwindow->session->drag_assets->values[0]);
127                 }
128         }
129         else
130         if(mwindow->session->drag_clips->total)
131         {
132                 popup->gui->awindow->clip_edit->edit_clip(
133                         mwindow->session->drag_clips->values[0]);
134         }
135         return 1;
144 AssetPopupBuildIndex::AssetPopupBuildIndex(MWindow *mwindow, AssetPopup *popup)
145  : BC_MenuItem(_("Rebuild index"))
147         this->mwindow = mwindow;
148         this->popup = popup;
151 AssetPopupBuildIndex::~AssetPopupBuildIndex()
155 int AssetPopupBuildIndex::handle_event()
157 //printf("AssetPopupBuildIndex::handle_event 1\n");
158         mwindow->rebuild_indices();
159         return 1;
168 AssetPopupSort::AssetPopupSort(MWindow *mwindow, AssetPopup *popup)
169  : BC_MenuItem(_("Sort items"))
171         this->mwindow = mwindow;
172         this->popup = popup;
175 AssetPopupSort::~AssetPopupSort()
179 int AssetPopupSort::handle_event()
181         mwindow->awindow->gui->sort_assets();
182         return 1;
191 AssetPopupView::AssetPopupView(MWindow *mwindow, AssetPopup *popup)
192  : BC_MenuItem(_("View"))
194         this->mwindow = mwindow;
195         this->popup = popup;
198 AssetPopupView::~AssetPopupView()
202 int AssetPopupView::handle_event()
204         mwindow->vwindow->gui->lock_window("AssetPopupView::handle_event");
206         if(mwindow->session->drag_assets->total)
207                 mwindow->vwindow->change_source(
208                         mwindow->session->drag_assets->values[0]);
209         else
210         if(mwindow->session->drag_clips->total)
211                 mwindow->vwindow->change_source(
212                         mwindow->session->drag_clips->values[0]);
214         mwindow->vwindow->gui->unlock_window();
215         return 1;
224 AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup)
225  : BC_MenuItem(_("Paste"))
227         this->mwindow = mwindow;
228         this->popup = popup;
231 AssetPopupPaste::~AssetPopupPaste()
235 int AssetPopupPaste::handle_event()
237         popup->paste_assets();
238         return 1;
248 AssetMatchSize::AssetMatchSize(MWindow *mwindow, AssetPopup *popup)
249  : BC_MenuItem(_("Match project size"))
251         this->mwindow = mwindow;
252         this->popup = popup;
255 int AssetMatchSize::handle_event()
257         popup->match_size();
258         return 1;
268 AssetMatchRate::AssetMatchRate(MWindow *mwindow, AssetPopup *popup)
269  : BC_MenuItem(_("Match frame rate"))
271         this->mwindow = mwindow;
272         this->popup = popup;
275 int AssetMatchRate::handle_event()
277         popup->match_rate();
278         return 1;
294 AssetPopupProjectRemove::AssetPopupProjectRemove(MWindow *mwindow, AssetPopup *popup)
295  : BC_MenuItem(_("Remove from project"))
297         this->mwindow = mwindow;
298         this->popup = popup;
303 AssetPopupProjectRemove::~AssetPopupProjectRemove()
307 int AssetPopupProjectRemove::handle_event()
309         mwindow->remove_assets_from_project(1);
310         return 1;
316 AssetPopupDiskRemove::AssetPopupDiskRemove(MWindow *mwindow, AssetPopup *popup)
317  : BC_MenuItem(_("Remove from disk"))
319         this->mwindow = mwindow;
320         this->popup = popup;
324 AssetPopupDiskRemove::~AssetPopupDiskRemove()
329 int AssetPopupDiskRemove::handle_event()
331         mwindow->awindow->asset_remove->start();
332         return 1;