#include "awindow.h"
#include "awindowmenu.h"
#include "bcsignals.h"
+#include "bchash.h"
#include "cache.h"
-#include "colormodels.h"
+#include "bccmodels.h"
#include "cursors.h"
#include "cwindowgui.h"
#include "cwindow.h"
#include "preferences.h"
#include "theme.h"
#include "vframe.h"
+#include "vicon.h"
#include "vwindowgui.h"
#include "vwindow.h"
#include "data/lad_picon_png.h"
+#include "data/ff_audio_png.h"
+#include "data/ff_video_png.h"
#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
+
+
+AssetVIcon::AssetVIcon(AssetPicon *picon, int w, int h, double framerate, int64_t length)
+ : VIcon(w, h, framerate)
+{
+ this->picon = picon;
+ this->length = length;
+ temp = 0;
+}
+
+AssetVIcon::~AssetVIcon()
+{
+ delete temp;
+}
+
+VFrame *AssetVIcon::frame()
+{
+ if( seq_no >= images.size() ) {
+ MWindow *mwindow = picon->mwindow;
+ Asset *asset = (Asset *)picon->indexable;
+ File *file = mwindow->video_cache->check_out(asset, mwindow->edl, 1);
+ if( !file ) return 0;
+ if( temp && (temp->get_w() != asset->width || temp->get_h() != asset->height) ) {
+ delete temp; temp = 0;
+ }
+ if( !temp )
+ temp = new VFrame(asset->width, asset->height, BC_RGB888);
+ int ww = picon->gui->vicon_thread->view_w;
+ int hh = picon->gui->vicon_thread->view_h;
+ while( seq_no >= images.size() ) {
+ file->set_layer(0);
+ int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate;
+ file->set_video_position(pos,0);
+ file->read_frame(temp);
+ add_image(temp, ww, hh, BC_RGB8);
+ }
+ mwindow->video_cache->check_in(asset);
+ }
+ return *images[seq_no];
+}
+
+int64_t AssetVIcon::set_seq_no(int64_t no)
+{
+ if( no >= length ) no = 0;
+ return seq_no = no;
+}
+
+int AssetVIcon::get_vx()
+{
+ BC_ListBox *lbox = picon->gui->asset_list;
+ return lbox->get_item_x(picon);
+}
+int AssetVIcon::get_vy()
+{
+ BC_ListBox *lbox = picon->gui->asset_list;
+ return lbox->get_item_y(picon) + lbox->get_title_h();
+}
+
AssetPicon::AssetPicon(MWindow *mwindow,
AWindowGUI *gui,
Indexable *indexable)
AssetPicon::~AssetPicon()
{
+ if( vicon )
+ gui->vicon_thread->del_vicon(vicon);
if(indexable) indexable->remove_user();
if(edl) edl->remove_user();
if( icon && !gui->protected_pixmap(icon) ) {
delete icon;
+ if( !plugin ) delete icon_vframe;
}
}
edl = 0;
icon = 0;
icon_vframe = 0;
+ vicon = 0;
in_use = 1;
id = 0;
persistent = 0;
int pixmap_w, pixmap_h;
const int debug = 0;
- pixmap_h = 50;
+ pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale;
if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
if(indexable)
//printf("%d %d\n", gui->temp_picon->get_w(), gui->temp_picon->get_h());
icon_vframe = new VFrame(0,
-1, pixmap_w, pixmap_h, BC_RGB888, -1);
- BC_CModels::transfer(
- icon_vframe->get_rows(),
- gui->temp_picon->get_rows(),
- 0, 0, 0, 0, 0, 0, 0, 0,
- gui->temp_picon->get_w(),
- gui->temp_picon->get_h(),
- 0, 0, pixmap_w, pixmap_h,
- BC_RGB888, BC_RGB888,
- 0, 0, 0);
-
+ icon_vframe->transfer_from(gui->temp_picon);
+// vicon images
+ double framerate = asset->get_frame_rate();
+ if( !framerate ) framerate = VICON_RATE;
+ int64_t frames = asset->get_video_frames();
+ double secs = frames / framerate;
+ if( secs > 5 ) secs = 5;
+ int64_t length = secs * gui->vicon_thread->refresh_rate;
+ vicon = new AssetVIcon(this, pixmap_w, pixmap_h, framerate, length);
+ gui->vicon_thread->add_vicon(vicon);
if(debug) printf("AssetPicon::create_objects %d\n", __LINE__);
}
icon = gui->atransition_icon;
icon_vframe = gui->atransition_vframe;
}
- else if( !plugin->is_ladspa() ) {
- icon = gui->aeffect_icon;
- icon_vframe = gui->aeffect_vframe;
+ else if( plugin->is_ffmpeg() ) {
+ icon = gui->ff_aud_icon;
+ icon_vframe = gui->ff_aud_vframe;
}
- else {
+ else if( plugin->is_ladspa() ) {
icon = gui->ladspa_icon;
icon_vframe = gui->ladspa_vframe;
}
+ else {
+ icon = gui->aeffect_icon;
+ icon_vframe = gui->aeffect_vframe;
+ }
}
else if( plugin->video ) {
if( plugin->transition ) {
icon = gui->vtransition_icon;
icon_vframe = gui->vtransition_vframe;
}
+ else if( plugin->is_ffmpeg() ) {
+ icon = gui->ff_vid_icon;
+ icon_vframe = gui->ff_vid_vframe;
+ }
else {
icon = gui->veffect_icon;
icon_vframe = gui->veffect_vframe;
aeffect_icon = 0; aeffect_vframe = 0;
ladspa_icon = 0; ladspa_vframe = 0;
veffect_icon = 0; veffect_vframe = 0;
+ ff_aud_icon = 0; ff_aud_vframe = 0;
+ ff_vid_icon = 0; ff_vid_vframe = 0;
+ plugin_visibility = ((uint64_t)1<<(8*sizeof(uint64_t)-1))-1;
newfolder_thread = 0;
asset_menu = 0;
assetlist_menu = 0;
folderlist_menu = 0;
temp_picon = 0;
remove_plugin = 0;
- plugin_visibility = ~0;
+ vicon_thread = 0;
+ vicon_drawing = 1;
}
AWindowGUI::~AWindowGUI()
atransitions.remove_all_objects();
vtransitions.remove_all_objects();
displayed_assets[1].remove_all_objects();
+
+ delete vicon_thread;
delete file_icon;
delete audio_icon;
delete video_icon;
delete aeffect_icon;
delete ladspa_icon;
delete ladspa_vframe;
+ delete ff_aud_icon;
+ delete ff_aud_vframe;
+ delete ff_vid_icon;
+ delete ff_vid_vframe;
delete veffect_icon;
delete newfolder_thread;
delete asset_menu;
bool AWindowGUI::protected_pixmap(BC_Pixmap *icon)
{
return icon == file_icon ||
- icon == audio_icon ||
icon == folder_icon ||
- icon == clip_icon ||
+ icon == audio_icon ||
icon == video_icon ||
- icon == veffect_icon ||
+ icon == clip_icon ||
icon == vtransition_icon ||
+ icon == atransition_icon ||
+ icon == veffect_icon ||
icon == aeffect_icon ||
icon == ladspa_icon ||
- icon == atransition_icon;
+ icon == ff_aud_icon ||
+ icon == ff_vid_icon;
}
void AWindowGUI::create_objects()
vtransition_icon = new BC_Pixmap(this, vtransition_vframe, PIXMAP_ALPHA);
aeffect_vframe = mwindow->theme->get_image("aeffect_icon");
aeffect_icon = new BC_Pixmap(this, aeffect_vframe, PIXMAP_ALPHA);
- ladspa_vframe = new VFrame(lad_picon_png);
+ ladspa_vframe = new VFramePng(lad_picon_png);
ladspa_icon = new BC_Pixmap(this, ladspa_vframe, PIXMAP_ALPHA);
+ ff_aud_vframe = new VFramePng(ff_audio_png);
+ ff_aud_icon = new BC_Pixmap(this, ff_aud_vframe, PIXMAP_ALPHA);
+ ff_vid_vframe = new VFramePng(ff_video_png);
+ ff_vid_icon = new BC_Pixmap(this, ff_vid_vframe, PIXMAP_ALPHA);
veffect_vframe = mwindow->theme->get_image("veffect_icon");
veffect_icon = new BC_Pixmap(this, veffect_vframe, PIXMAP_ALPHA);
SET_TRACE
mwindow->theme->get_awindow_sizes(this);
+ load_defaults(mwindow->defaults);
SET_TRACE
add_subwindow(asset_list = new AWindowAssets(mwindow,
mwindow->theme->alist_w,
mwindow->theme->alist_h));
+ vicon_thread = new VIconThread(asset_list);
+ vicon_thread->start();
+
SET_TRACE
add_subwindow(divider = new AWindowDivider(mwindow,
this,
divider->set_cursor(HSEPARATE_CURSOR, 0, 0);
SET_TRACE
- int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
- int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
- add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, fw));
+ int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
+ int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
+ VFrame **images = mwindow->theme->get_image_set("playpatch_data");
+ AVIconDrawing::calculate_geometry(this, images, &avicon_w, &avicon_h);
+ add_subwindow(avicon_drawing = new AVIconDrawing(this, fw-avicon_w, fy, images));
+ add_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, fw-avicon_w));
add_tools->create_objects();
fy += add_tools->get_h(); fh -= add_tools->get_h();
SET_TRACE
mwindow->theme->get_awindow_sizes(this);
mwindow->theme->draw_awindow_bg(this);
-
- asset_list->reposition_window(mwindow->theme->alist_x,
- mwindow->theme->alist_y,
- mwindow->theme->alist_w,
- mwindow->theme->alist_h);
- divider->reposition_window(mwindow->theme->adivider_x,
- mwindow->theme->adivider_y,
- mwindow->theme->adivider_w,
- mwindow->theme->adivider_h);
-
- int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
- int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
- add_tools->reposition_window(fx, fy, fw, add_tools->get_h());
- fy += add_tools->get_h(); fh -= add_tools->get_h();
- folder_list->reposition_window(fx, fy, fw, fh);
+ reposition_objects();
// int x = mwindow->theme->abuttons_x;
// int y = mwindow->theme->abuttons_y;
void AWindowGUI::reposition_objects()
{
mwindow->theme->get_awindow_sizes(this);
- asset_list->reposition_window(mwindow->theme->alist_x,
- mwindow->theme->alist_y,
- mwindow->theme->alist_w,
- mwindow->theme->alist_h);
- divider->reposition_window(mwindow->theme->adivider_x,
- mwindow->theme->adivider_y,
- mwindow->theme->adivider_w,
- mwindow->theme->adivider_h);
- folder_list->reposition_window(mwindow->theme->afolders_x,
- mwindow->theme->afolders_y,
- mwindow->theme->afolders_w,
- mwindow->theme->afolders_h);
- flush();
+ asset_list->reposition_window(
+ mwindow->theme->alist_x, mwindow->theme->alist_y,
+ mwindow->theme->alist_w, mwindow->theme->alist_h);
+ divider->reposition_window(
+ mwindow->theme->adivider_x, mwindow->theme->adivider_y,
+ mwindow->theme->adivider_w, mwindow->theme->adivider_h);
+ int fx = mwindow->theme->afolders_x, fy = mwindow->theme->afolders_y;
+ int fw = mwindow->theme->afolders_w, fh = mwindow->theme->afolders_h;
+ add_tools->resize_event(fw-avicon_w, add_tools->get_h());
+ avicon_drawing->reposition_window(fw-avicon_w, fy);
+ fy += add_tools->get_h(); fh -= add_tools->get_h();
+ folder_list->reposition_window(fx, fy, fw, fh);
+}
+
+int AWindowGUI::save_defaults(BC_Hash *defaults)
+{
+ defaults->update("PLUGIN_VISIBILTY", plugin_visibility);
+ defaults->update("VICON_DRAWING", vicon_drawing);
+ return 0;
+}
+
+int AWindowGUI::load_defaults(BC_Hash *defaults)
+{
+ plugin_visibility = defaults->get("PLUGIN_VISIBILTY", plugin_visibility);
+ vicon_drawing = defaults->get("VICON_DRAWING", vicon_drawing);
+ return 0;
}
+
int AWindowGUI::close_event()
{
hide_window();
mwindow->gui->unlock_window();
lock_window("AWindowGUI::close_event");
+ save_defaults(mwindow->defaults);
mwindow->save_defaults();
return 1;
}
+void AWindowGUI::start_vicon_drawing()
+{
+ if( !vicon_drawing ) return;
+ if( strcmp(mwindow->edl->session->current_folder, MEDIA_FOLDER) ) return;
+ if( mwindow->edl->session->assetlist_format != ASSETS_ICONS ) return;
+ vicon_thread->start_drawing();
+}
+
+void AWindowGUI::stop_vicon_drawing()
+{
+ vicon_thread->stop_drawing();
+}
+
AWindowRemovePluginGUI::
AWindowRemovePluginGUI(AWindow *awindow, AWindowRemovePlugin *thread,
int x, int y, PluginServer *plugin)
void AWindowGUI::update_folder_list()
{
+ stop_vicon_drawing();
//printf("AWindowGUI::update_folder_list 1\n");
for(int i = 0; i < folders.total; i++)
{
//for(int i = 0; i < folders.total; i++)
// printf("AWindowGUI::update_folder_list %s\n", folders.values[i]->get_text());
//printf("AWindowGUI::update_folder_list 2\n");
+ start_vicon_drawing();
}
void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
-
-
AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
: BC_SubWindow(x, y, w, h)
{
{
mwindow->session->afolders_w = gui->get_relative_cursor_x();
gui->reposition_objects();
+ gui->flush();
}
return 0;
}
AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
if(picon)
{
+ gui->stop_vicon_drawing();
+
if(get_button_down() && get_buttonpress() == 3)
{
gui->folderlist_menu->update_titles();
//printf("AWindowFolders::selection_changed 1\n");
gui->asset_list->draw_background();
gui->update_assets();
+
+ gui->start_vicon_drawing();
}
return 1;
}
BC_ListBox::deactivate_selection();
return 1;
}
+ else if( get_button_down() && get_buttonpress() == 1 && get_selection(0, 0) ) {
+ VIcon *vicon = 0;
+ if( !gui->vicon_thread->viewing ) {
+ AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
+ vicon = picon->vicon;
+ }
+ gui->vicon_thread->set_view_popup(vicon);
+
+ }
return 0;
}
return 1;
}
+int AWindowAssets::cursor_enter_event()
+{
+ int ret = BC_ListBox::cursor_enter_event();
+ gui->start_vicon_drawing();
+ return ret;
+}
+
+int AWindowAssets::cursor_leave_event()
+{
+ gui->stop_vicon_drawing();
+ return BC_ListBox::cursor_leave_event();
+}
+
void AddPluginsMenu::create_objects()
{
- uint32_t vis = 0;
+ uint64_t vis = 0;
+ add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
+ vis |= 1 << PLUGIN_LADSPA_ID;
+ add_item(new AddPluginItem(this, "ffmpeg", PLUGIN_FFMPEG_ID));
+ vis |= 1 << PLUGIN_FFMPEG_ID;
for( int i=0; i<MWindow::plugindb->size(); ++i ) {
PluginServer *plugin = MWindow::plugindb->get(i);
if( !plugin->audio && !plugin->video ) continue;
vis |= msk;
char parent[BCTEXTLEN];
strcpy(parent, plugin->path);
- char *cp = strrchr(parent, '/');
- if( !cp ) continue;
- *cp = 0;
char *bp = strrchr(parent, '/');
+ if( bp ) { *bp = 0; bp = strrchr(parent, '/'); }
if( !bp ) bp = parent; else ++bp;
- if( !strcmp(bp, "ladspa") )
- gui->plugin_visibility &= ~(1 << idx);
add_item(new AddPluginItem(this, bp, idx));
}
-
}
AddPluginItem::AddPluginItem(AddPluginsMenu *menu, char const *text, int idx)
{
this->menu = menu;
this->idx = idx;
- uint32_t msk = 1 << idx, vis = menu->gui->plugin_visibility;
+ uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
int chk = (msk & vis) ? 1 : 0;
set_checked(chk);
}
{
int chk = get_checked() ^ 1;
set_checked(chk);
- uint32_t msk = 1 << idx, vis = menu->gui->plugin_visibility;
+ uint64_t msk = (uint64_t)1 << idx, vis = menu->gui->plugin_visibility;
menu->gui->plugin_visibility = chk ? vis | msk : vis & ~msk;
menu->gui->update_effects();
menu->gui->update_assets();
+ menu->gui->save_defaults(menu->mwindow->defaults);
+ return 1;
+}
+
+AVIconDrawing::AVIconDrawing(AWindowGUI *agui, int x, int y, VFrame **images)
+ : BC_Toggle(x, y, images, agui->vicon_drawing)
+{
+ this->agui = agui;
+ set_tooltip(_("draw vicons"));
+}
+
+void AVIconDrawing::calculate_geometry(AWindowGUI *agui, VFrame **images, int *ww, int *hh)
+{
+ int text_line = -1, toggle_x = -1, toggle_y = -1;
+ int text_x = -1, text_y = -1, text_w = -1, text_h = -1;
+ BC_Toggle::calculate_extents(agui, images, 1,
+ &text_line, ww, hh, &toggle_x, &toggle_y,
+ &text_x, &text_y, &text_w, &text_h, "", MEDIUMFONT);
+}
+
+AVIconDrawing::~AVIconDrawing()
+{
+}
+
+int AVIconDrawing::handle_event()
+{
+ agui->vicon_drawing = get_value();
+ if( agui->vicon_drawing )
+ agui->start_vicon_drawing();
+ else
+ agui->stop_vicon_drawing();
return 1;
}