prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / cinelerra / awindowgui.C
index f340bb0e207f92b6b0bdbf2de80ee7a07af74293..f7fd1c60707d36f64f6133d9591b2e1851008ea1 100644 (file)
@@ -90,11 +90,12 @@ VFrame *AssetVIcon::frame()
                }
                if( !temp )
                        temp = new VFrame(asset->width, asset->height, BC_RGB888);
-               file->set_layer(0);
-               file->set_video_position(images.size(),0);
                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);
                }
@@ -103,11 +104,10 @@ VFrame *AssetVIcon::frame()
        return *images[seq_no];
 }
 
-int64_t AssetVIcon::next_frame(int n)
+int64_t AssetVIcon::set_seq_no(int64_t no)
 {
-       age += n * period;
-       if( (seq_no+=n) >= length ) seq_no = 0;
-       return seq_no;
+       if( no >= length ) no = 0;
+       return seq_no = no;
 }
 
 int AssetVIcon::get_vx()
@@ -201,7 +201,7 @@ void AssetPicon::create_objects()
        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)
@@ -262,10 +262,11 @@ void AssetPicon::create_objects()
                                        icon_vframe->transfer_from(gui->temp_picon);
 // vicon images
                                        double framerate = asset->get_frame_rate();
-                                       if( !framerate ) framerate = 24;
-                                       int64_t length = framerate * 5;
-                                       int64_t vframes = asset->get_video_frames();
-                                       if( length > vframes ) length = vframes;
+                                       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__);
@@ -495,11 +496,11 @@ SET_TRACE
        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 VFrame(ff_audio_png);
+       ff_aud_vframe = new VFramePng(ff_audio_png);
        ff_aud_icon = new BC_Pixmap(this, ff_aud_vframe, PIXMAP_ALPHA);
-       ff_vid_vframe = new VFrame(ff_video_png);
+       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);
@@ -556,7 +557,7 @@ SET_TRACE
        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_subwindow(add_tools = new AddTools(mwindow, this, fx, fy, "Visibility"));
        add_tools->create_objects();
        fy += add_tools->get_h();  fh -= add_tools->get_h();
 SET_TRACE
@@ -765,16 +766,20 @@ void AWindowRemovePlugin::handle_close_event(int result)
                        0;
                if( folder ) remove_plugin(plugin, *folder);
                awindow->gui->update_assets();
-               char png_path[BCTEXTLEN], plugin_path[BCTEXTLEN], index_path[BCTEXTLEN];
+               char plugin_path[BCTEXTLEN];
                strcpy(plugin_path, plugin->path);
-               if( !plugin->get_plugin_png_path(png_path) ) png_path[0] = 0;
                MWindow *mwindow = awindow->mwindow;
-               sprintf(index_path, "%s/%s", mwindow->preferences->plugin_dir, PLUGIN_FILE);
                mwindow->plugindb->remove(plugin);
-               plugin->delete_this();
+               delete plugin;  plugin = 0;
                remove(plugin_path);
-               if( png_path[0] ) remove(png_path);
+               char index_path[BCTEXTLEN];
+               sprintf(index_path, "%s/%s", mwindow->preferences->plugin_dir, PLUGIN_FILE);
                remove(index_path);
+               char png_path[BCTEXTLEN];
+               if( plugin->get_theme_png_path(png_path, mwindow->preferences->theme) )
+                       remove(png_path);
+               if( plugin->get_theme_png_path(png_path, "picon") )
+                       remove(png_path);
        }
 }
 
@@ -1847,27 +1852,14 @@ int AWindowView::handle_event()
        return 1;
 }
 
-AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w)
- : BC_MenuBar(x, y, w)
+AddTools::AddTools(MWindow *mwindow, AWindowGUI *gui, int x, int y, const char *title)
+ : BC_PopupMenu(x, y, BC_Title::calculate_w(gui, title, MEDIUMFONT)+8, title, -1, 0, 4)
 {
        this->mwindow = mwindow;
        this->gui = gui;
 }
 
 void AddTools::create_objects()
-{
-       add_menu(add_plugins = new AddPluginsMenu(mwindow, gui));
-       add_plugins->create_objects();
-}
-
-AddPluginsMenu::AddPluginsMenu(MWindow *mwindow, AWindowGUI *gui)
- : BC_Menu("Add Tools")
-{
-       this->mwindow = mwindow;
-       this->gui = gui;
-}
-
-void AddPluginsMenu::create_objects()
 {
        uint64_t vis = 0;
        add_item(new AddPluginItem(this, "ladspa", PLUGIN_LADSPA_ID));
@@ -1890,7 +1882,7 @@ void AddPluginsMenu::create_objects()
        }
 }
 
-AddPluginItem::AddPluginItem(AddPluginsMenu *menu, char const *text, int idx)
+AddPluginItem::AddPluginItem(AddTools *menu, char const *text, int idx)
  : BC_MenuItem(text)
 {
        this->menu = menu;