[Bf-blender-cvs] [8c55481e337] master: UI: Add curve handle buttons to CurveMap interface
Charlie Jolly
noreply at git.blender.org
Sun Dec 12 08:18:07 CET 2021
Commit: 8c55481e337c9c5232766d74045b43c1956b2bc1
Author: Charlie Jolly
Date: Sun Dec 12 07:16:10 2021 +0000
Branches: master
https://developer.blender.org/rB8c55481e337c9c5232766d74045b43c1956b2bc1
UI: Add curve handle buttons to CurveMap interface
This patch exposes the vector handle options as buttons
and aligns the UI between CurveMap and CurveProfile more closely.
- CurveMap point editing is on a single row like CurveProfile
- Tools menu is moved to the right hand side on both widgets
- Emboss curve map buttons
Reviewed By: HooglyBoogly
Differential Revision: https://developer.blender.org/D10980
===================================================================
M source/blender/editors/interface/interface_templates.c
===================================================================
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 7f00db26da9..e45884ea73b 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -4117,51 +4117,6 @@ static uiBlock *curvemap_tools_func(
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_("Auto Clamped Handle"),
- 0,
- yco -= UI_UNIT_Y,
- menuwidth,
- UI_UNIT_Y,
- NULL,
- 0.0,
- 0.0,
- 0,
- UICURVE_FUNC_HANDLE_AUTO_ANIM,
- "");
}
if (show_extend) {
@@ -4241,6 +4196,21 @@ static uiBlock *curvemap_brush_tools_negslope_func(bContext *C, ARegion *region,
return curvemap_tools_func(C, region, cumap_v, false, UICURVE_FUNC_RESET_POS);
}
+static void curvemap_tools_handle_vector(bContext *C, void *cumap_v, void *UNUSED(arg))
+{
+ curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_VECTOR);
+}
+
+static void curvemap_tools_handle_auto(bContext *C, void *cumap_v, void *UNUSED(arg))
+{
+ curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_AUTO);
+}
+
+static void curvemap_tools_handle_auto_clamped(bContext *C, void *cumap_v, void *UNUSED(arg))
+{
+ curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_AUTO_ANIM);
+}
+
static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
{
ED_region_tag_redraw(CTX_wm_region(C));
@@ -4292,6 +4262,8 @@ static void curvemap_buttons_layout(uiLayout *layout,
uiBlock *block = uiLayoutGetBlock(layout);
+ UI_block_emboss_set(block, UI_EMBOSS);
+
if (tone) {
uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
uiItemR(uiLayoutRow(split, false), ptr, "tone", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
@@ -4377,10 +4349,11 @@ static void curvemap_buttons_layout(uiLayout *layout,
}
/* operation buttons */
- uiLayoutRow(row, true);
-
- UI_block_emboss_set(block, UI_EMBOSS_NONE);
+ /* (Right aligned) */
+ uiLayout *sub = uiLayoutRow(row, true);
+ uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT);
+ /* Zoom in */
bt = uiDefIconBut(block,
UI_BTYPE_BUT,
0,
@@ -4397,6 +4370,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
TIP_("Zoom in"));
UI_but_func_set(bt, curvemap_buttons_zoom_in, cumap, NULL);
+ /* Zoom out */
bt = uiDefIconBut(block,
UI_BTYPE_BUT,
0,
@@ -4413,97 +4387,53 @@ static void curvemap_buttons_layout(uiLayout *layout,
TIP_("Zoom out"));
UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, NULL);
+ /* Clippoing button. */
+ const int icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
+ bt = uiDefIconBlockBut(
+ block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options"));
+ bt->drawflag &= ~UI_BUT_ICON_LEFT;
+ UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
if (brush && neg_slope) {
- bt = uiDefIconBlockBut(block,
- curvemap_brush_tools_negslope_func,
- cumap,
- 0,
- ICON_DOWNARROW_HLT,
- 0,
- 0,
- dx,
- dx,
- TIP_("Tools"));
+ bt = uiDefIconBlockBut(
+ block, curvemap_brush_tools_negslope_func, cumap, 0, 0, 0, 0, dx, dx, TIP_("Tools"));
}
else if (brush) {
- bt = uiDefIconBlockBut(block,
- curvemap_brush_tools_func,
- cumap,
- 0,
- ICON_DOWNARROW_HLT,
- 0,
- 0,
- dx,
- dx,
- TIP_("Tools"));
+ bt = uiDefIconBlockBut(
+ block, curvemap_brush_tools_func, cumap, 0, 0, 0, 0, dx, dx, TIP_("Tools"));
}
else if (neg_slope) {
- bt = uiDefIconBlockBut(block,
- curvemap_tools_negslope_func,
- cumap,
- 0,
- ICON_DOWNARROW_HLT,
- 0,
- 0,
- dx,
- dx,
- TIP_("Tools"));
+ bt = uiDefIconBlockBut(
+ block, curvemap_tools_negslope_func, cumap, 0, 0, 0, 0, dx, dx, TIP_("Tools"));
}
else {
- bt = uiDefIconBlockBut(block,
- curvemap_tools_posslope_func,
- cumap,
- 0,
- ICON_DOWNARROW_HLT,
- 0,
- 0,
- dx,
- dx,
- TIP_("Tools"));
+ bt = uiDefIconBlockBut(
+ block, curvemap_tools_posslope_func, cumap, 0, 0, 0, 0, dx, dx, TIP_("Tools"));
}
-
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- const int icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
- bt = uiDefIconBlockBut(
- block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options"));
- UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
-
- bt = uiDefIconBut(block,
- UI_BTYPE_BUT,
- 0,
- ICON_X,
- 0,
- 0,
- dx,
- dx,
- NULL,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- TIP_("Delete points"));
- UI_but_funcN_set(bt, curvemap_buttons_delete, MEM_dupallocN(cb), cumap);
-
- UI_block_emboss_set(block, UI_EMBOSS);
-
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL);
- /* curve itself */
+ /* Curve itself. */
const int size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
row = uiLayoutRow(layout, false);
uiButCurveMapping *curve_but = (uiButCurveMapping *)uiDefBut(
- block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, 0, 0, "");
+ block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, -1, 0, "");
curve_but->gradient_type = bg;
- /* sliders for selected point */
+ /* Sliders for selected curve point. */
+ int i;
CurveMapPoint *cmp = NULL;
- for (int i = 0; i < cm->totpoint; i++) {
+ bool point_last_or_first = false;
+ for (i = 0; i < cm->totpoint; i++) {
if (cm->curve[i].flag & CUMA_SELECT) {
cmp = &cm->curve[i];
break;
}
}
+ if (ELEM(i, 0, cm->totpoint - 1)) {
+ point_last_or_first = true;
+ }
if (cmp) {
rctf bounds;
@@ -4515,12 +4445,75 @@ static void curvemap_buttons_layout(uiLayout *layout,
bounds.xmax = bounds.ymax = 1000.0;
}
+ UI_block_emboss_set(block, UI_EMBOSS);
+
uiLayoutRow(layout, true);
+
+ /* Curve handle buttons. */
+ bt = uiDefIconBut(block,
+ UI_BTYPE_BUT,
+ 1,
+ ICON_HANDLE_AUTO,
+ 0,
+ UI_UNIT_Y,
+ UI_UNIT_X,
+ UI_UNIT_Y,
+ NULL,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ TIP_("Auto Handle"));
+ UI_but_func_set(bt, curvemap_tools_handle_auto, cumap, NULL);
+ if (((cmp->flag & CUMA_HANDLE_AUTO_ANIM) == false) &&
+ ((cmp->flag & CUMA_HANDLE_VECTOR) == false)) {
+ bt->flag |= UI_SELECT_DRAW;
+ }
+
+ bt = uiDefIconBut(block,
+ UI_BTYPE_BUT,
+ 1,
+ ICON_HANDLE_VECTOR,
+ 0,
+ UI_UNIT_Y,
+ UI_UNIT_X,
+ UI_UNIT_Y,
+ NULL,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ TIP_("Vector Handle"));
+ UI_but_func_set(bt, curvemap_tools_handle_vector, cumap, NULL);
+ if (cmp->flag & CUMA_HANDLE_VECTOR) {
+ bt->flag |= UI_SELECT_DRAW;
+ }
+
+ bt = uiDefIconBut(block,
+ UI_BTYPE_BUT,
+ 1,
+ ICON_HANDLE_AUTOCLAMPED,
+ 0,
+ UI_UNIT_Y,
+ UI_UNIT_X,
+ UI_UNIT_Y,
+ NULL,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ TIP_("Auto Clamped"));
+ UI_but_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list