Cleanup: de-duplicate curve menu
This commit is contained in:
parent
837c4c5d47
commit
3f602fff3c
Notes:
blender-bot
2023-10-12 12:49:04 +02:00
Referenced by issue #45093, Cycles: NVidia GTX 980 Ti rendering at 1/3rd speed of NVidia GTX 980 the same machine?
|
@ -1972,26 +1972,42 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
|
|||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
}
|
||||
|
||||
static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *ar, void *cumap_v)
|
||||
static uiBlock *curvemap_tools_func(
|
||||
bContext *C, ARegion *ar, CurveMapping *cumap,
|
||||
bool show_extend, int reset_mode)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco = 0, menuwidth = 10 * UI_UNIT_X;
|
||||
|
||||
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
||||
UI_block_func_butmenu_set(block, curvemap_tools_dofunc, cumap_v);
|
||||
UI_block_func_butmenu_set(block, curvemap_tools_dofunc, cumap);
|
||||
|
||||
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y,
|
||||
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_POS, "");
|
||||
{
|
||||
uiDefIconTextBut(
|
||||
block, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, "");
|
||||
}
|
||||
|
||||
if (show_extend) {
|
||||
uiDefIconTextBut(
|
||||
block, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset Curve"),
|
||||
0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, reset_mode, "");
|
||||
}
|
||||
|
||||
UI_block_direction_set(block, UI_DIR_RIGHT);
|
||||
UI_block_bounds_set_text(block, 50);
|
||||
|
@ -1999,54 +2015,19 @@ static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *ar, void *cum
|
|||
return block;
|
||||
}
|
||||
|
||||
static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *ar, void *cumap_v)
|
||||
{
|
||||
return curvemap_tools_func(C, ar, cumap_v, true, UICURVE_FUNC_RESET_POS);
|
||||
}
|
||||
|
||||
static uiBlock *curvemap_tools_negslope_func(bContext *C, ARegion *ar, void *cumap_v)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco = 0, menuwidth = 10 * UI_UNIT_X;
|
||||
|
||||
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
||||
UI_block_func_butmenu_set(block, curvemap_tools_dofunc, cumap_v);
|
||||
|
||||
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, "");
|
||||
|
||||
UI_block_direction_set(block, UI_DIR_RIGHT);
|
||||
UI_block_bounds_set_text(block, 50);
|
||||
|
||||
return block;
|
||||
return curvemap_tools_func(C, ar, cumap_v, true, UICURVE_FUNC_RESET_NEG);
|
||||
}
|
||||
|
||||
static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_v)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco = 0, menuwidth = 10 * UI_UNIT_X;
|
||||
|
||||
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
||||
UI_block_func_butmenu_set(block, curvemap_tools_dofunc, cumap_v);
|
||||
|
||||
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, UI_BTYPE_BUT_MENU, 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, "");
|
||||
|
||||
UI_block_direction_set(block, UI_DIR_RIGHT);
|
||||
UI_block_bounds_set_text(block, 50);
|
||||
|
||||
return block;
|
||||
return curvemap_tools_func(C, ar, cumap_v, false, UICURVE_FUNC_RESET_NEG);
|
||||
}
|
||||
|
||||
static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
|
||||
|
|
Loading…
Reference in New Issue