Blender V4.3
rna_vfont.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cstdlib>
10
11#include "RNA_define.hh"
12
13#include "rna_internal.hh"
14
15#include "DNA_vfont_types.h"
16
17#include "WM_types.hh"
18
19#ifdef RNA_RUNTIME
20
21# include "BKE_vfont.hh"
22# include "DNA_object_types.h"
23
24# include "DEG_depsgraph.hh"
25
26# include "WM_api.hh"
27
28/* Matching function in rna_ID.cc */
29static int rna_VectorFont_filepath_editable(const PointerRNA *ptr, const char ** /*r_info*/)
30{
31 VFont *vfont = (VFont *)ptr->owner_id;
32 if (BKE_vfont_is_builtin(vfont)) {
33 return 0;
34 }
35 return PROP_EDITABLE;
36}
37
38static void rna_VectorFont_reload_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
39{
40 VFont *vf = (VFont *)ptr->owner_id;
42
43 /* update */
46}
47
48#else
49
51{
52 StructRNA *srna;
53 PropertyRNA *prop;
54
55 srna = RNA_def_struct(brna, "VectorFont", "ID");
56 RNA_def_struct_ui_text(srna, "Vector Font", "Vector font for Text objects");
57 RNA_def_struct_sdna(srna, "VFont");
58 RNA_def_struct_ui_icon(srna, ICON_FILE_FONT);
59
60 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
61 RNA_def_property_string_sdna(prop, nullptr, "filepath");
62 RNA_def_property_editable_func(prop, "rna_VectorFont_filepath_editable");
63 RNA_def_property_ui_text(prop, "File Path", "");
64 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_VectorFont_reload_update");
65
66 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
67 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
68 RNA_def_property_ui_text(prop, "Packed File", "");
69
70 RNA_api_vfont(srna);
71}
72
73#endif
bool BKE_vfont_is_builtin(const VFont *vfont)
Definition vfont.cc:232
void BKE_vfont_free_data(VFont *vfont)
Definition vfont.cc:200
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1021
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1041
Object is a sort of wrapper for general info.
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_FILEPATH
Definition RNA_types.hh:139
#define NC_GEOM
Definition WM_types.hh:360
#define ND_DATA
Definition WM_types.hh:475
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_api_vfont(StructRNA *srna)
void RNA_def_vfont(BlenderRNA *brna)
Definition rna_vfont.cc:50
ID * owner_id
Definition RNA_types.hh:40
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126