From: Good Guy Date: Wed, 5 Dec 2018 17:58:47 +0000 (-0700) Subject: inter-view map media popup tweaks, new vicon mode/size prefs X-Git-Tag: 2019-08~164 X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=commitdiff_plain;h=6226b2633b6460755969cb624550854669b1c79f inter-view map media popup tweaks, new vicon mode/size prefs --- diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.C b/cinelerra-5.1/cinelerra/appearanceprefs.C index 94c4b346..e27ebd02 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.C +++ b/cinelerra-5.1/cinelerra/appearanceprefs.C @@ -66,11 +66,12 @@ 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, x2 = x + 160; + int x = x0, y = y0, x1 = x + 100; add_subwindow(new BC_Title(x, y, _("Layout:"), LARGEFONT, resources->text_default)); y += 35; + int y1 = y; ViewTheme *theme; add_subwindow(new BC_Title(x, y, _("Theme:"))); @@ -84,11 +85,23 @@ void AppearancePrefs::create_objects() add_subwindow(plugin_icons = new ViewPluginIcons(x1, y, pwindow)); plugin_icons->create_objects(); y += plugin_icons->get_h() + 15; + x1 = get_w()/2; - add_subwindow(new BC_Title(x, y, _("View Thumbnail size:"))); + int x2 = x1 + 160, y2 = y; + y = y1; + add_subwindow(new BC_Title(x1, y, _("View thumbnail size:"))); thumbnail_size = new ViewThumbnailSize(pwindow, this, x2, y); thumbnail_size->create_objects(); y += thumbnail_size->get_h() + 5; + add_subwindow(new BC_Title(x1, y, _("Vicon memory size:"))); + vicon_size = new ViewViconSize(pwindow, this, x2, y); + vicon_size->create_objects(); + y += vicon_size->get_h() + 5; + add_subwindow(new BC_Title(x1, y, _("Vicon color mode:"))); + add_subwindow(vicon_color_mode = new ViewViconColorMode(pwindow, x2, y)); + vicon_color_mode->create_objects(); + y += vicon_color_mode->get_h() + 5; + y = bmax(y, y2); y += 10; add_subwindow(new BC_Bar(5, y, get_w() - 10)); @@ -97,13 +110,12 @@ void AppearancePrefs::create_objects() add_subwindow(new BC_Title(x, y, _("Time Format:"), LARGEFONT, resources->text_default)); - x1 = get_w()/2; add_subwindow(new BC_Title(x1, y, _("Flags:"), LARGEFONT, resources->text_default)); y += get_text_height(LARGEFONT) + 5; y += 10; - int y1 = y; + y1 = y; add_subwindow(hms = new TimeFormatHMS(pwindow, this, pwindow->thread->edl->session->time_format == TIME_HMS, @@ -426,6 +438,68 @@ int ViewThumbnailSize::handle_event() return 1; } +ViewViconSize::ViewViconSize(PreferencesWindow *pwindow, + AppearancePrefs *aprefs, int x, int y) + : BC_TumbleTextBox(aprefs, + pwindow->thread->preferences->vicon_size, + 16, 512, x, y, 80) + +{ + this->pwindow = pwindow; + this->aprefs = aprefs; +} + +int ViewViconSize::handle_event() +{ + int v = atoi(get_text()); + bclamp(v, 16,512); + pwindow->thread->preferences->vicon_size = v; + return 1; +} + +ViewViconColorMode::ViewViconColorMode(PreferencesWindow *pwindow, int x, int y) + : BC_PopupMenu(x, y, 100, + _(vicon_color_modes[pwindow->thread->preferences->vicon_color_mode]), 1) +{ + this->pwindow = pwindow; +} +ViewViconColorMode::~ViewViconColorMode() +{ +} + +const char *ViewViconColorMode::vicon_color_modes[] = { + N_("Low"), + N_("Med"), + N_("High"), +}; + +void ViewViconColorMode::create_objects() +{ + for( int id=0,nid=sizeof(vicon_color_modes)/sizeof(vicon_color_modes[0]); idthread->preferences->vicon_color_mode])); + return 1; +} + +ViewViconColorModeItem::ViewViconColorModeItem(ViewViconColorMode *popup, const char *text, int id) + : BC_MenuItem(text) +{ + this->popup = popup; + this->id = id; +} + +int ViewViconColorModeItem::handle_event() +{ + popup->set_text(get_text()); + popup->pwindow->thread->preferences->vicon_color_mode = id; + return popup->handle_event(); +} + UseTipWindow::UseTipWindow(PreferencesWindow *pwindow, int x, int y) : BC_CheckBox(x, @@ -597,7 +671,7 @@ void YuvColorSpace::create_objects() int YuvColorSpace::handle_event() { - set_text(color_space[pwindow->thread->preferences->yuv_color_space]); + set_text(_(color_space[pwindow->thread->preferences->yuv_color_space])); return 1; } diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.h b/cinelerra-5.1/cinelerra/appearanceprefs.h index e8122474..e44c0025 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.h +++ b/cinelerra-5.1/cinelerra/appearanceprefs.h @@ -48,6 +48,8 @@ public: TimeFormatSeconds *seconds; ViewThumbnails *thumbnails; ViewThumbnailSize *thumbnail_size; + ViewViconSize *vicon_size; + ViewViconColorMode *vicon_color_mode; YuvColorSpace *yuv_color_space; YuvColorRange *yuv_color_range; }; @@ -184,6 +186,38 @@ public: PreferencesWindow *pwindow; }; +class ViewViconSize : public BC_TumbleTextBox +{ +public: + ViewViconSize(PreferencesWindow *pwindow, + AppearancePrefs *aprefs, int x, int y); + int handle_event(); + AppearancePrefs *aprefs; + PreferencesWindow *pwindow; +}; + +class ViewViconColorMode : public BC_PopupMenu +{ + static const char *vicon_color_modes[3]; +public: + ViewViconColorMode(PreferencesWindow *pwindow, int x, int y); + ~ViewViconColorMode(); + + void create_objects(); + int handle_event(); + + PreferencesWindow *pwindow; +}; + +class ViewViconColorModeItem : public BC_MenuItem +{ +public: + ViewViconColorModeItem(ViewViconColorMode *popup, const char *text, int id); + int handle_event(); + ViewViconColorMode *popup; + int id; +}; + class UseTipWindow : public BC_CheckBox { public: diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.inc b/cinelerra-5.1/cinelerra/appearanceprefs.inc index 2276099a..9201a42f 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.inc +++ b/cinelerra-5.1/cinelerra/appearanceprefs.inc @@ -37,6 +37,9 @@ class ViewPluginIcons; class ViewPluginIconItem; class ViewThumbnails; class ViewThumbnailSize; +class ViewViconSize; +class ViewViconColorMode; +class ViewViconModeItem; class UseTipWindow; class UseWarnIndecies; class UseWarnVersion; @@ -51,7 +54,6 @@ class YuvColorSpace; class YuvColorSpaceItem; class YuvColorRange; class YuvColorRangeItem; -class PrefsAutostartLV2UI; class PerpetualSession; #endif diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index 2e02562c..042a793d 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -113,7 +113,7 @@ VFrame *AssetVIcon::frame() { Asset *asset = (Asset *)picon->indexable; if( !asset->video_data && audio_data && audio_size && length > 0 ) { - if( !temp ) temp = new VFrame(0, -1, vw, vh, BC_RGB888, -1); + if( !temp ) temp = new VFrame(0, -1, w, h, BC_RGB888, -1); temp->clear_frame(); int sample_rate = asset->get_sample_rate(); int64_t audio_samples = asset->get_audio_samples(); @@ -134,9 +134,9 @@ VFrame *AssetVIcon::frame() while( i < len ) data[i++] = *audio_data++ * sample_scale; while( i < bfrsz ) data[i++] = 0; picon->draw_wave(temp, data, bfrsz, RED, GREEN); - int x = (vw-1) * line_pos; + int x = (w-1) * line_pos; temp->pixel_rgb = RED; - temp->draw_line(x,0, x,vh); + temp->draw_line(x,0, x,h); return temp; } int vw = picon->gui->vicon_thread->vw; @@ -157,6 +157,12 @@ VFrame *AssetVIcon::frame() } if( !temp ) temp = new VFrame(0, -1, asset->width, asset->height, BC_RGB888, -1); + int vicon_cmodel = BC_RGB8; + switch( mwindow->preferences->vicon_color_mode ) { + case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break; + case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break; + case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break; + } while( seq_no >= images.size() ) { mwindow->video_cache->check_in(asset); Thread::yield(); @@ -166,7 +172,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, vw, vh, BC_RGB8); + add_image(temp, vw, vh, vicon_cmodel); } mwindow->video_cache->check_in(asset); } @@ -418,11 +424,9 @@ int AssetViewPopup::button_press_event() } } mwindow->gui->lock_window("AssetVIcon::popup_button_press"); - edl->local_session->set_selectionstart(pos); - edl->local_session->set_selectionend(pos); - mwindow->find_cursor(); - edl->local_session->set_selectionstart(start); - edl->local_session->set_selectionend(end); + if( !shift_down() ) mwindow->select_point(!ctrl_down() ? pos : start); + edl->local_session->set_selectionstart(!ctrl_down() ? pos : start); + edl->local_session->set_selectionend(!ctrl_down() ? pos : !shift_down() ? start : end); mwindow->zoom_sample(edl->local_session->zoom_sample); mwindow->gui->unlock_window(); return 1; @@ -531,10 +535,10 @@ void AssetViewPopup::draw_vframe(VFrame *vframe) 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) + asset_list->mwindow->preferences->vicon_size * 16/9, + asset_list->mwindow->preferences->vicon_size, + 4*asset_list->mwindow->preferences->awindow_picon_h * 16/9, + 4*asset_list->mwindow->preferences->awindow_picon_h) { draw_mode = ASSET_DRAW_IMAGE; } @@ -559,8 +563,8 @@ ViewPopup *AssetVIconThread::new_view_window(VFrame *frame) 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); + rx += (rx >= cx ? -view_w : viewing->w); + ry += (ry >= cy ? -view_h : viewing->h); AssetViewPopup *popup = new AssetViewPopup(this, draw_mode, frame, rx, ry, view_w, view_h); if( draw_mode == ASSET_DRAW_MEDIA_MAP ) @@ -1565,7 +1569,7 @@ VFrame *AssetPicon::get_vicon_frame() VFrame *frame = vicon->frame(); if( !frame ) return 0; if( !vicon_frame ) - vicon_frame = new VFrame(vicon->vw, vicon->vh, frame->get_color_model()); + vicon_frame = new VFrame(vicon->w, vicon->h, frame->get_color_model()); vicon_frame->transfer_from(frame); return vicon_frame; } diff --git a/cinelerra-5.1/cinelerra/preferences.C b/cinelerra-5.1/cinelerra/preferences.C index 6a351518..744755dc 100644 --- a/cinelerra-5.1/cinelerra/preferences.C +++ b/cinelerra-5.1/cinelerra/preferences.C @@ -69,6 +69,8 @@ Preferences::Preferences() trap_sigsegv = 1; trap_sigintr = 1; awindow_picon_h = 50; + vicon_size = 50; + vicon_color_mode = VICON_COLOR_MODE_LOW; theme[0] = 0; plugin_icons[0] = 0; strcpy(snapshot_path, "/tmp"); @@ -174,6 +176,8 @@ void Preferences::copy_from(Preferences *that) keyframe_reticle = that->keyframe_reticle; perpetual_session = that->perpetual_session; awindow_picon_h = that->awindow_picon_h; + vicon_size = that->vicon_size; + vicon_color_mode = that->vicon_color_mode; strcpy(theme, that->theme); strcpy(plugin_icons, that->plugin_icons); strcpy(snapshot_path, that->snapshot_path); @@ -316,6 +320,8 @@ int Preferences::load_defaults(BC_Hash *defaults) trap_sigintr = defaults->get("TRAP_SIGINTR", trap_sigintr); awindow_picon_h = defaults->get("AWINDOW_PICON_H", awindow_picon_h); + vicon_size = defaults->get("VICON_SIZE",vicon_size); + vicon_color_mode = defaults->get("VICON_COLOR_MODE",vicon_color_mode); strcpy(theme, _(DEFAULT_THEME)); strcpy(plugin_icons, DEFAULT_PICON); defaults->get("THEME", theme); @@ -458,6 +464,8 @@ int Preferences::save_defaults(BC_Hash *defaults) defaults->update("TRAP_SIGSEGV", trap_sigsegv); defaults->update("TRAP_SIGINTR", trap_sigintr); defaults->update("AWINDOW_PICON_H", awindow_picon_h); + defaults->update("VICON_SIZE",vicon_size); + defaults->update("VICON_COLOR_MODE",vicon_color_mode); 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 e8698b71..d6748183 100644 --- a/cinelerra-5.1/cinelerra/preferences.h +++ b/cinelerra-5.1/cinelerra/preferences.h @@ -94,6 +94,7 @@ public: int trap_sigintr; // media thumbnail size int awindow_picon_h; + int vicon_size, vicon_color_mode; // Title of theme char theme[BCTEXTLEN]; // plugin icon set diff --git a/cinelerra-5.1/cinelerra/preferences.inc b/cinelerra-5.1/cinelerra/preferences.inc index 29779763..d1a30f95 100644 --- a/cinelerra-5.1/cinelerra/preferences.inc +++ b/cinelerra-5.1/cinelerra/preferences.inc @@ -31,6 +31,10 @@ #define FFMPEG_EARLY_TIP _("Currently: Try FFMpeg first\n Click to: Try FFMpeg last") #define FFMPEG_LATE_TIP _("Currently: Try FFMpeg last\n Click to: Try FFMpeg first") +#define VICON_COLOR_MODE_LOW 0 +#define VICON_COLOR_MODE_MED 1 +#define VICON_COLOR_MODE_HIGH 2 + class Preferences; class PlaybackConfig; class AudioOutConfig; diff --git a/cinelerra-5.1/cinelerra/preferencesthread.C b/cinelerra-5.1/cinelerra/preferencesthread.C index 74ee37e6..31bd5b8a 100644 --- a/cinelerra-5.1/cinelerra/preferencesthread.C +++ b/cinelerra-5.1/cinelerra/preferencesthread.C @@ -231,12 +231,12 @@ int PreferencesThread::apply_settings() mwindow->stop_brender(); if( window ) window->lock_window("PreferencesThread::apply_settings 5"); - if( strcmp(preferences->theme, mwindow->preferences->theme) != 0 ) - 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->theme, mwindow->preferences->theme) || + strcmp(preferences->plugin_icons, mwindow->preferences->plugin_icons) || + preferences->awindow_picon_h != mwindow->preferences->awindow_picon_h || + preferences->vicon_size != mwindow->preferences->vicon_size || + preferences->vicon_color_mode != mwindow->preferences->vicon_color_mode ) + mwindow->restart_status = -1; // reconstruct/restart program 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 296b3b08..751d61e4 100644 --- a/cinelerra-5.1/guicast/vicon.C +++ b/cinelerra-5.1/guicast/vicon.C @@ -8,10 +8,10 @@ #include "condition.h" VIcon:: -VIcon(int vw, int vh, double rate) +VIcon(int w, int h, double rate) { - this->vw = vw; - this->vh = vh; + this->w = w; + this->h = h; this->frame_rate = rate; cycle_start = 0; @@ -47,12 +47,12 @@ draw_vframe(VIconThread *vt, BC_WindowBase *wdw, int x, int y) if( !vfrm ) return; 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->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 dx0 = x, dx1 = dx0 + w; + int dy0 = y, dy1 = dy0 + h; + if( (x=vt->draw_x0-dx0) > 0 ) { sx0 += (x*vt->vw)/w; dx0 = vt->draw_x0; } + if( (x=dx1-vt->draw_x1) > 0 ) { sx1 -= (x*vt->vw)/w; dx1 = vt->draw_x1; } + if( (y=vt->draw_y0-dy0) > 0 ) { sy0 += (y*vt->vh)/h; dy0 = vt->draw_y0; } + if( (y=dy1-vt->draw_y1) > 0 ) { sy1 -= (y*vt->vh)/h; 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 ) @@ -179,9 +179,9 @@ bool VIconThread:: visible(VIcon *vicon, int x, int y) { if( vicon->hidden ) return false; - if( y+vicon->vh <= draw_y0 ) return false; + if( y+vicon->h <= draw_y0 ) return false; if( y >= draw_y1 ) return false; - if( x+vicon->vw <= draw_x0 ) return false; + if( x+vicon->w <= draw_x0 ) return false; if( x >= draw_x1 ) return false; return true; } @@ -213,8 +213,8 @@ ViewPopup *VIconThread::new_view_window(VFrame *frame) 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); + rx += (rx >= cx ? -view_w : viewing->w); + ry += (ry >= cy ? -view_h : viewing->h); ViewPopup *vwin = new ViewPopup(this, frame, rx, ry, view_w, view_h); wdw->set_active_subwindow(vwin); return vwin; diff --git a/cinelerra-5.1/guicast/vicon.h b/cinelerra-5.1/guicast/vicon.h index 14f2a99b..de8072ae 100644 --- a/cinelerra-5.1/guicast/vicon.h +++ b/cinelerra-5.1/guicast/vicon.h @@ -40,7 +40,7 @@ public: class VIcon { public: - int vw, vh, in_use, hidden; + int w, h, in_use, hidden; ArrayList images; int64_t seq_no; double cycle_start, age, frame_rate;