From afab33e0b97cc5e5278c3e8af5490b9583c3b95c Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 7 Oct 2020 16:29:15 +0200 Subject: UV/Image Editor: Overlay Popover The overlay options in the image/uv editor is hidden in side panels and menus. Sometimes this panel is even hidden, while still useful. The goal of this task is to introduce an overlay pop-over just like the overlay-popover of the 3d viewport. Popover has * UV Stretching (only available in the UV mode, when active object mode is a mesh and in OB_EDIT mode) * Display As (only available in the UV mode, when active object mode is a mesh and in OB_EDIT mode) * Show Modified (only available in the UV mode, when active object mode is a mesh and in OB_EDIT mode) * Show UV Edges (including opacity slider; available UV, View, Paint, when active object mode is a mesh and in OB_EDIT mode) * Udim tiles when no image is available. Like the 3d viewport, there will be a editor toggle to enable/disable the overlays For compatibility reasons the RNA properties are added to both the `SpaceImage.uv_editor` amd `SpaceImage.overlay`. On DNA level they are still stored in the SpaceImage. only new properties are added to the SpaceImageOverlay struct. During the next major release we could remove these options from `SpaceImage.uv_editor`. This should be noted in the Python section of release notes. Reviewed By: Julian Eisel, Pablo Vazquez Differential Revision: https://developer.blender.org/D8890 --- release/scripts/startup/bl_ui/space_image.py | 190 ++++++++++++++++++--------- 1 file changed, 126 insertions(+), 64 deletions(-) (limited to 'release/scripts/startup/bl_ui/space_image.py') diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 300f367ab27..9c6ad39e25b 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -742,6 +742,7 @@ class IMAGE_HT_header(Header): layout = self.layout sima = context.space_data + overlay = sima.overlay ima = sima.image iuser = sima.image_user tool_settings = context.tool_settings @@ -787,6 +788,13 @@ class IMAGE_HT_header(Header): layout.separator_spacer() + # Overlay toggle & popover + row = layout.row(align=True) + row.prop(overlay, "show_overlays", icon='OVERLAY', text="") + sub = row.row(align=True) + sub.active = overlay.show_overlays + sub.popover(panel="IMAGE_PT_overlay", text="") + if show_uvedit: uvedit = sima.uv_editor @@ -994,68 +1002,6 @@ class IMAGE_PT_view_display(Panel): col.prop(uvedit, "show_pixel_coords", text="Pixel Coordinates") -class IMAGE_PT_view_display_uv_edit_overlays(Panel): - bl_space_type = 'IMAGE_EDITOR' - bl_region_type = 'UI' - bl_label = "Overlays" - bl_parent_id = 'IMAGE_PT_view_display' - bl_category = "View" - bl_options = {'DEFAULT_CLOSED'} - - @classmethod - def poll(cls, context): - sima = context.space_data - return (sima and (sima.show_uvedit)) - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - layout.use_property_decorate = False - - sima = context.space_data - uvedit = sima.uv_editor - - col = layout.column() - - col.prop(uvedit, "edge_display_type", text="Display As") - col.prop(uvedit, "show_faces", text="Faces") - - col = layout.column() - if context.preferences.experimental.use_image_editor_legacy_drawing: - col.prop(uvedit, "show_smooth_edges", text="Smooth") - col.prop(uvedit, "show_modified_edges", text="Modified") - col.prop(uvedit, "uv_opacity") - - -class IMAGE_PT_view_display_uv_edit_overlays_stretch(Panel): - bl_space_type = 'IMAGE_EDITOR' - bl_region_type = 'UI' - bl_label = "Stretching" - bl_parent_id = 'IMAGE_PT_view_display_uv_edit_overlays' - bl_category = "View" - bl_options = {'DEFAULT_CLOSED'} - - @classmethod - def poll(cls, context): - sima = context.space_data - return (sima and (sima.show_uvedit)) - - def draw_header(self, context): - sima = context.space_data - uvedit = sima.uv_editor - self.layout.prop(uvedit, "show_stretch", text="") - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - - sima = context.space_data - uvedit = sima.uv_editor - - layout.active = uvedit.show_stretch - layout.prop(uvedit, "display_stretch_type", text="Type") - - class IMAGE_UL_render_slots(UIList): def draw_item(self, _context, layout, _data, item, _icon, _active_data, _active_propname, _index): slot = item @@ -1512,6 +1458,119 @@ class IMAGE_PT_udim_grid(Panel): col.prop(uvedit, "tile_grid_shape", text="Grid Shape") +class IMAGE_PT_overlay(Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'HEADER' + bl_label = "Overlays" + bl_ui_units_x = 13 + + def draw(self, context): + pass + + +class IMAGE_PT_overlay_uv_edit(Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'HEADER' + bl_label = "UV Editing" + bl_parent_id = 'IMAGE_PT_overlay' + + @classmethod + def poll(cls, context): + sima = context.space_data + return (sima and (sima.show_uvedit)) + + def draw(self, context): + layout = self.layout + + sima = context.space_data + uvedit = sima.uv_editor + overlay = sima.overlay + + layout.active = overlay.show_overlays + + # UV Stretching + row = layout.row() + row.prop(uvedit, "show_stretch") + subrow = row.row(align=True) + subrow.active = uvedit.show_stretch + subrow.prop(uvedit, "display_stretch_type", text="") + + + +class IMAGE_PT_overlay_uv_edit_geometry(Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'HEADER' + bl_label = "Geometry" + bl_parent_id = 'IMAGE_PT_overlay' + + @classmethod + def poll(cls, context): + sima = context.space_data + return (sima and (sima.show_uvedit)) + + def draw(self, context): + layout = self.layout + + sima = context.space_data + uvedit = sima.uv_editor + overlay = sima.overlay + + layout.active = overlay.show_overlays + + # Edges + col = layout.column() + col.prop(uvedit, "uv_opacity") + col.prop(uvedit, "edge_display_type", text="") + if context.preferences.experimental.use_image_editor_legacy_drawing: + col.prop(uvedit, "show_smooth_edges", text="Smooth") + col.prop(uvedit, "show_modified_edges", text="Modified Edges") + + # Faces + row = col.row() + row.active = not uvedit.show_stretch + row.prop(uvedit, "show_faces", text="Faces") + + + +class IMAGE_PT_overlay_texture_paint(Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'HEADER' + bl_label = "Geometry" + bl_parent_id = 'IMAGE_PT_overlay' + + @classmethod + def poll(cls, context): + sima = context.space_data + return (sima and (sima.show_paint)) + + def draw(self, context): + layout = self.layout + + sima = context.space_data + uvedit = sima.uv_editor + overlay = sima.overlay + + layout.active = overlay.show_overlays + layout.prop(uvedit, "show_texpaint") + + +class IMAGE_PT_overlay_image(Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'HEADER' + bl_label = "Image" + bl_parent_id = 'IMAGE_PT_overlay' + + def draw(self, context): + layout = self.layout + + sima = context.space_data + uvedit = sima.uv_editor + overlay = sima.overlay + + layout.active = overlay.show_overlays + layout.prop(uvedit, "show_metadata") + + # Grease Pencil properties class IMAGE_PT_annotation(AnnotationDataPanel, Panel): bl_space_type = 'IMAGE_EDITOR' @@ -1560,8 +1619,6 @@ classes = ( IMAGE_UL_udim_tiles, IMAGE_PT_udim_tiles, IMAGE_PT_view_display, - IMAGE_PT_view_display_uv_edit_overlays, - IMAGE_PT_view_display_uv_edit_overlays_stretch, IMAGE_PT_paint_select, IMAGE_PT_paint_settings, IMAGE_PT_paint_color, @@ -1587,6 +1644,11 @@ classes = ( IMAGE_PT_uv_cursor, IMAGE_PT_annotation, IMAGE_PT_udim_grid, + IMAGE_PT_overlay, + IMAGE_PT_overlay_uv_edit, + IMAGE_PT_overlay_uv_edit_geometry, + IMAGE_PT_overlay_texture_paint, + IMAGE_PT_overlay_image, ) -- cgit v1.2.3