3 * Copyright (C) 2016-2020 William Morrow
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 #include "edlsession.h"
28 #include "localsession.h"
29 #include "mainsession.h"
32 #include "trackcanvas.h"
37 STrack::STrack(EDL *edl, Tracks *tracks)
40 data_type = TRACK_SUBTITLE;
41 data_h = edl->local_session->zoom_atrack;
49 // Used by PlaybackEngine
50 void STrack::synchronize_params(Track *track)
52 Track::synchronize_params(track);
55 int STrack::copy_settings(Track *track)
57 Track::copy_settings(track);
61 int STrack::load_defaults(BC_Hash *defaults)
63 Track::load_defaults(defaults);
67 void STrack::set_default_title()
69 Track *current = ListItem<Track>::list->first;
71 for(i = 0; current; current = NEXT)
73 if(current->data_type == TRACK_SUBTITLE) i++;
75 sprintf(title, _("Subttl %d"), i);
78 void STrack::create_objects()
80 Track::create_objects();
81 automation = new SAutomation(edl, this);
82 automation->create_objects();
83 edits = new SEdits(edl, this);
86 int STrack::vertical_span(Theme *theme)
88 int track_h = Track::vertical_span(theme);
89 int patch_h = theme->title_h;
91 patch_h += theme->play_h;
92 return MAX(track_h, patch_h);
96 int64_t STrack::to_units(double position, int round)
100 return Units::round(position * edl->session->frame_rate);
104 // Kludge for rounding errors, just on a smaller scale than formal rounding
105 position *= edl->session->frame_rate;
106 return Units::to_int64(position);
110 double STrack::to_doubleunits(double position)
112 return position * edl->session->frame_rate;
116 double STrack::from_units(int64_t position)
118 return (double)position / edl->session->frame_rate;
124 int STrack::identical(int64_t sample1, int64_t sample2)
127 if(labs(sample1 - sample2) <= 1) return 1; else return 0;
130 int STrack::save_header(FileXML *file)
132 file->tag.set_property("TYPE", "SUBTTL");
136 int STrack::save_derived(FileXML *file)
138 file->append_newline();
142 int STrack::load_header(FileXML *file, uint32_t load_flags)
147 int STrack::load_derived(FileXML *file, uint32_t load_flags)
153 int STrack::get_dimensions(int pane_number,
158 view_start = edl->local_session->view_start[pane_number] * edl->session->frame_rate;
160 // view_units = Units::toframes(tracks->view_samples(), mwindow->session->sample_rate, mwindow->session->frame_rate);
161 zoom_units = edl->local_session->zoom_sample / edl->session->sample_rate * edl->session->frame_rate;
165 int64_t STrack::length()
167 return edits->length();
170 SEdit::SEdit(EDL *edl, Edits *edits)
183 copy_from(Edit *edit)
185 Edit::copy_from(edit);
186 SEdit *sedit = (SEdit*)edit;
187 strcpy(text,sedit->text);
190 int SEdit::load_properties_derived(FileXML *xml)
192 xml->tag.get_property("TEXT", text);
196 int SEdit::copy_properties_derived(FileXML *xml, int64_t length_in_selection)
198 xml->tag.set_property("TEXT", text);
203 int SEdit::dump_derived()
209 int64_t SEdit::get_source_end(int64_t default_)
211 return default_; // Infinity