From: Good Guy Date: Thu, 26 Jul 2018 20:38:26 +0000 (-0600) Subject: 4 bt fixes, xft unrefd font fix, add: find in resources, add: user title, filebox... X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=b30123c9534e8df8da1694d40396d86396bf1c08;p=goodguy%2Fhistory.git 4 bt fixes, xft unrefd font fix, add: find in resources, add: user title, filebox ctrl-a fix --- diff --git a/cinelerra-5.1/cinelerra/cwindowtool.C b/cinelerra-5.1/cinelerra/cwindowtool.C index e5e6b2ad..f0f372a5 100644 --- a/cinelerra-5.1/cinelerra/cwindowtool.C +++ b/cinelerra-5.1/cinelerra/cwindowtool.C @@ -913,7 +913,9 @@ void CWindowCameraGUI::update() if(z_auto) { float value = z_auto->get_value(); z->update(value); + thread->gui->lock_window("CWindowCameraGUI::update"); thread->gui->composite_panel->cpanel_zoom->update(value); + thread->gui->unlock_window(); } if( x_auto && y_auto && z_auto ) @@ -1355,7 +1357,9 @@ void CWindowProjectorGUI::update() if(z_auto) { float value = z_auto->get_value(); z->update(value); + thread->gui->lock_window("CWindowProjectorGUI::update"); thread->gui->composite_panel->cpanel_zoom->update(value); + thread->gui->unlock_window(); } if( x_auto && y_auto && z_auto ) diff --git a/cinelerra-5.1/cinelerra/editpopup.C b/cinelerra-5.1/cinelerra/editpopup.C index e8d27b96..5fcd8152 100644 --- a/cinelerra-5.1/cinelerra/editpopup.C +++ b/cinelerra-5.1/cinelerra/editpopup.C @@ -28,6 +28,7 @@ #include "edl.h" #include "edlsession.h" #include "file.h" +#include "keys.h" #include "language.h" #include "localsession.h" #include "mainerror.h" @@ -60,7 +61,8 @@ void EditPopup::create_objects() add_item(new EditMoveTrackDown(mwindow, this)); add_item(new EditPopupDeleteTrack(mwindow, this)); add_item(new EditPopupAddTrack(mwindow, this)); -// add_item(new EditPopupTitle(mwindow, this)); + add_item(new EditPopupFindAsset(mwindow, this)); + add_item(new EditPopupTitle(mwindow, this)); resize_option = 0; matchsize_option = 0; } @@ -85,13 +87,6 @@ int EditPopup::update(Track *track, Edit *edit) } - - - - - - - EditAttachEffect::EditAttachEffect(MWindow *mwindow, EditPopup *popup) : BC_MenuItem(_("Attach effect...")) { @@ -219,6 +214,46 @@ int EditPopupAddTrack::handle_event() return 1; } +EditPopupFindAsset::EditPopupFindAsset(MWindow *mwindow, EditPopup *popup) + : BC_MenuItem(_("Find in Resources")) +{ + this->mwindow = mwindow; + this->popup = popup; +} + +int EditPopupFindAsset::handle_event() +{ + Edit *edit = popup->edit; + if( edit ) { + Indexable *idxbl = (Indexable *)edit->asset; + if( !idxbl ) idxbl = (Indexable *)edit->nested_edl; + if( idxbl ) { + AWindowGUI *agui = mwindow->awindow->gui; + agui->lock_window("EditPopupFindAsset::handle_event"); + AssetPicon *picon = 0; + for( int i=0, n=agui->assets.size(); iassets[i]; + int found = ap->indexable && ( idxbl == ap->indexable || + !strcmp(idxbl->path, ap->indexable->path) ); + if( found && !picon ) picon = ap; + ap->set_selected(found); + } + if( picon ) { + int selected_folder = picon->indexable->awindow_folder; + mwindow->edl->session->awindow_folder = selected_folder; + for( int i=0,n=agui->folders.size(); ifolders[i]; + int selected = folder_item->foldernum == selected_folder ? 1 : 0; + folder_item->set_selected(selected); + } + } + agui->unlock_window(); + agui->async_update_assets(); + } + } + return 1; +} + EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup) : BC_MenuItem(_("User title...")) @@ -230,32 +265,21 @@ EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup) EditPopupTitle::~EditPopupTitle() { - delete popup; } int EditPopupTitle::handle_event() { int result; - - Track *trc = mwindow->session->track_highlighted; - - if (trc && trc->record) - { - Edit *edt = mwindow->session->edit_highlighted; - if(!edt) return 1; - + if( popup->edit ) { window = new EditPopupTitleWindow (mwindow, popup); window->create_objects(); result = window->run_window(); - - - if(!result && edt) - { - strcpy(edt->user_title, window->title_text->get_text()); + if( !result && popup->edit ) { + strcpy(popup->edit->user_title, window->title_text->get_text()); + mwindow->gui->draw_canvas(1, 0); + mwindow->gui->flash_canvas(1); } - - delete window; - window = 0; + delete window; window = 0; } return 1; @@ -266,20 +290,12 @@ EditPopupTitleWindow::EditPopupTitleWindow (MWindow *mwindow, EditPopup *popup) : BC_Window (_(PROGRAM_NAME ": Set edit title"), mwindow->gui->get_abs_cursor_x(0) - 400 / 2, mwindow->gui->get_abs_cursor_y(0) - 500 / 2, - 300, - 100, - 300, - 100, - 0, - 0, - 1) + 300, 130, 300, 130, 0, 0, 1) { this->mwindow = mwindow; this->popup = popup; - this->edt = this->mwindow->session->edit_highlighted; - if(this->edt) - { - strcpy(new_text, this->edt->user_title); + if( popup->edit ) { + strcpy(new_text, popup->edit->user_title); } } @@ -296,12 +312,12 @@ int EditPopupTitleWindow::close_event() void EditPopupTitleWindow::create_objects() { lock_window("EditPopupTitleWindow::create_objects"); - int x = 5; + int x = 10; int y = 10; - - add_subwindow (new BC_Title (x, y, _("User title"))); - add_subwindow (title_text = new EditPopupTitleText (this, - mwindow, x, y + 20)); + add_subwindow (new BC_Title (x, y, _("User title:"))); + title_text = new EditPopupTitleText (this, mwindow, x+15, y+20, + popup->edit ? popup->edit->user_title : ""); + add_subwindow(title_text); add_tool(new BC_OKButton(this)); add_tool(new BC_CancelButton(this)); @@ -313,8 +329,8 @@ void EditPopupTitleWindow::create_objects() EditPopupTitleText::EditPopupTitleText (EditPopupTitleWindow *window, - MWindow *mwindow, int x, int y) - : BC_TextBox(x, y, 250, 1, (char*)(window->edt ? window->edt->user_title : "")) + MWindow *mwindow, int x, int y, const char *text) + : BC_TextBox(x, y, 250, 1, text) { this->window = window; this->mwindow = mwindow; @@ -326,6 +342,8 @@ EditPopupTitleText::~EditPopupTitleText() int EditPopupTitleText::handle_event() { + if( get_keypress() == RETURN ) + window->set_done(0); return 1; } diff --git a/cinelerra-5.1/cinelerra/editpopup.h b/cinelerra-5.1/cinelerra/editpopup.h index e6a4c5dc..50ae9293 100644 --- a/cinelerra-5.1/cinelerra/editpopup.h +++ b/cinelerra-5.1/cinelerra/editpopup.h @@ -93,6 +93,15 @@ public: EditPopup *popup; }; +class EditPopupFindAsset : public BC_MenuItem +{ +public: + EditPopupFindAsset(MWindow *mwindow, EditPopup *popup); + int handle_event(); + MWindow *mwindow; + EditPopup *popup; +}; + class EditAttachEffect : public BC_MenuItem { @@ -149,7 +158,7 @@ class EditPopupTitleText : public BC_TextBox { public: EditPopupTitleText (EditPopupTitleWindow *window, - MWindow *mwindow, int x, int y); + MWindow *mwindow, int x, int y, const char *text); ~EditPopupTitleText(); int handle_event(); @@ -169,7 +178,6 @@ public: int close_event(); EditPopupTitleText *title_text; - Edit *edt; MWindow *mwindow; EditPopup *popup; char new_text[BCTEXTLEN]; diff --git a/cinelerra-5.1/cinelerra/edl.C b/cinelerra-5.1/cinelerra/edl.C index cfed55d6..cbde2640 100644 --- a/cinelerra-5.1/cinelerra/edl.C +++ b/cinelerra-5.1/cinelerra/edl.C @@ -1585,3 +1585,10 @@ void EDL::add_proxy(int use_scaler, } } +double EDL::get_cursor_position(int cursor_x, int pane_no) +{ + return (double)cursor_x * local_session->zoom_sample / session->sample_rate + + (double)local_session->view_start[pane_no] * + local_session->zoom_sample / session->sample_rate; +} + diff --git a/cinelerra-5.1/cinelerra/edl.h b/cinelerra-5.1/cinelerra/edl.h index bc22b290..606dcead 100644 --- a/cinelerra-5.1/cinelerra/edl.h +++ b/cinelerra-5.1/cinelerra/edl.h @@ -96,6 +96,8 @@ public: double frame_align(double position, int round); // frame align if cursor alignment is enabled double align_to_frame(double position, int round); +// get position under cursor in pane + double get_cursor_position(int cursor_x, int pane_no); // increase track w/h to at least session w/h void retrack(); diff --git a/cinelerra-5.1/cinelerra/gwindowgui.C b/cinelerra-5.1/cinelerra/gwindowgui.C index 97a9adc2..c5248b48 100644 --- a/cinelerra-5.1/cinelerra/gwindowgui.C +++ b/cinelerra-5.1/cinelerra/gwindowgui.C @@ -60,7 +60,7 @@ void GWindowGUI::start_color_thread(GWindowColorButton *color_button) { unlock_window(); delete color_thread; - color_thread = new GWindowColorThread(color_button); + color_thread = new GWindowColorThread(this, color_button); int color = auto_colors[color_button->auto_toggle->info->ref]; color_thread->start(color); lock_window("GWindowGUI::start_color_thread"); @@ -249,11 +249,12 @@ void GWindowColorButton::update_gui(int color) draw_face(); } -GWindowColorThread::GWindowColorThread(GWindowColorButton *color_button) +GWindowColorThread::GWindowColorThread(GWindowGUI *gui, GWindowColorButton *color_button) : ColorPicker(0, color_button->auto_toggle->caption) { - this->color = 0; + this->gui = gui; this->color_button = color_button; + this->color = 0; color_update = new GWindowColorUpdate(this); } @@ -271,7 +272,6 @@ void GWindowColorThread::start(int color) void GWindowColorThread::handle_done_event(int result) { color_update->stop(); - GWindowGUI *gui = color_button->auto_toggle->gui; int ref = color_button->auto_toggle->info->ref; gui->lock_window("GWindowColorThread::handle_done_event"); if( !result ) { @@ -284,7 +284,7 @@ void GWindowColorThread::handle_done_event(int result) color_button->update_gui(color); } gui->unlock_window(); - MWindowGUI *mwindow_gui = color_button->auto_toggle->gui->mwindow->gui; + MWindowGUI *mwindow_gui = gui->mwindow->gui; mwindow_gui->lock_window("GWindowColorUpdate::run"); mwindow_gui->draw_overlays(1); mwindow_gui->unlock_window(); @@ -299,7 +299,9 @@ int GWindowColorThread::handle_new_color(int color, int alpha) void GWindowColorThread::update_gui() { + gui->lock_window("GWindowColorThread::update_gui"); color_button->update_gui(color); + gui->unlock_window(); } GWindowColorUpdate::GWindowColorUpdate(GWindowColorThread *color_thread) @@ -373,7 +375,7 @@ void GWindowGUI::create_objects() } const char *label = _(tp->isauto ? auto_text[tp->ref] : other_text[tp->ref]); int color = !tp->isauto ? -1 : auto_colors[tp->ref]; - GWindowToggle *toggle = new GWindowToggle(mwindow, this, x, y, label, color, tp); + GWindowToggle *toggle = new GWindowToggle(this, x, y, label, color, tp); add_tool(toggles[i] = toggle); if( vframe ) draw_vframe(vframe, get_w()-vframe->get_w()-10, y); @@ -447,11 +449,10 @@ int GWindowGUI::keypress_event() } -GWindowToggle::GWindowToggle(MWindow *mwindow, GWindowGUI *gui, int x, int y, +GWindowToggle::GWindowToggle(GWindowGUI *gui, int x, int y, const char *text, int color, toggleinfo *info) - : BC_CheckBox(x, y, *get_main_value(mwindow, info), text, MEDIUMFONT, color) + : BC_CheckBox(x, y, *get_main_value(gui->mwindow, info), text, MEDIUMFONT, color) { - this->mwindow = mwindow; this->gui = gui; this->info = info; this->color = color; @@ -466,12 +467,13 @@ GWindowToggle::~GWindowToggle() int GWindowToggle::handle_event() { int value = get_value(); - *get_main_value(mwindow, info) = value; + *get_main_value(gui->mwindow, info) = value; gui->update_mwindow(); // Update stuff in MWindow unlock_window(); + MWindow *mwindow = gui->mwindow; mwindow->gui->lock_window("GWindowToggle::handle_event"); if( info->isauto ) { int autogroup_type = -1; @@ -538,7 +540,7 @@ int* GWindowToggle::get_main_value(MWindow *mwindow, toggleinfo *info) void GWindowToggle::update() { - int *vp = get_main_value(mwindow, info); + int *vp = get_main_value(gui->mwindow, info); if( !vp ) return; set_value(*vp); } diff --git a/cinelerra-5.1/cinelerra/gwindowgui.h b/cinelerra-5.1/cinelerra/gwindowgui.h index 1687e037..8a347d6c 100644 --- a/cinelerra-5.1/cinelerra/gwindowgui.h +++ b/cinelerra-5.1/cinelerra/gwindowgui.h @@ -71,7 +71,7 @@ public: class GWindowToggle : public BC_CheckBox { public: - GWindowToggle(MWindow *mwindow, GWindowGUI *gui, int x, int y, + GWindowToggle(GWindowGUI *gui, int x, int y, const char *text, int color, toggleinfo *info); ~GWindowToggle(); @@ -82,9 +82,8 @@ public: static int* get_main_value(MWindow *mwindow, toggleinfo *info); int color; - MWindow *mwindow; - GWindowGUI *gui; toggleinfo *info; + GWindowGUI *gui; GWindowColorButton *color_button; }; @@ -106,13 +105,14 @@ public: class GWindowColorThread : public ColorPicker { public: - GWindowColorThread(GWindowColorButton *color_button); + GWindowColorThread(GWindowGUI *gui, GWindowColorButton *color_button); ~GWindowColorThread(); void start(int color); int handle_new_color(int color, int alpha); void update_gui(); void handle_done_event(int result); + GWindowGUI *gui; int color; GWindowColorButton *color_button; GWindowColorUpdate *color_update; diff --git a/cinelerra-5.1/cinelerra/shbtnprefs.C b/cinelerra-5.1/cinelerra/shbtnprefs.C index b1de0be6..5d719beb 100644 --- a/cinelerra-5.1/cinelerra/shbtnprefs.C +++ b/cinelerra-5.1/cinelerra/shbtnprefs.C @@ -255,7 +255,9 @@ BC_Window *ShBtnTextDialog::new_gui() void ShBtnTextDialog::handle_close_event(int result) { if( !result ) { + sb_window->lock_window("ShBtnTextDialog::handle_close_event"); sb_window->list_update(); + sb_window->unlock_window(); } st_window = 0; } diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index 62aa0b28..f593b580 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -642,7 +642,6 @@ int64_t TrackCanvas::drop_plugin_position(PluginSet *plugin_set, Plugin *moved_p return -1; } - void TrackCanvas::draw(int mode, int hide_cursor) { const int debug = 0; @@ -4571,9 +4570,15 @@ int TrackCanvas::do_tracks(int cursor_x, int cursor_y, int button_press) int64_t track_x, track_y, track_w, track_h; track_dimensions(track, track_x, track_y, track_w, track_h); - if(button_press && get_buttonpress() == RIGHT_BUTTON && - cursor_y >= track_y && cursor_y < track_y + track_h) { - gui->edit_menu->update(track, 0); + if( button_press && get_buttonpress() == RIGHT_BUTTON && + cursor_y >= track_y && cursor_y < track_y + track_h) { + double pos = (double)cursor_x * mwindow->edl->local_session->zoom_sample / + mwindow->edl->session->sample_rate + + (double)mwindow->edl->local_session->view_start[pane->number] * + mwindow->edl->local_session->zoom_sample / + mwindow->edl->session->sample_rate; + int64_t position = track->to_units(pos, 0); + gui->edit_menu->update(track, track->edits->editof(position, PLAY_FORWARD, 0)); gui->edit_menu->activate_menu(); result = 1; } @@ -4836,12 +4841,7 @@ int TrackCanvas::button_press_event() mwindow->session->trim_edits = 0; if(is_event_win() && cursor_inside()) { -// double position = (double)cursor_x * -// mwindow->edl->local_session->zoom_sample / -// mwindow->edl->session->sample_rate + -// (double)mwindow->edl->local_session->view_start[pane->number] * -// mwindow->edl->local_session->zoom_sample / -// mwindow->edl->session->sample_rate; +// double position = mwindow->edl->get_cursor_position(cursor_x, pane->number); result = 1; if(!active) { @@ -4921,12 +4921,7 @@ int TrackCanvas::button_press_event() // Test handles only and select a region case EDITING_IBEAM: { - double position = (double)cursor_x * - mwindow->edl->local_session->zoom_sample / - mwindow->edl->session->sample_rate + - (double)mwindow->edl->local_session->view_start[pane->number] * - mwindow->edl->local_session->zoom_sample / - mwindow->edl->session->sample_rate; + double position = mwindow->edl->get_cursor_position(cursor_x, pane->number); //printf("TrackCanvas::button_press_event %d\n", position); if( do_transitions(cursor_x, cursor_y, diff --git a/cinelerra-5.1/guicast/bcfilebox.C b/cinelerra-5.1/guicast/bcfilebox.C index 6e194eba..80cf3320 100644 --- a/cinelerra-5.1/guicast/bcfilebox.C +++ b/cinelerra-5.1/guicast/bcfilebox.C @@ -808,6 +808,7 @@ static inline int ilen(int64_t v) int BC_FileBox::create_tables(int select_all) { + int preload_textbox = select_all; delete_tables(); char string[BCTEXTLEN]; BC_ListBoxItem *new_item; @@ -833,6 +834,10 @@ int BC_FileBox::create_tables(int select_all) // { if(!is_dir) { + if( preload_textbox ) { + preload_textbox = 0; + textbox->update(new_item->get_text()); + } int64_t size = file_item->size; if( (size_format == FILEBOX_SIZE_1000 && size >= 1000) || (size_format == FILEBOX_SIZE_1024 && size >= 1024) ) { diff --git a/cinelerra-5.1/guicast/bcresources.C b/cinelerra-5.1/guicast/bcresources.C index 43343ca2..955aa5f5 100644 --- a/cinelerra-5.1/guicast/bcresources.C +++ b/cinelerra-5.1/guicast/bcresources.C @@ -383,6 +383,7 @@ BC_Resources::BC_Resources() filebox_history[i].path[0] = 0; #ifdef HAVE_XFT + xftInit(0); xftInitFtLibrary(); #endif diff --git a/cinelerra-5.1/guicast/bcwindowbase.C b/cinelerra-5.1/guicast/bcwindowbase.C index db085e86..d7440bde 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.C +++ b/cinelerra-5.1/guicast/bcwindowbase.C @@ -182,10 +182,12 @@ BC_WindowBase::~BC_WindowBase() for( int i=sizeof(xfont)/sizeof(xfont[0]); --i>=0; ) XFreeFont(display, this->*xfont[i]); -// past bug in X caused XRenderExtensionInfo to be damaged -// if this is done here. left to be done in XCloseDisplay by Xlib. -// works in more modern systems, and needed for leak testing. -#if defined(HAVE_XFT) && defined(VALGRIND) +#ifdef HAVE_XFT +// prevents a bug when Xft closes with unrefd fonts + FcPattern *defaults = FcPatternCreate(); + FcPatternAddInteger(defaults, "maxunreffonts", 0); + XftDefaultSet(display, defaults); + static void *BC_WindowBase::*xft_font[] = { &BC_WindowBase::smallfont_xft, &BC_WindowBase::mediumfont_xft, diff --git a/cinelerra-5.1/guicast/workarounds.C b/cinelerra-5.1/guicast/workarounds.C index 652cde30..5bf28351 100644 --- a/cinelerra-5.1/guicast/workarounds.C +++ b/cinelerra-5.1/guicast/workarounds.C @@ -77,6 +77,14 @@ float Workarounds::pow(float x, float y) // not thread safe static Mutex xft_lock("xft_lock"); +Bool xftInit(const char *config) +{ + xft_lock.lock("XftInit"); + Bool ret = XftInit(config); + xft_lock.unlock(); + return ret; +} + FcBool xftInitFtLibrary(void) { xft_lock.lock("xftInitFtLibrary"); @@ -93,6 +101,14 @@ Bool xftDefaultHasRender(Display *dpy) return ret; } +Bool xftDefaultSet(Display *dpy, FcPattern *defaults) +{ + xft_lock.lock("xftDefaultHasRender"); + Bool ret = XftDefaultSet(dpy, defaults); + xft_lock.unlock(); + return ret; +} + FcBool xftCharExists(Display *dpy, XftFont *pub, FcChar32 ucs4) { xft_lock.lock("xftCharExists"); diff --git a/cinelerra-5.1/guicast/workarounds.h b/cinelerra-5.1/guicast/workarounds.h index d3a11004..c2ee4582 100644 --- a/cinelerra-5.1/guicast/workarounds.h +++ b/cinelerra-5.1/guicast/workarounds.h @@ -52,8 +52,10 @@ public: #include #include +Bool xftInit(const char *config); FcBool xftInitFtLibrary(void); Bool xftDefaultHasRender(Display *dpy); +Bool xftDefaultSet(Display *dpy, FcPattern *defaults); FcBool xftCharExists(Display *dpy, XftFont *pub, FcChar32 ucs4); void xftTextExtents8(Display *dpy, XftFont *pub, _Xconst FcChar8 *string, int len, XGlyphInfo *extents);