diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-16 19:41:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-17 16:57:33 +0300 |
commit | edf6676a77b30290918e60547544bc1a6f7a8838 (patch) | |
tree | 26012f315c75686553e6be87b73ad270b98eb01a /source/blender/makesrna/intern/rna_workspace_api.c | |
parent | 20cc14e2b7551bb043472174b8be79d8aaa4df3d (diff) |
Tool System: per space/mode tool support
This patch adds support for:
- Per space-type tools (3D view and edit).
- Per mode tools (object, edit, weight-paint .. etc).
The top-bar shows the last activated tools options, this is a design
issue with using a global topbar to show per-space settings.
See D3395
Diffstat (limited to 'source/blender/makesrna/intern/rna_workspace_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_workspace_api.c | 90 |
1 files changed, 90 insertions, 0 deletions
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 |