Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / cinelerra / sharedlocation.C
blob008b1d47ed9a67f83005554ae18892977581f8b7
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,
83         int use_nudge)
85         if(plugin_type == PLUGIN_SHAREDPLUGIN)
86         {
87                 Track *track = 0;
88                 Plugin *plugin = 0;
90                 track = edl->tracks->get_item_number(module);
91                 if(track && this->plugin >= 0)
92                 {
93                         plugin = track->get_current_plugin(position, 
94                                 this->plugin, 
95                                 PLAY_FORWARD,
96                                 convert_units,
97                                 use_nudge);
98                 }
100                 char track_title[BCTEXTLEN];
101                 char plugin_title[BCTEXTLEN];
103                 if(track)
104                         strcpy(track_title, track->title);
105                 else
106                         sprintf(track_title, _("None"));
108                 if(plugin)
109                         strcpy(plugin_title, _(plugin->title));
110                 else
111                         sprintf(plugin_title, _("None"));
113                 sprintf(string, "%s: %s", track_title, plugin_title);
114         }
115         else
116         if(plugin_type == PLUGIN_SHAREDMODULE)
117         {
118                 Track *track = 0;
119                 track = edl->tracks->get_item_number(module);
121                 if(track)
122                         strcpy(string, track->title);
123                 else
124                         sprintf(string, _("None"));
125 //printf("SharedLocation::calculate_title %p %s\n", string);
126         }
132 //      Local Variables:
133 //      mode: C++
134 //      c-file-style: "linux"
135 //      End: