~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/makesrna/intern/rna_property.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: rna_property.c 28677 2010-05-08 22:11:00Z dfelinto $
3
 
 *
 
1
/*
4
2
 * ***** BEGIN GPL LICENSE BLOCK *****
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or
22
20
 * ***** END GPL LICENSE BLOCK *****
23
21
 */
24
22
 
 
23
/** \file blender/makesrna/intern/rna_property.c
 
24
 *  \ingroup RNA
 
25
 */
 
26
 
 
27
 
25
28
#include <stdlib.h>
26
29
 
27
30
#include "RNA_define.h"
32
35
 
33
36
#include "WM_types.h"
34
37
 
 
38
EnumPropertyItem gameproperty_type_items[] = {
 
39
        {GPROP_BOOL, "BOOL", 0, "Boolean", "Boolean Property"},
 
40
        {GPROP_INT, "INT", 0, "Integer", "Integer Property"},
 
41
        {GPROP_FLOAT, "FLOAT", 0, "Float", "Floating-Point Property"},
 
42
        {GPROP_STRING, "STRING", 0, "String", "String Property"},
 
43
        {GPROP_TIME, "TIMER", 0, "Timer", "Timer Property"},
 
44
        {0, NULL, 0, NULL, NULL}};
 
45
 
 
46
 
35
47
#ifdef RNA_RUNTIME
36
48
 
37
49
#include "BKE_property.h"
38
50
 
