From: Good Guy Date: Wed, 5 Dec 2018 00:21:18 +0000 (-0700) Subject: add view thumbnail size pref, rework vicon view popup, add view popup zoom scale X-Git-Tag: 2019-08~165 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=debf38f78ae5ce154f54183b1638278bf8a24736;p=goodguy%2Fcinelerra.git add view thumbnail size pref, rework vicon view popup, add view popup zoom scale --- diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.C b/cinelerra-5.1/cinelerra/appearanceprefs.C index 766cf6ce..94c4b346 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.C +++ b/cinelerra-5.1/cinelerra/appearanceprefs.C @@ -43,6 +43,7 @@ AppearancePrefs::AppearancePrefs(MWindow *mwindow, PreferencesWindow *pwindow) hex = 0; feet = 0; thumbnails = 0; + thumbnail_size = 0; } AppearancePrefs::~AppearancePrefs() @@ -54,6 +55,7 @@ AppearancePrefs::~AppearancePrefs() delete hex; delete feet; delete thumbnails; + delete thumbnail_size; } @@ -64,7 +66,7 @@ void AppearancePrefs::create_objects() char string[BCTEXTLEN]; int x0 = mwindow->theme->preferencesoptions_x; int y0 = mwindow->theme->preferencesoptions_y; - int x = x0, y = y0, x1 = x + 100; + int x = x0, y = y0, x1 = x + 100, x2 = x + 160; add_subwindow(new BC_Title(x, y, _("Layout:"), LARGEFONT, resources->text_default)); @@ -81,7 +83,12 @@ void AppearancePrefs::create_objects() add_subwindow(new BC_Title(x, y, _("Plugin Icons:"))); add_subwindow(plugin_icons = new ViewPluginIcons(x1, y, pwindow)); plugin_icons->create_objects(); - y += plugin_icons->get_h() + 5; + y += plugin_icons->get_h() + 15; + + add_subwindow(new BC_Title(x, y, _("View Thumbnail size:"))); + thumbnail_size = new ViewThumbnailSize(pwindow, this, x2, y); + thumbnail_size->create_objects(); + y += thumbnail_size->get_h() + 5; y += 10; add_subwindow(new BC_Bar(5, y, get_w() - 10)); @@ -400,6 +407,25 @@ int ViewThumbnails::handle_event() } +ViewThumbnailSize::ViewThumbnailSize(PreferencesWindow *pwindow, + AppearancePrefs *aprefs, int x, int y) + : BC_TumbleTextBox(aprefs, + pwindow->thread->preferences->awindow_picon_h, + 16, 512, x, y, 80) + +{ + this->pwindow = pwindow; + this->aprefs = aprefs; +} + +int ViewThumbnailSize::handle_event() +{ + int v = atoi(get_text()); + bclamp(v, 16,512); + pwindow->thread->preferences->awindow_picon_h = v; + return 1; +} + UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y) : BC_CheckBox(x, diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.h b/cinelerra-5.1/cinelerra/appearanceprefs.h index b59a9ed9..e8122474 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.h +++ b/cinelerra-5.1/cinelerra/appearanceprefs.h @@ -47,6 +47,7 @@ public: TimeFormatFeet *feet; TimeFormatSeconds *seconds; ViewThumbnails *thumbnails; + ViewThumbnailSize *thumbnail_size; YuvColorSpace *yuv_color_space; YuvColorRange *yuv_color_range; }; @@ -173,6 +174,16 @@ public: PreferencesWindow *pwindow; }; +class ViewThumbnailSize : public BC_TumbleTextBox +{ +public: + ViewThumbnailSize(PreferencesWindow *pwindow, + AppearancePrefs *aprefs, int x, int y); + int handle_event(); + AppearancePrefs *aprefs; + PreferencesWindow *pwindow; +}; + class UseTipWindow : public BC_CheckBox { public: diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.inc b/cinelerra-5.1/cinelerra/appearanceprefs.inc index 5d079cdc..2276099a 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.inc +++ b/cinelerra-5.1/cinelerra/appearanceprefs.inc @@ -36,6 +36,7 @@ class ViewThemeItem; class ViewPluginIcons; class ViewPluginIconItem; class ViewThumbnails; +class ViewThumbnailSize; class UseTipWindow; class UseWarnIndecies; class UseWarnVersion; diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index e8701eaa..2e02562c 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -139,11 +139,11 @@ VFrame *AssetVIcon::frame() temp->draw_line(x,0, x,vh); return temp; } - int ww = picon->gui->vicon_thread->view_w; - int hh = picon->gui->vicon_thread->view_h; + int vw = picon->gui->vicon_thread->vw; + int vh = picon->gui->vicon_thread->vh; if( !asset->video_data ) { if( !temp ) { - temp = new VFrame(0, -1, ww, hh, BC_RGB888, -1); + temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1); temp->clear_frame(); } return temp; @@ -166,7 +166,7 @@ VFrame *AssetVIcon::frame() int64_t pos = images.size() / picon->gui->vicon_thread->refresh_rate * frame_rate; file->set_video_position(pos,0); if( file->read_frame(temp) ) temp->clear_frame(); - add_image(temp, ww, hh, BC_RGB8); + add_image(temp, vw, vh, BC_RGB8); } mwindow->video_cache->check_in(asset); } @@ -307,28 +307,42 @@ void AssetVIcon::stop_audio() playing_audio = 0; } - -AssetVIconThread::AssetVIconThread(AWindowAssets *asset_list) - : VIconThread(asset_list) +AssetViewPopup::AssetViewPopup(VIconThread *vt, int draw_mode, + VFrame *frame, int x, int y, int w, int h) + : ViewPopup(vt, frame, x, y, w, h) { - popup_dragging = 0; + this->draw_mode = draw_mode; + this->bar_h = (VIEW_POPUP_BAR_H * h) / 200; } -AssetVIconThread::~AssetVIconThread() +AssetViewPopup::~AssetViewPopup() { } -int AssetVIconThread::popup_button_press(int x, int y) +int AssetViewPopup::button_press_event() { - if( !view_win || !view_win->is_event_win() ) return 0; - if( !vicon || vicon->playing_audio >= 0 ) return 0; - popup_dragging = 0; - int view_w = view_win->get_w(), view_h = view_win->get_h(); - AssetVIcon *vicon = (AssetVIcon *)this->vicon; + if( !is_event_win() ) return 0; + AssetVIconThread *avt = (AssetVIconThread *)vt; + if( !avt->vicon ) return 0; + + int dir = 1, button = get_buttonpress(); + switch( button ) { + case WHEEL_DOWN: dir = -1; // fall thru + case WHEEL_UP: return zoom_scale(dir); + case LEFT_BUTTON: + break; + default: + return 0; + } + + if( draw_mode != ASSET_DRAW_MEDIA_MAP ) return 0; + int x = get_cursor_x(), y = get_cursor_y(); + AssetVIcon *vicon = (AssetVIcon *)avt->vicon; AssetPicon *picon = vicon->picon; MWindow *mwindow = picon->mwindow; EDL *edl = mwindow->edl; - if( y < VIEW_POPUP_BAR_H ) { + dragging = 0; + if( y < bar_h ) { Indexable *idxbl = picon->indexable ? picon->indexable : picon->edl ? picon->edl : 0; @@ -340,7 +354,7 @@ int AssetVIconThread::popup_button_press(int x, int y) double video_length = frame_rate > 0 && idxbl->have_video() ? idxbl->get_video_frames() / frame_rate : 0; double idxbl_length = bmax(audio_length, video_length); - double pos = x * idxbl_length / view_w; + double pos = x * idxbl_length / get_w(); double start = 0, end = idxbl_length; double lt = DBL_MAX, rt = DBL_MAX; for( Track *track=edl->tracks->first; track!=0; track=track->next ) { @@ -373,16 +387,16 @@ int AssetVIconThread::popup_button_press(int x, int y) vwindow->update_position(CHANGE_NONE, 0, 1, 0); return 1; } - if( y >= view_h-VIEW_POPUP_BAR_H ) { - popup_dragging = 1; - if( !view_win->ctrl_down() ) - return popup_cursor_motion(x, y); + if( y >= get_h()-bar_h ) { + dragging = 1; + if( !ctrl_down() ) + return cursor_motion_event(); Indexable *idxbl = picon->indexable ? picon->indexable : picon->edl ? picon->edl : 0; if( !idxbl ) return 0; double total_length = mwindow->edl->tracks->total_length(); - double pos = x * total_length / view_w; + double pos = x * total_length / get_w(); double start = 0, end = total_length; double lt = DBL_MAX, rt = DBL_MAX; for( Track *track=edl->tracks->first; track!=0; track=track->next ) { @@ -416,28 +430,28 @@ int AssetVIconThread::popup_button_press(int x, int y) return 0; } -int AssetVIconThread::popup_button_release(int x, int y) +int AssetViewPopup::button_release_event() { - if( !view_win || !view_win->is_event_win() ) return 0; - if( !vicon || vicon->playing_audio >= 0 ) return 0; - popup_dragging = 0; + if( !is_event_win() ) return 0; + dragging = 0; return 1; } -int AssetVIconThread::popup_cursor_motion(int x, int y) +int AssetViewPopup::cursor_motion_event() { - if( !view_win || !view_win->is_event_win() ) return 0; - if( !vicon || vicon->playing_audio >= 0 ) return 0; - if( !view_win->get_button_down() || view_win->get_buttonpress() != 1 || - view_win->ctrl_down() || view_win->alt_down() || view_win->shift_down() ) + if( !is_event_win() ) return 0; + AssetVIconThread *avt = (AssetVIconThread *)vt; + if( !avt->vicon || draw_mode != ASSET_DRAW_MEDIA_MAP ) return 0; + if( !get_button_down() || get_buttonpress() != 1 || + ctrl_down() || alt_down() || shift_down() ) return 0; - AssetVIcon *vicon = (AssetVIcon *)this->vicon; + AssetVIcon *vicon = (AssetVIcon *)avt->vicon; MWindow *mwindow = vicon->picon->mwindow; EDL *edl = mwindow->edl; - if( popup_dragging ) { + if( dragging ) { + int x = get_cursor_x(); double total_length = edl->tracks->total_length(); - int view_w = view_win->get_w(); - double pos = x * total_length / view_w; + double pos = x * total_length / get_w(); mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion"); mwindow->select_point(pos); mwindow->zoom_sample(edl->local_session->zoom_sample); @@ -447,6 +461,114 @@ int AssetVIconThread::popup_cursor_motion(int x, int y) return 0; } +void AssetViewPopup::draw_vframe(VFrame *vframe) +{ + if( draw_mode == ASSET_DRAW_IMAGE ) { + ViewPopup::draw_vframe(vframe); + return; + } + set_color(BLACK); + draw_box(0,0,get_w(),get_h()); + if( draw_mode != ASSET_DRAW_MEDIA_MAP ) + return; + int y1 = bar_h; + int y2 = get_h()-bar_h; + BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1); + AssetVIconThread *avt = (AssetVIconThread *)vt; + AssetVIcon *vicon = (AssetVIcon *)avt->vicon; + AssetPicon *picon = (AssetPicon *)vicon->picon; + Indexable *idxbl = + picon->indexable ? picon->indexable : + picon->edl ? picon->edl : 0; + if( !idxbl ) return; + double sample_rate = idxbl->get_sample_rate(); + double audio_length = sample_rate > 0 && idxbl->have_audio() ? + idxbl->get_audio_samples() / sample_rate : 0; + double frame_rate = idxbl->get_frame_rate(); + double video_length = frame_rate > 0 && idxbl->have_video() ? + idxbl->get_video_frames() / frame_rate : 0; + double idxbl_length = bmax(audio_length, video_length); + if( !idxbl_length ) idxbl_length = 1; + + EDL *edl = picon->mwindow->edl; + double total_length = edl->tracks->total_length(); + if( !total_length ) total_length = 1; + for( Track *track=edl->tracks->first; track!=0; track=track->next ) { + for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) { + Indexable *indexable = (Indexable *)edit->asset; + if( !indexable ) indexable = (Indexable *)edit->nested_edl; + if( !indexable ) continue; + if( indexable->id == idxbl->id || + (!indexable->is_asset == !idxbl->is_asset && + !strcmp(indexable->path, idxbl->path)) ) { + double pos1 = track->from_units(edit->startsource); + double pos2 = track->from_units(edit->startsource + edit->length); + double xscale = get_w() / idxbl_length; + int ex1 = pos1 * xscale, ex2 = pos2 * xscale; + set_color(WHITE); + draw_box(ex1,0, ex2-ex1,y1); + set_color(BLACK); + draw_line(ex1,0, ex1,y1); + draw_line(ex2,0, ex2,y1); + pos1 = track->from_units(edit->startproject); + pos2 = track->from_units(edit->startproject + edit->length); + xscale = get_w() / total_length; + int px1 = pos1 * xscale, px2 = pos2 * xscale; + set_color(RED); + draw_box(px1,y2, px2-px1,get_h()-y2); + set_color(BLACK); + draw_line(px1,y2, px1,get_h()-1); + draw_line(px2,y2, px2,get_h()-1); + + set_color(YELLOW); + draw_line(ex1,y1, px1,y2); + draw_line(ex2,y1, px2,y2); + } + } + } +} + + +AssetVIconThread::AssetVIconThread(AWindowAssets *asset_list) + : VIconThread(asset_list, + asset_list->mwindow->preferences->awindow_picon_h * 16/9, + asset_list->mwindow->preferences->awindow_picon_h, + 4 * asset_list->mwindow->preferences->awindow_picon_h * 16/9, + 4 * asset_list->mwindow->preferences->awindow_picon_h) +{ + draw_mode = ASSET_DRAW_IMAGE; +} + +AssetVIconThread::~AssetVIconThread() +{ +} + +void AssetVIconThread::set_view_popup(AssetVIcon *vicon, int draw_mode) +{ + if( draw_mode >= 0 ) + this->draw_mode = draw_mode; + VIconThread::set_view_popup(vicon); +} + +ViewPopup *AssetVIconThread::new_view_window(VFrame *frame) +{ + BC_WindowBase *parent = wdw->get_parent(); + XineramaScreenInfo *info = parent->get_xinerama_info(-1); + int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2; + int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2; + int vx = viewing->get_vx(), rx = 0; + int vy = viewing->get_vy(), ry = 0; + wdw->get_root_coordinates(vx, vy, &rx, &ry); + rx += (rx >= cx ? -view_w : viewing->vw); + ry += (ry >= cy ? -view_h : viewing->vh); + AssetViewPopup *popup = new AssetViewPopup(this, draw_mode, + frame, rx, ry, view_w, view_h); + if( draw_mode == ASSET_DRAW_MEDIA_MAP ) + vicon->playing_audio = -1; + wdw->set_active_subwindow(popup); + return popup; +} + AWindowFolderItem::AWindowFolderItem() : BC_ListBoxItem() @@ -671,7 +793,8 @@ void AssetPicon::create_objects() char name[BCTEXTLEN]; int pixmap_w, pixmap_h; - pixmap_h = 50 * BC_WindowBase::get_resources()->icon_scale; + int picon_h = mwindow->preferences->awindow_picon_h; + pixmap_h = picon_h * BC_WindowBase::get_resources()->icon_scale; if( indexable ) { fs.extract_name(name, indexable->path); @@ -2313,12 +2436,25 @@ int AWindowFolders::selection_changed() int AWindowFolders::button_press_event() { - int result = 0; + AssetVIconThread *avt = gui->vicon_thread; + if( gui->asset_list->is_event_win() && + avt->viewing && avt->view_win ) { + int dir = 1, button = get_buttonpress(); + switch( button ) { + case WHEEL_DOWN: dir = -1; // fall thru + case WHEEL_UP: { + int x = get_cursor_x(), y = get_cursor_y(); + if( avt->cursor_inside(x, y) ) + return avt->view_win->zoom_scale(dir); + break; } + } + } - result = BC_ListBox::button_press_event(); + int result = BC_ListBox::button_press_event(); if( !result ) { - if( get_buttonpress() == 3 && is_event_win() && cursor_inside() ) { + if( get_buttonpress() == RIGHT_BUTTON && + is_event_win() && cursor_inside() ) { gui->folderlist_menu->update_titles(); gui->folderlist_menu->activate_menu(); result = 1; @@ -2438,7 +2574,6 @@ AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, in this->gui = gui; set_drag_scroll(0); set_scroll_stretch(1, 1); - draw_func = 0; } AWindowAssets::~AWindowAssets() @@ -2563,83 +2698,17 @@ int AWindowAssets::selection_changed() mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER || mwindow->edl->session->awindow_folder >= AWINDOW_USER_FOLDERS ) && (item = (AssetPicon*)get_selection(0, 0)) != 0 ) { - VIcon *vicon = 0; + AssetVIcon *vicon = 0; if( !gui->vicon_thread->vicon ) { vicon = item->vicon; } - if( vicon && get_buttonpress() == 2 ) { - vicon->playing_audio = -1; - draw_func = AWindowAssets::draw_vframe; - } - else - draw_func = 0; - gui->vicon_thread->set_view_popup(vicon, draw_func); + int draw_mode = vicon && get_buttonpress() == 2 ? + ASSET_DRAW_MEDIA_MAP : ASSET_DRAW_IMAGE; + gui->vicon_thread->set_view_popup(vicon, draw_mode); } return 1; } -void AWindowAssets::draw_vframe(BC_WindowBase *wdw, VFrame *vframe) -{ - int y1 = VIEW_POPUP_BAR_H; - int y2 = wdw->get_h()-VIEW_POPUP_BAR_H; - wdw->set_color(BLACK); - wdw->draw_box(0,0,wdw->get_w(),wdw->get_h()); - wdw->draw_vframe(vframe, 0,y1, wdw->get_w(),y2-y1); - ViewPopup *view_popup = (ViewPopup *)wdw; - AssetVIconThread *vt = (AssetVIconThread *)view_popup->vt; - AssetVIcon *vicon = (AssetVIcon *)vt->vicon; - AssetPicon *picon = (AssetPicon *)vicon->picon; - Indexable *idxbl = - picon->indexable ? picon->indexable : - picon->edl ? picon->edl : 0; - if( !idxbl ) return; - double sample_rate = idxbl->get_sample_rate(); - double audio_length = sample_rate > 0 && idxbl->have_audio() ? - idxbl->get_audio_samples() / sample_rate : 0; - double frame_rate = idxbl->get_frame_rate(); - double video_length = frame_rate > 0 && idxbl->have_video() ? - idxbl->get_video_frames() / frame_rate : 0; - double idxbl_length = bmax(audio_length, video_length); - if( !idxbl_length ) idxbl_length = 1; - - EDL *edl = picon->mwindow->edl; - double total_length = edl->tracks->total_length(); - if( !total_length ) total_length = 1; - for( Track *track=edl->tracks->first; track!=0; track=track->next ) { - for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) { - Indexable *indexable = (Indexable *)edit->asset; - if( !indexable ) indexable = (Indexable *)edit->nested_edl; - if( !indexable ) continue; - if( indexable->id == idxbl->id || - (!indexable->is_asset == !idxbl->is_asset && - !strcmp(indexable->path, idxbl->path)) ) { - double pos1 = track->from_units(edit->startsource); - double pos2 = track->from_units(edit->startsource + edit->length); - double xscale = wdw->get_w() / idxbl_length; - int ex1 = pos1 * xscale, ex2 = pos2 * xscale; - wdw->set_color(WHITE); - wdw->draw_box(ex1,0, ex2-ex1,y1); - wdw->set_color(BLACK); - wdw->draw_line(ex1,0, ex1,y1); - wdw->draw_line(ex2,0, ex2,y1); - pos1 = track->from_units(edit->startproject); - pos2 = track->from_units(edit->startproject + edit->length); - xscale = wdw->get_w() / total_length; - int px1 = pos1 * xscale, px2 = pos2 * xscale; - wdw->set_color(RED); - wdw->draw_box(px1,y2, px2-px1,wdw->get_h()-y2); - wdw->set_color(BLACK); - wdw->draw_line(px1,y2, px1,wdw->get_h()-1); - wdw->draw_line(px2,y2, px2,wdw->get_h()-1); - - wdw->set_color(YELLOW); - wdw->draw_line(ex1,y1, px1,y2); - wdw->draw_line(ex2,y1, px2,y2); - } - } - } -} - void AWindowAssets::draw_background() { clear_box(0,0,get_w(),get_h(),get_bg_surface()); @@ -2818,21 +2887,6 @@ int AWindowAssets::focus_out_event() return BC_ListBox::focus_out_event(); } -int AWindowAssets::cursor_enter_event() -{ - int ret = BC_ListBox::cursor_enter_event(); - gui->start_vicon_drawing(); - return ret; -} - -int AWindowAssets::cursor_leave_event() -{ - VIcon *vicon = gui->vicon_thread->vicon; - if( vicon && vicon->playing_audio >= 0 ) - gui->stop_vicon_drawing(); - return BC_ListBox::cursor_leave_event(); -} - void AWindowAssets::update_vicon_area() { int x0 = 0, x1 = get_w(); @@ -2850,11 +2904,7 @@ int AWindowAssets::mouse_over_event(int no) if( gui->vicon_thread->viewing && no >= 0 && no < gui->displayed_assets[0].size() ) { AssetPicon *picon = (AssetPicon *)gui->displayed_assets[0][no]; - VIcon *vicon = picon->vicon; - if( gui->vicon_thread->vicon && - gui->vicon_thread->vicon->playing_audio < 0 ) - vicon->playing_audio = -1; - picon->gui->vicon_thread->set_view_popup(vicon, draw_func); + gui->vicon_thread->set_view_popup(picon->vicon); } return 0; } diff --git a/cinelerra-5.1/cinelerra/awindowgui.h b/cinelerra-5.1/cinelerra/awindowgui.h index d15e19f5..99db0753 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.h +++ b/cinelerra-5.1/cinelerra/awindowgui.h @@ -53,8 +53,13 @@ #define SELECT_USED 1 #define SELECT_UNUSED 2 #define SELECT_NONE 3 + +// in percent view_h #define VIEW_POPUP_BAR_H 15 +#define ASSET_DRAW_IMAGE 0 +#define ASSET_DRAW_MEDIA_MAP 1 + class AWindowFolderItem : public BC_ListBoxItem { public: @@ -160,17 +165,34 @@ public: ~AssetVIcon(); }; +class AssetViewPopup : public ViewPopup +{ +public: + AssetViewPopup(VIconThread *vt, int draw_mode, + VFrame *frame, int x, int y, int w, int h); + ~AssetViewPopup(); + + int button_press_event(); + int button_release_event(); + int cursor_motion_event(); + + void draw_vframe(VFrame *frame); + + int bar_h; + int draw_mode; + int dragging; +}; + class AssetVIconThread : public VIconThread { public: AssetVIconThread(AWindowAssets *asset_list); ~AssetVIconThread(); - int popup_button_press(int x, int y); - int popup_button_release(int x, int y); - int popup_cursor_motion(int x, int y); + void set_view_popup(AssetVIcon *vicon, int draw_mode=-1); + ViewPopup *new_view_window(VFrame *frame); - int popup_dragging; + int draw_mode; }; @@ -319,14 +341,15 @@ public: AddTools *add_tools; // Temporary for reading picons from files VFrame *temp_picon; - VIconThread *vicon_thread; + AssetVIconThread *vicon_thread; AssetVIconAudio *vicon_audio; int64_t plugin_visibility; AWindowRemovePlugin *remove_plugin; AVIconDrawing *avicon_drawing; - int avicon_w, avicon_h, vicon_drawing; + int avicon_w, avicon_h; + int vicon_drawing; int allow_iconlisting; // Create custom atoms to be used for async messages between windows @@ -362,12 +385,8 @@ public: int column_resize_event(); int focus_in_event(); int focus_out_event(); - int cursor_enter_event(); - int cursor_leave_event(); void update_vicon_area(); int mouse_over_event(int no); - static VIconDrawVFrame draw_vframe; - VIconDrawVFrame *draw_func; MWindow *mwindow; AWindowGUI *gui; diff --git a/cinelerra-5.1/cinelerra/dbwindow.C b/cinelerra-5.1/cinelerra/dbwindow.C index 780fc650..d61e6363 100644 --- a/cinelerra-5.1/cinelerra/dbwindow.C +++ b/cinelerra-5.1/cinelerra/dbwindow.C @@ -350,7 +350,7 @@ DbWindowVIcon::~DbWindowVIcon() DbWindowVIconThread:: DbWindowVIconThread(DbWindowGUI *gui) - : VIconThread(gui->search_list, 4*SWIDTH, 4*SHEIGHT) + : VIconThread(gui->search_list, SWIDTH,SHEIGHT, 4*SWIDTH,4*SHEIGHT) { this->gui = gui; list_update = 0; diff --git a/cinelerra-5.1/cinelerra/preferences.C b/cinelerra-5.1/cinelerra/preferences.C index abb5f756..6a351518 100644 --- a/cinelerra-5.1/cinelerra/preferences.C +++ b/cinelerra-5.1/cinelerra/preferences.C @@ -68,6 +68,7 @@ Preferences::Preferences() autostart_lv2ui = 0; trap_sigsegv = 1; trap_sigintr = 1; + awindow_picon_h = 50; theme[0] = 0; plugin_icons[0] = 0; strcpy(snapshot_path, "/tmp"); @@ -172,6 +173,7 @@ void Preferences::copy_from(Preferences *that) use_thumbnails = that->use_thumbnails; keyframe_reticle = that->keyframe_reticle; perpetual_session = that->perpetual_session; + awindow_picon_h = that->awindow_picon_h; strcpy(theme, that->theme); strcpy(plugin_icons, that->plugin_icons); strcpy(snapshot_path, that->snapshot_path); @@ -313,6 +315,7 @@ int Preferences::load_defaults(BC_Hash *defaults) trap_sigsegv = defaults->get("TRAP_SIGSEGV", trap_sigsegv); trap_sigintr = defaults->get("TRAP_SIGINTR", trap_sigintr); + awindow_picon_h = defaults->get("AWINDOW_PICON_H", awindow_picon_h); strcpy(theme, _(DEFAULT_THEME)); strcpy(plugin_icons, DEFAULT_PICON); defaults->get("THEME", theme); @@ -454,6 +457,7 @@ int Preferences::save_defaults(BC_Hash *defaults) defaults->update("AUTOSTART_LV2UI", autostart_lv2ui); defaults->update("TRAP_SIGSEGV", trap_sigsegv); defaults->update("TRAP_SIGINTR", trap_sigintr); + defaults->update("AWINDOW_PICON_H", awindow_picon_h); defaults->update("THEME", theme); defaults->update("PLUGIN_ICONS", plugin_icons); defaults->update("SNAPSHOT_PATH", snapshot_path); diff --git a/cinelerra-5.1/cinelerra/preferences.h b/cinelerra-5.1/cinelerra/preferences.h index 0500641c..e8698b71 100644 --- a/cinelerra-5.1/cinelerra/preferences.h +++ b/cinelerra-5.1/cinelerra/preferences.h @@ -92,6 +92,8 @@ public: int perpetual_session; int trap_sigsegv; int trap_sigintr; +// media thumbnail size + int awindow_picon_h; // Title of theme char theme[BCTEXTLEN]; // plugin icon set diff --git a/cinelerra-5.1/cinelerra/preferencesthread.C b/cinelerra-5.1/cinelerra/preferencesthread.C index fbac1848..74ee37e6 100644 --- a/cinelerra-5.1/cinelerra/preferencesthread.C +++ b/cinelerra-5.1/cinelerra/preferencesthread.C @@ -235,6 +235,8 @@ int PreferencesThread::apply_settings() mwindow->restart_status = -1; // reload, need new bcresources if( strcmp(preferences->plugin_icons, mwindow->preferences->plugin_icons) != 0 ) mwindow->restart_status = -1; + if( preferences->awindow_picon_h != mwindow->preferences->awindow_picon_h ) + mwindow->restart_status = -1; if( strcmp(preferences->lv2_path, mwindow->preferences->lv2_path) != 0 ) reload_plugins = 1; if( reload_plugins ) { diff --git a/cinelerra-5.1/guicast/vicon.C b/cinelerra-5.1/guicast/vicon.C index ecd55512..296b3b08 100644 --- a/cinelerra-5.1/guicast/vicon.C +++ b/cinelerra-5.1/guicast/vicon.C @@ -45,20 +45,31 @@ draw_vframe(VIconThread *vt, BC_WindowBase *wdw, int x, int y) { VFrame *vfrm = frame(); if( !vfrm ) return; - int sx0 = 0, sx1 = sx0 + vt->view_w; - int sy0 = 0, sy1 = sy0 + vt->view_h; + int sx0 = 0, sx1 = sx0 + vt->vw; + int sy0 = 0, sy1 = sy0 + vt->vh; int dx0 = x, dx1 = dx0 + vw; int dy0 = y, dy1 = dy0 + vh; - if( (x=vt->draw_x0-dx0) > 0 ) { sx0 += (x*vt->view_w)/vw; dx0 = vt->draw_x0; } - if( (x=dx1-vt->draw_x1) > 0 ) { sx1 -= (x*vt->view_w)/vw; dx1 = vt->draw_x1; } - if( (y=vt->draw_y0-dy0) > 0 ) { sy0 += (y*vt->view_h)/vh; dy0 = vt->draw_y0; } - if( (y=dy1-vt->draw_y1) > 0 ) { sy1 -= (y*vt->view_h)/vh; dy1 = vt->draw_y1; } + if( (x=vt->draw_x0-dx0) > 0 ) { sx0 += (x*vt->vw)/vw; dx0 = vt->draw_x0; } + if( (x=dx1-vt->draw_x1) > 0 ) { sx1 -= (x*vt->vw)/vw; dx1 = vt->draw_x1; } + if( (y=vt->draw_y0-dy0) > 0 ) { sy0 += (y*vt->vh)/vh; dy0 = vt->draw_y0; } + if( (y=dy1-vt->draw_y1) > 0 ) { sy1 -= (y*vt->vh)/vh; dy1 = vt->draw_y1; } int sw = sx1 - sx0, sh = sy1 - sy0; int dw = dx1 - dx0, dh = dy1 - dy0; if( dw > 0 && dh > 0 && sw > 0 && sh > 0 ) wdw->draw_vframe(vfrm, dx0,dy0, dw,dh, sx0,sy0, sw,sh); } + +int VIconThread::cursor_inside(int x, int y) +{ + if( !viewing ) return 0; + int vx = viewing->get_vx(); + if( x < vx || x >= vx+vw ) return 0; + int vy = viewing->get_vy(); + if( y < vy || y >= vy+vh ) return 0; + return 1; +} + void VIconThread:: set_drawing_area(int x0, int y0, int x1, int y1) { @@ -91,15 +102,15 @@ void VIconThread::remove_vicon(int i) VIconThread:: -VIconThread(BC_WindowBase *wdw, int vw, int vh) +VIconThread(BC_WindowBase *wdw, int vw, int vh, int view_w, int view_h) : Thread(1, 0, 0) { this->wdw = wdw; - this->view_win = 0; this->vicon = 0; - this->view_w = vw; this->view_h = vh; - this->viewing = 0; - this->draw_x0 = 0; this->draw_x1 = wdw->get_w(); - this->draw_y0 = 0; this->draw_y1 = wdw->get_h(); + this->vw = vw; this->vh = vh; + this->view_w = view_w; this->view_h = view_h; + this->view_win = 0; this->vicon = 0; this->viewing = 0; + this->draw_x0 = 0; this->draw_x1 = wdw->get_w(); + this->draw_y0 = 0; this->draw_y1 = wdw->get_h(); draw_lock = new Condition(0, "VIconThread::draw_lock", 1); timer = new Timer(); this->refresh_rate = VICON_RATE; @@ -148,6 +159,15 @@ stop_drawing() wdw->unlock_window(); } +void VIconThread:: +stop_viewing() +{ + if( viewing ) { + viewing->stop_audio(); + viewing = 0; + } +} + int VIconThread::keypress_event(int key) { if( key != ESC ) return 0; @@ -172,19 +192,6 @@ int ViewPopup::keypress_event() return vt->keypress_event(key); } -int ViewPopup::button_press_event() -{ - return vt->popup_button_press(get_cursor_x(), get_cursor_y()); -} -int ViewPopup::button_release_event() -{ - return vt->popup_button_release(get_cursor_x(), get_cursor_y()); -} -int ViewPopup::cursor_motion_event() -{ - return vt->popup_cursor_motion(get_cursor_x(), get_cursor_y()); -} - ViewPopup::ViewPopup(VIconThread *vt, VFrame *frame, int x, int y, int w, int h) : BC_Popup(vt->wdw, x, y, w, h, BLACK) @@ -213,6 +220,17 @@ ViewPopup *VIconThread::new_view_window(VFrame *frame) return vwin; } +int ViewPopup::zoom_scale(int dir) +{ + int view_h = vt->view_h + dir*vt->view_h/10 + dir; + bclamp(view_h, 16,512); + vt->view_h = view_h; + vt->view_w = view_h * vt->vw/vt->vh; + vt->stop_viewing(); + return 1; +} + + void VIconThread:: reset_images() { @@ -239,16 +257,15 @@ int VIconThread::del_vicon(VIcon *vicon) return 1; } -void VIconThread::draw_vframe(BC_WindowBase *wdw, VFrame *frame) +void ViewPopup::draw_vframe(VFrame *frame) { - if( !wdw || !frame ) return; - wdw->draw_vframe(frame, 0,0, wdw->get_w(),wdw->get_h()); + if( !frame ) return; + BC_WindowBase::draw_vframe(frame, 0,0, get_w(),get_h()); } -void VIconThread::set_view_popup(VIcon *vicon, VIconDrawVFrame *draw_vfrm) +void VIconThread::set_view_popup(VIcon *vicon) { this->vicon = vicon; - this->draw_vfrm = vicon && !draw_vfrm ? VIconThread::draw_vframe : draw_vfrm; } void VIconThread::close_view_popup() @@ -301,7 +318,7 @@ draw(VIcon *vicon) img_dirty = 1; } if( draw_win ) { - draw_vfrm(view_win, vicon->frame()); + view_win->draw_vframe(vicon->frame()); win_dirty = 1; } return 1; diff --git a/cinelerra-5.1/guicast/vicon.h b/cinelerra-5.1/guicast/vicon.h index 09618298..14f2a99b 100644 --- a/cinelerra-5.1/guicast/vicon.h +++ b/cinelerra-5.1/guicast/vicon.h @@ -9,15 +9,15 @@ #include "vicon.inc" #include "vframe.h" -typedef void VIconDrawVFrame(BC_WindowBase *wdw, VFrame *frame); - class ViewPopup : public BC_Popup { public: VIconThread *vt; - int keypress_event(); - int button_press_event(); - int button_release_event(); - int cursor_motion_event(); + virtual int keypress_event(); + virtual int button_press_event() { return 0; } + virtual int button_release_event() { return 0; } + virtual int cursor_motion_event() { return 0; } + virtual void draw_vframe(VFrame *frame); + int zoom_scale(int dir); ViewPopup(VIconThread *vt, VFrame *frame, int x, int y, int w, int h); ~ViewPopup(); @@ -78,7 +78,7 @@ public: Condition *draw_lock; ViewPopup *view_win; VIcon *viewing, *vicon; - int view_w, view_h; + int vw, vh, view_w, view_h; int draw_x0, draw_y0; int draw_x1, draw_y1; int img_dirty, win_dirty; @@ -96,25 +96,24 @@ public: void draw_images(); void start_drawing(); void stop_drawing(); + void stop_viewing(); void reset_images(); void remove_vicon(int i); int keypress_event(int key); + int cursor_inside(int x, int y); void set_drawing_area(int x0, int y0, int x1, int y1); - void set_view_popup(VIcon *vicon, VIconDrawVFrame *draw_vfrm=0); + void set_view_popup(VIcon *vicon); void close_view_popup(); void hide_vicons(int v=1); - ViewPopup *new_view_window(VFrame *frame); - virtual int popup_button_press(int x, int y) { return 0; } - virtual int popup_button_release(int x, int y) { return 0; } - virtual int popup_cursor_motion(int x, int y) { return 0; } + virtual ViewPopup *new_view_window(VFrame *frame); virtual bool visible(VIcon *vicon, int x, int y); virtual void drawing_started() {} virtual void drawing_stopped() {} - static VIconDrawVFrame draw_vframe; - VIconDrawVFrame *draw_vfrm; - VIconThread(BC_WindowBase *wdw, int vw=4*VICON_WIDTH, int vh=4*VICON_HEIGHT); + VIconThread(BC_WindowBase *wdw, + int vw=VICON_WIDTH, int vh=VICON_HEIGHT, + int view_w=4*VICON_WIDTH, int view_h=4*VICON_HEIGHT); ~VIconThread(); };