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:
authorCampbell Barton <ideasman42@gmail.com>2018-08-02 09:24:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-08-02 11:18:53 +0300
commitd79df6c0bc65e4c94a6fd24160445b98eb408949 (patch)
tree7ca1136c24672462c1c24a85dbc8877da4dca08d /source/blender/makesrna/intern/rna_workspace_api.c
parentd3c387d605470838e8f8349fa37c4b123e3e0471 (diff)
Tool System: sync changes from changes to brushes
Changing a brush now updates the tool.
Diffstat (limited to 'source/blender/makesrna/intern/rna_workspace_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_workspace_api.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c
index 98e84f60b33..4469b88da6d 100644
--- a/source/blender/makesrna/intern/rna_workspace_api.c
+++ b/source/blender/makesrna/intern/rna_workspace_api.c
@@ -41,6 +41,8 @@
#ifdef RNA_RUNTIME
+#include "BKE_paint.h"
+
#include "ED_screen.h"
static void rna_WorkspaceTool_setup(
@@ -68,6 +70,34 @@ static void rna_WorkspaceTool_setup(
WM_toolsystem_ref_set_from_runtime(C, (WorkSpace *)id, tref, &tref_rt, name);
}
+static void rna_WorkspaceTool_refresh_from_context(
+ ID *id,
+ bToolRef *tref,
+ Main *bmain)
+{
+ bToolRef_Runtime *tref_rt = tref->runtime;
+ if ((tref_rt == NULL) || (tref_rt->data_block[0] == '\0')) {
+ return;
+ }
+ wmWindowManager *wm = bmain->wm.first;
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ WorkSpace *workspace = WM_window_get_active_workspace(win);
+ if (&workspace->id == id) {
+ Scene *scene = WM_window_get_active_scene(win);
+ ViewLayer *view_layer = WM_window_get_active_view_layer(win);
+ Paint *paint = BKE_paint_get_active(scene, view_layer);
+ if (paint) {
+ const ID *brush = (ID *)paint->brush;
+ if (!STREQ(tref_rt->data_block, brush->name + 2)) {
+ STRNCPY(tref_rt->data_block, brush->name + 2);
+ STRNCPY(tref->idname, brush->name + 2);
+ printf("Found\n");
+ }
+ }
+ }
+ }
+}
+
static PointerRNA rna_WorkspaceTool_operator_properties(
bToolRef *tref,
const char *idname)
@@ -124,6 +154,8 @@ void RNA_api_workspace_tool(StructRNA *srna)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
RNA_def_function_return(func, parm);
+ func = RNA_def_function(srna, "refresh_from_context", "rna_WorkspaceTool_refresh_from_context");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
}
#endif