diff options
author | Joshua Leung <aligorith@gmail.com> | 2018-05-22 17:22:28 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2018-05-22 17:44:13 +0300 |
commit | 6573af5211161bc621cd8f5d2bf6284666bb4381 (patch) | |
tree | e8bed63d17ab9958b82b04ae98c416b0c872b9e0 | |
parent | c685c19df9513a3263e78b417a87fc102840437e (diff) |
Drivers Editor UI Tweaks (Part of T55145)
To bring the UI more in line with the proposed design in T54653 for the "Add Drivers"
popup panel (NOTE: this is separate from the "Drivers Editor", in previous commit!),
this commit adds a new panel - "Driven Property" to the Drivers Editor UI.
This basically duplicates the "Active F-Curve" panel (with less options)
to make it easier to see at a glance which property the Drivers Editor is
showing you.
-rw-r--r-- | source/blender/editors/space_graph/graph_buttons.c | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index c79652795ac..cc7448fafd6 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -728,6 +728,50 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE); } + +/* property driven by the driver - duplicates Active FCurve, but useful for clarity */ +static void graph_panel_driven_property(const bContext *C, Panel *pa) +{ + bAnimListElem *ale; + FCurve *fcu; + PointerRNA fcu_ptr; + uiLayout *layout = pa->layout; + char name[256]; + int icon = 0; + + if (!graph_panel_context(C, &ale, &fcu)) + return; + + /* F-Curve pointer */ + RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr); + + /* user-friendly 'name' for F-Curve */ + if (ale->type == ANIMTYPE_FCURVE) { + /* get user-friendly name for F-Curve */ + icon = getname_anim_fcurve(name, ale->id, fcu); + } + else { + /* NLA Control Curve, etc. */ + const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + + /* get name */ + if (acf && acf->name) { + acf->name(ale, name); + } + else { + strcpy(name, IFACE_("<invalid>")); + icon = ICON_ERROR; + } + + /* icon */ + if (ale->type == ANIMTYPE_NLACURVE) + icon = ICON_NLA; + } + uiItemL(layout, name, icon); + + MEM_freeN(ale); +} + /* driver settings for active F-Curve (only for 'Drivers' mode) */ static void graph_panel_drivers(const bContext *C, Panel *pa) { @@ -1035,10 +1079,18 @@ void graph_buttons_register(ARegionType *art) pt->poll = graph_panel_poll; BLI_addtail(&art->paneltypes, pt); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers driven"); + strcpy(pt->idname, "GRAPH_PT_driven_property"); + strcpy(pt->label, N_("Driven Property")); + strcpy(pt->category, "Drivers"); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + pt->draw = graph_panel_driven_property; + pt->poll = graph_panel_drivers_poll; + BLI_addtail(&art->paneltypes, pt); pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers"); strcpy(pt->idname, "GRAPH_PT_drivers"); - strcpy(pt->label, N_("Drivers")); + strcpy(pt->label, N_("Driver")); strcpy(pt->category, "Drivers"); strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = graph_panel_drivers; |