diff options
author | Jeroen Bakker <jbakker> | 2020-10-07 17:29:15 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2020-10-07 18:15:17 +0300 |
commit | afab33e0b97cc5e5278c3e8af5490b9583c3b95c (patch) | |
tree | ad1aaabdfea64ca9b66ab7292e3f18452ed7acf3 /source/blender/draw | |
parent | fc767502dc7dce4ff92d239abbcc49a68fe45e02 (diff) |
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
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_edit_uv.c | 42 | ||||
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_engine.c | 1 | ||||
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_private.h | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_view.c | 11 |
4 files changed, 34 insertions, 21 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c b/source/blender/draw/engines/overlay/overlay_edit_uv.c index bc41042ef02..af20e85a89b 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.c +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.c @@ -78,6 +78,7 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; const Scene *scene = draw_ctx->scene; const ToolSettings *ts = scene->toolsettings; + const bool show_overlays = !pd->hide_overlays; Image *image = sima->image; /* By design no image is an image type. This so editor shows UV's by default. */ @@ -99,21 +100,20 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) ((sima->flag & SI_DRAW_STRETCH) != 0); const bool do_tex_paint_shadows = (sima->flag & SI_NO_DRAW_TEXPAINT) == 0; - pd->edit_uv.do_faces = do_faces && !do_uvstretching_overlay; - pd->edit_uv.do_face_dots = do_faces && do_face_dots; - - pd->edit_uv.do_uv_overlay = do_uv_overlay; - pd->edit_uv.do_uv_shadow_overlay = is_image_type && + pd->edit_uv.do_faces = show_overlays && do_faces && !do_uvstretching_overlay; + pd->edit_uv.do_face_dots = show_overlays && do_faces && do_face_dots; + pd->edit_uv.do_uv_overlay = show_overlays && do_uv_overlay; + pd->edit_uv.do_uv_shadow_overlay = show_overlays && is_image_type && ((is_paint_mode && do_tex_paint_shadows && ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) || (is_view_mode && do_tex_paint_shadows && ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT)) != 0)) || (do_uv_overlay && (show_modified_uvs))); - pd->edit_uv.do_uv_stretching_overlay = do_uvstretching_overlay; + pd->edit_uv.do_uv_stretching_overlay = show_overlays && do_uvstretching_overlay; pd->edit_uv.uv_opacity = sima->uv_opacity; - pd->edit_uv.do_tiled_image_overlay = is_image_type && is_tiled_image; - + pd->edit_uv.do_tiled_image_overlay = show_overlays && is_image_type && is_tiled_image; + pd->edit_uv.do_tiled_image_border_overlay = is_image_type && is_tiled_image; pd->edit_uv.dash_length = 4.0f * UI_DPI_FAC; pd->edit_uv.line_style = edit_uv_line_style_from_space_image(sima); pd->edit_uv.do_smooth_wire = ((U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) > 0); @@ -223,7 +223,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) } } - if (pd->edit_uv.do_tiled_image_overlay) { + if (pd->edit_uv.do_tiled_image_border_overlay) { const DRWContextState *draw_ctx = DRW_context_state_get(); SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; Image *image = sima->image; @@ -252,14 +252,22 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) obmat[3][0] = (float)tile_x; DRW_shgroup_call_obmat(grp, geom, obmat); } + /* Only mark active border when overlays are enabled. */ + if (pd->edit_uv.do_tiled_image_overlay) { + /* Active tile border */ + ImageTile *active_tile = BLI_findlink(&image->tiles, image->active_tile_index); + obmat[3][0] = (float)((active_tile->tile_number - 1001) % 10); + obmat[3][1] = (float)((active_tile->tile_number - 1001) / 10); + grp = DRW_shgroup_create(sh, psl->edit_uv_tiled_image_borders_ps); + DRW_shgroup_uniform_vec4_copy(grp, "color", selected_color); + DRW_shgroup_call_obmat(grp, geom, obmat); + } + } - /* Active tile border */ - ImageTile *active_tile = BLI_findlink(&image->tiles, image->active_tile_index); - obmat[3][0] = (float)((active_tile->tile_number - 1001) % 10); - obmat[3][1] = (float)((active_tile->tile_number - 1001) / 10); - grp = DRW_shgroup_create(sh, psl->edit_uv_tiled_image_borders_ps); - DRW_shgroup_uniform_vec4_copy(grp, "color", selected_color); - DRW_shgroup_call_obmat(grp, geom, obmat); + if (pd->edit_uv.do_tiled_image_overlay) { + const DRWContextState *draw_ctx = DRW_context_state_get(); + SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; + Image *image = sima->image; struct DRWTextStore *dt = DRW_text_cache_ensure(); uchar color[4]; @@ -377,7 +385,7 @@ void OVERLAY_edit_uv_draw(OVERLAY_Data *vedata) OVERLAY_StorageList *stl = vedata->stl; OVERLAY_PrivateData *pd = stl->pd; - if (pd->edit_uv.do_tiled_image_overlay) { + if (pd->edit_uv.do_tiled_image_border_overlay) { DRW_draw_pass(psl->edit_uv_tiled_image_borders_ps); } diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index 5a87af7238e..76697b42a52 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -66,6 +66,7 @@ static void OVERLAY_engine_init(void *vedata) pd->is_image_editor = sima != NULL; if (pd->is_image_editor) { + pd->hide_overlays = (sima->overlay.flag & SI_OVERLAY_SHOW_OVERLAYS) == 0; pd->clipping_state = 0; OVERLAY_grid_init(data); OVERLAY_edit_uv_init(data); diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index ada2c2c8d1f..ef7a2db476c 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -356,6 +356,7 @@ typedef struct OVERLAY_PrivateData { bool do_uv_shadow_overlay; bool do_uv_stretching_overlay; bool do_tiled_image_overlay; + bool do_tiled_image_border_overlay; bool do_faces; bool do_face_dots; diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 86f19c6cfd7..1f1b52e9577 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -208,11 +208,14 @@ static bool is_cursor_visible_2d(const DRWContextState *draw_ctx) if (space_data == NULL) { return false; } - if (space_data->spacetype == SPACE_IMAGE) { - SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; - return sima->mode == SI_MODE_UV; + if (space_data->spacetype != SPACE_IMAGE) { + return false; + } + SpaceImage *sima = (SpaceImage *)space_data; + if (sima->mode != SI_MODE_UV) { + return false; } - return false; + return (sima->overlay.flag & SI_OVERLAY_SHOW_OVERLAYS) != 0; } void DRW_draw_cursor_2d(void) |