Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/CMakeLists.txt1
-rw-r--r--source/blender/makesrna/intern/makesrna.c6
-rw-r--r--source/blender/makesrna/intern/rna_internal.h2
-rw-r--r--source/blender/makesrna/intern/rna_space.c18
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c132
-rw-r--r--source/blender/makesrna/intern/rna_workspace_api.c90
6 files changed, 216 insertions, 33 deletions
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt
index 7bd5ad2b959..c62e8ed4da8 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -122,6 +122,7 @@ set(APISRC
rna_vfont_api.c
rna_wm_api.c
rna_wm_manipulator_api.c
+ rna_workspace_api.c
)
string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}")
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 0b2efe27059..4daf8b6a965 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -2831,6 +2831,10 @@ static void rna_generate_struct_prototypes(FILE *f)
if (dp->prop->type == PROP_POINTER) {
int a, found = 0;
const char *struct_name = rna_parameter_type_name(dp->prop);
+ if (struct_name == NULL) {
+ printf("No struct found for property '%s'\n", dp->prop->identifier);
+ exit(1);
+ }
for (a = 0; a < all_structures; a++) {
if (STREQ(struct_name, structures[a])) {
@@ -3404,7 +3408,7 @@ static RNAProcessItem PROCESS_ITEMS[] = {
{"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont},
{"rna_wm.c", "rna_wm_api.c", RNA_def_wm},
{"rna_wm_manipulator.c", "rna_wm_manipulator_api.c", RNA_def_wm_manipulator},
- {"rna_workspace.c", NULL, RNA_def_workspace},
+ {"rna_workspace.c", "rna_workspace_api.c", RNA_def_workspace},
{"rna_world.c", NULL, RNA_def_world},
{"rna_movieclip.c", NULL, RNA_def_movieclip},
{"rna_tracking.c", NULL, RNA_def_tracking},
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 11ad39a2dd1..ce16cb69bbd 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -342,6 +342,8 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_api_sequence_elements(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_api_sound(struct StructRNA *srna);
void RNA_api_vfont(struct StructRNA *srna);
+void RNA_api_workspace(struct StructRNA *srna);
+void RNA_api_workspace_tool(struct StructRNA *srna);
/* main collection functions */
void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 12bb4dd0617..3ce799dfb88 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -103,6 +103,15 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
+
+const EnumPropertyItem rna_enum_space_image_mode_items[] = {
+ {SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image and UV edit in mesh editmode"},
+ {SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"},
+ {SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"},
+ {0, NULL, 0, NULL, NULL}
+};
+
+
#define V3D_S3D_CAMERA_LEFT {STEREO_LEFT_ID, "LEFT", ICON_RESTRICT_RENDER_OFF, "Left", ""},
#define V3D_S3D_CAMERA_RIGHT {STEREO_RIGHT_ID, "RIGHT", ICON_RESTRICT_RENDER_OFF, "Right", ""},
#define V3D_S3D_CAMERA_S3D {STEREO_3D_ID, "S3D", ICON_CAMERA_STEREO, "3D", ""},
@@ -2950,13 +2959,6 @@ static void rna_def_space_buttons(BlenderRNA *brna)
static void rna_def_space_image(BlenderRNA *brna)
{
- static const EnumPropertyItem image_space_mode_items[] = {
- {SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image and UV edit in mesh editmode"},
- {SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"},
- {SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"},
- {0, NULL, 0, NULL, NULL}
- };
-
StructRNA *srna;
PropertyRNA *prop;
@@ -3037,7 +3039,7 @@ static void rna_def_space_image(BlenderRNA *brna)
/* mode */
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mode");
- RNA_def_property_enum_items(prop, image_space_mode_items);
+ RNA_def_property_enum_items(prop, rna_enum_space_image_mode_items);
RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_mode_update");
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index b82ca145f5f..485cb298dae 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -49,6 +49,7 @@
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
#include "RNA_access.h"
@@ -107,6 +108,42 @@ static void rna_WorkSpace_owner_ids_clear(
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, workspace);
}
+static bToolRef *rna_WorkSpace_tools_from_tkey(WorkSpace *workspace, const bToolKey *tkey, bool create)
+{
+ if (create) {
+ bToolRef *tref;
+ WM_toolsystem_ref_ensure(workspace, tkey, &tref);
+ return tref;
+ }
+ return WM_toolsystem_ref_find(workspace, tkey);
+}
+
+static bToolRef *rna_WorkSpace_tools_from_space_view3d_mode(
+ WorkSpace *workspace, int mode, int create)
+{
+ return rna_WorkSpace_tools_from_tkey(workspace, &(bToolKey){ .space_type = SPACE_VIEW3D, .mode = mode}, create);
+}
+
+static bToolRef *rna_WorkSpace_tools_from_space_image_mode(
+ WorkSpace *workspace, int mode, int create)
+{
+ return rna_WorkSpace_tools_from_tkey(workspace, &(bToolKey){ .space_type = SPACE_IMAGE, .mode = mode}, create);
+}
+
+const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
+{
+ WorkSpace *workspace = ptr->id.data;
+
+ switch (workspace->tools_space_type) {
+ case SPACE_VIEW3D:
+ return rna_enum_object_mode_items;
+ case SPACE_IMAGE:
+ return rna_enum_space_image_mode_items;
+ }
+ return DummyRNA_NULL_items;
+}
+
#else /* RNA_RUNTIME */
static void rna_def_workspace_owner(BlenderRNA *brna)
@@ -159,6 +196,56 @@ static void rna_def_workspace_owner_ids(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove all tags");
}
+static void rna_def_workspace_tool(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "WorkspaceTool", NULL);
+ RNA_def_struct_sdna(srna, "bToolRef");
+ RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
+ RNA_def_struct_ui_text(srna, "Work Space Tool", "");
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "idname");
+ RNA_def_property_ui_text(prop, "Name", "");
+ RNA_def_struct_name_property(srna, prop);
+
+ RNA_api_workspace_tool(srna);
+}
+
+static void rna_def_workspace_tools(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "wmTools");
+ srna = RNA_def_struct(brna, "wmTools", NULL);
+ RNA_def_struct_sdna(srna, "WorkSpace");
+ RNA_def_struct_ui_text(srna, "WorkSpace UI Tags", "");
+
+ /* add owner_id */
+ func = RNA_def_function(srna, "from_space_view3d_mode", "rna_WorkSpace_tools_from_space_view3d_mode");
+ RNA_def_function_ui_description(func, "");
+ parm = RNA_def_enum(func, "mode", rna_enum_object_mode_items, 0, "", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_boolean(func, "create", false, "Create", "");
+ /* return type */
+ parm = RNA_def_pointer(func, "result", "WorkspaceTool", "", "");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "from_space_image_mode", "rna_WorkSpace_tools_from_space_image_mode");
+ RNA_def_function_ui_description(func, "");
+ parm = RNA_def_enum(func, "mode", rna_enum_space_image_mode_items, 0, "", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_boolean(func, "create", false, "Create", "");
+ /* return type */
+ parm = RNA_def_pointer(func, "result", "WorkspaceTool", "", "");
+ RNA_def_function_return(func, parm);
+}
+
static void rna_def_workspace(BlenderRNA *brna)
{
StructRNA *srna;
@@ -177,36 +264,29 @@ static void rna_def_workspace(BlenderRNA *brna)
"rna_workspace_screens_item_get", NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Screens", "Screen layouts of a workspace");
- prop = RNA_def_property(srna, "tool_keymap", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "tool.keymap");
- RNA_def_property_ui_text(prop, "Active Tool", "Currently active tool keymap");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "tool_manipulator_group", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "tool.manipulator_group");
- RNA_def_property_ui_text(prop, "Active Tool", "Currently active tool manipulator");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-
- prop = RNA_def_property(srna, "tool_data_block", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "tool.data_block");
- RNA_def_property_ui_text(prop, "Active Tool", "Currently active data-block");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ prop = RNA_def_property(srna, "owner_ids", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "wmOwnerID");
+ RNA_def_property_ui_text(prop, "UI Tags", "");
+ rna_def_workspace_owner_ids(brna, prop);
- prop = RNA_def_property(srna, "tool_index", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "tool.index");
- RNA_def_property_ui_text(prop, "Active Tool Index", "Tool group index");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ prop = RNA_def_property(srna, "tools", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "tools", NULL);
+ RNA_def_property_struct_type(prop, "WorkspaceTool");
+ RNA_def_property_ui_text(prop, "Tools", "");
+ rna_def_workspace_tools(brna, prop);
- prop = RNA_def_property(srna, "tool_space_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "tool.spacetype");
+ prop = RNA_def_property(srna, "tools_space_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "tools_space_type");
RNA_def_property_enum_items(prop, rna_enum_space_type_items);
RNA_def_property_ui_text(prop, "Active Tool Space", "Tool space type");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- prop = RNA_def_property(srna, "owner_ids", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_type(prop, "wmOwnerID");
- RNA_def_property_ui_text(prop, "UI Tags", "");
- rna_def_workspace_owner_ids(brna, prop);
+ prop = RNA_def_property(srna, "tools_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "tools_mode");
+ RNA_def_property_enum_items(prop, rna_enum_object_mode_items); /* value is placeholder, itemf is used. */
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_WorkSpace_tools_mode_itemf");
+ RNA_def_property_ui_text(prop, "Active Tool Space", "Tool mode");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
#if 0
prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE);
@@ -221,11 +301,15 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Use UI Tags",
"Filter the UI by tags");
RNA_def_property_update(prop, 0, "rna_window_update_all");
+
+ RNA_api_workspace(srna);
}
void RNA_def_workspace(BlenderRNA *brna)
{
rna_def_workspace_owner(brna);
+ rna_def_workspace_tool(brna);
+
rna_def_workspace(brna);
}
diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c
new file mode 100644
index 00000000000..4b0e2b5918e
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_workspace_api.c
@@ -0,0 +1,90 @@
+/*
+ * ***** 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_workspace_api.c
+ * \ingroup RNA
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include "BLI_utildefines.h"
+
+#include "RNA_define.h"
+
+#include "DNA_object_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "rna_internal.h" /* own include */
+
+#ifdef RNA_RUNTIME
+
+static void rna_WorkspaceTool_setup(
+ ID *id,
+ bToolRef *tref,
+ bContext *C,
+ const char *name,
+ /* Args for: 'bToolRef_Runtime'. */
+ const char *keymap,
+ const char *manipulator_group,
+ const char *data_block,
+ int index)
+{
+ bToolRef_Runtime tref_rt = {0};
+
+ STRNCPY(tref_rt.keymap, keymap);
+ STRNCPY(tref_rt.manipulator_group, manipulator_group);
+ STRNCPY(tref_rt.data_block, data_block);
+ tref_rt.index = index;
+
+ WM_toolsystem_ref_set_from_runtime(C, (WorkSpace *)id, tref, &tref_rt, name);
+}
+
+#else
+
+void RNA_api_workspace(StructRNA *UNUSED(srna))
+{
+ /* FunctionRNA *func; */
+ /* PropertyRNA *parm; */
+}
+
+void RNA_api_workspace_tool(StructRNA *srna)
+{
+ PropertyRNA *parm;
+ FunctionRNA *func;
+
+ func = RNA_def_function(srna, "setup", "rna_WorkspaceTool_setup");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_CONTEXT);
+ RNA_def_function_ui_description(func, "Set the tool settings");
+
+ parm = RNA_def_string(func, "name", NULL, KMAP_MAX_NAME, "Name", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+
+ /* 'bToolRef_Runtime' */
+ RNA_def_string(func, "keymap", NULL, KMAP_MAX_NAME, "Key Map", "");
+ RNA_def_string(func, "manipulator_group", NULL, MAX_NAME, "Manipulator Group", "");
+ RNA_def_string(func, "data_block", NULL, MAX_NAME, "Data Block", "");
+ RNA_def_int(func, "index", 0, INT_MIN, INT_MAX, "Index", "", INT_MIN, INT_MAX);
+}
+
+#endif