4 bt fixes, xft unrefd font fix, add: find in resources, add: user title, filebox...
authorGood Guy <[email protected]>
Thu, 26 Jul 2018 20:38:26 +0000 (14:38 -0600)
committerGood Guy <[email protected]>
Thu, 26 Jul 2018 20:38:26 +0000 (14:38 -0600)
14 files changed:
cinelerra-5.1/cinelerra/cwindowtool.C
cinelerra-5.1/cinelerra/editpopup.C
cinelerra-5.1/cinelerra/editpopup.h
cinelerra-5.1/cinelerra/edl.C
cinelerra-5.1/cinelerra/edl.h
cinelerra-5.1/cinelerra/gwindowgui.C
cinelerra-5.1/cinelerra/gwindowgui.h
cinelerra-5.1/cinelerra/shbtnprefs.C
cinelerra-5.1/cinelerra/trackcanvas.C
cinelerra-5.1/guicast/bcfilebox.C
cinelerra-5.1/guicast/bcresources.C
cinelerra-5.1/guicast/bcwindowbase.C
cinelerra-5.1/guicast/workarounds.C
cinelerra-5.1/guicast/workarounds.h

index e5e6b2adf43f660e843e5e5aa9002d260b8e0ee7..f0f372a5aba2f82315f2ee38d7a232af060e21a8 100644 (file)
@@ -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 )
index e8d27b9609800942374ad2a56ae1f6138a72eebc..5fcd8152485f90d156c90d0d3a25b8790055c9d4 100644 (file)
@@ -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(); i<n; ++i ) {
+                               AssetPicon *ap = (AssetPicon *)agui->assets[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(); i<n; ++i ) {
+                                       AssetPicon *folder_item = (AssetPicon *)agui->folders[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;
 }
 
index e6a4c5dced970a05b0c6f473b25f80878890c956..50ae929382ebaeb0c723039f4324fd2871397bfc 100644 (file)
@@ -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];
index cfed55d6c59adb89c24bd61b008d256ca660b003..cbde2640730df60673f6099fcd9e79f13050e544 100644 (file)
@@ -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;
+}
+
index bc22b29067182d4fdd0063acd4fdb4adaea46ea9..606dcead99d9f05015d1426a44beb014bf9c367a 100644 (file)
@@ -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();
index 97a9adc2da970616ef6d263430214ae992df6879..c5248b4839b18591c02913405e7ebd2cd12f4c13 100644 (file)
@@ -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);
 }
index 1687e037eedba05dec428e69bfb5e58da372e159..8a347d6c3cd03dee2335a492166c26793bce6c4b 100644 (file)
@@ -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;
index b1de0be6c3310f3867bec76418069654fe3d80be..5d719beb7c91486af8735ab973c1ca70392424d3 100644 (file)
@@ -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;
 }
index 62aa0b282388ab8c71bab0164e09ff5d3ad5e024..f593b5803af6b586cb79e16289747889769d5112 100644 (file)
@@ -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,
index 6e194ebada7064bc5f8ca83686e17a8aad8be7e1..80cf3320191f37ec35b4096c7f418485292cb71e 100644 (file)
@@ -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) ) {
index 43343ca27a6fd81551e8cc0b3765269cb8bde4d5..955aa5f5281a05b7ec2912c759253f78a3a53748 100644 (file)
@@ -383,6 +383,7 @@ BC_Resources::BC_Resources()
                filebox_history[i].path[0] = 0;
 
 #ifdef HAVE_XFT
+       xftInit(0);
        xftInitFtLibrary();
 #endif
 
index db085e863655fc86bc011af6c875b825a7d9d43a..d7440bde39000d7499153dada1e0dbbda26fcb4e 100644 (file)
@@ -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,
index 652cde30e34a322b8f21c806e0b87cee9ca0c453..5bf28351f0e4b1478569bc5e8d385751cb9ed065 100644 (file)
@@ -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");
index d3a11004a5d64b9a5d5fe0675b778def493e8dae..c2ee45827e9eab7e8ed1e9b4cbe05853e9e38595 100644 (file)
@@ -52,8 +52,10 @@ public:
 #include <fontconfig/fontconfig.h>
 #include <fontconfig/fcfreetype.h>
 
+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);