r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / assetpopup.C
blob6dc79ee6f13ad8333390ec3772f477059f58805e
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 "localsession.h"
12 #include "mainindexes.h"
13 #include "mainsession.h"
14 #include "mwindow.h"
15 #include "mwindowgui.h"
16 #include "tracks.h"
17 #include "vwindow.h"
18 #include "vwindowgui.h"
20 #include <libintl.h>
21 #define _(String) gettext(String)
22 #define gettext_noop(String) String
23 #define N_(String) gettext_noop (String)
26 AssetPopup::AssetPopup(MWindow *mwindow, AWindowGUI *gui)
27  : BC_PopupMenu(0, 
28                 0, 
29                 0, 
30                 "", 
31                 0)
33         this->mwindow = mwindow;
34         this->gui = gui;
37 AssetPopup::~AssetPopup()
41 void AssetPopup::create_objects()
43         add_item(format = new AssetListFormat(mwindow));
44         add_item(info = new AssetPopupInfo(mwindow, this));
45         add_item(new AssetPopupSort(mwindow, this));
46         add_item(index = new AssetPopupBuildIndex(mwindow, this));
47         add_item(view = new AssetPopupView(mwindow, this));
48         add_item(new AssetPopupPaste(mwindow, this));
49         add_item(new AssetMatchSize(mwindow, this));
50         add_item(new AssetPopupProjectRemove(mwindow, this));
51         add_item(new AssetPopupDiskRemove(mwindow, this));
54 void AssetPopup::paste_assets()
56 // Collect items into the drag vectors for temporary storage
57         gui->lock_window();
58         mwindow->gui->lock_window();
59         mwindow->cwindow->gui->lock_window();
61         gui->collect_assets();
62         mwindow->paste_assets(mwindow->edl->local_session->selectionstart, 
63                 mwindow->edl->tracks->first);
65         gui->unlock_window();
66         mwindow->gui->unlock_window();
67         mwindow->cwindow->gui->unlock_window();
70 void AssetPopup::match_size()
72 // Collect items into the drag vectors for temporary storage
73         gui->collect_assets();
74         mwindow->gui->lock_window();
75         mwindow->asset_to_size();
76         mwindow->gui->unlock_window();
79 int AssetPopup::update()
81         format->update();
82         gui->collect_assets();
83         return 0;
94 AssetPopupInfo::AssetPopupInfo(MWindow *mwindow, AssetPopup *popup)
95  : BC_MenuItem(_("Info..."))
97         this->mwindow = mwindow;
98         this->popup = popup;
101 AssetPopupInfo::~AssetPopupInfo()
105 int AssetPopupInfo::handle_event()
107         if(mwindow->session->drag_assets->total)
108         {
109                 if(mwindow->awindow->asset_edit->running() && 
110                         mwindow->awindow->asset_edit->window)
111                 {
112                         mwindow->awindow->asset_edit->window->raise_window();
113                         mwindow->awindow->asset_edit->window->flush();
114                 }
115                 else
116                 {
117                         mwindow->awindow->asset_edit->edit_asset(
118                                 mwindow->session->drag_assets->values[0]);
119                 }
120         }
121         else
122         if(mwindow->session->drag_clips->total)
123         {
124                 popup->gui->awindow->clip_edit->edit_clip(
125                         mwindow->session->drag_clips->values[0]);
126         }
127         return 1;
136 AssetPopupBuildIndex::AssetPopupBuildIndex(MWindow *mwindow, AssetPopup *popup)
137  : BC_MenuItem(_("Rebuild index"))
139         this->mwindow = mwindow;
140         this->popup = popup;
143 AssetPopupBuildIndex::~AssetPopupBuildIndex()
147 int AssetPopupBuildIndex::handle_event()
149 //printf("AssetPopupBuildIndex::handle_event 1\n");
150         mwindow->rebuild_indices();
151         return 1;
160 AssetPopupSort::AssetPopupSort(MWindow *mwindow, AssetPopup *popup)
161  : BC_MenuItem(_("Sort items"))
163         this->mwindow = mwindow;
164         this->popup = popup;
167 AssetPopupSort::~AssetPopupSort()
171 int AssetPopupSort::handle_event()
173         mwindow->awindow->gui->sort_assets();
174         return 1;
183 AssetPopupView::AssetPopupView(MWindow *mwindow, AssetPopup *popup)
184  : BC_MenuItem(_("View"))
186         this->mwindow = mwindow;
187         this->popup = popup;
190 AssetPopupView::~AssetPopupView()
194 int AssetPopupView::handle_event()
196         mwindow->vwindow->gui->lock_window();
198         if(mwindow->session->drag_assets->total)
199                 mwindow->vwindow->change_source(
200                         mwindow->session->drag_assets->values[0]);
201         else
202         if(mwindow->session->drag_clips->total)
203                 mwindow->vwindow->change_source(
204                         mwindow->session->drag_clips->values[0]);
206         mwindow->vwindow->gui->unlock_window();
207         return 1;
216 AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup)
217  : BC_MenuItem(_("Paste"))
219         this->mwindow = mwindow;
220         this->popup = popup;
223 AssetPopupPaste::~AssetPopupPaste()
227 int AssetPopupPaste::handle_event()
229         popup->paste_assets();
230         return 1;
240 AssetMatchSize::AssetMatchSize(MWindow *mwindow, AssetPopup *popup)
241  : BC_MenuItem(_("Match project size"))
243         this->mwindow = mwindow;
244         this->popup = popup;
247 AssetMatchSize::~AssetMatchSize()
251 int AssetMatchSize::handle_event()
253         popup->match_size();
254         return 1;
270 AssetPopupProjectRemove::AssetPopupProjectRemove(MWindow *mwindow, AssetPopup *popup)
271  : BC_MenuItem(_("Remove from project"))
273         this->mwindow = mwindow;
274         this->popup = popup;
279 AssetPopupProjectRemove::~AssetPopupProjectRemove()
283 int AssetPopupProjectRemove::handle_event()
285         mwindow->remove_assets_from_project(1);
286         return 1;
292 AssetPopupDiskRemove::AssetPopupDiskRemove(MWindow *mwindow, AssetPopup *popup)
293  : BC_MenuItem(_("Remove from disk"))
295         this->mwindow = mwindow;
296         this->popup = popup;
300 AssetPopupDiskRemove::~AssetPopupDiskRemove()
305 int AssetPopupDiskRemove::handle_event()
307         mwindow->awindow->asset_remove->start();
308         return 1;