From c056c58493acc5c5fbc7026955aece2af8dc3758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Davidovi=C4=87?= Date: Thu, 28 Mar 2024 12:15:33 +0100 Subject: [PATCH] Fix #106641: Missing Annotation widgets Annotation layer widget was missing on the Tool Settings bar and the side bar for some of the editors, as well as both color and layer widgets on the Tool tab of the Properties editor. Also fixed the Tool Settings bar not updating when drawing annotations on the Image editor viewport, and the Tool panel in Properties editor not updating when drawing annotations on the 3D scene. Pull Request: https://projects.blender.org/blender/blender/pulls/112688 --- .../bl_ui/properties_grease_pencil_common.py | 8 +++++++- scripts/startup/bl_ui/space_toolsystem_toolbar.py | 12 ++++++++++-- .../blender/editors/gpencil_legacy/gpencil_utils.cc | 8 ++++---- .../blender/editors/space_buttons/space_buttons.cc | 13 +++++++------ source/blender/editors/space_image/space_image.cc | 8 ++++++++ 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/scripts/startup/bl_ui/properties_grease_pencil_common.py b/scripts/startup/bl_ui/properties_grease_pencil_common.py index 5fed23cf1e9..9642cd56962 100644 --- a/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -417,7 +417,13 @@ class AnnotationDataPanel: bl_options = {'DEFAULT_CLOSED'} def draw_header(self, context): - if context.space_data.type not in {'VIEW_3D', 'TOPBAR', 'SEQUENCE_EDITOR'}: + if context.space_data.type not in { + 'VIEW_3D', + 'TOPBAR', + 'SEQUENCE_EDITOR', + 'IMAGE_EDITOR', + 'NODE_EDITOR', + 'PROPERTIES'}: self.layout.prop(context.space_data, "show_annotation", text="") def draw(self, context): diff --git a/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/scripts/startup/bl_ui/space_toolsystem_toolbar.py index e0195d19ce2..f6d9b3afcdc 100644 --- a/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -171,8 +171,8 @@ class _defs_annotate: gpl = context.active_annotation_layer if gpl is not None: - layout.label(text="Annotation:") - if context.space_data.type in {'VIEW_3D', 'SEQUENCE_EDITOR'}: + if context.space_data.type in {'VIEW_3D', 'SEQUENCE_EDITOR', 'IMAGE_EDITOR', 'NODE_EDITOR'}: + layout.label(text="Annotation:") if region_type == 'TOOL_HEADER': sub = layout.split(align=True, factor=0.5) sub.ui_units_x = 6.5 @@ -184,7 +184,15 @@ class _defs_annotate: panel="TOPBAR_PT_annotation_layers", text=text, ) + elif context.space_data.type == 'PROPERTIES': + row = layout.row(align=True) + row.prop(gpl, "color", text="Annotation") + row.popover( + panel="TOPBAR_PT_annotation_layers", + text=text, + ) else: + layout.label(text="Annotation:") layout.prop(gpl, "color", text="") space_type = tool.space_type diff --git a/source/blender/editors/gpencil_legacy/gpencil_utils.cc b/source/blender/editors/gpencil_legacy/gpencil_utils.cc index b2504c851c3..f9bcc74eb5e 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_utils.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_utils.cc @@ -123,14 +123,14 @@ bGPdata **ED_annotation_data_get_pointers_direct(ID *screen_id, SpaceLink *sl = static_cast(area->spacedata.first); switch (area->spacetype) { - case SPACE_PROPERTIES: /* properties */ - case SPACE_INFO: /* header info */ + case SPACE_INFO: /* header info */ { return nullptr; } - case SPACE_TOPBAR: /* Top-bar */ - case SPACE_VIEW3D: /* 3D-View */ + case SPACE_TOPBAR: /* Top-bar */ + case SPACE_VIEW3D: /* 3D-View */ + case SPACE_PROPERTIES: /* properties */ { if (r_ptr) { *r_ptr = RNA_id_pointer_create(&scene->id); diff --git a/source/blender/editors/space_buttons/space_buttons.cc b/source/blender/editors/space_buttons/space_buttons.cc index 1d7d26e9b17..b2d0a839323 100644 --- a/source/blender/editors/space_buttons/space_buttons.cc +++ b/source/blender/editors/space_buttons/space_buttons.cc @@ -812,12 +812,13 @@ static void buttons_area_listener(const wmSpaceTypeListenerParams *params) } break; case NC_GPENCIL: - switch (wmn->data) { - case ND_DATA: - if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED, NA_SELECTED, NA_RENAME)) { - ED_area_tag_redraw(area); - } - break; + if (wmn->data == ND_DATA) { + if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED, NA_SELECTED, NA_RENAME)) { + ED_area_tag_redraw(area); + } + } + else if (wmn->action == NA_EDITED) { + ED_area_tag_redraw(area); } break; case NC_NODE: diff --git a/source/blender/editors/space_image/space_image.cc b/source/blender/editors/space_image/space_image.cc index a2004fb3bd0..de28b866934 100644 --- a/source/blender/editors/space_image/space_image.cc +++ b/source/blender/editors/space_image/space_image.cc @@ -1004,6 +1004,14 @@ static void image_header_region_listener(const wmRegionListenerParams *params) ED_region_tag_redraw(region); } break; + case NC_GPENCIL: + if (wmn->data & ND_GPENCIL_EDITMODE) { + ED_region_tag_redraw(region); + } + else if (wmn->action == NA_EDITED) { + ED_region_tag_redraw(region); + } + break; } }