diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 4c79b57a16d..458ca9edc5c 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1893,32 +1893,45 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) return block; } +/* only for curvemap_tools_dofunc */ +enum { + UICURVE_FUNC_RESET_NEG, + UICURVE_FUNC_RESET_POS, + UICURVE_FUNC_RESET_VIEW, + UICURVE_FUNC_HANDLE_VECTOR, + UICURVE_FUNC_HANDLE_AUTO, + UICURVE_FUNC_EXTEND_HOZ, + UICURVE_FUNC_EXTEND_EXP, +}; + static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) { CurveMapping *cumap = cumap_v; CurveMap *cuma = cumap->cm + cumap->cur; switch (event) { - case 0: /* reset */ - curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); + case UICURVE_FUNC_RESET_NEG: + case UICURVE_FUNC_RESET_POS: /* reset */ + curvemap_reset(cuma, &cumap->clipr, cumap->preset, + (event == -1) ? CURVEMAP_SLOPE_NEGATIVE : CURVEMAP_SLOPE_POSITIVE); curvemapping_changed(cumap, FALSE); break; - case 1: + case UICURVE_FUNC_RESET_VIEW: cumap->curr = cumap->clipr; break; - case 2: /* set vector */ + case UICURVE_FUNC_HANDLE_VECTOR: /* set vector */ curvemap_sethandle(cuma, 1); curvemapping_changed(cumap, FALSE); break; - case 3: /* set auto */ + case UICURVE_FUNC_HANDLE_AUTO: /* set auto */ curvemap_sethandle(cuma, 0); curvemapping_changed(cumap, FALSE); break; - case 4: /* extend horiz */ + case UICURVE_FUNC_EXTEND_HOZ: /* extend horiz */ cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE; curvemapping_changed(cumap, FALSE); break; - case 5: /* extend extrapolate */ + case UICURVE_FUNC_EXTEND_EXP: /* extend extrapolate */ cuma->flag |= CUMA_EXTEND_EXTRAPOLATE; curvemapping_changed(cumap, FALSE); break; @@ -1935,17 +1948,17 @@ static uiBlock *curvemap_tools_func(bContext *C, ARegion *ar, void *cumap_v) uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, - menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, - menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, - menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco -= UI_UNIT_Y, - menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 4, ""); + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_HOZ, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco -= UI_UNIT_Y, - menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 5, ""); + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_EXP, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, - menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_POS, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); @@ -1963,13 +1976,13 @@ static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_ uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, - menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, - menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, ""); + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, - menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, ""); + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, - menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); + menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_NEG, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50);