1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 /** \file
18  * \ingroup RNA
19  */
20 
21 #include <stdlib.h>
22 
23 #include "DNA_scene_types.h"
24 
25 #include "RNA_define.h"
26 
27 #include "rna_internal.h"
28 
29 #include "WM_types.h"
30 
31 #ifdef RNA_RUNTIME
32 
33 #  include "BKE_idprop.h"
34 #  include "WM_api.h"
35 
rna_TimelineMarker_idprops(PointerRNA * ptr,bool create)36 static IDProperty *rna_TimelineMarker_idprops(PointerRNA *ptr, bool create)
37 {
38   TimeMarker *marker = ptr->data;
39 
40   if (create && marker->prop == NULL) {
41     IDPropertyTemplate val = {0};
42     marker->prop = IDP_New(IDP_GROUP, &val, "Marker ID properties");
43   }
44 
45   return marker->prop;
46 }
47 
rna_TimelineMarker_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * UNUSED (ptr))48 static void rna_TimelineMarker_update(Main *UNUSED(bmain),
49                                       Scene *UNUSED(scene),
50                                       PointerRNA *UNUSED(ptr))
51 {
52   WM_main_add_notifier(NC_SCENE | ND_MARKERS, NULL);
53   WM_main_add_notifier(NC_ANIMATION | ND_MARKERS, NULL);
54 }
55 
56 #else
57 
rna_def_timeline_marker(BlenderRNA * brna)58 static void rna_def_timeline_marker(BlenderRNA *brna)
59 {
60   StructRNA *srna;
61   PropertyRNA *prop;
62 
63   srna = RNA_def_struct(brna, "TimelineMarker", NULL);
64   RNA_def_struct_sdna(srna, "TimeMarker");
65   RNA_def_struct_ui_text(srna, "Marker", "Marker for noting points in the timeline");
66   RNA_def_struct_idprops_func(srna, "rna_TimelineMarker_idprops");
67 
68   /* String values */
69   prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
70   RNA_def_property_ui_text(prop, "Name", "");
71   RNA_def_struct_name_property(srna, prop);
72   RNA_def_property_update(prop, 0, "rna_TimelineMarker_update");
73 
74   prop = RNA_def_property(srna, "frame", PROP_INT, PROP_TIME);
75   RNA_def_property_ui_text(prop, "Frame", "The frame on which the timeline marker appears");
76   RNA_def_property_update(prop, 0, "rna_TimelineMarker_update");
77 
78   prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
79   RNA_def_property_boolean_sdna(prop, NULL, "flag", 1 /*SELECT*/);
80   RNA_def_property_ui_text(prop, "Select", "Marker selection state");
81   RNA_def_property_update(prop, 0, "rna_TimelineMarker_update");
82 
83 #  ifdef DURIAN_CAMERA_SWITCH
84   prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
85   RNA_def_property_struct_type(prop, "Object");
86   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
87   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
88   RNA_def_property_ui_text(prop, "Camera", "Camera that becomes active on this frame");
89 #  endif
90 }
91 
RNA_def_timeline_marker(BlenderRNA * brna)92 void RNA_def_timeline_marker(BlenderRNA *brna)
93 {
94   rna_def_timeline_marker(brna);
95 }
96 
97 #endif
98