[Bf-blender-cvs] [b69301d4aa1] blender2.8: Context: add uv_sculpt_object
Campbell Barton
noreply at git.blender.org
Fri Oct 5 09:13:18 CEST 2018
Commit: b69301d4aa1bec6de596042d48df2846723c7445
Author: Campbell Barton
Date: Fri Oct 5 17:10:27 2018 +1000
Branches: blender2.8
https://developer.blender.org/rBb69301d4aa1bec6de596042d48df2846723c7445
Context: add uv_sculpt_object
While this may be temporary, it avoids copy-pasting these
checks in Python code.
===================================================================
M release/scripts/startup/bl_ui/space_image.py
M release/scripts/startup/bl_ui/space_topbar.py
M source/blender/editors/screen/screen_context.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 22f85ad37ae..436cf4e4cad 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -1167,7 +1167,7 @@ class IMAGE_PT_uv_sculpt_curve(Panel):
@classmethod
def poll(cls, context):
- return IMAGE_PT_uv_sculpt.poll(context)
+ return (context.uv_sculpt_object is not None)
def draw(self, context):
layout = self.layout
@@ -1196,16 +1196,7 @@ class IMAGE_PT_uv_sculpt(Panel):
@classmethod
def poll(cls, context):
- tool_settings = context.tool_settings
- if tool_settings.use_uv_sculpt:
- if context.mode == 'EDIT_MESH':
- workspace = context.workspace
- space_type = workspace.tools_space_type
- if space_type == 'IMAGE_EDITOR':
- mode = workspace.tools_mode
- if mode == 'VIEW':
- return True
- return False
+ return (context.uv_sculpt_object is not None)
def draw(self, context):
from .properties_paint_common import UnifiedPaintPanel
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 2712d09c272..76fcb2b4cdb 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -163,12 +163,8 @@ class TOPBAR_HT_lower_bar(Header):
elif tool_mode == 'GPENCIL_WEIGHT':
layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".greasepencil_weight", category="")
elif tool_space_type == 'IMAGE_EDITOR':
- if tool_mode == 'VIEW':
- mode = context.mode
- if mode == 'EDIT_MESH':
- tool_settings = context.tool_settings
- if tool_settings.use_uv_sculpt:
- layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".uv_sculpt", category="")
+ if context.uv_sculpt_object is not None:
+ layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".uv_sculpt", category="")
def draw_center(self, context):
pass
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 44dfb9bb0a6..a87184120ca 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -65,6 +65,7 @@
#include "ED_armature.h"
#include "ED_gpencil.h"
#include "ED_anim_api.h"
+#include "ED_uvedit.h"
#include "WM_api.h"
#include "UI_interface.h"
@@ -80,7 +81,7 @@ const char *screen_context_dir[] = {
"visible_pose_bones", "selected_pose_bones", "active_bone", "active_pose_bone",
"active_base", "active_object", "object", "edit_object",
"sculpt_object", "vertex_paint_object", "weight_paint_object",
- "image_paint_object", "particle_edit_object",
+ "image_paint_object", "particle_edit_object", "uv_sculpt_object",
"sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */
"gpencil_data", "gpencil_data_owner", /* grease pencil data */
"visible_gpencil_layers", "editable_gpencil_layers", "editable_gpencil_strokes",
@@ -428,6 +429,23 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
+ else if (CTX_data_equals(member, "uv_sculpt_object")) {
+ /* TODO(campbell): most likely we change rules for uv_sculpt. */
+ if (obact && (obact->mode & OB_MODE_EDIT)) {
+ const ToolSettings *ts = scene->toolsettings;
+ if (ts->use_uv_sculpt) {
+ if (ED_uvedit_test(obedit)) {
+ WorkSpace *workspace = CTX_wm_workspace(C);
+ if ((workspace->tools_space_type == SPACE_IMAGE) &&
+ (workspace->tools_mode == SI_MODE_VIEW))
+ {
+ CTX_data_id_pointer_set(result, &obact->id);
+ }
+ }
+ }
+ }
+ return 1;
+ }
else if (CTX_data_equals(member, "sequences")) {
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed) {
More information about the Bf-blender-cvs
mailing list