diff options
author | Hans Goudey <h.goudey@me.com> | 2021-02-19 19:11:35 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-02-19 19:11:35 +0300 |
commit | 1f5647c07d15d2b298b491ebe260a411f7b0d1b8 (patch) | |
tree | 7776a1724a24fa4391f2fd1c93827c2d4de63d63 /source/blender/editors/space_nla | |
parent | 0d94695cc458b1f7666104314b57b174f0ee93d1 (diff) |
UI: FModifier layout updates, drag and drop
This patch implements the list panel system D7490 for FCurve modifiers.
The UI layouts are updated to make use of subpanels and to be consistent
with the rest of the interface, and easier to understand.
See the differential revision for screenshots.
This commit also significantly cleans up the FModifier UI code, and
improves, mainly by replacing the old button creation code is with
the newer interface API using RNA. In turn there is a bit of complexity
added because each FModifier has a separate panel.
Although reordering of FModifiers was not implemented before, we get
drag and drop basically for free here, so it is also included.
As noted in some older to do tasks, FModifiers aren't evaluated
in perfect order, which may be a point of improvement for the future.
Differential Revision: https://developer.blender.org/D7997
Diffstat (limited to 'source/blender/editors/space_nla')
-rw-r--r-- | source/blender/editors/space_nla/nla_buttons.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index b82fcf3db47..d019573bf93 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -37,6 +37,7 @@ #include "BLT_translation.h" #include "BKE_context.h" +#include "BKE_fcurve.h" #include "BKE_nla.h" #include "BKE_screen.h" @@ -184,6 +185,17 @@ bool nla_panel_context(const bContext *C, return (found != 0); } +NlaStrip *ANIM_nla_context_strip(const bContext *C) +{ + PointerRNA strip_ptr; + if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) { + return NULL; + } + NlaStrip *strip = strip_ptr.data; + + return strip; +} + #if 0 static bool nla_panel_poll(const bContext *C, PanelType *pt) { @@ -535,13 +547,23 @@ static void nla_panel_animated_strip_time(const bContext *C, Panel *panel) uiItemR(layout, &strip_ptr, "strip_time", 0, NULL, ICON_NONE); } +#define NLA_FMODIFIER_PANEL_PREFIX "NLA" + +static void nla_fmodifier_panel_id(void *fcm_link, char *r_name) +{ + FModifier *fcm = (FModifier *)fcm_link; + eFModifier_Types type = fcm->type; + snprintf(r_name, BKE_ST_MAXNAME, "%s_PT_", NLA_FMODIFIER_PANEL_PREFIX); + const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type); + BLI_snprintf(r_name, BKE_ST_MAXNAME, "%s_PT_%s", NLA_FMODIFIER_PANEL_PREFIX, fmi->name); +} + /* F-Modifiers for active NLA-Strip */ static void nla_panel_modifiers(const bContext *C, Panel *panel) { PointerRNA strip_ptr; NlaStrip *strip; - FModifier *fcm; - uiLayout *col, *row; + uiLayout *row; uiBlock *block; /* check context and also validity of pointer */ @@ -569,12 +591,7 @@ static void nla_panel_modifiers(const bContext *C, Panel *panel) uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste"); } - /* draw each modifier */ - for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) { - col = uiLayoutColumn(panel->layout, true); - - ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.owner_id, &strip->modifiers, fcm); - } + ANIM_fmodifier_panels(C, strip_ptr.owner_id, &strip->modifiers, nla_fmodifier_panel_id); } /* ******************* general ******************************** */ @@ -657,5 +674,9 @@ void nla_buttons_register(ARegionType *art) strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = nla_panel_modifiers; pt->poll = nla_strip_eval_panel_poll; + pt->flag = PANEL_TYPE_NO_HEADER; BLI_addtail(&art->paneltypes, pt); + + ANIM_modifier_panels_register_graph_and_NLA( + art, NLA_FMODIFIER_PANEL_PREFIX, nla_strip_eval_panel_poll); } |