From 94d8bf3f24dae6d7b0a26fdcfb0422aecc25f941 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Sun, 29 Oct 2023 14:41:20 +0100 Subject: [PATCH 01/30] working operator --- .../editors/animation/anim_channels_edit.cc | 110 ++++++++++++++++++ .../interface/interface_context_menu.cc | 8 ++ 2 files changed, 118 insertions(+) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 54370669bab..0ceb75e967c 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -25,6 +25,7 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_path.hh" #include "BKE_action.h" #include "BKE_anim_data.h" @@ -39,6 +40,7 @@ #include "BKE_nla.h" #include "BKE_scene.h" #include "BKE_screen.hh" +#include "BKE_workspace.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -850,6 +852,113 @@ void ANIM_frame_channel_y_extents(bContext *C, bAnimContext *ac) ANIM_animdata_freelist(&anim_data); } + +static int prop_view_exec(bContext *C, wmOperator *op) +{ + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; + uiBut *but; + int index; + + if (!(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index))) { + /* pass event on if no active button found */ + return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); + } + + ListBase selection = {nullptr, nullptr}; + if (CTX_data_mode_enum(C) == CTX_MODE_POSE) { + CTX_data_selected_pose_bones(C, &selection); + } + else { + CTX_data_selected_objects(C, &selection); + } + + rctf bounds{}; + bounds.xmin = INFINITY; + bounds.xmax = -INFINITY; + bounds.ymin = INFINITY; + bounds.ymax = -INFINITY; + const bool include_handles = RNA_boolean_get(op->ptr, "include_handles"); + + LISTBASE_FOREACH (CollectionPointerLink *, selected, &selection) { + ID *selected_id = selected->ptr.owner_id; + if (!BKE_animdata_id_is_animated(selected_id)) { + continue; + } + AnimData *anim_data = BKE_animdata_from_id(selected_id); + char *path = RNA_path_from_ID_to_property(&selected->ptr, prop); + bAction *action; + bool driven; + FCurve *fcurve = BKE_animadata_fcurve_find_by_rna_path( + anim_data, path, index, &action, &driven); + fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); + + rctf fcu_bounds; + BKE_fcurve_calc_bounds(fcurve, false, include_handles, nullptr, &fcu_bounds); + BLI_rctf_union(&bounds, &fcu_bounds); + MEM_freeN(path); + } + + BLI_freelistN(&selection); + + if (!BLI_rctf_is_valid(&bounds)) { + return OPERATOR_CANCELLED; + } + + LISTBASE_FOREACH (wmWindow *, win, &CTX_wm_manager(C)->windows) { + const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); + + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + if (area->spacetype != SPACE_GRAPH) { + continue; + } + ARegion *window_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); + + if (!window_region) { + continue; + } + add_region_padding(C, window_region, &bounds); + const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); + UI_view2d_smooth_view(C, window_region, &bounds, smooth_viewtx); + ED_area_tag_redraw(area); + break; + } + } + + return OPERATOR_FINISHED; +} + +static bool prop_view_poll(bContext *C) +{ + return true; +} + +static void ANIM_OT_prop_view(wmOperatorType *ot) +{ + /* Identifiers */ + ot->name = "Frame In Graph Editor"; + ot->idname = "ANIM_OT_prop_view"; + ot->description = "Frame the property under the cursor in the Graph Editor"; + + /* API callbacks */ + ot->exec = prop_view_exec; + ot->poll = prop_view_poll; + + ot->flag = 0; + + ot->prop = RNA_def_boolean(ot->srna, + "include_handles", + true, + "Include Handles", + "Include handles of keyframes when calculating extents"); + + ot->prop = RNA_def_boolean(ot->srna, + "use_preview_range", + true, + "Use Preview Range", + "Ignore frames outside of the preview range"); +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -4359,6 +4468,7 @@ void ED_operatortypes_animchannels() WM_operatortype_append(ANIM_OT_channel_view_pick); WM_operatortype_append(ANIM_OT_channels_view_selected); + WM_operatortype_append(ANIM_OT_prop_view); WM_operatortype_append(ANIM_OT_channels_delete); diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 015b3fc89e5..da18fc951f6 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -558,6 +558,10 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev /* Keyframes */ if (but->flag & UI_BUT_ANIMATED_KEY) { /* Replace/delete keyframes. */ + uiItemO(layout, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show in Graph Editor"), + ICON_NONE, + "ANIM_OT_prop_view"); if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframes"), @@ -606,6 +610,10 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev /* pass */ } else if (is_anim) { + uiItemO(layout, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show in Graph Editor"), + ICON_NONE, + "ANIM_OT_prop_view"); if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"), -- 2.30.2 From 1be313ab89047490f1653ee382f06313de4b6404 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 31 Oct 2023 09:43:51 +0100 Subject: [PATCH 02/30] respect preview range --- .../editors/animation/anim_channels_edit.cc | 210 +++++++++--------- .../interface/interface_context_menu.cc | 30 ++- 2 files changed, 126 insertions(+), 114 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 0ceb75e967c..6247829c7de 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -853,112 +853,6 @@ void ANIM_frame_channel_y_extents(bContext *C, bAnimContext *ac) ANIM_animdata_freelist(&anim_data); } -static int prop_view_exec(bContext *C, wmOperator *op) -{ - PointerRNA ptr = {nullptr}; - PropertyRNA *prop = nullptr; - uiBut *but; - int index; - - if (!(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index))) { - /* pass event on if no active button found */ - return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); - } - - ListBase selection = {nullptr, nullptr}; - if (CTX_data_mode_enum(C) == CTX_MODE_POSE) { - CTX_data_selected_pose_bones(C, &selection); - } - else { - CTX_data_selected_objects(C, &selection); - } - - rctf bounds{}; - bounds.xmin = INFINITY; - bounds.xmax = -INFINITY; - bounds.ymin = INFINITY; - bounds.ymax = -INFINITY; - const bool include_handles = RNA_boolean_get(op->ptr, "include_handles"); - - LISTBASE_FOREACH (CollectionPointerLink *, selected, &selection) { - ID *selected_id = selected->ptr.owner_id; - if (!BKE_animdata_id_is_animated(selected_id)) { - continue; - } - AnimData *anim_data = BKE_animdata_from_id(selected_id); - char *path = RNA_path_from_ID_to_property(&selected->ptr, prop); - bAction *action; - bool driven; - FCurve *fcurve = BKE_animadata_fcurve_find_by_rna_path( - anim_data, path, index, &action, &driven); - fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); - - rctf fcu_bounds; - BKE_fcurve_calc_bounds(fcurve, false, include_handles, nullptr, &fcu_bounds); - BLI_rctf_union(&bounds, &fcu_bounds); - MEM_freeN(path); - } - - BLI_freelistN(&selection); - - if (!BLI_rctf_is_valid(&bounds)) { - return OPERATOR_CANCELLED; - } - - LISTBASE_FOREACH (wmWindow *, win, &CTX_wm_manager(C)->windows) { - const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - - LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - if (area->spacetype != SPACE_GRAPH) { - continue; - } - ARegion *window_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); - - if (!window_region) { - continue; - } - add_region_padding(C, window_region, &bounds); - const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); - UI_view2d_smooth_view(C, window_region, &bounds, smooth_viewtx); - ED_area_tag_redraw(area); - break; - } - } - - return OPERATOR_FINISHED; -} - -static bool prop_view_poll(bContext *C) -{ - return true; -} - -static void ANIM_OT_prop_view(wmOperatorType *ot) -{ - /* Identifiers */ - ot->name = "Frame In Graph Editor"; - ot->idname = "ANIM_OT_prop_view"; - ot->description = "Frame the property under the cursor in the Graph Editor"; - - /* API callbacks */ - ot->exec = prop_view_exec; - ot->poll = prop_view_poll; - - ot->flag = 0; - - ot->prop = RNA_def_boolean(ot->srna, - "include_handles", - true, - "Include Handles", - "Include handles of keyframes when calculating extents"); - - ot->prop = RNA_def_boolean(ot->srna, - "use_preview_range", - true, - "Use Preview Range", - "Ignore frames outside of the preview range"); -} - /** \} */ /* -------------------------------------------------------------------- */ @@ -4445,6 +4339,110 @@ static void ANIM_OT_channel_view_pick(wmOperatorType *ot) "Ignore frames outside of the preview range"); } +static int prop_view_exec(bContext *C, wmOperator *op) +{ + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; + uiBut *but; + int index; + + if (!(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index))) { + /* pass event on if no active button found */ + return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); + } + + ListBase selection = {nullptr, nullptr}; + if (CTX_data_mode_enum(C) == CTX_MODE_POSE) { + CTX_data_selected_pose_bones(C, &selection); + } + else { + CTX_data_selected_objects(C, &selection); + } + + rctf bounds{}; + bounds.xmin = INFINITY; + bounds.xmax = -INFINITY; + bounds.ymin = INFINITY; + bounds.ymax = -INFINITY; + const bool include_handles = RNA_boolean_get(op->ptr, "include_handles"); + + Scene *scene = CTX_data_scene(C); + float frame_range[2]; + get_view_range(scene, true, frame_range); + + LISTBASE_FOREACH (CollectionPointerLink *, selected, &selection) { + ID *selected_id = selected->ptr.owner_id; + if (!BKE_animdata_id_is_animated(selected_id)) { + continue; + } + AnimData *anim_data = BKE_animdata_from_id(selected_id); + char *path = RNA_path_from_ID_to_property(&selected->ptr, prop); + bAction *action; + bool driven; + FCurve *fcurve = BKE_animadata_fcurve_find_by_rna_path( + anim_data, path, index, &action, &driven); + fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); + + rctf fcu_bounds; + BKE_fcurve_calc_bounds(fcurve, false, include_handles, frame_range, &fcu_bounds); + BLI_rctf_union(&bounds, &fcu_bounds); + MEM_freeN(path); + } + + BLI_freelistN(&selection); + + if (!BLI_rctf_is_valid(&bounds)) { + return OPERATOR_CANCELLED; + } + + LISTBASE_FOREACH (wmWindow *, win, &CTX_wm_manager(C)->windows) { + const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); + + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + if (area->spacetype != SPACE_GRAPH) { + continue; + } + ARegion *window_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); + + if (!window_region) { + continue; + } + add_region_padding(C, window_region, &bounds); + const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); + UI_view2d_smooth_view(C, window_region, &bounds, smooth_viewtx); + ED_area_tag_redraw(area); + break; + } + } + + return OPERATOR_FINISHED; +} + +static void ANIM_OT_prop_view(wmOperatorType *ot) +{ + /* Identifiers */ + ot->name = "Frame In Graph Editor"; + ot->idname = "ANIM_OT_prop_view"; + ot->description = "Frame the property under the cursor in the Graph Editor"; + + /* API callbacks */ + ot->exec = prop_view_exec; + + ot->flag = 0; + + RNA_def_boolean(ot->srna, + "include_handles", + true, + "Include Handles", + "Include handles of keyframes when calculating extents"); + + RNA_def_boolean(ot->srna, + "all", + false, + "Show All", + "Frame the whole array property instead of only the index under the cursor"); +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index da18fc951f6..605dea20a28 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -558,10 +558,6 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev /* Keyframes */ if (but->flag & UI_BUT_ANIMATED_KEY) { /* Replace/delete keyframes. */ - uiItemO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show in Graph Editor"), - ICON_NONE, - "ANIM_OT_prop_view"); if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframes"), @@ -610,10 +606,6 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev /* pass */ } else if (is_anim) { - uiItemO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show in Graph Editor"), - ICON_NONE, - "ANIM_OT_prop_view"); if (is_array_component) { uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"), @@ -663,6 +655,28 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev } } + if (is_anim || but->flag & UI_BUT_ANIMATED_KEY) { + uiItemS(layout); + if (is_array_component) { + uiItemO(layout, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show Single in Graph Editor"), + ICON_NONE, + "ANIM_OT_prop_view"); + uiItemBooleanO(layout, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show All in Graph Editor"), + ICON_NONE, + "ANIM_OT_prop_view", + "all", + true); + } + else { + uiItemO(layout, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show in Graph Editor"), + ICON_NONE, + "ANIM_OT_prop_view"); + } + } + /* Drivers */ if (but->flag & UI_BUT_DRIVEN) { uiItemS(layout); -- 2.30.2 From a4adc3e5dfadb597b38931594277955c58fcceb2 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 31 Oct 2023 10:40:23 +0100 Subject: [PATCH 03/30] make it work in a different window --- .../editors/animation/anim_channels_edit.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 6247829c7de..ca00a25ec1c 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4395,6 +4395,8 @@ static int prop_view_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } + bool found_graph_editor = false; + LISTBASE_FOREACH (wmWindow *, win, &CTX_wm_manager(C)->windows) { const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); @@ -4408,11 +4410,23 @@ static int prop_view_exec(bContext *C, wmOperator *op) continue; } add_region_padding(C, window_region, &bounds); + /* Setting the window to the context is needed for the case when the Graph Editor is found in + * a different window. Otherwise smooth view wouldn't work. */ + CTX_wm_window_set(C, win); const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); UI_view2d_smooth_view(C, window_region, &bounds, smooth_viewtx); ED_area_tag_redraw(area); + found_graph_editor = true; break; } + + if (found_graph_editor) { + break; + } + } + + if (!found_graph_editor) { + WM_report(RPT_WARNING, "No open Graph Editor window found"); } return OPERATOR_FINISHED; -- 2.30.2 From 686b266aa6c2e9d32c85e26f9c0cddddc1c62f04 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 31 Oct 2023 11:12:15 +0100 Subject: [PATCH 04/30] make "show all" work --- .../editors/animation/anim_channels_edit.cc | 37 +++++++++++++++---- .../interface/interface_context_menu.cc | 20 ++++++---- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index ca00a25ec1c..0852dd273fe 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4370,6 +4370,8 @@ static int prop_view_exec(bContext *C, wmOperator *op) float frame_range[2]; get_view_range(scene, true, frame_range); + const bool whole_array = RNA_boolean_get(op->ptr, "all"); + LISTBASE_FOREACH (CollectionPointerLink *, selected, &selection) { ID *selected_id = selected->ptr.owner_id; if (!BKE_animdata_id_is_animated(selected_id)) { @@ -4379,16 +4381,36 @@ static int prop_view_exec(bContext *C, wmOperator *op) char *path = RNA_path_from_ID_to_property(&selected->ptr, prop); bAction *action; bool driven; - FCurve *fcurve = BKE_animadata_fcurve_find_by_rna_path( - anim_data, path, index, &action, &driven); - fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); - rctf fcu_bounds; - BKE_fcurve_calc_bounds(fcurve, false, include_handles, frame_range, &fcu_bounds); - BLI_rctf_union(&bounds, &fcu_bounds); + blender::Vector fcurves; + + if (RNA_property_array_check(prop) && whole_array) { + const int length = RNA_property_array_length(&selected->ptr, prop); + for (int i = 0; i < length; i++) { + FCurve *fcurve = BKE_animadata_fcurve_find_by_rna_path( + anim_data, path, i, &action, &driven); + if (fcurve != nullptr) { + fcurves.append(fcurve); + } + } + } + else { + FCurve *fcurve = BKE_animadata_fcurve_find_by_rna_path( + anim_data, path, index, &action, &driven); + if (fcurve != nullptr) { + fcurves.append(fcurve); + } + } + MEM_freeN(path); - } + for (FCurve *fcurve : fcurves) { + fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); + rctf fcu_bounds; + BKE_fcurve_calc_bounds(fcurve, false, include_handles, frame_range, &fcu_bounds); + BLI_rctf_union(&bounds, &fcu_bounds); + } + } BLI_freelistN(&selection); if (!BLI_rctf_is_valid(&bounds)) { @@ -4413,6 +4435,7 @@ static int prop_view_exec(bContext *C, wmOperator *op) /* Setting the window to the context is needed for the case when the Graph Editor is found in * a different window. Otherwise smooth view wouldn't work. */ CTX_wm_window_set(C, win); + CTX_wm_area_set(C, area); const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); UI_view2d_smooth_view(C, window_region, &bounds, smooth_viewtx); ED_area_tag_redraw(area); diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 605dea20a28..9fef8464cbb 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -658,10 +658,12 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev if (is_anim || but->flag & UI_BUT_ANIMATED_KEY) { uiItemS(layout); if (is_array_component) { - uiItemO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show Single in Graph Editor"), - ICON_NONE, - "ANIM_OT_prop_view"); + uiItemBooleanO(layout, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show Single in Graph Editor"), + ICON_NONE, + "ANIM_OT_prop_view", + "all", + false); uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show All in Graph Editor"), ICON_NONE, @@ -670,10 +672,12 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev true); } else { - uiItemO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show in Graph Editor"), - ICON_NONE, - "ANIM_OT_prop_view"); + uiItemBooleanO(layout, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show in Graph Editor"), + ICON_NONE, + "ANIM_OT_prop_view", + "all", + false); } } -- 2.30.2 From a0058c9adec4e4cbd342af8af415478c9044d41c Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 31 Oct 2023 13:30:02 +0100 Subject: [PATCH 05/30] normalization working --- .../editors/animation/anim_channels_edit.cc | 130 +++++++++++++----- 1 file changed, 95 insertions(+), 35 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 0852dd273fe..869d60c68f8 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4339,6 +4339,53 @@ static void ANIM_OT_channel_view_pick(wmOperatorType *ot) "Ignore frames outside of the preview range"); } +static short get_normalization_flags(SpaceLink *sl) +{ + if (sl->spacetype == SPACE_GRAPH) { + SpaceGraph *sipo = (SpaceGraph *)sl; + bool use_normalization = (sipo->flag & SIPO_NORMALIZE) != 0; + bool freeze_normalization = (sipo->flag & SIPO_NORMALIZE_FREEZE) != 0; + return use_normalization ? (ANIM_UNITCONV_NORMALIZE | + (freeze_normalization ? ANIM_UNITCONV_NORMALIZE_FREEZE : 0)) : + 0; + } + + return 0; +} + +static bool get_normalized_fcurve_bounds_foo(FCurve *fcu, + SpaceLink *sl, + Scene *scene, + ID *id, + const bool include_handles, + const float range[2], + rctf *r_bounds) +{ + const bool fcu_selection_only = false; + const bool found_bounds = BKE_fcurve_calc_bounds( + fcu, fcu_selection_only, include_handles, range, r_bounds); + + if (!found_bounds) { + return false; + } + + const short mapping_flag = get_normalization_flags(sl); + + float offset; + const float unit_fac = ANIM_unit_mapping_get_factor(scene, id, fcu, mapping_flag, &offset); + + r_bounds->ymin = (r_bounds->ymin + offset) * unit_fac; + r_bounds->ymax = (r_bounds->ymax + offset) * unit_fac; + + const float min_height = 0.01f; + const float height = BLI_rctf_size_y(r_bounds); + if (height < min_height) { + r_bounds->ymin -= (min_height - height) / 2; + r_bounds->ymax += (min_height - height) / 2; + } + return true; +} + static int prop_view_exec(bContext *C, wmOperator *op) { PointerRNA ptr = {nullptr}; @@ -4351,6 +4398,43 @@ static int prop_view_exec(bContext *C, wmOperator *op) return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } + bool found_graph_editor = false; + + wmWindow *found_window; + bScreen *screen; + ScrArea *graph_editor_area; + ARegion *ge_window_region; + SpaceLink *ge; + + LISTBASE_FOREACH (wmWindow *, win, &CTX_wm_manager(C)->windows) { + screen = BKE_workspace_active_screen_get(win->workspace_hook); + + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + if (area->spacetype != SPACE_GRAPH) { + continue; + } + ge_window_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); + + if (!ge_window_region) { + continue; + } + + graph_editor_area = area; + found_window = win; + ge = (SpaceLink *)area->spacedata.first; + found_graph_editor = true; + break; + } + + if (found_graph_editor) { + break; + } + } + + if (!found_graph_editor) { + WM_report(RPT_WARNING, "No open Graph Editor window found"); + } + ListBase selection = {nullptr, nullptr}; if (CTX_data_mode_enum(C) == CTX_MODE_POSE) { CTX_data_selected_pose_bones(C, &selection); @@ -4407,7 +4491,9 @@ static int prop_view_exec(bContext *C, wmOperator *op) for (FCurve *fcurve : fcurves) { fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); rctf fcu_bounds; - BKE_fcurve_calc_bounds(fcurve, false, include_handles, frame_range, &fcu_bounds); + get_normalized_fcurve_bounds_foo( + fcurve, ge, scene, selected_id, include_handles, frame_range, &fcu_bounds); + // BKE_fcurve_calc_bounds(fcurve, false, include_handles, frame_range, &fcu_bounds); BLI_rctf_union(&bounds, &fcu_bounds); } } @@ -4417,40 +4503,14 @@ static int prop_view_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - bool found_graph_editor = false; - - LISTBASE_FOREACH (wmWindow *, win, &CTX_wm_manager(C)->windows) { - const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - - LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - if (area->spacetype != SPACE_GRAPH) { - continue; - } - ARegion *window_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); - - if (!window_region) { - continue; - } - add_region_padding(C, window_region, &bounds); - /* Setting the window to the context is needed for the case when the Graph Editor is found in - * a different window. Otherwise smooth view wouldn't work. */ - CTX_wm_window_set(C, win); - CTX_wm_area_set(C, area); - const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); - UI_view2d_smooth_view(C, window_region, &bounds, smooth_viewtx); - ED_area_tag_redraw(area); - found_graph_editor = true; - break; - } - - if (found_graph_editor) { - break; - } - } - - if (!found_graph_editor) { - WM_report(RPT_WARNING, "No open Graph Editor window found"); - } + add_region_padding(C, ge_window_region, &bounds); + /* Setting the window to the context is needed for the case when the Graph Editor is found in + * a different window. Otherwise smooth view wouldn't work. */ + CTX_wm_window_set(C, found_window); + CTX_wm_area_set(C, graph_editor_area); + const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); + UI_view2d_smooth_view(C, ge_window_region, &bounds, smooth_viewtx); + ED_area_tag_redraw(graph_editor_area); return OPERATOR_FINISHED; } -- 2.30.2 From 26c22e82984a50571261b836eded7c8ebca267e4 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 2 Nov 2023 10:29:27 +0100 Subject: [PATCH 06/30] nla remap --- .../blender/editors/animation/anim_channels_edit.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 5be6c2e9d35..01dbd2c4551 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4498,7 +4498,8 @@ static int prop_view_exec(bContext *C, wmOperator *op) rctf fcu_bounds; get_normalized_fcurve_bounds_foo( fcurve, ge, scene, selected_id, include_handles, frame_range, &fcu_bounds); - // BKE_fcurve_calc_bounds(fcurve, false, include_handles, frame_range, &fcu_bounds); + fcu_bounds.xmin = BKE_nla_tweakedit_remap(anim_data, fcu_bounds.xmin, NLATIME_CONVERT_MAP); + fcu_bounds.xmax = BKE_nla_tweakedit_remap(anim_data, fcu_bounds.xmax, NLATIME_CONVERT_MAP); BLI_rctf_union(&bounds, &fcu_bounds); } } @@ -4509,12 +4510,8 @@ static int prop_view_exec(bContext *C, wmOperator *op) } add_region_padding(C, ge_window_region, &bounds); - /* Setting the window to the context is needed for the case when the Graph Editor is found in - * a different window. Otherwise smooth view wouldn't work. */ - CTX_wm_window_set(C, found_window); - CTX_wm_area_set(C, graph_editor_area); - const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); - UI_view2d_smooth_view(C, ge_window_region, &bounds, smooth_viewtx); + /* Not using smooth view since that creates issues because the context isn't right. */ + ge_window_region->v2d.cur = bounds; ED_area_tag_redraw(graph_editor_area); return OPERATOR_FINISHED; -- 2.30.2 From 4c4af768e86d8f29ee59d517ac3816f43583dbf3 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 2 Nov 2023 10:49:03 +0100 Subject: [PATCH 07/30] cleanup variables --- .../blender/editors/animation/anim_channels_edit.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 01dbd2c4551..6e7a6496378 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4405,14 +4405,12 @@ static int prop_view_exec(bContext *C, wmOperator *op) bool found_graph_editor = false; - wmWindow *found_window; - bScreen *screen; ScrArea *graph_editor_area; ARegion *ge_window_region; - SpaceLink *ge; + SpaceLink *ge_space_link; LISTBASE_FOREACH (wmWindow *, win, &CTX_wm_manager(C)->windows) { - screen = BKE_workspace_active_screen_get(win->workspace_hook); + bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype != SPACE_GRAPH) { @@ -4425,8 +4423,7 @@ static int prop_view_exec(bContext *C, wmOperator *op) } graph_editor_area = area; - found_window = win; - ge = (SpaceLink *)area->spacedata.first; + ge_space_link = (SpaceLink *)area->spacedata.first; found_graph_editor = true; break; } @@ -4497,7 +4494,7 @@ static int prop_view_exec(bContext *C, wmOperator *op) fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); rctf fcu_bounds; get_normalized_fcurve_bounds_foo( - fcurve, ge, scene, selected_id, include_handles, frame_range, &fcu_bounds); + fcurve, ge_space_link, scene, selected_id, include_handles, frame_range, &fcu_bounds); fcu_bounds.xmin = BKE_nla_tweakedit_remap(anim_data, fcu_bounds.xmin, NLATIME_CONVERT_MAP); fcu_bounds.xmax = BKE_nla_tweakedit_remap(anim_data, fcu_bounds.xmax, NLATIME_CONVERT_MAP); BLI_rctf_union(&bounds, &fcu_bounds); -- 2.30.2 From 4b6cb877aecdc88e137cbe9da50e61942f8f04d4 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 2 Nov 2023 13:17:14 +0100 Subject: [PATCH 08/30] works from anywhere now with rna path magic --- .../editors/animation/anim_channels_edit.cc | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 6e7a6496378..080f8f6df8b 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4435,14 +4435,18 @@ static int prop_view_exec(bContext *C, wmOperator *op) if (!found_graph_editor) { WM_report(RPT_WARNING, "No open Graph Editor window found"); + return OPERATOR_CANCELLED; } ListBase selection = {nullptr, nullptr}; - if (CTX_data_mode_enum(C) == CTX_MODE_POSE) { - CTX_data_selected_pose_bones(C, &selection); - } - else { - CTX_data_selected_objects(C, &selection); + bool path_from_id; + char *id_to_prop_path; + const bool selected_list_success = UI_context_copy_to_selected_list( + C, &ptr, prop, &selection, &path_from_id, &id_to_prop_path); + + if (!selected_list_success) { + WM_report(RPT_ERROR, "No selection found"); + return OPERATOR_CANCELLED; } rctf bounds{}; @@ -4463,18 +4467,22 @@ static int prop_view_exec(bContext *C, wmOperator *op) if (!BKE_animdata_id_is_animated(selected_id)) { continue; } + PointerRNA foo_ptr; + PropertyRNA *foo_prop; + const bool resolved = RNA_path_resolve_property( + &selected->ptr, id_to_prop_path, &foo_ptr, &foo_prop); + if (!resolved) { + continue; + } + char *path = RNA_path_from_ID_to_property(&foo_ptr, foo_prop); + AnimData *anim_data = BKE_animdata_from_id(selected_id); - char *path = RNA_path_from_ID_to_property(&selected->ptr, prop); - bAction *action; - bool driven; - blender::Vector fcurves; - if (RNA_property_array_check(prop) && whole_array) { const int length = RNA_property_array_length(&selected->ptr, prop); for (int i = 0; i < length; i++) { FCurve *fcurve = BKE_animadata_fcurve_find_by_rna_path( - anim_data, path, i, &action, &driven); + anim_data, path, i, nullptr, nullptr); if (fcurve != nullptr) { fcurves.append(fcurve); } @@ -4482,7 +4490,7 @@ static int prop_view_exec(bContext *C, wmOperator *op) } else { FCurve *fcurve = BKE_animadata_fcurve_find_by_rna_path( - anim_data, path, index, &action, &driven); + anim_data, path, index, nullptr, nullptr); if (fcurve != nullptr) { fcurves.append(fcurve); } -- 2.30.2 From 1eb54ee19c099a6036fe28a878ebb828a6fa3bc9 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 2 Nov 2023 14:32:21 +0100 Subject: [PATCH 09/30] fix basic channels now not working --- .../editors/animation/anim_channels_edit.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 080f8f6df8b..855a2cd2d7b 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4469,10 +4469,16 @@ static int prop_view_exec(bContext *C, wmOperator *op) } PointerRNA foo_ptr; PropertyRNA *foo_prop; - const bool resolved = RNA_path_resolve_property( - &selected->ptr, id_to_prop_path, &foo_ptr, &foo_prop); - if (!resolved) { - continue; + if (id_to_prop_path != nullptr) { + const bool resolved = RNA_path_resolve_property( + &selected->ptr, id_to_prop_path, &foo_ptr, &foo_prop); + if (!resolved) { + continue; + } + } + else { + foo_ptr = selected->ptr; + foo_prop = prop; } char *path = RNA_path_from_ID_to_property(&foo_ptr, foo_prop); @@ -4509,6 +4515,9 @@ static int prop_view_exec(bContext *C, wmOperator *op) } } BLI_freelistN(&selection); + if (id_to_prop_path != nullptr) { + MEM_freeN(id_to_prop_path); + } if (!BLI_rctf_is_valid(&bounds)) { return OPERATOR_CANCELLED; -- 2.30.2 From 11b0d974b240bfa887aa12181e13e7ecbe592d6d Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 2 Nov 2023 14:51:58 +0100 Subject: [PATCH 10/30] don't show menu entry when thing isn't animated --- source/blender/editors/interface/interface_context_menu.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 9fef8464cbb..4b7f181f89c 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -655,7 +655,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev } } - if (is_anim || but->flag & UI_BUT_ANIMATED_KEY) { + if (but->flag & UI_BUT_ANIMATED) { uiItemS(layout); if (is_array_component) { uiItemBooleanO(layout, -- 2.30.2 From 42fe235e61921a4f9b3221e88d0fb77f48289343 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 7 Nov 2023 13:45:05 +0100 Subject: [PATCH 11/30] rename to "view" --- .../blender/editors/animation/anim_channels_edit.cc | 12 ++++++------ .../editors/interface/interface_context_menu.cc | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 855a2cd2d7b..f9d584008fa 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4391,7 +4391,7 @@ static bool get_normalized_fcurve_bounds_foo(FCurve *fcu, return true; } -static int prop_view_exec(bContext *C, wmOperator *op) +static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) { PointerRNA ptr = {nullptr}; PropertyRNA *prop = nullptr; @@ -4531,15 +4531,15 @@ static int prop_view_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static void ANIM_OT_prop_view(wmOperatorType *ot) +static void ANIM_OT_view_curve_in_graph_editor(wmOperatorType *ot) { /* Identifiers */ - ot->name = "Frame In Graph Editor"; - ot->idname = "ANIM_OT_prop_view"; + ot->name = "View In Graph Editor"; + ot->idname = "ANIM_OT_view_curve_in_graph_editor"; ot->description = "Frame the property under the cursor in the Graph Editor"; /* API callbacks */ - ot->exec = prop_view_exec; + ot->exec = view_curve_in_graph_editor_exec; ot->flag = 0; @@ -4579,7 +4579,7 @@ void ED_operatortypes_animchannels() WM_operatortype_append(ANIM_OT_channel_view_pick); WM_operatortype_append(ANIM_OT_channels_view_selected); - WM_operatortype_append(ANIM_OT_prop_view); + WM_operatortype_append(ANIM_OT_view_curve_in_graph_editor); WM_operatortype_append(ANIM_OT_channels_delete); diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 4b7f181f89c..5c846428a13 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -661,13 +661,13 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show Single in Graph Editor"), ICON_NONE, - "ANIM_OT_prop_view", + "ANIM_OT_view_curve_in_graph_editor", "all", false); uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show All in Graph Editor"), ICON_NONE, - "ANIM_OT_prop_view", + "ANIM_OT_view_curve_in_graph_editor", "all", true); } @@ -675,7 +675,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev uiItemBooleanO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show in Graph Editor"), ICON_NONE, - "ANIM_OT_prop_view", + "ANIM_OT_view_curve_in_graph_editor", "all", false); } -- 2.30.2 From 1a04d42972a76d9e3fc8c74095d4f2cb9ce16165 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 7 Nov 2023 13:47:42 +0100 Subject: [PATCH 12/30] remove "include handles" --- source/blender/editors/animation/anim_channels_edit.cc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index f9d584008fa..0e608dc8f47 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4454,7 +4454,7 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) bounds.xmax = -INFINITY; bounds.ymin = INFINITY; bounds.ymax = -INFINITY; - const bool include_handles = RNA_boolean_get(op->ptr, "include_handles"); + const bool include_handles = false; Scene *scene = CTX_data_scene(C); float frame_range[2]; @@ -4541,14 +4541,6 @@ static void ANIM_OT_view_curve_in_graph_editor(wmOperatorType *ot) /* API callbacks */ ot->exec = view_curve_in_graph_editor_exec; - ot->flag = 0; - - RNA_def_boolean(ot->srna, - "include_handles", - true, - "Include Handles", - "Include handles of keyframes when calculating extents"); - RNA_def_boolean(ot->srna, "all", false, -- 2.30.2 From 8e15af3f15e8a4e7bd34c6e223eae3cc9620c76c Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Nov 2023 15:06:02 +0100 Subject: [PATCH 13/30] extract function --- .../editors/animation/anim_channels_edit.cc | 70 ++++++++++--------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index eeec59d589e..12b85ce7a46 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4316,6 +4316,37 @@ static bool get_normalized_fcurve_bounds_foo(FCurve *fcu, return true; } +static bool move_context_to_graph_editor(bContext *C) +{ + bool found_graph_editor = false; + LISTBASE_FOREACH (wmWindow *, win, &CTX_wm_manager(C)->windows) { + bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); + + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + if (area->spacetype != SPACE_GRAPH) { + continue; + } + ARegion *window_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); + + if (!window_region) { + continue; + } + + CTX_wm_window_set(C, win); + CTX_wm_screen_set(C, screen); + CTX_wm_area_set(C, area); + CTX_wm_region_set(C, window_region); + found_graph_editor = true; + break; + } + + if (found_graph_editor) { + break; + } + } + return found_graph_editor; +} + static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) { PointerRNA ptr = {nullptr}; @@ -4328,35 +4359,7 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } - bool found_graph_editor = false; - - ScrArea *graph_editor_area; - ARegion *ge_window_region; - SpaceLink *ge_space_link; - - LISTBASE_FOREACH (wmWindow *, win, &CTX_wm_manager(C)->windows) { - bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); - - LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - if (area->spacetype != SPACE_GRAPH) { - continue; - } - ge_window_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); - - if (!ge_window_region) { - continue; - } - - graph_editor_area = area; - ge_space_link = (SpaceLink *)area->spacedata.first; - found_graph_editor = true; - break; - } - - if (found_graph_editor) { - break; - } - } + const bool found_graph_editor = move_context_to_graph_editor(C); if (!found_graph_editor) { WM_report(RPT_WARNING, "No open Graph Editor window found"); @@ -4429,6 +4432,8 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) MEM_freeN(path); + SpaceLink *ge_space_link = CTX_wm_space_data(C); + for (FCurve *fcurve : fcurves) { fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); rctf fcu_bounds; @@ -4448,10 +4453,11 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - add_region_padding(C, ge_window_region, &bounds); + ARegion *region = CTX_wm_region(C); + add_region_padding(C, region, &bounds); /* Not using smooth view since that creates issues because the context isn't right. */ - ge_window_region->v2d.cur = bounds; - ED_area_tag_redraw(graph_editor_area); + region->v2d.cur = bounds; + ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; } -- 2.30.2 From 8399d936d316ec532b1217e1ee364b0dd127ae90 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Nov 2023 15:20:54 +0100 Subject: [PATCH 14/30] deselect other curves when viewing fcurves --- .../editors/animation/anim_channels_edit.cc | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 12b85ce7a46..81b6cb89104 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4347,6 +4347,22 @@ static bool move_context_to_graph_editor(bContext *C) return found_graph_editor; } +static void deselect_all_fcurves(bAnimContext *ac) +{ + ListBase anim_data = {nullptr, nullptr}; + const eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | + ANIMFILTER_FCURVESONLY | ANIMFILTER_NODUPLIS); + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype)); + + LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { + FCurve *fcu = (FCurve *)ale->key_data; + fcu->flag &= ~FCURVE_SELECTED; + fcu->flag &= ~FCURVE_ACTIVE; + } + + ANIM_animdata_freelist(&anim_data); +} + static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) { PointerRNA ptr = {nullptr}; @@ -4374,9 +4390,18 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) if (!selected_list_success) { WM_report(RPT_ERROR, "No selection found"); + BLI_freelistN(&selection); return OPERATOR_CANCELLED; } + bAnimContext ac; + if (!ANIM_animdata_get_context(C, &ac)) { + WM_report(RPT_ERROR, "Cannot create animcontext"); + return OPERATOR_CANCELLED; + } + + deselect_all_fcurves(&ac); + rctf bounds{}; bounds.xmin = INFINITY; bounds.xmax = -INFINITY; -- 2.30.2 From 52ad27cc52f6b30ab9a2a6bc07bb2bbcd7a8ca1f Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Nov 2023 15:21:26 +0100 Subject: [PATCH 15/30] fix potential memory leak --- source/blender/editors/animation/anim_channels_edit.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 81b6cb89104..acffa208643 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4397,6 +4397,7 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) bAnimContext ac; if (!ANIM_animdata_get_context(C, &ac)) { WM_report(RPT_ERROR, "Cannot create animcontext"); + BLI_freelistN(&selection); return OPERATOR_CANCELLED; } -- 2.30.2 From 65c4ad81ff7743a238329fdf59df9e9acbe3f49b Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Nov 2023 15:33:33 +0100 Subject: [PATCH 16/30] extact function and use smooth view --- .../editors/animation/anim_channels_edit.cc | 124 ++++++++++-------- 1 file changed, 71 insertions(+), 53 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index acffa208643..32a8a10555e 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4363,60 +4363,25 @@ static void deselect_all_fcurves(bAnimContext *ac) ANIM_animdata_freelist(&anim_data); } -static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) +static void calculate_selection_fcurve_bounds(bContext *C, + ListBase *selection, + PropertyRNA *prop, + char *id_to_prop_path, + const int index, + const bool whole_array, + rctf *r_bounds) { - PointerRNA ptr = {nullptr}; - PropertyRNA *prop = nullptr; - uiBut *but; - int index; - - if (!(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index))) { - /* pass event on if no active button found */ - return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); + SpaceLink *ge_space_link = CTX_wm_space_data(C); + if (ge_space_link->spacetype != SPACE_GRAPH) { + return; } - const bool found_graph_editor = move_context_to_graph_editor(C); - - if (!found_graph_editor) { - WM_report(RPT_WARNING, "No open Graph Editor window found"); - return OPERATOR_CANCELLED; - } - - ListBase selection = {nullptr, nullptr}; - bool path_from_id; - char *id_to_prop_path; - const bool selected_list_success = UI_context_copy_to_selected_list( - C, &ptr, prop, &selection, &path_from_id, &id_to_prop_path); - - if (!selected_list_success) { - WM_report(RPT_ERROR, "No selection found"); - BLI_freelistN(&selection); - return OPERATOR_CANCELLED; - } - - bAnimContext ac; - if (!ANIM_animdata_get_context(C, &ac)) { - WM_report(RPT_ERROR, "Cannot create animcontext"); - BLI_freelistN(&selection); - return OPERATOR_CANCELLED; - } - - deselect_all_fcurves(&ac); - - rctf bounds{}; - bounds.xmin = INFINITY; - bounds.xmax = -INFINITY; - bounds.ymin = INFINITY; - bounds.ymax = -INFINITY; - const bool include_handles = false; - Scene *scene = CTX_data_scene(C); float frame_range[2]; get_view_range(scene, true, frame_range); + const bool include_handles = false; - const bool whole_array = RNA_boolean_get(op->ptr, "all"); - - LISTBASE_FOREACH (CollectionPointerLink *, selected, &selection) { + LISTBASE_FOREACH (CollectionPointerLink *, selected, selection) { ID *selected_id = selected->ptr.owner_id; if (!BKE_animdata_id_is_animated(selected_id)) { continue; @@ -4458,8 +4423,6 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) MEM_freeN(path); - SpaceLink *ge_space_link = CTX_wm_space_data(C); - for (FCurve *fcurve : fcurves) { fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); rctf fcu_bounds; @@ -4467,10 +4430,65 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) fcurve, ge_space_link, scene, selected_id, include_handles, frame_range, &fcu_bounds); fcu_bounds.xmin = BKE_nla_tweakedit_remap(anim_data, fcu_bounds.xmin, NLATIME_CONVERT_MAP); fcu_bounds.xmax = BKE_nla_tweakedit_remap(anim_data, fcu_bounds.xmax, NLATIME_CONVERT_MAP); - BLI_rctf_union(&bounds, &fcu_bounds); + BLI_rctf_union(r_bounds, &fcu_bounds); } } +} + +static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) +{ + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; + uiBut *but; + int index; + + if (!(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index))) { + /* pass event on if no active button found */ + return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); + } + + const bool found_graph_editor = move_context_to_graph_editor(C); + + if (!found_graph_editor) { + WM_report(RPT_WARNING, "No open Graph Editor window found"); + return OPERATOR_CANCELLED; + } + + ListBase selection = {nullptr, nullptr}; + bool path_from_id; + char *id_to_prop_path; + const bool selected_list_success = UI_context_copy_to_selected_list( + C, &ptr, prop, &selection, &path_from_id, &id_to_prop_path); + + if (!selected_list_success) { + WM_report(RPT_ERROR, "No selection found"); + BLI_freelistN(&selection); + return OPERATOR_CANCELLED; + } + + bAnimContext ac; + if (!ANIM_animdata_get_context(C, &ac)) { + /* This might never be called since we are manually setting the Graph Editor just before. */ + WM_report(RPT_ERROR, "Cannot create the Animation Context"); + BLI_freelistN(&selection); + return OPERATOR_CANCELLED; + } + + deselect_all_fcurves(&ac); + + rctf bounds{}; + bounds.xmin = INFINITY; + bounds.xmax = -INFINITY; + bounds.ymin = INFINITY; + bounds.ymax = -INFINITY; + + const bool whole_array = RNA_boolean_get(op->ptr, "all"); + + calculate_selection_fcurve_bounds( + C, &selection, prop, id_to_prop_path, index, whole_array, &bounds); + BLI_freelistN(&selection); + if (id_to_prop_path != nullptr) { MEM_freeN(id_to_prop_path); } @@ -4481,9 +4499,9 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) ARegion *region = CTX_wm_region(C); add_region_padding(C, region, &bounds); - /* Not using smooth view since that creates issues because the context isn't right. */ - region->v2d.cur = bounds; - ED_area_tag_redraw(CTX_wm_area(C)); + + const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); + UI_view2d_smooth_view(C, region, &bounds, smooth_viewtx); return OPERATOR_FINISHED; } -- 2.30.2 From cd5d36cc8e3f4a7920eb85e0b13ffb6d310c760a Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Nov 2023 15:35:02 +0100 Subject: [PATCH 17/30] add function comment --- source/blender/editors/animation/anim_channels_edit.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 32a8a10555e..ca88219372a 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4316,6 +4316,7 @@ static bool get_normalized_fcurve_bounds_foo(FCurve *fcu, return true; } +/* Find a Graph Editor area and modify the given context to be the window region of it. */ static bool move_context_to_graph_editor(bContext *C) { bool found_graph_editor = false; -- 2.30.2 From 267145e54b2f4ca8fb749dfe5f234a5f9962ee77 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Nov 2023 15:49:26 +0100 Subject: [PATCH 18/30] clean up code --- .../editors/animation/anim_channels_edit.cc | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index ca88219372a..6d7c553ab96 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4387,20 +4387,20 @@ static void calculate_selection_fcurve_bounds(bContext *C, if (!BKE_animdata_id_is_animated(selected_id)) { continue; } - PointerRNA foo_ptr; - PropertyRNA *foo_prop; + PointerRNA resolved_ptr; + PropertyRNA *resolved_prop; if (id_to_prop_path != nullptr) { const bool resolved = RNA_path_resolve_property( - &selected->ptr, id_to_prop_path, &foo_ptr, &foo_prop); + &selected->ptr, id_to_prop_path, &resolved_ptr, &resolved_prop); if (!resolved) { continue; } } else { - foo_ptr = selected->ptr; - foo_prop = prop; + resolved_ptr = selected->ptr; + resolved_prop = prop; } - char *path = RNA_path_from_ID_to_property(&foo_ptr, foo_prop); + char *path = RNA_path_from_ID_to_property(&resolved_ptr, resolved_prop); AnimData *anim_data = BKE_animdata_from_id(selected_id); blender::Vector fcurves; @@ -4444,7 +4444,7 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) int index; if (!(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index))) { - /* pass event on if no active button found */ + /* Pass event on if no active button found. */ return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } @@ -4455,6 +4455,15 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } + bAnimContext ac; + if (!ANIM_animdata_get_context(C, &ac)) { + /* This might never be called since we are manually setting the Graph Editor just before. */ + WM_report(RPT_ERROR, "Cannot create the Animation Context"); + return OPERATOR_CANCELLED; + } + + deselect_all_fcurves(&ac); + ListBase selection = {nullptr, nullptr}; bool path_from_id; char *id_to_prop_path; @@ -4467,16 +4476,6 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - bAnimContext ac; - if (!ANIM_animdata_get_context(C, &ac)) { - /* This might never be called since we are manually setting the Graph Editor just before. */ - WM_report(RPT_ERROR, "Cannot create the Animation Context"); - BLI_freelistN(&selection); - return OPERATOR_CANCELLED; - } - - deselect_all_fcurves(&ac); - rctf bounds{}; bounds.xmin = INFINITY; bounds.xmax = -INFINITY; @@ -4495,6 +4494,7 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) } if (!BLI_rctf_is_valid(&bounds)) { + WM_report(RPT_ERROR, "F-Curves have no valid size"); return OPERATOR_CANCELLED; } -- 2.30.2 From cf1d62d30ab014409723eff49ac70709e1c4bde2 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Nov 2023 16:01:02 +0100 Subject: [PATCH 19/30] add redraw tag back in --- source/blender/editors/animation/anim_channels_edit.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 6d7c553ab96..218f2ecc300 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4365,7 +4365,7 @@ static void deselect_all_fcurves(bAnimContext *ac) } static void calculate_selection_fcurve_bounds(bContext *C, - ListBase *selection, + ListBase /* CollectionPointerLink */ *selection, PropertyRNA *prop, char *id_to_prop_path, const int index, @@ -4504,6 +4504,9 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); UI_view2d_smooth_view(C, region, &bounds, smooth_viewtx); + /* This ensures the channel list updates. */ + ED_area_tag_redraw(CTX_wm_area(C)); + return OPERATOR_FINISHED; } -- 2.30.2 From c25f4939faaef01d230878cae55a54189a8e50ec Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Nov 2023 16:27:16 +0100 Subject: [PATCH 20/30] add userpref setting for isolating F-Curves --- scripts/startup/bl_ui/space_userpref.py | 1 + source/blender/editors/animation/anim_channels_edit.cc | 3 +++ source/blender/makesdna/DNA_userdef_types.h | 2 ++ source/blender/makesrna/intern/rna_userdef.cc | 8 ++++++++ 4 files changed, 14 insertions(+) diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index 2292c6dd9c9..1061fa5f1f4 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -603,6 +603,7 @@ class USERPREF_PT_animation_fcurves(AnimationPanel, CenterAlignMixIn, Panel): flow.prop(edit, "use_anim_channel_group_colors") flow.prop(edit, "show_only_selected_curve_keyframes") flow.prop(edit, "use_fcurve_high_quality_drawing") + flow.prop(edit, "view_isolates_curves") # ----------------------------------------------------------------------------- diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 218f2ecc300..98fe707494e 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4359,6 +4359,9 @@ static void deselect_all_fcurves(bAnimContext *ac) FCurve *fcu = (FCurve *)ale->key_data; fcu->flag &= ~FCURVE_SELECTED; fcu->flag &= ~FCURVE_ACTIVE; + if (U.animation_flag & USER_ANIM_VIEW_ISOLATE_FCURVE) { + fcu->flag &= ~FCURVE_VISIBLE; + } } ANIM_animdata_freelist(&anim_data); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 26d70a20869..529e7a617cf 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -1304,6 +1304,8 @@ typedef enum eUserpref_Anim_Flags { USER_ANIM_SHOW_CHANNEL_GROUP_COLORS = (1 << 0), USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS = (1 << 1), USER_ANIM_HIGH_QUALITY_DRAWING = (1 << 2), + /* If set, viewing a set of FCurves will hide all other FCurves in the Graph Editor. */ + USER_ANIM_VIEW_ISOLATE_FCURVE = (1 << 3), } eUserpref_Anim_Flags; /** #UserDef.transopts */ diff --git a/source/blender/makesrna/intern/rna_userdef.cc b/source/blender/makesrna/intern/rna_userdef.cc index 9dba218a81c..b0310fa4e49 100644 --- a/source/blender/makesrna/intern/rna_userdef.cc +++ b/source/blender/makesrna/intern/rna_userdef.cc @@ -5509,6 +5509,14 @@ static void rna_def_userdef_edit(BlenderRNA *brna) "Draw F-Curves using Anti-Aliasing (disable for better performance)"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, nullptr); + /* Graph Editor view FCurve behavior. */ + prop = RNA_def_property(srna, "view_isolates_curves", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, nullptr, "animation_flag", USER_ANIM_VIEW_ISOLATE_FCURVE); + RNA_def_property_ui_text(prop, + "Isolate F-Curves when framed", + "Hides all other F-Curves when framing a selection of them"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, nullptr); + /* grease pencil */ prop = RNA_def_property(srna, "grease_pencil_manhattan_distance", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, nullptr, "gp_manhattandist"); -- 2.30.2 From 1989c92eed6447993d42a949050edb05959d5832 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Nov 2023 17:27:47 +0100 Subject: [PATCH 21/30] reuse existing code for getting fcu bounds --- .../editors/animation/anim_channels_edit.cc | 65 ++++--------------- 1 file changed, 11 insertions(+), 54 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index b2836ed72a7..5d8db20ca6d 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -68,7 +68,7 @@ static bool get_normalized_fcurve_bounds(FCurve *fcu, AnimData *anim_data, SpaceLink *space_link, Scene *scene, - bAnimListElem *ale, + ID *id, const bool include_handles, const float range[2], rctf *r_bounds) @@ -84,7 +84,7 @@ static bool get_normalized_fcurve_bounds(FCurve *fcu, const short mapping_flag = ANIM_get_normalization_flags(space_link); float offset; - const float unit_fac = ANIM_unit_mapping_get_factor(scene, ale->id, fcu, mapping_flag, &offset); + const float unit_fac = ANIM_unit_mapping_get_factor(scene, id, fcu, mapping_flag, &offset); r_bounds->ymin = (r_bounds->ymin + offset) * unit_fac; r_bounds->ymax = (r_bounds->ymax + offset) * unit_fac; @@ -144,7 +144,7 @@ static bool get_channel_bounds(bAnimContext *ac, FCurve *fcu = (FCurve *)ale->key_data; AnimData *anim_data = ANIM_nla_mapping_get(ac, ale); found_bounds = get_normalized_fcurve_bounds( - fcu, anim_data, ac->sl, ac->scene, ale, include_handles, range, r_bounds); + fcu, anim_data, ac->sl, ac->scene, ale->id, include_handles, range, r_bounds); break; } } @@ -4271,53 +4271,6 @@ static void ANIM_OT_channel_view_pick(wmOperatorType *ot) "Ignore frames outside of the preview range"); } -static short get_normalization_flags(SpaceLink *sl) -{ - if (sl->spacetype == SPACE_GRAPH) { - SpaceGraph *sipo = (SpaceGraph *)sl; - bool use_normalization = (sipo->flag & SIPO_NORMALIZE) != 0; - bool freeze_normalization = (sipo->flag & SIPO_NORMALIZE_FREEZE) != 0; - return use_normalization ? (ANIM_UNITCONV_NORMALIZE | - (freeze_normalization ? ANIM_UNITCONV_NORMALIZE_FREEZE : 0)) : - 0; - } - - return 0; -} - -static bool get_normalized_fcurve_bounds_foo(FCurve *fcu, - SpaceLink *sl, - Scene *scene, - ID *id, - const bool include_handles, - const float range[2], - rctf *r_bounds) -{ - const bool fcu_selection_only = false; - const bool found_bounds = BKE_fcurve_calc_bounds( - fcu, fcu_selection_only, include_handles, range, r_bounds); - - if (!found_bounds) { - return false; - } - - const short mapping_flag = get_normalization_flags(sl); - - float offset; - const float unit_fac = ANIM_unit_mapping_get_factor(scene, id, fcu, mapping_flag, &offset); - - r_bounds->ymin = (r_bounds->ymin + offset) * unit_fac; - r_bounds->ymax = (r_bounds->ymax + offset) * unit_fac; - - const float min_height = 0.01f; - const float height = BLI_rctf_size_y(r_bounds); - if (height < min_height) { - r_bounds->ymin -= (min_height - height) / 2; - r_bounds->ymax += (min_height - height) / 2; - } - return true; -} - /* Find a Graph Editor area and modify the given context to be the window region of it. */ static bool move_context_to_graph_editor(bContext *C) { @@ -4432,10 +4385,14 @@ static void calculate_selection_fcurve_bounds(bContext *C, for (FCurve *fcurve : fcurves) { fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); rctf fcu_bounds; - get_normalized_fcurve_bounds_foo( - fcurve, ge_space_link, scene, selected_id, include_handles, frame_range, &fcu_bounds); - fcu_bounds.xmin = BKE_nla_tweakedit_remap(anim_data, fcu_bounds.xmin, NLATIME_CONVERT_MAP); - fcu_bounds.xmax = BKE_nla_tweakedit_remap(anim_data, fcu_bounds.xmax, NLATIME_CONVERT_MAP); + get_normalized_fcurve_bounds(fcurve, + anim_data, + ge_space_link, + scene, + selected_id, + include_handles, + frame_range, + &fcu_bounds); BLI_rctf_union(r_bounds, &fcu_bounds); } } -- 2.30.2 From 4ef5128e0ac6b945c5b2c06dfdb69f3b42ad8805 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Nov 2023 21:18:56 +0100 Subject: [PATCH 22/30] remove user preference and add modifier key --- scripts/startup/bl_ui/space_userpref.py | 1 - .../editors/animation/anim_channels_edit.cc | 24 +++++++++++++++---- source/blender/makesdna/DNA_userdef_types.h | 2 -- source/blender/makesrna/intern/rna_userdef.cc | 8 ------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index 1061fa5f1f4..2292c6dd9c9 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -603,7 +603,6 @@ class USERPREF_PT_animation_fcurves(AnimationPanel, CenterAlignMixIn, Panel): flow.prop(edit, "use_anim_channel_group_colors") flow.prop(edit, "show_only_selected_curve_keyframes") flow.prop(edit, "use_fcurve_high_quality_drawing") - flow.prop(edit, "view_isolates_curves") # ----------------------------------------------------------------------------- diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 5d8db20ca6d..b9e52dbebf6 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4303,7 +4303,7 @@ static bool move_context_to_graph_editor(bContext *C) return found_graph_editor; } -static void deselect_all_fcurves(bAnimContext *ac) +static void deselect_all_fcurves(bAnimContext *ac, const bool isolate) { ListBase anim_data = {nullptr, nullptr}; const eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | @@ -4314,7 +4314,7 @@ static void deselect_all_fcurves(bAnimContext *ac) FCurve *fcu = (FCurve *)ale->key_data; fcu->flag &= ~FCURVE_SELECTED; fcu->flag &= ~FCURVE_ACTIVE; - if (U.animation_flag & USER_ANIM_VIEW_ISOLATE_FCURVE) { + if (isolate) { fcu->flag &= ~FCURVE_VISIBLE; } } @@ -4424,7 +4424,8 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - deselect_all_fcurves(&ac); + const bool isolate = RNA_boolean_get(op->ptr, "isolate"); + deselect_all_fcurves(&ac, isolate); ListBase selection = {nullptr, nullptr}; bool path_from_id; @@ -4472,14 +4473,23 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int view_curve_in_graph_editor_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + RNA_boolean_set(op->ptr, "isolate", event->modifier == KM_ALT); + return view_curve_in_graph_editor_exec(C, op); +} + static void ANIM_OT_view_curve_in_graph_editor(wmOperatorType *ot) { /* Identifiers */ ot->name = "View In Graph Editor"; ot->idname = "ANIM_OT_view_curve_in_graph_editor"; - ot->description = "Frame the property under the cursor in the Graph Editor"; + ot->description = + "Frame the property under the cursor in the Graph Editor. Use Alt+Click to isolate the " + "curves"; /* API callbacks */ + ot->invoke = view_curve_in_graph_editor_invoke; ot->exec = view_curve_in_graph_editor_exec; RNA_def_boolean(ot->srna, @@ -4487,6 +4497,12 @@ static void ANIM_OT_view_curve_in_graph_editor(wmOperatorType *ot) false, "Show All", "Frame the whole array property instead of only the index under the cursor"); + + RNA_def_boolean(ot->srna, + "isolate", + false, + "Isolate", + "Hides all other F-Curves other than the ones being framed"); } /** \} */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 529e7a617cf..26d70a20869 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -1304,8 +1304,6 @@ typedef enum eUserpref_Anim_Flags { USER_ANIM_SHOW_CHANNEL_GROUP_COLORS = (1 << 0), USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS = (1 << 1), USER_ANIM_HIGH_QUALITY_DRAWING = (1 << 2), - /* If set, viewing a set of FCurves will hide all other FCurves in the Graph Editor. */ - USER_ANIM_VIEW_ISOLATE_FCURVE = (1 << 3), } eUserpref_Anim_Flags; /** #UserDef.transopts */ diff --git a/source/blender/makesrna/intern/rna_userdef.cc b/source/blender/makesrna/intern/rna_userdef.cc index b0310fa4e49..9dba218a81c 100644 --- a/source/blender/makesrna/intern/rna_userdef.cc +++ b/source/blender/makesrna/intern/rna_userdef.cc @@ -5509,14 +5509,6 @@ static void rna_def_userdef_edit(BlenderRNA *brna) "Draw F-Curves using Anti-Aliasing (disable for better performance)"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, nullptr); - /* Graph Editor view FCurve behavior. */ - prop = RNA_def_property(srna, "view_isolates_curves", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "animation_flag", USER_ANIM_VIEW_ISOLATE_FCURVE); - RNA_def_property_ui_text(prop, - "Isolate F-Curves when framed", - "Hides all other F-Curves when framing a selection of them"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, nullptr); - /* grease pencil */ prop = RNA_def_property(srna, "grease_pencil_manhattan_distance", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, nullptr, "gp_manhattandist"); -- 2.30.2 From 43d70d67ebc478f488b1c9eff5110cf703c42bf5 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 10 Nov 2023 09:19:24 +0100 Subject: [PATCH 23/30] fixx issue with preview range and nla offset --- source/blender/editors/animation/anim_channels_edit.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index b9e52dbebf6..8d3926f32ad 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4385,13 +4385,18 @@ static void calculate_selection_fcurve_bounds(bContext *C, for (FCurve *fcurve : fcurves) { fcurve->flag |= (FCURVE_SELECTED | FCURVE_VISIBLE); rctf fcu_bounds; + float mapped_frame_range[2]; + mapped_frame_range[0] = BKE_nla_tweakedit_remap( + anim_data, frame_range[0], NLATIME_CONVERT_UNMAP); + mapped_frame_range[1] = BKE_nla_tweakedit_remap( + anim_data, frame_range[1], NLATIME_CONVERT_UNMAP); get_normalized_fcurve_bounds(fcurve, anim_data, ge_space_link, scene, selected_id, include_handles, - frame_range, + mapped_frame_range, &fcu_bounds); BLI_rctf_union(r_bounds, &fcu_bounds); } -- 2.30.2 From e140da9bf0c1719f847a4537c9cd6b37bb62886c Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 14 Nov 2023 11:13:32 +0100 Subject: [PATCH 24/30] return rctf from function --- .../editors/animation/anim_channels_edit.cc | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 8d3926f32ad..46fc743ed77 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4303,7 +4303,7 @@ static bool move_context_to_graph_editor(bContext *C) return found_graph_editor; } -static void deselect_all_fcurves(bAnimContext *ac, const bool isolate) +static void deselect_all_fcurves(bAnimContext *ac, const bool hide) { ListBase anim_data = {nullptr, nullptr}; const eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | @@ -4314,7 +4314,7 @@ static void deselect_all_fcurves(bAnimContext *ac, const bool isolate) FCurve *fcu = (FCurve *)ale->key_data; fcu->flag &= ~FCURVE_SELECTED; fcu->flag &= ~FCURVE_ACTIVE; - if (isolate) { + if (hide) { fcu->flag &= ~FCURVE_VISIBLE; } } @@ -4322,17 +4322,22 @@ static void deselect_all_fcurves(bAnimContext *ac, const bool isolate) ANIM_animdata_freelist(&anim_data); } -static void calculate_selection_fcurve_bounds(bContext *C, +static rctf calculate_selection_fcurve_bounds(bContext *C, ListBase /* CollectionPointerLink */ *selection, PropertyRNA *prop, char *id_to_prop_path, const int index, - const bool whole_array, - rctf *r_bounds) + const bool whole_array) { + rctf bounds; + bounds.xmin = INFINITY; + bounds.xmax = -INFINITY; + bounds.ymin = INFINITY; + bounds.ymax = -INFINITY; + SpaceLink *ge_space_link = CTX_wm_space_data(C); if (ge_space_link->spacetype != SPACE_GRAPH) { - return; + return bounds; } Scene *scene = CTX_data_scene(C); @@ -4398,9 +4403,11 @@ static void calculate_selection_fcurve_bounds(bContext *C, include_handles, mapped_frame_range, &fcu_bounds); - BLI_rctf_union(r_bounds, &fcu_bounds); + BLI_rctf_union(&bounds, &fcu_bounds); } } + + return bounds; } static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) @@ -4444,16 +4451,10 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - rctf bounds{}; - bounds.xmin = INFINITY; - bounds.xmax = -INFINITY; - bounds.ymin = INFINITY; - bounds.ymax = -INFINITY; - const bool whole_array = RNA_boolean_get(op->ptr, "all"); - calculate_selection_fcurve_bounds( - C, &selection, prop, id_to_prop_path, index, whole_array, &bounds); + rctf bounds = calculate_selection_fcurve_bounds( + C, &selection, prop, id_to_prop_path, index, whole_array); BLI_freelistN(&selection); -- 2.30.2 From d0f50cfa2a8c973bfa6c30ca4fbe3fa88171359c Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 14 Nov 2023 13:09:23 +0100 Subject: [PATCH 25/30] get selection before moving context so it works for shaders --- .../editors/animation/anim_channels_edit.cc | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 46fc743ed77..e77dd312d94 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4422,6 +4422,19 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } + ListBase selection = {nullptr, nullptr}; + + bool path_from_id; + char *id_to_prop_path; + const bool selected_list_success = UI_context_copy_to_selected_list( + C, &ptr, prop, &selection, &path_from_id, &id_to_prop_path); + + if (BLI_listbase_is_empty(&selection) || !selected_list_success) { + WM_report(RPT_ERROR, "No selection found"); + BLI_freelistN(&selection); + return OPERATOR_CANCELLED; + } + const bool found_graph_editor = move_context_to_graph_editor(C); if (!found_graph_editor) { @@ -4439,18 +4452,6 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) const bool isolate = RNA_boolean_get(op->ptr, "isolate"); deselect_all_fcurves(&ac, isolate); - ListBase selection = {nullptr, nullptr}; - bool path_from_id; - char *id_to_prop_path; - const bool selected_list_success = UI_context_copy_to_selected_list( - C, &ptr, prop, &selection, &path_from_id, &id_to_prop_path); - - if (!selected_list_success) { - WM_report(RPT_ERROR, "No selection found"); - BLI_freelistN(&selection); - return OPERATOR_CANCELLED; - } - const bool whole_array = RNA_boolean_get(op->ptr, "all"); rctf bounds = calculate_selection_fcurve_bounds( -- 2.30.2 From aaba317b23c323e021794cc1cc446c2b8fd60018 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 14 Nov 2023 14:12:14 +0100 Subject: [PATCH 26/30] change error message to "Nothing selected" --- source/blender/editors/animation/anim_channels_edit.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index e77dd312d94..7b88e4a703a 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4430,7 +4430,7 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) C, &ptr, prop, &selection, &path_from_id, &id_to_prop_path); if (BLI_listbase_is_empty(&selection) || !selected_list_success) { - WM_report(RPT_ERROR, "No selection found"); + WM_report(RPT_ERROR, "Nothing selected"); BLI_freelistN(&selection); return OPERATOR_CANCELLED; } -- 2.30.2 From 992aa1db338efe935fa6344fc3fdd2a2d2226c6a Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 16 Nov 2023 14:15:36 +0100 Subject: [PATCH 27/30] reaname function --- .../editors/animation/anim_channels_edit.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 8988e9dcc19..ebe34717272 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4361,12 +4361,13 @@ static void deselect_all_fcurves(bAnimContext *ac, const bool hide) ANIM_animdata_freelist(&anim_data); } -static rctf calculate_selection_fcurve_bounds(bContext *C, - ListBase /* CollectionPointerLink */ *selection, - PropertyRNA *prop, - char *id_to_prop_path, - const int index, - const bool whole_array) +static rctf calculate_selection_fcurve_bounds_and_unhide( + bContext *C, + ListBase /* CollectionPointerLink */ *selection, + PropertyRNA *prop, + char *id_to_prop_path, + const int index, + const bool whole_array) { rctf bounds; bounds.xmin = INFINITY; @@ -4493,7 +4494,7 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) const bool whole_array = RNA_boolean_get(op->ptr, "all"); - rctf bounds = calculate_selection_fcurve_bounds( + rctf bounds = calculate_selection_fcurve_bounds_and_unhide( C, &selection, prop, id_to_prop_path, index, whole_array); BLI_freelistN(&selection); -- 2.30.2 From 3343a3fc4dd77b255a415532ce39970baaef6a8f Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 16 Nov 2023 15:21:23 +0100 Subject: [PATCH 28/30] change logic of Alt key press now allows using "isolate" with a hotkey --- .../editors/animation/anim_channels_edit.cc | 14 ++++- .../interface/interface_context_menu.cc | 57 +++++++++++++------ 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index ebe34717272..dccb98f2246 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4522,7 +4522,9 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) static int view_curve_in_graph_editor_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - RNA_boolean_set(op->ptr, "isolate", event->modifier == KM_ALT); + if (RNA_boolean_get(op->ptr, "use_modifier_key")) { + RNA_boolean_set(op->ptr, "isolate", event->modifier == KM_ALT); + } return view_curve_in_graph_editor_exec(C, op); } @@ -4550,6 +4552,16 @@ static void ANIM_OT_view_curve_in_graph_editor(wmOperatorType *ot) false, "Isolate", "Hides all other F-Curves other than the ones being framed"); + + PropertyRNA *prop = RNA_def_boolean( + ot->srna, + "use_modifier_key", + false, + "Use Modifier Key", + "Check the Alt key when the operator is executed to define the isolation behavior. If true, " + "overrides the isolate property"); + RNA_def_property_flag(prop, PROP_HIDDEN); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index bb275469989..85e65baaff0 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -658,26 +658,47 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev if (but->flag & UI_BUT_ANIMATED) { uiItemS(layout); if (is_array_component) { - uiItemBooleanO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show Single in Graph Editor"), - ICON_NONE, - "ANIM_OT_view_curve_in_graph_editor", - "all", - false); - uiItemBooleanO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show All in Graph Editor"), - ICON_NONE, - "ANIM_OT_view_curve_in_graph_editor", - "all", - true); + PointerRNA op_ptr; + wmOperatorType *ot; + ot = WM_operatortype_find("ANIM_OT_view_curve_in_graph_editor", false); + uiItemFullO_ptr( + layout, + ot, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "View Single in Graph Editor"), + ICON_NONE, + nullptr, + WM_OP_INVOKE_DEFAULT, + UI_ITEM_NONE, + &op_ptr); + RNA_boolean_set(&op_ptr, "all", false); + RNA_boolean_set(&op_ptr, "use_modifier_key", true); + + uiItemFullO_ptr(layout, + ot, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "View All in Graph Editor"), + ICON_NONE, + nullptr, + WM_OP_INVOKE_DEFAULT, + UI_ITEM_NONE, + &op_ptr); + RNA_boolean_set(&op_ptr, "all", true); + RNA_boolean_set(&op_ptr, "use_modifier_key", true); } else { - uiItemBooleanO(layout, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Show in Graph Editor"), - ICON_NONE, - "ANIM_OT_view_curve_in_graph_editor", - "all", - false); + PointerRNA op_ptr; + wmOperatorType *ot; + ot = WM_operatortype_find("ANIM_OT_view_curve_in_graph_editor", false); + + uiItemFullO_ptr(layout, + ot, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "View in Graph Editor"), + ICON_NONE, + nullptr, + WM_OP_INVOKE_DEFAULT, + UI_ITEM_NONE, + &op_ptr); + RNA_boolean_set(&op_ptr, "all", false); + RNA_boolean_set(&op_ptr, "use_modifier_key", true); } } -- 2.30.2 From 406826a3280bdc8ac419fa24df9bf16af7f0760a Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 21 Nov 2023 11:06:17 +0100 Subject: [PATCH 29/30] remove ALT key to isolate --- .../editors/animation/anim_channels_edit.cc | 19 ------------------- .../interface/interface_context_menu.cc | 3 --- 2 files changed, 22 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index dccb98f2246..272ab3e0825 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4520,14 +4520,6 @@ static int view_curve_in_graph_editor_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int view_curve_in_graph_editor_invoke(bContext *C, wmOperator *op, const wmEvent *event) -{ - if (RNA_boolean_get(op->ptr, "use_modifier_key")) { - RNA_boolean_set(op->ptr, "isolate", event->modifier == KM_ALT); - } - return view_curve_in_graph_editor_exec(C, op); -} - static void ANIM_OT_view_curve_in_graph_editor(wmOperatorType *ot) { /* Identifiers */ @@ -4538,7 +4530,6 @@ static void ANIM_OT_view_curve_in_graph_editor(wmOperatorType *ot) "curves"; /* API callbacks */ - ot->invoke = view_curve_in_graph_editor_invoke; ot->exec = view_curve_in_graph_editor_exec; RNA_def_boolean(ot->srna, @@ -4552,16 +4543,6 @@ static void ANIM_OT_view_curve_in_graph_editor(wmOperatorType *ot) false, "Isolate", "Hides all other F-Curves other than the ones being framed"); - - PropertyRNA *prop = RNA_def_boolean( - ot->srna, - "use_modifier_key", - false, - "Use Modifier Key", - "Check the Alt key when the operator is executed to define the isolation behavior. If true, " - "overrides the isolate property"); - RNA_def_property_flag(prop, PROP_HIDDEN); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /** \} */ diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 85e65baaff0..ef2efbfd891 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -671,7 +671,6 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev UI_ITEM_NONE, &op_ptr); RNA_boolean_set(&op_ptr, "all", false); - RNA_boolean_set(&op_ptr, "use_modifier_key", true); uiItemFullO_ptr(layout, ot, @@ -682,7 +681,6 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev UI_ITEM_NONE, &op_ptr); RNA_boolean_set(&op_ptr, "all", true); - RNA_boolean_set(&op_ptr, "use_modifier_key", true); } else { PointerRNA op_ptr; @@ -698,7 +696,6 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev UI_ITEM_NONE, &op_ptr); RNA_boolean_set(&op_ptr, "all", false); - RNA_boolean_set(&op_ptr, "use_modifier_key", true); } } -- 2.30.2 From 682ae2c342a502f157ccc69842adf087f50cbcb3 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Tue, 21 Nov 2023 13:53:16 +0100 Subject: [PATCH 30/30] fix description to remove mention of the ALT hotkey --- source/blender/editors/animation/anim_channels_edit.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 272ab3e0825..4fd07486bbb 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -4525,9 +4525,7 @@ static void ANIM_OT_view_curve_in_graph_editor(wmOperatorType *ot) /* Identifiers */ ot->name = "View In Graph Editor"; ot->idname = "ANIM_OT_view_curve_in_graph_editor"; - ot->description = - "Frame the property under the cursor in the Graph Editor. Use Alt+Click to isolate the " - "curves"; + ot->description = "Frame the property under the cursor in the Graph Editor"; /* API callbacks */ ot->exec = view_curve_in_graph_editor_exec; -- 2.30.2