Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_graph/graph_buttons.c
| Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | static void graph_panel_properties(const bContext *C, Panel *pa) | ||||
| char name[256]; | char name[256]; | ||||
| int icon = 0; | int icon = 0; | ||||
| if (!graph_panel_context(C, &ale, &fcu)) | if (!graph_panel_context(C, &ale, &fcu)) | ||||
| return; | return; | ||||
| // UNUSED | // UNUSED | ||||
| // block = uiLayoutGetBlock(layout); | // block = uiLayoutGetBlock(layout); | ||||
| // uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL); | // UI_block_func_handle_set(block, do_graph_region_buttons, NULL); | ||||
| /* F-Curve pointer */ | /* F-Curve pointer */ | ||||
| RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr); | RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr); | ||||
| /* user-friendly 'name' for F-Curve */ | /* user-friendly 'name' for F-Curve */ | ||||
| /* TODO: only show the path if this is invalid? */ | /* TODO: only show the path if this is invalid? */ | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| icon = getname_anim_fcurve(name, ale->id, fcu); | icon = getname_anim_fcurve(name, ale->id, fcu); | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | static void graph_panel_key_properties(const bContext *C, Panel *pa) | ||||
| uiLayout *layout = pa->layout; | uiLayout *layout = pa->layout; | ||||
| uiLayout *col; | uiLayout *col; | ||||
| uiBlock *block; | uiBlock *block; | ||||
| if (!graph_panel_context(C, &ale, &fcu)) | if (!graph_panel_context(C, &ale, &fcu)) | ||||
| return; | return; | ||||
| block = uiLayoutGetBlock(layout); | block = uiLayoutGetBlock(layout); | ||||
| /* uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL); */ | /* UI_block_func_handle_set(block, do_graph_region_buttons, NULL); */ | ||||
| /* only show this info if there are keyframes to edit */ | /* only show this info if there are keyframes to edit */ | ||||
| if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) { | if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) { | ||||
| PointerRNA bezt_ptr, id_ptr, fcu_prop_ptr; | PointerRNA bezt_ptr, id_ptr, fcu_prop_ptr; | ||||
| PropertyRNA *fcu_prop = NULL; | PropertyRNA *fcu_prop = NULL; | ||||
| uiBut *but; | uiBut *but; | ||||
| int unit = B_UNIT_NONE; | int unit = B_UNIT_NONE; | ||||
| Show All 34 Lines | if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) { | ||||
| * - we use the button-versions of the calls so that we can attach special update handlers | * - we use the button-versions of the calls so that we can attach special update handlers | ||||
| * and unit conversion magic that cannot be achieved using a purely RNA-approach | * and unit conversion magic that cannot be achieved using a purely RNA-approach | ||||
| */ | */ | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| /* keyframe itself */ | /* keyframe itself */ | ||||
| { | { | ||||
| uiItemL(col, IFACE_("Key:"), ICON_NONE); | uiItemL(col, IFACE_("Key:"), ICON_NONE); | ||||
| but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame:"), 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, IFACE_("Frame:"), 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| &bezt_ptr, "co", 0, 0, 0, -1, -1, NULL); | &bezt_ptr, "co", 0, 0, 0, -1, -1, NULL); | ||||
| uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); | UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt); | ||||
| but = uiDefButR(block, NUM, B_REDR, IFACE_("Value:"), 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, IFACE_("Value:"), 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| &bezt_ptr, "co", 1, 0, 0, -1, -1, NULL); | &bezt_ptr, "co", 1, 0, 0, -1, -1, NULL); | ||||
| uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); | UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt); | ||||
| uiButSetUnitType(but, unit); | UI_but_unit_type_set(but, unit); | ||||
| } | } | ||||
| /* previous handle - only if previous was Bezier interpolation */ | /* previous handle - only if previous was Bezier interpolation */ | ||||
| if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) { | if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) { | ||||
| uiItemL(col, IFACE_("Left Handle:"), ICON_NONE); | uiItemL(col, IFACE_("Left Handle:"), ICON_NONE); | ||||
| but = uiDefButR(block, NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| &bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL); | &bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL); | ||||
| uiButSetFunc(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt); | UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt); | ||||
| but = uiDefButR(block, NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| &bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL); | &bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL); | ||||
| uiButSetFunc(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt); | UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt); | ||||
| uiButSetUnitType(but, unit); | UI_but_unit_type_set(but, unit); | ||||
| /* XXX: with label? */ | /* XXX: with label? */ | ||||
| but = uiDefButR(block, MENU, B_REDR, NULL, 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefButR(block, UI_BTYPE_MENU, B_REDR, NULL, 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| &bezt_ptr, "handle_left_type", 0, 0, 0, -1, -1, "Type of left handle"); | &bezt_ptr, "handle_left_type", 0, 0, 0, -1, -1, "Type of left handle"); | ||||
| uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); | UI_but_func_set(but, graphedit_activekey_handles_cb, fcu, bezt); | ||||
| } | } | ||||
| /* next handle - only if current is Bezier interpolation */ | /* next handle - only if current is Bezier interpolation */ | ||||
| if (bezt->ipo == BEZT_IPO_BEZ) { | if (bezt->ipo == BEZT_IPO_BEZ) { | ||||
| /* NOTE: special update callbacks are needed on the coords here due to T39911 */ | /* NOTE: special update callbacks are needed on the coords here due to T39911 */ | ||||
| uiItemL(col, IFACE_("Right Handle:"), ICON_NONE); | uiItemL(col, IFACE_("Right Handle:"), ICON_NONE); | ||||
| but = uiDefButR(block, NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| &bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL); | &bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL); | ||||
| uiButSetFunc(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt); | UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt); | ||||
| but = uiDefButR(block, NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| &bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL); | &bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL); | ||||
| uiButSetFunc(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt); | UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt); | ||||
| uiButSetUnitType(but, unit); | UI_but_unit_type_set(but, unit); | ||||
| /* XXX: with label? */ | /* XXX: with label? */ | ||||
| but = uiDefButR(block, MENU, B_REDR, NULL, 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefButR(block, UI_BTYPE_MENU, B_REDR, NULL, 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| &bezt_ptr, "handle_right_type", 0, 0, 0, -1, -1, "Type of right handle"); | &bezt_ptr, "handle_right_type", 0, 0, 0, -1, -1, "Type of right handle"); | ||||
| uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); | UI_but_func_set(but, graphedit_activekey_handles_cb, fcu, bezt); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if ((fcu->bezt == NULL) && (fcu->modifiers.first)) { | if ((fcu->bezt == NULL) && (fcu->modifiers.first)) { | ||||
| /* modifiers only - so no keyframes to be active */ | /* modifiers only - so no keyframes to be active */ | ||||
| uiItemL(layout, IFACE_("F-Curve only has F-Modifiers"), ICON_NONE); | uiItemL(layout, IFACE_("F-Curve only has F-Modifiers"), ICON_NONE); | ||||
| uiItemL(layout, IFACE_("See Modifiers panel below"), ICON_INFO); | uiItemL(layout, IFACE_("See Modifiers panel below"), ICON_INFO); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | static void graph_panel_drivers(const bContext *C, Panel *pa) | ||||
| /* Get settings from context */ | /* Get settings from context */ | ||||
| if (!graph_panel_context(C, &ale, &fcu)) | if (!graph_panel_context(C, &ale, &fcu)) | ||||
| return; | return; | ||||
| 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); // xxx? | ||||
| uiBlockSetHandleFunc(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); | col = uiLayoutColumn(pa->layout, false); | ||||
| block = uiLayoutGetBlock(col); | block = uiLayoutGetBlock(col); | ||||
| but = uiDefIconTextBut(block, 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, 22, | 0, 0, 10 * UI_UNIT_X, 22, | ||||
| NULL, 0.0, 0.0, 0, 0, | NULL, 0.0, 0.0, 0, 0, | ||||
| TIP_("Force updates of dependencies")); | TIP_("Force updates of dependencies")); | ||||
| uiButSetFunc(but, driver_update_flags_cb, fcu, NULL); | UI_but_func_set(but, driver_update_flags_cb, fcu, NULL); | ||||
| but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_ZOOMOUT, IFACE_("Remove Driver"), | but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ZOOMOUT, IFACE_("Remove Driver"), | ||||
| 0, 0, 10 * UI_UNIT_X, 18, | 0, 0, 10 * UI_UNIT_X, 18, | ||||
| NULL, 0.0, 0.0, 0, 0, | NULL, 0.0, 0.0, 0, 0, | ||||
| TIP_("Remove this driver")); | TIP_("Remove this driver")); | ||||
| uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL); | UI_but_funcN_set(but, driver_remove_cb, MEM_dupallocN(ale), NULL); | ||||
| /* driver-level settings - type, expressions, and errors */ | /* driver-level settings - type, expressions, and errors */ | ||||
| RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr); | RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr); | ||||
| col = uiLayoutColumn(pa->layout, true); | col = uiLayoutColumn(pa->layout, true); | ||||
| block = uiLayoutGetBlock(col); | block = uiLayoutGetBlock(col); | ||||
| uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); | uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { | ||||
| BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); | BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); | ||||
| uiItemL(row, valBuf, ICON_NONE); | uiItemL(row, valBuf, ICON_NONE); | ||||
| } | } | ||||
| /* add driver variables */ | /* add driver variables */ | ||||
| col = uiLayoutColumn(pa->layout, false); | col = uiLayoutColumn(pa->layout, false); | ||||
| block = uiLayoutGetBlock(col); | block = uiLayoutGetBlock(col); | ||||
| but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Variable"), | but = uiDefIconTextBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add 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 and that drivers will update correctly")); | ||||
| uiButSetFunc(but, driver_add_var_cb, driver, NULL); | UI_but_func_set(but, driver_add_var_cb, driver, NULL); | ||||
| /* 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, *row; | ||||
| /* sub-layout column for this variable's settings */ | /* sub-layout column for this variable's settings */ | ||||
| col = uiLayoutColumn(pa->layout, true); | col = uiLayoutColumn(pa->layout, true); | ||||
| /* header panel */ | /* header panel */ | ||||
| box = uiLayoutBox(col); | box = uiLayoutBox(col); | ||||
| /* first row context info for driver */ | /* first row context info for driver */ | ||||
| RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); | RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); | ||||
| row = uiLayoutRow(box, false); | row = uiLayoutRow(box, false); | ||||
| block = uiLayoutGetBlock(row); | block = uiLayoutGetBlock(row); | ||||
| /* variable name */ | /* variable name */ | ||||
| uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); | uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); | ||||
| /* remove button */ | /* remove button */ | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefIconBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable")); | NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable")); | ||||
| uiButSetFunc(but, driver_delete_var_cb, driver, dvar); | UI_but_func_set(but, driver_delete_var_cb, driver, dvar); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| /* variable type */ | /* variable type */ | ||||
| row = uiLayoutRow(box, false); | row = uiLayoutRow(box, false); | ||||
| uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); | uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); | ||||
| /* variable type settings */ | /* variable type settings */ | ||||
| box = uiLayoutBox(col); | box = uiLayoutBox(col); | ||||
| /* controls to draw depends on the type of variable */ | /* controls to draw depends on the type of variable */ | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static void graph_panel_modifiers(const bContext *C, Panel *pa) | ||||
| FModifier *fcm; | FModifier *fcm; | ||||
| uiLayout *col, *row; | uiLayout *col, *row; | ||||
| uiBlock *block; | uiBlock *block; | ||||
| if (!graph_panel_context(C, &ale, &fcu)) | if (!graph_panel_context(C, &ale, &fcu)) | ||||
| return; | return; | ||||
| block = uiLayoutGetBlock(pa->layout); | block = uiLayoutGetBlock(pa->layout); | ||||
| uiBlockSetHandleFunc(block, do_graph_region_modifier_buttons, NULL); | UI_block_func_handle_set(block, do_graph_region_modifier_buttons, NULL); | ||||
| /* 'add modifier' button at top of panel */ | /* 'add modifier' button at top of panel */ | ||||
| { | { | ||||
| row = uiLayoutRow(pa->layout, false); | row = uiLayoutRow(pa->layout, false); | ||||
| block = uiLayoutGetBlock(row); | block = uiLayoutGetBlock(row); | ||||
| /* this is an operator button which calls a 'add modifier' operator... | /* this is an operator button which calls a 'add modifier' operator... | ||||
| * a menu might be nicer but would be tricky as we need some custom filtering | * a menu might be nicer but would be tricky as we need some custom filtering | ||||
| */ | */ | ||||
| uiDefButO(block, BUT, "GRAPH_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"), | uiDefButO(block, UI_BTYPE_BUT, "GRAPH_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"), | ||||
| 0.5 * UI_UNIT_X, 0, 7.5 * UI_UNIT_X, UI_UNIT_Y, TIP_("Adds a new F-Curve Modifier for the active F-Curve")); | 0.5 * UI_UNIT_X, 0, 7.5 * UI_UNIT_X, UI_UNIT_Y, TIP_("Adds a new F-Curve Modifier for the active F-Curve")); | ||||
| /* copy/paste (as sub-row)*/ | /* copy/paste (as sub-row)*/ | ||||
| row = uiLayoutRow(row, true); | row = uiLayoutRow(row, true); | ||||
| uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy"); | uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy"); | ||||
| uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); | uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines | |||||