Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/anim_channels_edit.c
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
| #include "ED_keyframes_edit.h" /* XXX move the select modes out of there! */ | #include "ED_keyframes_edit.h" /* XXX move the select modes out of there! */ | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_select_utils.h" | #include "ED_select_utils.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| /* ************************************************************************** */ | /* -------------------------------------------------------------------- */ | ||||
| /* CHANNELS API - Exposed API */ | /** \name Public Channel Selection API | ||||
| * \{ */ | |||||
| /* -------------------------- Selection ------------------------------------- */ | |||||
| void ANIM_set_active_channel(bAnimContext *ac, | void ANIM_set_active_channel(bAnimContext *ac, | ||||
| void *data, | void *data, | ||||
| eAnimCont_Types datatype, | eAnimCont_Types datatype, | ||||
| eAnimFilter_Flags filter, | eAnimFilter_Flags filter, | ||||
| void *channel_data, | void *channel_data, | ||||
| eAnim_ChannelType channel_type) | eAnim_ChannelType channel_type) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 389 Lines • ▼ Show 20 Lines | |||||
| void ANIM_anim_channels_select_toggle(bAnimContext *ac) | void ANIM_anim_channels_select_toggle(bAnimContext *ac) | ||||
| { | { | ||||
| ListBase anim_data = anim_channels_for_selection(ac); | ListBase anim_data = anim_channels_for_selection(ac); | ||||
| const eAnimChannels_SetFlag sel = anim_channels_selection_flag_for_toggle(anim_data); | const eAnimChannels_SetFlag sel = anim_channels_selection_flag_for_toggle(anim_data); | ||||
| anim_channels_select_set(ac, anim_data, sel); | anim_channels_select_set(ac, anim_data, sel); | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| } | } | ||||
| /* ---------------------------- Graph Editor ------------------------------------- */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Public Graph Editor API | |||||
| * \{ */ | |||||
| /* Copy a certain channel setting to parents of the modified channel. */ | /* Copy a certain channel setting to parents of the modified channel. */ | ||||
| static void anim_flush_channel_setting_up(bAnimContext *ac, | static void anim_flush_channel_setting_up(bAnimContext *ac, | ||||
| const eAnimChannel_Settings setting, | const eAnimChannel_Settings setting, | ||||
| const eAnimChannels_SetFlag mode, | const eAnimChannels_SetFlag mode, | ||||
| bAnimListElem *const match, | bAnimListElem *const match, | ||||
| const int matchLevel) | const int matchLevel) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | if (match == NULL) { | ||||
| */ | */ | ||||
| matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0; | matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0; | ||||
| } | } | ||||
| anim_flush_channel_setting_up(ac, setting, mode, match, matchLevel); | anim_flush_channel_setting_up(ac, setting, mode, match, matchLevel); | ||||
| anim_flush_channel_setting_down(ac, setting, mode, match, matchLevel); | anim_flush_channel_setting_down(ac, setting, mode, match, matchLevel); | ||||
| } | } | ||||
| /* -------------------------- F-Curves ------------------------------------- */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Public F-Curves API | |||||
| * \{ */ | |||||
| void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *fcu) | void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *fcu) | ||||
| { | { | ||||
| /* - if no AnimData, we've got nowhere to remove the F-Curve from | /* - if no AnimData, we've got nowhere to remove the F-Curve from | ||||
| * (this doesn't guarantee that the F-Curve is in there, but at least we tried | * (this doesn't guarantee that the F-Curve is in there, but at least we tried | ||||
| * - if no F-Curve, there is nothing to remove | * - if no F-Curve, there is nothing to remove | ||||
| */ | */ | ||||
| if (ELEM(NULL, adt, fcu)) { | if (ELEM(NULL, adt, fcu)) { | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if (BLI_listbase_is_empty(&act->curves) && (adt->flag & ADT_NLA_EDIT_ON) == 0) { | ||||
| adt->action = NULL; | adt->action = NULL; | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* ************************************************************************** */ | /** \} */ | ||||
| /* OPERATORS */ | |||||
| /* ****************** Operator Utilities ********************************** */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Operator Utilities | |||||
| * \{ */ | |||||
| /* poll callback for being in an Animation Editor channels list region */ | /* poll callback for being in an Animation Editor channels list region */ | ||||
| static bool animedit_poll_channels_active(bContext *C) | static bool animedit_poll_channels_active(bContext *C) | ||||
| { | { | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| /* channels region test */ | /* channels region test */ | ||||
| /* TODO: could enhance with actually testing if channels region? */ | /* TODO: could enhance with actually testing if channels region? */ | ||||
| Show All 29 Lines | if (area->spacetype == SPACE_NLA) { | ||||
| if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) { | if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* ****************** Rearrange Channels Operator ******************* */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Move (Rearrange) Channels Operator | |||||
| * \{ */ | |||||
| /* constants for channel rearranging */ | /* constants for channel rearranging */ | ||||
| /* WARNING: don't change existing ones without modifying rearrange func accordingly */ | /* WARNING: don't change existing ones without modifying rearrange func accordingly */ | ||||
| typedef enum eRearrangeAnimChan_Mode { | typedef enum eRearrangeAnimChan_Mode { | ||||
| REARRANGE_ANIMCHAN_TOP = -2, | REARRANGE_ANIMCHAN_TOP = -2, | ||||
| REARRANGE_ANIMCHAN_UP = -1, | REARRANGE_ANIMCHAN_UP = -1, | ||||
| REARRANGE_ANIMCHAN_DOWN = 1, | REARRANGE_ANIMCHAN_DOWN = 1, | ||||
| REARRANGE_ANIMCHAN_BOTTOM = 2, | REARRANGE_ANIMCHAN_BOTTOM = 2, | ||||
| ▲ Show 20 Lines • Show All 816 Lines • ▼ Show 20 Lines | static void ANIM_OT_channels_move(wmOperatorType *ot) | ||||
| ot->prop = RNA_def_enum(ot->srna, | ot->prop = RNA_def_enum(ot->srna, | ||||
| "direction", | "direction", | ||||
| prop_animchannel_rearrange_types, | prop_animchannel_rearrange_types, | ||||
| REARRANGE_ANIMCHAN_DOWN, | REARRANGE_ANIMCHAN_DOWN, | ||||
| "Direction", | "Direction", | ||||
| ""); | ""); | ||||
| } | } | ||||
| /* ******************** Group Channel Operator ************************ */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Group Channel Operator | |||||
| * \{ */ | |||||
| static bool animchannels_grouping_poll(bContext *C) | static bool animchannels_grouping_poll(bContext *C) | ||||
| { | { | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| SpaceLink *sl; | SpaceLink *sl; | ||||
| /* channels region test */ | /* channels region test */ | ||||
| /* TODO: could enhance with actually testing if channels region? */ | /* TODO: could enhance with actually testing if channels region? */ | ||||
| ▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | ot->prop = RNA_def_string(ot->srna, | ||||
| "New Group", | "New Group", | ||||
| sizeof(((bActionGroup *)NULL)->name), | sizeof(((bActionGroup *)NULL)->name), | ||||
| "Name", | "Name", | ||||
| "Name of newly created group"); | "Name of newly created group"); | ||||
| /* XXX: still not too sure about this - keeping same text is confusing... */ | /* XXX: still not too sure about this - keeping same text is confusing... */ | ||||
| // RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); | // RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); | ||||
| } | } | ||||
| /* ----------------------------------------------------------- */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Ungroup Channels Operator | |||||
| * \{ */ | |||||
| static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) | static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| bAnimListElem *ale; | bAnimListElem *ale; | ||||
| int filter; | int filter; | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | static void ANIM_OT_channels_ungroup(wmOperatorType *ot) | ||||
| /* callbacks */ | /* callbacks */ | ||||
| ot->exec = animchannels_ungroup_exec; | ot->exec = animchannels_ungroup_exec; | ||||
| ot->poll = animchannels_grouping_poll; | ot->poll = animchannels_grouping_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| /* ******************** Delete Channel Operator *********************** */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Delete Channel Operator | |||||
| * \{ */ | |||||
| static void tag_update_animation_element(bAnimListElem *ale) | static void tag_update_animation_element(bAnimListElem *ale) | ||||
| { | { | ||||
| ID *id = ale->id; | ID *id = ale->id; | ||||
| AnimData *adt = BKE_animdata_from_id(id); | AnimData *adt = BKE_animdata_from_id(id); | ||||
| /* TODO(sergey): Technically, if the animation element is being deleted | /* TODO(sergey): Technically, if the animation element is being deleted | ||||
| * from a driver we don't have to tag action. This is something we can check | * from a driver we don't have to tag action. This is something we can check | ||||
| * for in the future. For now just do most reliable tag which was always happening. */ | * for in the future. For now just do most reliable tag which was always happening. */ | ||||
| ▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | static void ANIM_OT_channels_delete(wmOperatorType *ot) | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = animchannels_delete_exec; | ot->exec = animchannels_delete_exec; | ||||
| ot->poll = animedit_poll_channels_active; | ot->poll = animedit_poll_channels_active; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| /* ********************** Set Flags Operator *********************** */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Set/Toggle Channel Flags Operator Utilities | |||||
| * \{ */ | |||||
| /* defines for setting animation-channel flags */ | /* defines for setting animation-channel flags */ | ||||
| static const EnumPropertyItem prop_animchannel_setflag_types[] = { | static const EnumPropertyItem prop_animchannel_setflag_types[] = { | ||||
| {ACHANNEL_SETFLAG_TOGGLE, "TOGGLE", 0, "Toggle", ""}, | {ACHANNEL_SETFLAG_TOGGLE, "TOGGLE", 0, "Toggle", ""}, | ||||
| {ACHANNEL_SETFLAG_CLEAR, "DISABLE", 0, "Disable", ""}, | {ACHANNEL_SETFLAG_CLEAR, "DISABLE", 0, "Disable", ""}, | ||||
| {ACHANNEL_SETFLAG_ADD, "ENABLE", 0, "Enable", ""}, | {ACHANNEL_SETFLAG_ADD, "ENABLE", 0, "Enable", ""}, | ||||
| {ACHANNEL_SETFLAG_INVERT, "INVERT", 0, "Invert", ""}, | {ACHANNEL_SETFLAG_INVERT, "INVERT", 0, "Invert", ""}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| ▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | static void ANIM_OT_channels_editable_toggle(wmOperatorType *ot) | ||||
| RNA_def_enum( | RNA_def_enum( | ||||
| ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); | ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); | ||||
| /* setting to set */ | /* setting to set */ | ||||
| prop = RNA_def_enum( | prop = RNA_def_enum( | ||||
| ot->srna, "type", prop_animchannel_settings_types, ACHANNEL_SETTING_PROTECT, "Type", ""); | ot->srna, "type", prop_animchannel_settings_types, ACHANNEL_SETTING_PROTECT, "Type", ""); | ||||
| RNA_def_property_flag(prop, PROP_HIDDEN); /* internal hack - don't expose */ | RNA_def_property_flag(prop, PROP_HIDDEN); /* internal hack - don't expose */ | ||||
| } | } | ||||
| /* ********************** Expand Channels Operator *********************** */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Expand Channels Operator | |||||
| * \{ */ | |||||
| static int animchannels_expand_exec(bContext *C, wmOperator *op) | static int animchannels_expand_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| bool onlysel = true; | bool onlysel = true; | ||||
| /* get editor data */ | /* get editor data */ | ||||
| if (ANIM_animdata_get_context(C, &ac) == 0) { | if (ANIM_animdata_get_context(C, &ac) == 0) { | ||||
| Show All 28 Lines | static void ANIM_OT_channels_expand(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* props */ | /* props */ | ||||
| ot->prop = RNA_def_boolean( | ot->prop = RNA_def_boolean( | ||||
| ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)"); | ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)"); | ||||
| } | } | ||||
| /* ********************** Collapse Channels Operator *********************** */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Collapse Channels Operator | |||||
| * \{ */ | |||||
| static int animchannels_collapse_exec(bContext *C, wmOperator *op) | static int animchannels_collapse_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| bool onlysel = true; | bool onlysel = true; | ||||
| /* get editor data */ | /* get editor data */ | ||||
| if (ANIM_animdata_get_context(C, &ac) == 0) { | if (ANIM_animdata_get_context(C, &ac) == 0) { | ||||
| Show All 28 Lines | static void ANIM_OT_channels_collapse(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* props */ | /* props */ | ||||
| ot->prop = RNA_def_boolean( | ot->prop = RNA_def_boolean( | ||||
| ot->srna, "all", true, "All", "Collapse all channels (not just selected ones)"); | ot->srna, "all", true, "All", "Collapse all channels (not just selected ones)"); | ||||
| } | } | ||||
| /* ************ Remove All "Empty" AnimData Blocks Operator ********* */ | /** \} */ | ||||
| /* We define "empty" AnimData blocks here as those which have all 3 of criteria: | |||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Remove All "Empty" AnimData Blocks Operator | |||||
| * | |||||
| * We define "empty" AnimData blocks here as those which have all 3 of criteria: | |||||
| * | |||||
| * 1) No active action OR that active actions are empty | * 1) No active action OR that active actions are empty | ||||
| * Assuming that all legitimate entries will have an action, | * Assuming that all legitimate entries will have an action, | ||||
| * and that empty actions | * and that empty actions | ||||
| * 2) No NLA Tracks + NLA Strips | * 2) No NLA Tracks + NLA Strips | ||||
| * Assuming that users haven't set up any of these as "placeholders" | * Assuming that users haven't set up any of these as "placeholders" | ||||
| * for convenience sake, and that most that exist were either unintentional | * for convenience sake, and that most that exist were either unintentional | ||||
| * or are no longer wanted | * or are no longer wanted | ||||
| * 3) No drivers | * 3) No drivers | ||||
| */ | * \{ */ | ||||
| static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) | static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| bAnimListElem *ale; | bAnimListElem *ale; | ||||
| int filter; | int filter; | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | static void ANIM_OT_channels_clean_empty(wmOperatorType *ot) | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = animchannels_clean_empty_exec; | ot->exec = animchannels_clean_empty_exec; | ||||
| ot->poll = animedit_poll_channels_nla_tweakmode_off; | ot->poll = animedit_poll_channels_nla_tweakmode_off; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| /* ******************* Reenable Disabled Operator ******************* */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Re-enable Disabled Operator | |||||
| * \{ */ | |||||
| static bool animchannels_enable_poll(bContext *C) | static bool animchannels_enable_poll(bContext *C) | ||||
| { | { | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| /* channels region test */ | /* channels region test */ | ||||
| /* TODO: could enhance with actually testing if channels region? */ | /* TODO: could enhance with actually testing if channels region? */ | ||||
| if (ELEM(NULL, area, CTX_wm_region(C))) { | if (ELEM(NULL, area, CTX_wm_region(C))) { | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = animchannels_enable_exec; | ot->exec = animchannels_enable_exec; | ||||
| ot->poll = animchannels_enable_poll; | ot->poll = animchannels_enable_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| /* ****************** Select Filter Textbox Operator ******************** */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Select Filter Text-box Operator | |||||
| * \{ */ | |||||
| /* XXX: make this generic? */ | /* XXX: make this generic? */ | ||||
| static bool animchannels_select_filter_poll(bContext *C) | static bool animchannels_select_filter_poll(bContext *C) | ||||
| { | { | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| if (area == NULL) { | if (area == NULL) { | ||||
| return false; | return false; | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | ot->description = | ||||
| "matching names"; | "matching names"; | ||||
| /* callbacks */ | /* callbacks */ | ||||
| ot->invoke = animchannels_select_filter_invoke; | ot->invoke = animchannels_select_filter_invoke; | ||||
| ot->modal = animchannels_select_filter_modal; | ot->modal = animchannels_select_filter_modal; | ||||
| ot->poll = animchannels_select_filter_poll; | ot->poll = animchannels_select_filter_poll; | ||||
| } | } | ||||
| /* ********************** Select All Operator *********************** */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Select All Operator | |||||
| * \{ */ | |||||
| static int animchannels_selectall_exec(bContext *C, wmOperator *op) | static int animchannels_selectall_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| /* get editor data */ | /* get editor data */ | ||||
| if (ANIM_animdata_get_context(C, &ac) == 0) { | if (ANIM_animdata_get_context(C, &ac) == 0) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| Show All 38 Lines | static void ANIM_OT_channels_select_all(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* properties */ | /* properties */ | ||||
| WM_operator_properties_select_all(ot); | WM_operator_properties_select_all(ot); | ||||
| } | } | ||||
| /* ******************** Box Select Operator *********************** */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Box Select Operator | |||||
| * \{ */ | |||||
| static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectmode) | static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectmode) | ||||
| { | { | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| bAnimListElem *ale; | bAnimListElem *ale; | ||||
| int filter; | int filter; | ||||
| SpaceNla *snla = (SpaceNla *)ac->sl; | SpaceNla *snla = (SpaceNla *)ac->sl; | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | for (ale = anim_data.first; ale; ale = ale->next) { | ||||
| /* set minimum extent to be the maximum of the next channel */ | /* set minimum extent to be the maximum of the next channel */ | ||||
| ymax = ymin; | ymax = ymin; | ||||
| } | } | ||||
| /* cleanup */ | /* cleanup */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| } | } | ||||
| /* ------------------- */ | |||||
| static int animchannels_box_select_exec(bContext *C, wmOperator *op) | static int animchannels_box_select_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| rcti rect; | rcti rect; | ||||
| short selectmode = 0; | short selectmode = 0; | ||||
| const bool select = !RNA_boolean_get(op->ptr, "deselect"); | const bool select = !RNA_boolean_get(op->ptr, "deselect"); | ||||
| const bool extend = RNA_boolean_get(op->ptr, "extend"); | const bool extend = RNA_boolean_get(op->ptr, "extend"); | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | static void ANIM_OT_channels_select_box(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| /* rna */ | /* rna */ | ||||
| WM_operator_properties_gesture_box_select(ot); | WM_operator_properties_gesture_box_select(ot); | ||||
| } | } | ||||
| /* ******************* Rename Operator ***************************** */ | /** \} */ | ||||
| /* Allow renaming some channels by clicking on them */ | |||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Rename Channel Operator | |||||
| * | |||||
| * Allow renaming some channels by clicking on them. | |||||
| * \{ */ | |||||
| static bool rename_anim_channels(bAnimContext *ac, int channel_index) | static bool rename_anim_channels(bAnimContext *ac, int channel_index) | ||||
| { | { | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| const bAnimChannelType *acf; | const bAnimChannelType *acf; | ||||
| bAnimListElem *ale; | bAnimListElem *ale; | ||||
| int filter; | int filter; | ||||
| bool success = false; | bool success = false; | ||||
| ▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | static void ANIM_OT_channels_rename(wmOperatorType *ot) | ||||
| ot->idname = "ANIM_OT_channels_rename"; | ot->idname = "ANIM_OT_channels_rename"; | ||||
| ot->description = "Rename animation channel under mouse"; | ot->description = "Rename animation channel under mouse"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->invoke = animchannels_rename_invoke; | ot->invoke = animchannels_rename_invoke; | ||||
| ot->poll = animedit_poll_channels_active; | ot->poll = animedit_poll_channels_active; | ||||
| } | } | ||||
| /* ******************** Mouse-Click Operator *********************** */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Select Channel Keyframes Operator (Internal Logic) | |||||
| * \{ */ | |||||
| /* Handle selection changes due to clicking on channels. Settings will get caught by UI code... */ | /* Handle selection changes due to clicking on channels. Settings will get caught by UI code... */ | ||||
| static int click_select_channel_scene(bAnimListElem *ale, | static int click_select_channel_scene(bAnimListElem *ale, | ||||
| const short /* eEditKeyframes_Select or -1 */ selectmode) | const short /* eEditKeyframes_Select or -1 */ selectmode) | ||||
| { | { | ||||
| Scene *sce = (Scene *)ale->data; | Scene *sce = (Scene *)ale->data; | ||||
| AnimData *adt = sce->adt; | AnimData *adt = sce->adt; | ||||
| ▲ Show 20 Lines • Show All 426 Lines • ▼ Show 20 Lines | static int mouse_anim_channels(bContext *C, | ||||
| /* free channels */ | /* free channels */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| /* return notifier flags */ | /* return notifier flags */ | ||||
| return notifierFlags; | return notifierFlags; | ||||
| } | } | ||||
| /* ------------------- */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Select Channel Keyframes Operator | |||||
| * \{ */ | |||||
| /* handle clicking */ | /** Handle picking logic. */ | ||||
| static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| ARegion *region; | ARegion *region; | ||||
| View2D *v2d; | View2D *v2d; | ||||
| int channel_index; | int channel_index; | ||||
| int notifierFlags = 0; | int notifierFlags = 0; | ||||
| short selectmode; | short selectmode; | ||||
| ▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | static void ANIM_OT_channel_select_keys(wmOperatorType *ot) | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->invoke = animchannels_channel_select_keys_invoke; | ot->invoke = animchannels_channel_select_keys_invoke; | ||||
| ot->poll = animedit_poll_channels_active; | ot->poll = animedit_poll_channels_active; | ||||
| prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection"); | prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection"); | ||||
| RNA_def_property_flag(prop, PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_SKIP_SAVE); | ||||
| } | } | ||||
| /* ************************************************************************** */ | /** \} */ | ||||
| /* Operator Registration */ | |||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Operator Registration | |||||
| * \{ */ | |||||
| void ED_operatortypes_animchannels(void) | void ED_operatortypes_animchannels(void) | ||||
| { | { | ||||
| WM_operatortype_append(ANIM_OT_channels_select_all); | WM_operatortype_append(ANIM_OT_channels_select_all); | ||||
| WM_operatortype_append(ANIM_OT_channels_select_box); | WM_operatortype_append(ANIM_OT_channels_select_box); | ||||
| WM_operatortype_append(ANIM_OT_channels_click); | WM_operatortype_append(ANIM_OT_channels_click); | ||||
| WM_operatortype_append(ANIM_OT_channel_select_keys); | WM_operatortype_append(ANIM_OT_channel_select_keys); | ||||
| Show All 24 Lines | |||||
| } | } | ||||
| /* TODO: check on a poll callback for this, to get hotkeys into menus */ | /* TODO: check on a poll callback for this, to get hotkeys into menus */ | ||||
| void ED_keymap_animchannels(wmKeyConfig *keyconf) | void ED_keymap_animchannels(wmKeyConfig *keyconf) | ||||
| { | { | ||||
| WM_keymap_ensure(keyconf, "Animation Channels", 0, 0); | WM_keymap_ensure(keyconf, "Animation Channels", 0, 0); | ||||
| } | } | ||||
| /* ************************************************************************** */ | /** \} */ | ||||