diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-05-01 11:10:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-05-01 13:32:38 +0300 |
commit | 928becec60d16880838dd756cc8b6b5ee73f9b2d (patch) | |
tree | a54a8038c357c20d7b88a52d065b0f487480597d /release/scripts/startup/bl_ui/space_image.py | |
parent | 5fd69f6bd8c91b73135d22b3cad829b0892dabca (diff) |
UV Sculpt: improve tool-system integration
In 2.7x UV sculpt was a kind of sub-mode
(a toggle with it's own key-map & drawing code).
Move this to an operator that uses the tool-system,
this simplifies internal logic, especially brush selection
which now matches sculpt and other paint modes.
- Remove toggle used to enable uv sculpt.
- Expose the brush, which was already used but there was no way to
select different brushes.
- Make UV sculpt use paint paint tool slots
(using brushes how all other paint mode currently do).
- Move UV Sculpt keymap to the tools keymap.
- Remove Q to toggle UV sculpt mode,
S/P/G keys to switch tools.
Diffstat (limited to 'release/scripts/startup/bl_ui/space_image.py')
-rw-r--r-- | release/scripts/startup/bl_ui/space_image.py | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 466ba40b688..b27895fa04b 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -364,10 +364,6 @@ class IMAGE_MT_uvs(Menu): layout.separator() - layout.prop(tool_settings, "use_uv_sculpt") - - layout.separator() - layout.prop(uv, "use_live_unwrap") layout.operator("uv.unwrap") @@ -555,8 +551,9 @@ class IMAGE_HT_tool_header(Header): if tool_mode == 'PAINT': if (tool is not None) and tool.has_datablock: layout.popover_group(space_type='IMAGE_EDITOR', region_type='UI', context=".paint_common_2d", category="") - elif context.uv_sculpt_object is not None: - layout.popover_group(space_type='IMAGE_EDITOR', region_type='UI', context=".uv_sculpt", category="") + elif tool_mode == 'UV': + if (tool is not None) and tool.has_datablock: + layout.popover_group(space_type='IMAGE_EDITOR', region_type='UI', context=".uv_sculpt", category="") def draw_mode_settings(self, context): layout = self.layout @@ -573,10 +570,10 @@ class IMAGE_HT_tool_header(Header): class _draw_tool_settings_context_mode: @staticmethod - def VIEW(context, layout, _tool): - tool_settings = context.tool_settings - if tool_settings.use_uv_sculpt: + def UV(context, layout, tool): + if tool and tool.has_datablock: if context.mode == 'EDIT_MESH': + tool_settings = context.tool_settings uv_sculpt = tool_settings.uv_sculpt brush = uv_sculpt.brush if brush: @@ -1378,54 +1375,33 @@ class IMAGE_PT_tools_imagepaint_symmetry(BrushButtonsPanel, Panel): row.prop(ipaint, "tile_y", text="Y", toggle=True) -class IMAGE_PT_uv_sculpt_curve(Panel): +class IMAGE_PT_uv_sculpt_brush(Panel): bl_space_type = 'IMAGE_EDITOR' bl_region_type = 'UI' bl_context = ".uv_sculpt" # dot on purpose (access from topbar) bl_category = "Tool" - bl_label = "UV Sculpt Curve" - bl_options = {'DEFAULT_CLOSED'} + bl_label = "Brush" @classmethod def poll(cls, context): - return (context.uv_sculpt_object is not None) + sima = context.space_data + # TODO(campbell): nicer way to check if we're in uv sculpt mode. + if sima and sima.show_uvedit: + from .space_toolsystem_common import ToolSelectPanelHelper + tool = ToolSelectPanelHelper.tool_active_from_context(context) + if tool.has_datablock: + return True + return False def draw(self, context): + from .properties_paint_common import UnifiedPaintPanel layout = self.layout tool_settings = context.tool_settings uvsculpt = tool_settings.uv_sculpt - brush = uvsculpt.brush - - if brush is not None: - layout.template_curve_mapping(brush, "curve") - row = layout.row(align=True) - row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH' - row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND' - row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT' - row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP' - row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE' - row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX' - - -class IMAGE_PT_uv_sculpt(Panel): - bl_space_type = 'IMAGE_EDITOR' - bl_region_type = 'UI' - bl_context = ".uv_sculpt" # dot on purpose (access from topbar) - bl_category = "Tool" - bl_label = "UV Sculpt" - - @classmethod - def poll(cls, context): - return (context.uv_sculpt_object is not None) - - def draw(self, context): - from .properties_paint_common import UnifiedPaintPanel - layout = self.layout + layout.template_ID(uvsculpt, "brush") - tool_settings = context.tool_settings - uvsculpt = tool_settings.uv_sculpt brush = uvsculpt.brush if not self.is_popover: @@ -1444,13 +1420,43 @@ class IMAGE_PT_uv_sculpt(Panel): col.prop(tool_settings, "uv_sculpt_lock_borders") col.prop(tool_settings, "uv_sculpt_all_islands") - col.prop(tool_settings, "uv_sculpt_tool") - if tool_settings.uv_sculpt_tool == 'RELAX': - col.prop(tool_settings, "uv_relax_method") + if brush: + if brush.uv_sculpt_tool == 'RELAX': + col.prop(tool_settings, "uv_relax_method") col.prop(uvsculpt, "show_brush") +class IMAGE_PT_uv_sculpt_curve(Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'UI' + bl_context = ".uv_sculpt" # dot on purpose (access from topbar) + bl_category = "Tool" + bl_label = "Falloff" + bl_options = {'DEFAULT_CLOSED'} + + poll = IMAGE_PT_uv_sculpt_brush.poll + + def draw(self, context): + layout = self.layout + + tool_settings = context.tool_settings + uvsculpt = tool_settings.uv_sculpt + brush = uvsculpt.brush + + if brush is not None: + layout.template_curve_mapping(brush, "curve") + + row = layout.row(align=True) + row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH' + row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND' + row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT' + row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP' + row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE' + row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX' + + + class ImageScopesPanel: @classmethod def poll(cls, context): @@ -1646,7 +1652,7 @@ classes = ( IMAGE_PT_tools_brush_display_show_brush, IMAGE_PT_tools_brush_display_custom_icon, IMAGE_PT_tools_imagepaint_symmetry, - IMAGE_PT_uv_sculpt, + IMAGE_PT_uv_sculpt_brush, IMAGE_PT_uv_sculpt_curve, IMAGE_PT_view_histogram, IMAGE_PT_view_waveform, |