Context: add uv_sculpt_object

While this may be temporary, it avoids copy-pasting these
checks in Python code.
This commit is contained in:
Campbell Barton 2018-10-05 17:10:27 +10:00
parent 8b05d38305
commit b69301d4aa
3 changed files with 23 additions and 18 deletions

@ -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

@ -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

@ -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) {