r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / sharedlocation.C
blobb5f2687db410c2763a0a9d3288d97cf46211fd3a
1 #include "edl.h"
2 #include "filexml.h"
3 #include "plugin.h"
4 #include "sharedlocation.h"
5 #include "track.h"
6 #include "tracks.h"
7 #include "transportque.h"
9 // plugin locations
12 #include <string.h>
14 #include <libintl.h>
15 #define _(String) gettext(String)
16 #define gettext_noop(String) String
17 #define N_(String) gettext_noop (String)
20 SharedLocation::SharedLocation()
22         this->module = -1;
23         this->plugin = -1;
26 SharedLocation::SharedLocation(int module, int plugin)
28         this->module = module;
29         this->plugin = plugin;
32 void SharedLocation::save(FileXML *file)
34         file->tag.set_title("SHARED_LOCATION");
35         if(module >= 0) file->tag.set_property("SHARED_MODULE", (int64_t)module);
36         if(plugin >= 0) file->tag.set_property("SHARED_PLUGIN", (int64_t)plugin);
37         file->append_tag();
38         file->tag.set_title("/SHARED_LOCATION");
39         file->append_tag();
40         file->append_newline();
43 void SharedLocation::load(FileXML *file)
45         module = -1;
46         plugin = -1;
48         module = file->tag.get_property("SHARED_MODULE", (int64_t)module);
49         plugin = file->tag.get_property("SHARED_PLUGIN", (int64_t)plugin);
52 int SharedLocation::get_type()
54         if(plugin < 0)
55                 return PLUGIN_SHAREDMODULE;
56         else
57                 return PLUGIN_SHAREDPLUGIN;
61 int SharedLocation::operator==(const SharedLocation &that)
63         if(
64                 module == that.module &&
65                 plugin == that.plugin
66         ) return 1;
67         else
68         return 0;
71 SharedLocation& SharedLocation::operator=(const SharedLocation &that)
73         this->plugin = that.plugin;
74         this->module = that.module;
75         return *this;
78 void SharedLocation::calculate_title(char *string, 
79         EDL *edl, 
80         double position, 
81         int convert_units,
82         int plugin_type)
84         if(plugin_type == PLUGIN_SHAREDPLUGIN)
85         {
86                 Track *track = 0;
87                 Plugin *plugin = 0;
89                 track = edl->tracks->get_item_number(module);
90                 if(track && this->plugin >= 0)
91                 {
92                         plugin = track->get_current_plugin(position, 
93                                 this->plugin, 
94                                 PLAY_FORWARD,
95                                 convert_units);
96                 }
98                 char track_title[BCTEXTLEN];
99                 char plugin_title[BCTEXTLEN];
101                 if(track)
102                         strcpy(track_title, track->title);
103                 else
104                         sprintf(track_title, _("None"));
106                 if(plugin)
107                         strcpy(plugin_title, plugin->title);
108                 else
109                         sprintf(plugin_title, _("None"));
111                 sprintf(string, "%s: %s", track_title, plugin_title);
112         }
113         else
114         if(plugin_type == PLUGIN_SHAREDMODULE)
115         {
116                 Track *track = 0;
117                 track = edl->tracks->get_item_number(module);
119                 if(track)
120                         strcpy(string, track->title);
121                 else
122                         sprintf(string, _("None"));
123 //printf("SharedLocation::calculate_title %p %s\n", string);
124         }