Blender  V2.93
rna_vfont.c
Go to the documentation of this file.
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 
21 #include <stdlib.h>
22 
23 #include "RNA_define.h"
24 
25 #include "rna_internal.h"
26 
27 #include "DNA_vfont_types.h"
28 
29 #include "WM_types.h"
30 
31 #ifdef RNA_RUNTIME
32 
33 # include "BKE_font.h"
34 # include "DNA_object_types.h"
35 
36 # include "DEG_depsgraph.h"
37 
38 # include "WM_api.h"
39 
40 /* Matching function in rna_ID.c */
41 static int rna_VectorFont_filepath_editable(PointerRNA *ptr, const char **UNUSED(r_info))
42 {
43  VFont *vfont = (VFont *)ptr->owner_id;
44  if (BKE_vfont_is_builtin(vfont)) {
45  return 0;
46  }
47  return PROP_EDITABLE;
48 }
49 
50 static void rna_VectorFont_reload_update(Main *UNUSED(bmain),
51  Scene *UNUSED(scene),
52  PointerRNA *ptr)
53 {
54  VFont *vf = (VFont *)ptr->owner_id;
56 
57  /* update */
60 }
61 
62 #else
63 
65 {
66  StructRNA *srna;
67  PropertyRNA *prop;
68 
69  srna = RNA_def_struct(brna, "VectorFont", "ID");
70  RNA_def_struct_ui_text(srna, "Vector Font", "Vector font for Text objects");
71  RNA_def_struct_sdna(srna, "VFont");
72  RNA_def_struct_ui_icon(srna, ICON_FILE_FONT);
73 
74  prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
75  RNA_def_property_string_sdna(prop, NULL, "filepath");
76  RNA_def_property_editable_func(prop, "rna_VectorFont_filepath_editable");
77  RNA_def_property_ui_text(prop, "File Path", "");
78  RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_VectorFont_reload_update");
79 
80  prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
81  RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
82  RNA_def_property_ui_text(prop, "Packed File", "");
83 
84  RNA_api_vfont(srna);
85 }
86 
87 #endif
bool BKE_vfont_is_builtin(struct VFont *vfont)
Definition: font.c:222
void BKE_vfont_free_data(struct VFont *vfont)
Definition: font.c:187
#define UNUSED(x)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:599
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:611
Object is a sort of wrapper for general info.
@ PROP_STRING
Definition: RNA_types.h:76
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_EDITABLE
Definition: RNA_types.h:175
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_FILEPATH
Definition: RNA_types.h:116
#define NC_GEOM
Definition: WM_types.h:294
#define ND_DATA
Definition: WM_types.h:408
Scene scene
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2762
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2717
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1067
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2927
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
Definition: rna_define.c:2877
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1267
void RNA_api_vfont(struct StructRNA *srna)
Definition: rna_vfont_api.c:54
void RNA_def_vfont(BlenderRNA *brna)
Definition: rna_vfont.c:64
Definition: BKE_main.h:116
struct ID * owner_id
Definition: RNA_types.h:50
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3157