diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-06-21 06:54:46 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-06-21 07:10:14 +0300 |
commit | b7669ac1c672a92f31735ae9f92b369f9ba30eb1 (patch) | |
tree | 1747e45bcc61cd4c2fc02dd3f006f49b4a18ca2b /source/blender/makesrna | |
parent | 5b51dcacbc81df6283518317c274bf897010e967 (diff) |
Manipulators: move settings to ID properties
This makes manipulator access closer to operators,
and allows Python access.
This adds RNA for manipulators, but not Python registration yet.
- Split draw style into 2x settings:
`draw_style` (enum) & `draw_options` (enum-flag)
- Rename wmManipulator.properties -> properties_edit,
Use wmManipulator.properties for ID-properties.
Note that this area of the API will need further work since
manipulators now have 2 kinds of properties & API's to access them.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_manipulator.c | 231 |
5 files changed, 238 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 591f53ad0ab..d1a76d8b216 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -376,6 +376,8 @@ extern StructRNA RNA_LineStyleThicknessModifier_Tangent; extern StructRNA RNA_LockedTrackConstraint; extern StructRNA RNA_Macro; extern StructRNA RNA_MagicTexture; +extern StructRNA RNA_Manipulator; +extern StructRNA RNA_ManipulatorProperties; extern StructRNA RNA_MarbleTexture; extern StructRNA RNA_MaskModifier; extern StructRNA RNA_MaskSequence; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index c602521f0db..d57fbbbd764 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -95,6 +95,7 @@ set(DEFSRC rna_userdef.c rna_vfont.c rna_wm.c + rna_wm_manipulator.c rna_workspace.c rna_world.c ) diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index f501f6cbf7e..20b3daeb79d 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3365,6 +3365,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_userdef.c", NULL, RNA_def_userdef}, {"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont}, {"rna_wm.c", "rna_wm_api.c", RNA_def_wm}, + {"rna_wm_manipulator.c", NULL, RNA_def_wm_manipulator}, {"rna_workspace.c", NULL, RNA_def_workspace}, {"rna_world.c", NULL, RNA_def_world}, {"rna_movieclip.c", NULL, RNA_def_movieclip}, diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index e7636d492c4..7b8073d80b8 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -187,6 +187,7 @@ void RNA_def_ui(struct BlenderRNA *brna); void RNA_def_userdef(struct BlenderRNA *brna); void RNA_def_vfont(struct BlenderRNA *brna); void RNA_def_wm(struct BlenderRNA *brna); +void RNA_def_wm_manipulator(struct BlenderRNA *brna); void RNA_def_workspace(struct BlenderRNA *brna); void RNA_def_world(struct BlenderRNA *brna); void RNA_def_movieclip(struct BlenderRNA *brna); @@ -269,6 +270,8 @@ void RNA_api_image(struct StructRNA *srna); void RNA_api_lattice(struct StructRNA *srna); void RNA_api_operator(struct StructRNA *srna); void RNA_api_macro(struct StructRNA *srna); +void RNA_api_manipulator(struct StructRNA *srna); +void RNA_api_manipulatorgroup(struct StructRNA *srna); void RNA_api_keyconfig(struct StructRNA *srna); void RNA_api_keyconfigs(struct StructRNA *srna); void RNA_api_keyingset(struct StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c new file mode 100644 index 00000000000..06e31688a8a --- /dev/null +++ b/source/blender/makesrna/intern/rna_wm_manipulator.c @@ -0,0 +1,231 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_wm_manipulator.c + * \ingroup RNA + */ + +#include <stdlib.h> + +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "DNA_userdef_types.h" +#include "DNA_view3d_types.h" +#include "DNA_windowmanager_types.h" + +#include "BLI_utildefines.h" + +#include "BLT_translation.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "rna_internal.h" + +#include "WM_api.h" +#include "WM_types.h" + +#ifdef RNA_RUNTIME +/* enum definitions */ +#endif /* RNA_RUNTIME */ + +#ifdef RNA_RUNTIME + +#include <assert.h> + +#include "WM_api.h" +#include "WM_types.h" + +#include "DNA_workspace_types.h" + +#include "ED_screen.h" + +#include "UI_interface.h" + +#include "BKE_global.h" +#include "BKE_idprop.h" +#include "BKE_workspace.h" + +#include "MEM_guardedalloc.h" + +#ifdef WITH_PYTHON +# include "BPY_extern.h" +#endif + +/* -------------------------------------------------------------------- */ + +/** \name Manipulator API + * \{ */ + +static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr) +{ +#if 0 + wmWindowManager *wm = ptr->id.data; +#endif + + /* We could try workaruond this lookup, but not trivial. */ + for (bScreen *screen = G.main->screen.first; screen; screen = screen->id.next) { + IDProperty *properties = (IDProperty *)ptr->data; + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->manipulator_map) { + wmManipulatorMap *mmap = ar->manipulator_map; + for (wmManipulatorGroup *mgroup = WM_manipulatormap_group_list(mmap)->first; + mgroup; + mgroup = mgroup->next) + { + for (wmManipulator *mpr = mgroup->manipulators.first; mpr; mpr = mpr->next) { + if (mpr->properties == properties) { + return mpr; + } + } + } + } + } + } + } + return NULL; +} + +static StructRNA *rna_ManipulatorProperties_refine(PointerRNA *ptr) +{ + wmManipulator *mpr = rna_ManipulatorProperties_find_operator(ptr); + + if (mpr) + return mpr->type->srna; + else + return ptr->type; +} + +static IDProperty *rna_ManipulatorProperties_idprops(PointerRNA *ptr, bool create) +{ + if (create && !ptr->data) { + IDPropertyTemplate val = {0}; + ptr->data = IDP_New(IDP_GROUP, &val, "RNA_ManipulatorProperties group"); + } + + return ptr->data; +} + +static PointerRNA rna_Manipulator_properties_get(PointerRNA *ptr) +{ + wmManipulator *mpr = (wmManipulator *)ptr->data; + return rna_pointer_inherit_refine(ptr, mpr->type->srna, mpr->properties); +} + +static StructRNA *rna_Manipulator_refine(PointerRNA *mnp_ptr) +{ + wmManipulator *mpr = mnp_ptr->data; + return (mpr->type && mpr->type->ext.srna) ? mpr->type->ext.srna : &RNA_Manipulator; +} + +/** \} */ + +/** \name Manipulator Group API + * \{ */ + +static StructRNA *rna_ManipulatorGroup_refine(PointerRNA *mgroup_ptr) +{ + wmManipulatorGroup *mgroup = mgroup_ptr->data; + return (mgroup->type && mgroup->type->ext.srna) ? mgroup->type->ext.srna : &RNA_ManipulatorGroup; +} + +static void rna_ManipulatorGroup_manipulators_begin(CollectionPropertyIterator *iter, PointerRNA *mgroup_ptr) +{ + wmManipulatorGroup *mgroup = mgroup_ptr->data; + rna_iterator_listbase_begin(iter, &mgroup->manipulators, NULL); +} + +/** \} */ + + +#else /* RNA_RUNTIME */ + + +/* ManipulatorGroup.manipulators */ +static void rna_def_manipulators(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + RNA_def_property_srna(cprop, "Manipulators"); + srna = RNA_def_struct(brna, "Manipulators", NULL); + RNA_def_struct_sdna(srna, "wmManipulatorGroup"); + RNA_def_struct_ui_text(srna, "Manipulators", "Collection of manipulators"); +} + + +static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "Manipulator"); + srna = RNA_def_struct(brna, "Manipulator", NULL); + RNA_def_struct_sdna(srna, "wmManipulator"); + RNA_def_struct_ui_text(srna, "Manipulator", "Collection of manipulators"); + RNA_def_struct_refine_func(srna, "rna_Manipulator_refine"); + + prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "ManipulatorProperties"); + RNA_def_property_ui_text(prop, "Properties", ""); + RNA_def_property_pointer_funcs(prop, "rna_Manipulator_properties_get", NULL, NULL, NULL); + + srna = RNA_def_struct(brna, "ManipulatorProperties", NULL); + RNA_def_struct_ui_text(srna, "Manipulator Properties", "Input properties of an Manipulator"); + RNA_def_struct_refine_func(srna, "rna_ManipulatorProperties_refine"); + RNA_def_struct_idprops_func(srna, "rna_ManipulatorProperties_idprops"); + RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES); +} + +static void rna_def_manipulatorgroup(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ManipulatorGroup", NULL); + RNA_def_struct_ui_text(srna, "ManipulatorGroup", "Storage of an operator being executed, or registered after execution"); + RNA_def_struct_sdna(srna, "wmManipulatorGroup"); + RNA_def_struct_refine_func(srna, "rna_ManipulatorGroup_refine"); + + RNA_define_verify_sdna(0); /* not in sdna */ + + prop = RNA_def_property(srna, "manipulators", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "manipulators", NULL); + RNA_def_property_struct_type(prop, "Manipulator"); + RNA_def_property_collection_funcs( + prop, "rna_ManipulatorGroup_manipulators_begin", "rna_iterator_listbase_next", + "rna_iterator_listbase_end", "rna_iterator_listbase_get", + NULL, NULL, NULL, NULL); + + RNA_def_property_ui_text(prop, "Manipulators", "List of manipulators in the Manipulator Map"); + rna_def_manipulator(brna, prop); + rna_def_manipulators(brna, prop); + + RNA_define_verify_sdna(1); /* not in sdna */ +} + +void RNA_def_wm_manipulator(BlenderRNA *brna) +{ + rna_def_manipulatorgroup(brna); +} + +#endif /* RNA_RUNTIME */ |