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-10-05 06:07:01 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-10-05 06:13:30 +0300
commit143ece7199c20b231077273e4c16c7edd0bc4940 (patch)
tree046795b2e46defc6668fa1119a67716a537310a1
parentc15439bcdc52f90570dd22fc0f61b94bdf56145d (diff)
Tool System: initial support for UV-sculpt
This currently conflicts with the UV-sculpt toggle being manually set, ideally this would work more like other paint modes in Blender.
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py27
-rw-r--r--source/blender/makesrna/intern/rna_workspace_api.c17
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c51
3 files changed, 94 insertions, 1 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index b7dc8335a7b..01e9ac33491 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1190,6 +1190,15 @@ class _defs_weight_paint:
class _defs_image_generic:
+ @staticmethod
+ def poll_uvedit(context):
+ ob = context.edit_object
+ if ob is not None:
+ data = ob.data
+ if data is not None:
+ return bool(getattr(data, "uv_layers", False))
+ return False
+
@ToolDef.from_fn
def cursor():
return dict(
@@ -1282,6 +1291,18 @@ class _defs_image_uv_select:
)
+class _defs_image_uv_sculpt:
+
+ @staticmethod
+ def generate_from_brushes(context):
+ return generate_from_enum_ex(
+ context,
+ icon_prefix="brush.uv_sculpt.",
+ data=context.tool_settings,
+ attr="uv_sculpt_tool",
+ )
+
+
class _defs_gpencil_paint:
@staticmethod
def draw_color_selector(context, layout):
@@ -1772,6 +1793,12 @@ class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
*_tools_transform,
None,
*_tools_annotate,
+ None,
+ lambda context: (
+ _defs_image_uv_sculpt.generate_from_brushes(context)
+ if _defs_image_generic.poll_uvedit(context)
+ else ()
+ ),
],
'MASK': [
None,
diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c
index 898dc296299..fb237299dd0 100644
--- a/source/blender/makesrna/intern/rna_workspace_api.c
+++ b/source/blender/makesrna/intern/rna_workspace_api.c
@@ -90,7 +90,10 @@ static void rna_WorkspaceTool_refresh_from_context(
if (ob == NULL) {
/* pass */
}
- else if (ob->mode & OB_MODE_PARTICLE_EDIT) {
+ else if ((tref->space_type == SPACE_VIEW3D) &&
+ (tref->mode == CTX_MODE_PARTICLE) &&
+ (ob->mode & OB_MODE_PARTICLE_EDIT))
+ {
const EnumPropertyItem *items = rna_enum_particle_edit_hair_brush_items;
const int i = RNA_enum_from_value(items, ts->particle.brushtype);
const EnumPropertyItem *item = &items[i];
@@ -99,6 +102,18 @@ static void rna_WorkspaceTool_refresh_from_context(
STRNCPY(tref->idname, item->name);
}
}
+ else if ((tref->space_type == SPACE_IMAGE) &&
+ (tref->mode == SI_MODE_VIEW) &&
+ (ob->mode & OB_MODE_EDIT))
+ {
+ const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items;
+ const int i = RNA_enum_from_value(items, ts->uv_sculpt_tool);
+ const EnumPropertyItem *item = &items[i];
+ if (!STREQ(tref_rt->data_block, item->identifier)) {
+ STRNCPY(tref_rt->data_block, item->identifier);
+ STRNCPY(tref->idname, item->name);
+ }
+ }
else {
Paint *paint = BKE_paint_get_active(scene, view_layer);
if (paint) {
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index 3a112ac0597..5584fada329 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -169,6 +169,14 @@ void WM_toolsystem_unlink(bContext *C, WorkSpace *workspace, const bToolKey *tke
}
}
+static void toolsystem_ref_link__refresh_image_uv_sculpt(bContext *C, Scene *scene)
+{
+ PointerRNA ptr;
+ RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &ptr);
+ PropertyRNA *prop = RNA_struct_find_property(&ptr, "use_uv_sculpt");
+ RNA_property_update(C, &ptr, prop);
+}
+
static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tref)
{
bToolRef_Runtime *tref_rt = tref->runtime;
@@ -205,6 +213,30 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
}
}
}
+ if ((tref->space_type == SPACE_IMAGE) &&
+ (tref->mode == SI_MODE_VIEW))
+ {
+ /* Note that switching uv-sculpt boolean is a hack at the moment.
+ * It would be best to make this either an operator or a higher level mode (like mesh-object sculpt mode). */
+ const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items;
+ const int i = RNA_enum_from_identifier(items, tref_rt->data_block);
+ if (i != -1) {
+ const int value = items[i].value;
+ wmWindowManager *wm = bmain->wm.first;
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ if (workspace == WM_window_get_active_workspace(win)) {
+ Scene *scene = WM_window_get_active_scene(win);
+ ToolSettings *ts = scene->toolsettings;
+ ts->uv_sculpt_tool = value;
+
+ if (ts->use_uv_sculpt == false) {
+ ts->use_uv_sculpt = true;
+ toolsystem_ref_link__refresh_image_uv_sculpt(C, scene);
+ }
+ }
+ }
+ }
+ }
else {
struct Brush *brush = (struct Brush *)BKE_libblock_find_name(bmain, ID_BR, tref_rt->data_block);
if (brush) {
@@ -224,6 +256,25 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
}
}
}
+ else {
+ /* XXX, this part is weak, disables uv_sculpt when non uv-tool set. */
+ if ((tref->space_type == SPACE_IMAGE) &&
+ (tref->mode == SI_MODE_VIEW))
+ {
+ Main *bmain = CTX_data_main(C);
+ wmWindowManager *wm = bmain->wm.first;
+ for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ if (workspace == WM_window_get_active_workspace(win)) {
+ Scene *scene = WM_window_get_active_scene(win);
+ ToolSettings *ts = scene->toolsettings;
+ if (ts->use_uv_sculpt == true) {
+ ts->use_uv_sculpt = false;
+ toolsystem_ref_link__refresh_image_uv_sculpt(C, scene);
+ }
+ }
+ }
+ }
+ }
}
static void toolsystem_refresh_ref(bContext *C, WorkSpace *workspace, bToolRef *tref)