Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

localsession.C

Go to the documentation of this file.
00001 #include "clip.h"
00002 #include "defaults.h"
00003 #include "edl.h"
00004 #include "filexml.h"
00005 #include "localsession.h"
00006 
00007 
00008 
00009 
00010 
00011 LocalSession::LocalSession(EDL *edl)
00012 {
00013         this->edl = edl;
00014 
00015         selectionstart = selectionend = 0;
00016         in_point = out_point = -1;
00017         strcpy(folder, CLIP_FOLDER);
00018         sprintf(clip_title, "Program");
00019         strcpy(clip_notes, "Hello world");
00020         clipboard_length = 0;
00021         preview_start = preview_end = 0;
00022         loop_playback = 0;
00023         loop_start = 0;
00024         loop_end = 0;
00025         zoom_sample = 0;
00026         zoom_y = 0;
00027         zoom_track = 0;
00028         view_start = 0;
00029         track_start = 0;
00030         automation_min = -10;
00031         automation_max = 10;
00032         red = green = blue = 0;
00033 }
00034 
00035 LocalSession::~LocalSession()
00036 {
00037 }
00038 
00039 void LocalSession::copy_from(LocalSession *that)
00040 {
00041         strcpy(clip_title, that->clip_title);
00042         strcpy(clip_notes, that->clip_notes);
00043         strcpy(folder, that->folder);
00044         in_point = that->in_point;
00045         loop_playback = that->loop_playback;
00046         loop_start = that->loop_start;
00047         loop_end = that->loop_end;
00048         out_point = that->out_point;
00049         selectionend = that->selectionend;
00050         selectionstart = that->selectionstart;
00051         track_start = that->track_start;
00052         view_start = that->view_start;
00053         zoom_sample = that->zoom_sample;
00054         zoom_y = that->zoom_y;
00055         zoom_track = that->zoom_track;
00056         preview_start = that->preview_start;
00057         preview_end = that->preview_end;
00058         red = that->red;
00059         green = that->green;
00060         automation_min = that->automation_min;
00061         automation_max = that->automation_max;
00062         blue = that->blue;
00063 }
00064 
00065 void LocalSession::save_xml(FileXML *file, double start)
00066 {
00067         file->tag.set_title("LOCALSESSION");
00068 
00069         file->tag.set_property("IN_POINT", in_point - start);
00070         file->tag.set_property("LOOP_PLAYBACK", loop_playback);
00071         file->tag.set_property("LOOP_START", loop_start - start);
00072         file->tag.set_property("LOOP_END", loop_end - start);
00073         file->tag.set_property("OUT_POINT", out_point - start);
00074         file->tag.set_property("SELECTION_START", selectionstart - start);
00075         file->tag.set_property("SELECTION_END", selectionend - start);
00076         file->tag.set_property("CLIP_TITLE", clip_title);
00077         file->tag.set_property("CLIP_NOTES", clip_notes);
00078         file->tag.set_property("FOLDER", folder);
00079         file->tag.set_property("TRACK_START", track_start);
00080         file->tag.set_property("VIEW_START", view_start);
00081         file->tag.set_property("ZOOM_SAMPLE", zoom_sample);
00082 //printf("EDLSession::save_session 1\n");
00083         file->tag.set_property("ZOOMY", zoom_y);
00084 //printf("EDLSession::save_session 1 %d\n", zoom_track);
00085         file->tag.set_property("ZOOM_TRACK", zoom_track);
00086         
00087         double preview_start = this->preview_start - start;
00088         if(preview_start < 0) preview_start = 0;
00089         double preview_end = this->preview_end - start;
00090         if(preview_end < 0) preview_end = 0;
00091         
00092         file->tag.set_property("PREVIEW_START", preview_start);
00093         file->tag.set_property("PREVIEW_END", preview_end);
00094         file->tag.set_property("RED", red);
00095         file->tag.set_property("GREEN", green);
00096         file->tag.set_property("BLUE", blue);
00097         file->tag.set_property("AUTOMATION_MIN", automation_min);
00098         file->tag.set_property("AUTOMATION_MAX", automation_max);
00099         file->append_tag();
00100         file->tag.set_title("/LOCALSESSION");
00101         file->append_tag();
00102         file->append_newline();
00103         file->append_newline();
00104 }
00105 
00106 void LocalSession::synchronize_params(LocalSession *that)
00107 {
00108         loop_playback = that->loop_playback;
00109         loop_start = that->loop_start;
00110         loop_end = that->loop_end;
00111         preview_start = that->preview_start;
00112         preview_end = that->preview_end;
00113         red = that->red;
00114         green = that->green;
00115         blue = that->blue;
00116 }
00117 
00118 
00119 void LocalSession::load_xml(FileXML *file, unsigned long load_flags)
00120 {
00121         if(load_flags & LOAD_SESSION)
00122         {
00123                 clipboard_length = 0;
00124 // Overwritten by MWindow::load_filenames       
00125                 file->tag.get_property("CLIP_TITLE", clip_title);
00126                 file->tag.get_property("CLIP_NOTES", clip_notes);
00127                 file->tag.get_property("FOLDER", folder);
00128                 loop_playback = file->tag.get_property("LOOP_PLAYBACK", 0);
00129                 loop_start = file->tag.get_property("LOOP_START", (double)0);
00130                 loop_end = file->tag.get_property("LOOP_END", (double)0);
00131                 selectionstart = file->tag.get_property("SELECTION_START", (double)0);
00132                 selectionend = file->tag.get_property("SELECTION_END", (double)0);
00133                 track_start = file->tag.get_property("TRACK_START", track_start);
00134                 view_start = file->tag.get_property("VIEW_START", view_start);
00135                 zoom_sample = file->tag.get_property("ZOOM_SAMPLE", zoom_sample);
00136                 zoom_y = file->tag.get_property("ZOOMY", zoom_y);
00137                 zoom_track = file->tag.get_property("ZOOM_TRACK", zoom_track);
00138                 preview_start = file->tag.get_property("PREVIEW_START", preview_start);
00139                 preview_end = file->tag.get_property("PREVIEW_END", preview_end);
00140                 red = file->tag.get_property("RED", red);
00141                 green = file->tag.get_property("GREEN", green);
00142                 blue = file->tag.get_property("BLUE", blue);
00143                 automation_min = file->tag.get_property("AUTOMATION_MIN", automation_min);
00144                 automation_max = file->tag.get_property("AUTOMATION_MAX", automation_max);
00145         }
00146 
00147 
00148 // on operations like cut, paste, slice, clear... we should also undo the cursor position as users
00149 // expect - this is additionally important in keyboard-only editing in viewer window
00150         if(load_flags & LOAD_SESSION || load_flags & LOAD_TIMEBAR)
00151         {
00152                 selectionstart = file->tag.get_property("SELECTION_START", (double)0);
00153                 selectionend = file->tag.get_property("SELECTION_END", (double)0);
00154         }
00155 
00156 
00157 
00158         if(load_flags & LOAD_TIMEBAR)
00159         {
00160                 in_point = file->tag.get_property("IN_POINT", (double)-1);
00161                 out_point = file->tag.get_property("OUT_POINT", (double)-1);
00162         }
00163 }
00164 
00165 void LocalSession::boundaries()
00166 {
00167         zoom_sample = MAX(1, zoom_sample);
00168 }
00169 
00170 int LocalSession::load_defaults(Defaults *defaults)
00171 {
00172         loop_playback = defaults->get("LOOP_PLAYBACK", 0);
00173         loop_start = defaults->get("LOOP_START", (double)0);
00174         loop_end = defaults->get("LOOP_END", (double)0);
00175         selectionstart = defaults->get("SELECTIONSTART", selectionstart);
00176         selectionend = defaults->get("SELECTIONEND", selectionend);
00177 //      track_start = defaults->get("TRACK_START", 0);
00178 //      view_start = defaults->get("VIEW_START", 0);
00179         zoom_sample = defaults->get("ZOOM_SAMPLE", 1);
00180         zoom_y = defaults->get("ZOOMY", 64);
00181         zoom_track = defaults->get("ZOOM_TRACK", 64);
00182         red = defaults->get("RED", 0.0);
00183         green = defaults->get("GREEN", 0.0);
00184         blue = defaults->get("BLUE", 0.0);
00185         automation_min = defaults->get("AUTOMATION_MIN", automation_min);
00186         automation_max = defaults->get("AUTOMATION_MAX", automation_max);
00187         return 0;
00188 }
00189 
00190 int LocalSession::save_defaults(Defaults *defaults)
00191 {
00192         defaults->update("LOOP_PLAYBACK", loop_playback);
00193         defaults->update("LOOP_START", loop_start);
00194         defaults->update("LOOP_END", loop_end);
00195         defaults->update("SELECTIONSTART", selectionstart);
00196         defaults->update("SELECTIONEND", selectionend);
00197         defaults->update("TRACK_START", track_start);
00198         defaults->update("VIEW_START", view_start);
00199         defaults->update("ZOOM_SAMPLE", zoom_sample);
00200         defaults->update("ZOOMY", zoom_y);
00201         defaults->update("ZOOM_TRACK", zoom_track);
00202         defaults->update("RED", red);
00203         defaults->update("GREEN", green);
00204         defaults->update("BLUE", blue);
00205         defaults->update("AUTOMATION_MIN", automation_min);
00206         defaults->update("AUTOMATION_MAX", automation_max);
00207         return 0;
00208 }
00209 
00210 void LocalSession::set_selectionstart(double value)
00211 {
00212         this->selectionstart = value;
00213 }
00214 
00215 void LocalSession::set_selectionend(double value)
00216 {
00217         this->selectionend = value;
00218 }
00219 
00220 void LocalSession::set_inpoint(double value)
00221 {
00222         in_point = value;
00223 }
00224 
00225 void LocalSession::set_outpoint(double value)
00226 {
00227         out_point = value;
00228 }
00229 
00230 void LocalSession::unset_inpoint()
00231 {
00232         in_point = -1;
00233 }
00234 
00235 void LocalSession::unset_outpoint()
00236 {
00237         out_point = -1;
00238 }
00239 
00240 
00241 
00242 double LocalSession::get_selectionstart(int highlight_only)
00243 {
00244         if(highlight_only || !EQUIV(selectionstart, selectionend))
00245                 return selectionstart;
00246 
00247         if(in_point >= 0)
00248                 return in_point;
00249         else
00250         if(out_point >= 0)
00251                 return out_point;
00252         else
00253                 return selectionstart;
00254 }
00255 
00256 double LocalSession::get_selectionend(int highlight_only)
00257 {
00258         if(highlight_only || !EQUIV(selectionstart, selectionend))
00259                 return selectionend;
00260 
00261         if(out_point >= 0)
00262                 return out_point;
00263         else
00264         if(in_point >= 0)
00265                 return in_point;
00266         else
00267                 return selectionend;
00268 }
00269 
00270 double LocalSession::get_inpoint()
00271 {
00272         return in_point;
00273 }
00274 
00275 double LocalSession::get_outpoint()
00276 {
00277         return out_point;
00278 }
00279 
00280 int LocalSession::inpoint_valid()
00281 {
00282         return in_point >= 0;
00283 }
00284 
00285 int LocalSession::outpoint_valid()
00286 {
00287         return out_point >= 0;
00288 }
00289 
00290 
00291 
00292 

Generated on Sun Jan 8 13:38:56 2006 for Cinelerra-svn by  doxygen 1.4.4