39
51
static StructRNA* rna_GameProperty_refine(struct PointerRNA *ptr)
40
52
{
41
 
        bProperty *property= (bProperty*)ptr->data;
 
53
        bProperty *property = (bProperty*)ptr->data;
42
54
 
43
 
        switch(property->type){
 
55
        switch (property->type) {
44
56
                case GPROP_BOOL:
45
57
                        return &RNA_GameBooleanProperty;
46
58
                case GPROP_INT:
59
71
/* for both float and timer */
60
72
static float rna_GameFloatProperty_value_get(PointerRNA *ptr)
61
73
{
62
 
        bProperty *prop= (bProperty*)(ptr->data);
 
74
        bProperty *prop = (bProperty*)(ptr->data);
63
75
        return *(float*)(&prop->data);
64
76
}
65
77
 
66
78
static void rna_GameFloatProperty_value_set(PointerRNA *ptr, float value)
67
79
{
68
 
        bProperty *prop= (bProperty*)(ptr->data);
 
80
        bProperty *prop = (bProperty*)(ptr->data);
69
81
        CLAMP(value, -10000.0f, 10000.0f);
70
 
        *(float*)(&prop->data)= value;
 
82
        *(float*)(&prop->data) = value;
71
83
}
72
84
 
73
85
static void rna_GameProperty_type_set(PointerRNA *ptr, int value)
74
86
{
75
 
        bProperty *prop= (bProperty*)(ptr->data);
 
87
        bProperty *prop = (bProperty*)(ptr->data);
76
88
 
77
 
        if(prop->type != value) {
78
 
                prop->type= value;
 
89
        if (prop->type != value) {
 
90
                prop->type = value;
79
91
                init_property(prop);
80
92
        }
81
93
}
82
94
 
83
95
static void rna_GameProperty_name_set(PointerRNA *ptr, const char *value)
84
96
{
85
 
        bProperty *prop= (bProperty*)(ptr->data);
86
 
        BLI_strncpy(prop->name, value, sizeof(prop->name));
 
97
        bProperty *prop = (bProperty*)(ptr->data);
 
98
        BLI_strncpy_utf8(prop->name, value, sizeof(prop->name));
87
99
        unique_property(NULL, prop, 1);
88
100
}
89
101
 
95
107
        StructRNA *srna;
96
108
        PropertyRNA *prop;
97
109
 
98
 
        static EnumPropertyItem gameproperty_type_items[] ={
99
 
                {GPROP_BOOL, "BOOL", 0, "Boolean", ""},
100
 
                {GPROP_INT, "INT", 0, "Integer", ""},
101
 
                {GPROP_FLOAT, "FLOAT", 0, "Float", ""},
102
 
                {GPROP_STRING, "STRING", 0, "String", ""},
103
 
                {GPROP_TIME, "TIMER", 0, "Timer", ""},
104
 
                {0, NULL, 0, NULL, NULL}};
105
 
 
106
110
        /* Base Struct for GameProperty */
107
 
        srna= RNA_def_struct(brna, "GameProperty", NULL);
 
111
        srna = RNA_def_struct(brna, "GameProperty", NULL);
108
112
        RNA_def_struct_ui_text(srna , "Game Property", "Game engine user defined object property");
109
113
        RNA_def_struct_sdna(srna, "bProperty");
110
114
        RNA_def_struct_refine_func(srna, "rna_GameProperty_refine");
111
115
 
112
 
        prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
 
116
        prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
113
117
        RNA_def_property_ui_text(prop, "Name", "Available as GameObject attributes in the game engine's python API");
114
118
        RNA_def_struct_name_property(srna, prop);
115
119
        RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GameProperty_name_set");
116
120
        RNA_def_property_update(prop, NC_LOGIC, NULL);
117
121
 
118
 
        prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
 
122
        prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
119
123
        RNA_def_property_enum_items(prop, gameproperty_type_items);
120
124
        RNA_def_property_ui_text(prop, "Type", "");
121
125
        RNA_def_property_enum_funcs(prop, NULL, "rna_GameProperty_type_set", NULL);
122
126
        RNA_def_property_update(prop, NC_LOGIC, NULL);
123
127
 
124
 
        prop= RNA_def_property(srna, "debug", PROP_BOOLEAN, PROP_NONE);
 
128
        prop = RNA_def_property(srna, "show_debug", PROP_BOOLEAN, PROP_NONE);
125
129
        RNA_def_property_boolean_sdna(prop, NULL, "flag", PROP_DEBUG);
126
130
        RNA_def_property_ui_text(prop, "Debug", "Print debug information for this property");
127
131
        RNA_def_property_update(prop, NC_LOGIC, NULL);
128
132
 
129
133
        /* GameBooleanProperty */
130
 
        srna= RNA_def_struct(brna, "GameBooleanProperty", "GameProperty");
 
134
        srna = RNA_def_struct(brna, "GameBooleanProperty", "GameProperty");
131
135
        RNA_def_struct_ui_text(srna , "Game Boolean Property", "Game engine user defined Boolean property");
132
136
        RNA_def_struct_sdna(srna, "bProperty");
133
137
        RNA_def_property_update(prop, NC_LOGIC, NULL);
134
138
 
135
 
        prop= RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE);
 
139
        prop = RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE);
136
140
        RNA_def_property_boolean_sdna(prop, NULL, "data", 1);
137
141
        RNA_def_property_ui_text(prop, "Value", "Property value");
138
142
        RNA_def_property_update(prop, NC_LOGIC, NULL);
139
143
 
140
144
        /* GameIntProperty */
141
 
        srna= RNA_def_struct(brna, "GameIntProperty", "GameProperty");
 
145
        srna = RNA_def_struct(brna, "GameIntProperty", "GameProperty");
142
146
        RNA_def_struct_ui_text(srna , "Game Integer Property", "Game engine user defined integer number property");
143
147
        RNA_def_struct_sdna(srna, "bProperty");
144
148
 
145
 
        prop= RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
 
149
        prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
146
150
        RNA_def_property_int_sdna(prop, NULL, "data");
147
151
        RNA_def_property_ui_text(prop, "Value", "Property value");
148
152
        RNA_def_property_range(prop, -10000, 10000);
149
153
        RNA_def_property_update(prop, NC_LOGIC, NULL);
150
154
 
151
155
        /* GameFloatProperty */
152
 
        srna= RNA_def_struct(brna, "GameFloatProperty", "GameProperty");
153
 
        RNA_def_struct_ui_text(srna, "Game Float Property", "Game engine user defined floating pointer number property");
 
156
        srna = RNA_def_struct(brna, "GameFloatProperty", "GameProperty");
 
157
        RNA_def_struct_ui_text(srna, "Game Float Property", "Game engine user defined floating point number property");
154
158
        RNA_def_struct_sdna(srna, "bProperty");
155
159
 
156
 
        prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
157
 
        RNA_def_property_float_sdna(prop, NULL, "data");
 
160
        prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
 
161
        /* RNA_def_property_float_sdna(prop, NULL, "data"); */
158
162
        RNA_def_property_ui_text(prop, "Value", "Property value");
159
163
        RNA_def_property_range(prop, -10000, 10000);
160
164
        RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL);
161
165
        RNA_def_property_update(prop, NC_LOGIC, NULL);
162
166
 
163
167
        /* GameTimerProperty */
164
 
        srna= RNA_def_struct(brna, "GameTimerProperty", "GameProperty");
 
168
        srna = RNA_def_struct(brna, "GameTimerProperty", "GameProperty");
165
169
        RNA_def_struct_ui_text(srna, "Game Timer Property", "Game engine user defined timer property");
166
170
        RNA_def_struct_sdna(srna, "bProperty");
167
171
 
168
 
        prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
169
 
        RNA_def_property_float_sdna(prop, NULL, "data");
 
172
        prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
 
173
        /* RNA_def_property_float_sdna(prop, NULL, "data"); */
170
174
        RNA_def_property_ui_text(prop, "Value", "Property value");
171
175
        RNA_def_property_range(prop, -10000, 10000);
172
176
        RNA_def_property_float_funcs(prop, "rna_GameFloatProperty_value_get", "rna_GameFloatProperty_value_set", NULL);
173
177
        RNA_def_property_update(prop, NC_LOGIC, NULL);
174
178
 
175
179
        /* GameStringProperty */
176
 
        srna= RNA_def_struct(brna, "GameStringProperty", "GameProperty");
 
180
        srna = RNA_def_struct(brna, "GameStringProperty", "GameProperty");
177
181
        RNA_def_struct_ui_text(srna, "Game String Property", "Game engine user defined text string property");
178
182
        RNA_def_struct_sdna(srna, "bProperty");
179
183
 
180
 
        prop= RNA_def_property(srna, "value", PROP_STRING, PROP_NONE);
 
184
        prop = RNA_def_property(srna, "value", PROP_STRING, PROP_NONE);
181
185
        RNA_def_property_string_sdna(prop, NULL, "poin");
182
186
        RNA_def_property_string_maxlength(prop, MAX_PROPSTRING);
183
187
        RNA_def_property_ui_text(prop, "Value", "Property value");