diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-05 10:10:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-05 10:10:27 +0300 |
commit | b69301d4aa1bec6de596042d48df2846723c7445 (patch) | |
tree | afab43bcc2c5118e6be9aaee1b0113c6c9a69e0f | |
parent | 8b05d38305c4af49848b41e307ceb3ed424f5fbc (diff) |
Context: add uv_sculpt_object
While this may be temporary, it avoids copy-pasting these
checks in Python code.
-rw-r--r-- | release/scripts/startup/bl_ui/space_image.py | 13 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_topbar.py | 8 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 20 |
3 files changed, 23 insertions, 18 deletions
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) { |