Fix T40885: "Reset Curve" is backwards on Custom Falloff Curves (Lights).

Add ability to define negative slope by default to curvemapping template...
This commit is contained in:
Bastien Montagne 2014-06-30 16:20:02 +02:00
parent 03929ae202
commit 2e64b8354b
Notes: blender-bot 2023-02-14 10:24:46 +01:00
Referenced by issue #40885, "Reset Curve" is backwards on Custom Falloff Curves (Lights)
6 changed files with 48 additions and 13 deletions

View File

@ -378,7 +378,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
def draw(self, context):
lamp = context.lamp
self.layout.template_curve_mapping(lamp, "falloff_curve")
self.layout.template_curve_mapping(lamp, "falloff_curve", use_negative_slope=True)
class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, Panel):

View File

@ -844,7 +844,8 @@ void uiTemplateIconView(uiLayout *layout, struct PointerRNA *ptr, const char *pr
void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, int levels, int brush);
void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type,
int levels, int brush, int neg_slope);
void uiTemplateColorPicker(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic);
void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
PointerRNA *used_ptr, const char *used_propname, int active_layer);

View File

@ -1954,7 +1954,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
ED_region_tag_redraw(CTX_wm_region(C));
}
static uiBlock *curvemap_tools_func(bContext *C, ARegion *ar, void *cumap_v)
static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *ar, void *cumap_v)
{
uiBlock *block;
short yco = 0, menuwidth = 10 * UI_UNIT_X;
@ -1982,6 +1982,34 @@ static uiBlock *curvemap_tools_func(bContext *C, ARegion *ar, void *cumap_v)
return block;
}
static uiBlock *curvemap_tools_negslope_func(bContext *C, ARegion *ar, void *cumap_v)
{
uiBlock *block;
short yco = 0, menuwidth = 10 * UI_UNIT_X;
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
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, 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, 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, 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, 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, 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, UICURVE_FUNC_RESET_NEG, "");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
uiEndBlock(C, block);
return block;
}
static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_v)
{
uiBlock *block;
@ -2038,7 +2066,7 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
/* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */
static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labeltype, int levels,
int brush, RNAUpdateCb *cb)
int brush, int neg_slope, RNAUpdateCb *cb)
{
CurveMapping *cumap = ptr->data;
CurveMap *cm = &cumap->cm[cumap->cur];
@ -2132,8 +2160,12 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe
if (brush)
bt = uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools"));
else if (neg_slope)
bt = uiDefIconBlockBut(block, curvemap_tools_negslope_func, cumap, 0, ICON_MODIFIER,
0, 0, dx, dx, TIP_("Tools"));
else
bt = uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools"));
bt = uiDefIconBlockBut(block, curvemap_tools_posslope_func, cumap, 0, ICON_MODIFIER,
0, 0, dx, dx, TIP_("Tools"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
@ -2195,7 +2227,8 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe
uiBlockSetNFunc(block, NULL, NULL, NULL);
}
void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propname, int type, int levels, int brush)
void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propname, int type,
int levels, int brush, int neg_slope)
{
RNAUpdateCb *cb;
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
@ -2226,7 +2259,7 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn
id = cptr.id.data;
uiBlockSetButLock(block, (id && id->lib), ERROR_LIBDATA_MESSAGE);
curvemap_buttons_layout(layout, &cptr, type, levels, brush, cb);
curvemap_buttons_layout(layout, &cptr, type, levels, brush, neg_slope, cb);
uiBlockClearButLock(block);
@ -3521,7 +3554,7 @@ void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *UNUSED(C), P
col = uiLayoutColumn(layout, false);
uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, NULL, ICON_NONE);
if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES)
uiTemplateCurveMapping(col, &view_transform_ptr, "curve_mapping", 'c', true, 0);
uiTemplateCurveMapping(col, &view_transform_ptr, "curve_mapping", 'c', true, false, false);
}
/********************************* Component Menu *************************************/

View File

@ -181,7 +181,7 @@ static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt
}
#endif
uiTemplateCurveMapping(layout, ptr, "curve", 's', 0, 0);
uiTemplateCurveMapping(layout, ptr, "curve", 's', false, false, false);
row = uiLayoutRow(layout, true);
uiItemR(row, ptr, "frame_start", 0, IFACE_("Sta"), ICON_NONE);
@ -195,7 +195,7 @@ static void node_buts_colorramp(uiLayout *layout, bContext *UNUSED(C), PointerRN
static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0);
uiTemplateCurveMapping(layout, ptr, "mapping", 'v', false, false, false);
}
#define SAMPLE_FLT_ISNONE FLT_MAX
@ -223,7 +223,7 @@ static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA
cumap->flag &= ~CUMA_DRAW_SAMPLE;
}
uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0);
uiTemplateCurveMapping(layout, ptr, "mapping", 'c', false, false, false);
}
static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@ -1841,7 +1841,7 @@ static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C),
cumap->flag &= ~CUMA_DRAW_SAMPLE;
}
uiTemplateCurveMapping(layout, ptr, "mapping", 'h', 0, 0);
uiTemplateCurveMapping(layout, ptr, "mapping", 'h', false, false, false);
}
static void node_composit_buts_ycc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)

View File

@ -700,6 +700,7 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display");
RNA_def_boolean(func, "levels", false, "", "Show black/white levels");
RNA_def_boolean(func, "brush", false, "", "Show brush options");
RNA_def_boolean(func, "use_negative_slope", false, "", "Use a negative slope by default");
func = RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp");
RNA_def_function_ui_description(func, "Item. A color ramp widget");

View File

@ -530,7 +530,7 @@ struct uiLayout *uiTemplateConstraint(struct uiLayout *layout, struct PointerRNA
void uiTemplatePreview(struct uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent,
struct MTex *slot, const char *preview_id) RET_NONE
void uiTemplateIDPreview(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int rows, int cols) RET_NONE
void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, int levels, int brush) RET_NONE
void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int type, int levels, int brush, int neg_slope) RET_NONE
void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int expand) RET_NONE
void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *used_ptr, const char *used_propname, int active_layer) RET_NONE
void uiTemplateImageLayers(struct uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser) RET_NONE