Drivers UI Cleanup (Part of T55145)
* Remove "Show Debug Info" option. Everyone has it turned on all the time, since it's just useful to have * Make the "Remove Driver" button less prominent. It doesn't happen that much, so it shouldn't take up as much room * Make "expressions" textbox wider (i.e. taking up the whole column width) by separating the label and textbox on separate lines. * Rename "Add Variable" button to make it clearer to users what "variables" may be (i.e. they serve as a way to specify Inputs, just like adding a "Source Data" node in a nodetree) * Regroup buttons
This commit is contained in:
@@ -117,7 +117,6 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
|
|||||||
|
|
||||||
/* add some new driver data */
|
/* add some new driver data */
|
||||||
fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver");
|
fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver");
|
||||||
fcu->driver->flag |= DRIVER_FLAG_SHOWDEBUG;
|
|
||||||
|
|
||||||
/* F-Modifier or Keyframes? */
|
/* F-Modifier or Keyframes? */
|
||||||
// FIXME: replace these magic numbers with defines
|
// FIXME: replace these magic numbers with defines
|
||||||
|
|||||||
@@ -776,7 +776,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
|
|||||||
DriverVar *dvar;
|
DriverVar *dvar;
|
||||||
|
|
||||||
PointerRNA driver_ptr;
|
PointerRNA driver_ptr;
|
||||||
uiLayout *col;
|
uiLayout *col, *row;
|
||||||
uiBlock *block;
|
uiBlock *block;
|
||||||
uiBut *but;
|
uiBut *but;
|
||||||
|
|
||||||
@@ -786,20 +786,20 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
|
|||||||
driver = fcu->driver;
|
driver = fcu->driver;
|
||||||
|
|
||||||
/* set event handler for panel */
|
/* set event handler for panel */
|
||||||
block = uiLayoutGetBlock(pa->layout); // xxx?
|
block = uiLayoutGetBlock(pa->layout);
|
||||||
UI_block_func_handle_set(block, do_graph_region_driver_buttons, NULL);
|
UI_block_func_handle_set(block, do_graph_region_driver_buttons, NULL);
|
||||||
|
|
||||||
/* general actions - management */
|
/* general actions - management */
|
||||||
col = uiLayoutColumn(pa->layout, false);
|
row = uiLayoutRow(pa->layout, true);
|
||||||
block = uiLayoutGetBlock(col);
|
block = uiLayoutGetBlock(row);
|
||||||
but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_FILE_REFRESH, IFACE_("Update Dependencies"),
|
but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_FILE_REFRESH, IFACE_("Update Dependencies"),
|
||||||
0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
|
0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
|
||||||
NULL, 0.0, 0.0, 0, 0,
|
NULL, 0.0, 0.0, 0, 0,
|
||||||
TIP_("Force updates of dependencies"));
|
TIP_("Force updates of dependencies"));
|
||||||
UI_but_func_set(but, driver_update_flags_cb, fcu, NULL);
|
UI_but_func_set(but, driver_update_flags_cb, fcu, NULL);
|
||||||
|
|
||||||
but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ZOOMOUT, IFACE_("Remove Driver"),
|
but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_X, "",
|
||||||
0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
|
0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||||
NULL, 0.0, 0.0, 0, 0,
|
NULL, 0.0, 0.0, 0, 0,
|
||||||
TIP_("Remove this driver"));
|
TIP_("Remove this driver"));
|
||||||
UI_but_funcN_set(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
|
UI_but_funcN_set(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
|
||||||
@@ -811,16 +811,36 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
|
|||||||
block = uiLayoutGetBlock(col);
|
block = uiLayoutGetBlock(col);
|
||||||
uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
|
uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
|
||||||
|
|
||||||
|
{
|
||||||
|
char valBuf[32];
|
||||||
|
|
||||||
|
/* value of driver */
|
||||||
|
row = uiLayoutRow(col, true);
|
||||||
|
uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
|
||||||
|
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
|
||||||
|
uiItemL(row, valBuf, ICON_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
|
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
|
||||||
if (driver->type == DRIVER_TYPE_PYTHON) {
|
if (driver->type == DRIVER_TYPE_PYTHON) {
|
||||||
bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL);
|
bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL);
|
||||||
bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL);
|
bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL);
|
||||||
|
|
||||||
/* expression */
|
/* expression */
|
||||||
uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
|
/* TODO: "Show syntax hints" button */
|
||||||
|
col = uiLayoutColumn(pa->layout, true);
|
||||||
|
block = uiLayoutGetBlock(col);
|
||||||
|
|
||||||
|
uiItemL(col, IFACE_("Expression:"), ICON_NONE);
|
||||||
|
uiItemR(col, &driver_ptr, "expression", 0, "", ICON_NONE);
|
||||||
|
uiItemR(col, &driver_ptr, "use_self", 0, NULL, ICON_NONE);
|
||||||
|
|
||||||
/* errors? */
|
/* errors? */
|
||||||
|
col = uiLayoutColumn(pa->layout, true);
|
||||||
|
block = uiLayoutGetBlock(col);
|
||||||
|
|
||||||
if ((G.f & G_SCRIPT_AUTOEXEC) == 0) {
|
if ((G.f & G_SCRIPT_AUTOEXEC) == 0) {
|
||||||
|
/* TODO: Add button to enable? */
|
||||||
uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL);
|
uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL);
|
||||||
}
|
}
|
||||||
else if (driver->flag & DRIVER_FLAG_INVALID) {
|
else if (driver->flag & DRIVER_FLAG_INVALID) {
|
||||||
@@ -842,6 +862,9 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* errors? */
|
/* errors? */
|
||||||
|
col = uiLayoutColumn(pa->layout, true);
|
||||||
|
block = uiLayoutGetBlock(col);
|
||||||
|
|
||||||
if (driver->flag & DRIVER_FLAG_INVALID)
|
if (driver->flag & DRIVER_FLAG_INVALID)
|
||||||
uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR);
|
uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR);
|
||||||
|
|
||||||
@@ -861,37 +884,15 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
col = uiLayoutColumn(pa->layout, true);
|
|
||||||
|
|
||||||
if (driver->type == DRIVER_TYPE_PYTHON) {
|
|
||||||
uiItemR(col, &driver_ptr, "use_self", 0, NULL, ICON_NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* debug setting */
|
|
||||||
uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE);
|
|
||||||
|
|
||||||
/* value of driver */
|
|
||||||
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
|
|
||||||
uiLayout *row = uiLayoutRow(col, true);
|
|
||||||
char valBuf[32];
|
|
||||||
|
|
||||||
uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
|
|
||||||
|
|
||||||
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
|
|
||||||
uiItemL(row, valBuf, ICON_NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add/copy/paste driver variables */
|
/* add/copy/paste driver variables */
|
||||||
{
|
{
|
||||||
uiLayout *row;
|
|
||||||
|
|
||||||
/* add driver variable */
|
/* add driver variable */
|
||||||
row = uiLayoutRow(pa->layout, false);
|
row = uiLayoutRow(pa->layout, false);
|
||||||
block = uiLayoutGetBlock(row);
|
block = uiLayoutGetBlock(row);
|
||||||
but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Variable"),
|
but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Input Variable"),
|
||||||
0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
|
0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
|
||||||
NULL, 0.0, 0.0, 0, 0,
|
NULL, 0.0, 0.0, 0, 0,
|
||||||
TIP_("Driver variables ensure that all dependencies will be accounted for and that drivers will update correctly"));
|
TIP_("Driver variables ensure that all dependencies will be accounted for, eusuring that drivers will update correctly"));
|
||||||
UI_but_func_set(but, driver_add_var_cb, driver, NULL);
|
UI_but_func_set(but, driver_add_var_cb, driver, NULL);
|
||||||
|
|
||||||
/* copy/paste (as sub-row) */
|
/* copy/paste (as sub-row) */
|
||||||
@@ -905,7 +906,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
|
|||||||
/* loop over targets, drawing them */
|
/* loop over targets, drawing them */
|
||||||
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
||||||
PointerRNA dvar_ptr;
|
PointerRNA dvar_ptr;
|
||||||
uiLayout *box, *row;
|
uiLayout *box;
|
||||||
uiLayout *subrow, *sub;
|
uiLayout *subrow, *sub;
|
||||||
|
|
||||||
/* sub-layout column for this variable's settings */
|
/* sub-layout column for this variable's settings */
|
||||||
@@ -968,7 +969,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 3) value of variable */
|
/* 3) value of variable */
|
||||||
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
|
{
|
||||||
char valBuf[32];
|
char valBuf[32];
|
||||||
|
|
||||||
box = uiLayoutBox(col);
|
box = uiLayoutBox(col);
|
||||||
|
|||||||
@@ -438,6 +438,7 @@ typedef enum eDriver_Types {
|
|||||||
} eDriver_Types;
|
} eDriver_Types;
|
||||||
|
|
||||||
/* driver flags */
|
/* driver flags */
|
||||||
|
/* note: (1<<5) is deprecated; was "DRIVER_FLAG_SHOWDEBUG" */
|
||||||
typedef enum eDriver_Flags {
|
typedef enum eDriver_Flags {
|
||||||
/* driver has invalid settings (internal flag) */
|
/* driver has invalid settings (internal flag) */
|
||||||
DRIVER_FLAG_INVALID = (1<<0),
|
DRIVER_FLAG_INVALID = (1<<0),
|
||||||
@@ -450,8 +451,6 @@ typedef enum eDriver_Flags {
|
|||||||
DRIVER_FLAG_RECOMPILE = (1<<3),
|
DRIVER_FLAG_RECOMPILE = (1<<3),
|
||||||
/* the names are cached so they don't need have python unicode versions created each time */
|
/* the names are cached so they don't need have python unicode versions created each time */
|
||||||
DRIVER_FLAG_RENAMEVAR = (1<<4),
|
DRIVER_FLAG_RENAMEVAR = (1<<4),
|
||||||
/* intermediate values of driver should be shown in the UI for debugging purposes */
|
|
||||||
DRIVER_FLAG_SHOWDEBUG = (1<<5),
|
|
||||||
/* include 'self' in the drivers namespace. */
|
/* include 'self' in the drivers namespace. */
|
||||||
DRIVER_FLAG_USE_SELF = (1<<6),
|
DRIVER_FLAG_USE_SELF = (1<<6),
|
||||||
} eDriver_Flags;
|
} eDriver_Flags;
|
||||||
|
|||||||
@@ -1640,11 +1640,6 @@ static void rna_def_channeldriver(BlenderRNA *brna)
|
|||||||
rna_def_channeldriver_variables(brna, prop);
|
rna_def_channeldriver_variables(brna, prop);
|
||||||
|
|
||||||
/* Settings */
|
/* Settings */
|
||||||
prop = RNA_def_property(srna, "show_debug_info", PROP_BOOLEAN, PROP_NONE);
|
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_SHOWDEBUG);
|
|
||||||
RNA_def_property_ui_text(prop, "Show Debug Info",
|
|
||||||
"Show intermediate values for the driver calculations to allow debugging of drivers");
|
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_USE_SELF);
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_USE_SELF);
|
||||||
RNA_def_property_ui_text(prop, "Use Self",
|
RNA_def_property_ui_text(prop, "Use Self",
|
||||||
|
|||||||
Reference in New Issue
Block a user