repair default keyframe load, tweak init default histogram threshold
[goodguy/history.git] / cinelerra-5.1 / cinelerra / autoconf.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "autoconf.h"
23 #include "bchash.h"
24 #include "filexml.h"
25
26
27 static const char *xml_titles[AUTOMATION_TOTAL] =
28 {
29         "SHOW_MUTE",
30         "SHOW_CAMERA_X",
31         "SHOW_CAMERA_Y",
32         "SHOW_CAMERA_Z",
33         "SHOW_PROJECTOR_X",
34         "SHOW_PROJECTOR_Y",
35         "SHOW_PROJECTOR_Z",
36         "SHOW_FADE",
37         "SHOW_PAN",
38         "SHOW_MODE",
39         "SHOW_MASK",
40         "SHOW_SPEED"
41 };
42
43 static int auto_defaults[AUTOMATION_TOTAL] =
44 {
45         0, // MUTE,
46         0, // CAMERA_X
47         0, // CAMERA_Y
48         0, // CAMERA_Z
49         0, // PROJECTOR_X
50         0, // PROJECTOR_Y
51         0, // PROJECTOR_Z
52         1, // FADE
53         0, // PAN
54         0, // MODE
55         0, // MASK
56         0, // SPEED
57 };
58
59 int AutoConf::load_defaults(BC_Hash* defaults)
60 {
61         for(int i = 0; i < AUTOMATION_TOTAL; i++)
62         {
63                 autos[i] = defaults->get(xml_titles[i], auto_defaults[i]);
64         }
65         transitions = defaults->get("SHOW_TRANSITIONS", 1);
66         plugins = defaults->get("SHOW_PLUGINS", 1);
67         return 0;
68 }
69
70 void AutoConf::load_xml(FileXML *file)
71 {
72         for(int i = 0; i < AUTOMATION_TOTAL; i++)
73         {
74                 autos[i] = file->tag.get_property(xml_titles[i], auto_defaults[i]);
75         }
76         transitions = file->tag.get_property("SHOW_TRANSITIONS", 1);
77         plugins = file->tag.get_property("SHOW_PLUGINS", 1);
78 }
79
80 int AutoConf::save_defaults(BC_Hash* defaults)
81 {
82         for(int i = 0; i < AUTOMATION_TOTAL; i++)
83         {
84                 defaults->update(xml_titles[i], autos[i]);
85         }
86         defaults->update("SHOW_TRANSITIONS", transitions);
87         defaults->update("SHOW_PLUGINS", plugins);
88         return 0;
89 }
90
91 void AutoConf::save_xml(FileXML *file)
92 {
93         for(int i = 0; i < AUTOMATION_TOTAL; i++)
94         {
95                 file->tag.set_property(xml_titles[i], autos[i]);
96         }
97         file->tag.set_property("SHOW_TRANSITIONS", transitions);
98         file->tag.set_property("SHOW_PLUGINS", plugins);
99 }
100
101 int AutoConf::set_all(int value)
102 {
103         for(int i = 0; i < AUTOMATION_TOTAL; i++)
104         {
105                 autos[i] = value;
106         }
107         transitions = value;
108         plugins = value;
109         return 0;
110 }
111
112 AutoConf& AutoConf::operator=(AutoConf &that)
113 {
114         copy_from(&that);
115         return *this;
116 }
117
118 void AutoConf::copy_from(AutoConf *src)
119 {
120         for(int i = 0; i < AUTOMATION_TOTAL; i++)
121         {
122                 autos[i] = src->autos[i];
123         }
124         transitions = src->transitions;
125         plugins = src->plugins;
126 }
127
128