diff options
author | Joshua Leung <aligorith@gmail.com> | 2018-05-23 16:03:59 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2018-05-23 17:32:46 +0300 |
commit | 57b47ebb284c03fd6d9863bf0ec9ddbb672e2034 (patch) | |
tree | 071448df3238035de03375b5ba969f0e0ccad160 /source/blender/editors/space_graph/graph_buttons.c | |
parent | 83ed0df1c2f2b6d27de5bd2f8656931ab6bf8f6c (diff) |
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
Diffstat (limited to 'source/blender/editors/space_graph/graph_buttons.c')
-rw-r--r-- | source/blender/editors/space_graph/graph_buttons.c | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 3f64217a021..d7905a0c2d9 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -776,7 +776,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) DriverVar *dvar; PointerRNA driver_ptr; - uiLayout *col; + uiLayout *col, *row; uiBlock *block; uiBut *but; @@ -786,20 +786,20 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) driver = fcu->driver; /* 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); /* general actions - management */ - col = uiLayoutColumn(pa->layout, false); - block = uiLayoutGetBlock(col); + row = uiLayoutRow(pa->layout, true); + block = uiLayoutGetBlock(row); but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_FILE_REFRESH, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies")); 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"), - 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y, + but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_X, "", + 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver")); UI_but_funcN_set(but, driver_remove_cb, MEM_dupallocN(ale), NULL); @@ -810,6 +810,16 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) col = uiLayoutColumn(pa->layout, true); block = uiLayoutGetBlock(col); 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 */ if (driver->type == DRIVER_TYPE_PYTHON) { @@ -817,10 +827,20 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL); /* 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? */ + col = uiLayoutColumn(pa->layout, true); + block = uiLayoutGetBlock(col); + if ((G.f & G_SCRIPT_AUTOEXEC) == 0) { + /* TODO: Add button to enable? */ uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL); } else if (driver->flag & DRIVER_FLAG_INVALID) { @@ -842,6 +862,9 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) } else { /* errors? */ + col = uiLayoutColumn(pa->layout, true); + block = uiLayoutGetBlock(col); + if (driver->flag & DRIVER_FLAG_INVALID) uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR); @@ -860,38 +883,16 @@ 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 */ { - uiLayout *row; - /* add driver variable */ row = uiLayoutRow(pa->layout, false); 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, 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); /* copy/paste (as sub-row) */ @@ -905,7 +906,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* loop over targets, drawing them */ for (dvar = driver->variables.first; dvar; dvar = dvar->next) { PointerRNA dvar_ptr; - uiLayout *box, *row; + uiLayout *box; uiLayout *subrow, *sub; /* 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 */ - if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { + { char valBuf[32]; box = uiLayoutBox(col); |