Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-08-07 18:42:13 +0300
committerJulian Eisel <julian@blender.org>2020-08-07 18:46:58 +0300
commitdcff28e1e7a8b1be9bb6acec24af7ca6f6468e77 (patch)
tree33b588ed6c5688a377a2a7d2421e6715c1612217 /source/blender/editors/interface/interface_templates.c
parent60b42ef117b66cca61468be45aab54b9bb1217e0 (diff)
UI Code Quality: Use derived struct for HSV Cube buttons
For the main rationale behind this design, see 49f088e2d093. Further, this removes users of uiBut.a1, which is a very ugly design choice (hard to reason about). Part of T74432.
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r--source/blender/editors/interface/interface_templates.c246
1 files changed, 115 insertions, 131 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index c7d3d7bf501..56807621358 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -5188,6 +5188,7 @@ void uiTemplateColorPicker(uiLayout *layout,
uiBlock *block = uiLayoutGetBlock(layout);
uiLayout *col, *row;
uiBut *but = NULL;
+ uiButHSVCube *hsv_but;
ColorPicker *cpicker = ui_block_colorpicker_create(block);
float softmin, softmax, step, precision;
@@ -5203,58 +5204,36 @@ void uiTemplateColorPicker(uiLayout *layout,
switch (U.color_picker_type) {
case USER_CP_SQUARE_SV:
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 0,
- WHEEL_SIZE,
- WHEEL_SIZE,
- ptr,
- prop,
- -1,
- 0.0,
- 0.0,
- UI_GRAD_SV,
- 0,
- "");
- break;
case USER_CP_SQUARE_HS:
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 0,
- WHEEL_SIZE,
- WHEEL_SIZE,
- ptr,
- prop,
- -1,
- 0.0,
- 0.0,
- UI_GRAD_HS,
- 0,
- "");
- break;
case USER_CP_SQUARE_HV:
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 0,
- WHEEL_SIZE,
- WHEEL_SIZE,
- ptr,
- prop,
- -1,
- 0.0,
- 0.0,
- UI_GRAD_HV,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ 0,
+ 0,
+ WHEEL_SIZE,
+ WHEEL_SIZE,
+ ptr,
+ prop,
+ -1,
+ 0.0,
+ 0.0,
+ 0,
+ 0,
+ "");
+ switch (U.color_picker_type) {
+ case USER_CP_SQUARE_SV:
+ hsv_but->gradient_type = UI_GRAD_SV;
+ break;
+ case USER_CP_SQUARE_HS:
+ hsv_but->gradient_type = UI_GRAD_HS;
+ break;
+ case USER_CP_SQUARE_HV:
+ hsv_but->gradient_type = UI_GRAD_HV;
+ break;
+ }
+ but = &hsv_but->but;
break;
/* user default */
@@ -5297,105 +5276,110 @@ void uiTemplateColorPicker(uiLayout *layout,
switch (U.color_picker_type) {
case USER_CP_CIRCLE_HSL:
uiItemS(row);
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- WHEEL_SIZE + 6,
- 0,
- 14 * UI_DPI_FAC,
- WHEEL_SIZE,
- ptr,
- prop,
- -1,
- softmin,
- softmax,
- UI_GRAD_L_ALT,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ WHEEL_SIZE + 6,
+ 0,
+ 14 * UI_DPI_FAC,
+ WHEEL_SIZE,
+ ptr,
+ prop,
+ -1,
+ softmin,
+ softmax,
+ 0,
+ 0,
+ "");
+ hsv_but->gradient_type = UI_GRAD_L_ALT;
break;
case USER_CP_SQUARE_SV:
uiItemS(col);
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 4,
- WHEEL_SIZE,
- 18 * UI_DPI_FAC,
- ptr,
- prop,
- -1,
- softmin,
- softmax,
- UI_GRAD_SV + 3,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ 0,
+ 4,
+ WHEEL_SIZE,
+ 18 * UI_DPI_FAC,
+ ptr,
+ prop,
+ -1,
+ softmin,
+ softmax,
+ 0,
+ 0,
+ "");
+ hsv_but->gradient_type = UI_GRAD_SV + 3;
break;
case USER_CP_SQUARE_HS:
uiItemS(col);
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 4,
- WHEEL_SIZE,
- 18 * UI_DPI_FAC,
- ptr,
- prop,
- -1,
- softmin,
- softmax,
- UI_GRAD_HS + 3,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ 0,
+ 4,
+ WHEEL_SIZE,
+ 18 * UI_DPI_FAC,
+ ptr,
+ prop,
+ -1,
+ softmin,
+ softmax,
+ 0,
+ 0,
+ "");
+ hsv_but->gradient_type = UI_GRAD_HS + 3;
break;
case USER_CP_SQUARE_HV:
uiItemS(col);
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- 0,
- 4,
- WHEEL_SIZE,
- 18 * UI_DPI_FAC,
- ptr,
- prop,
- -1,
- softmin,
- softmax,
- UI_GRAD_HV + 3,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ 0,
+ 4,
+ WHEEL_SIZE,
+ 18 * UI_DPI_FAC,
+ ptr,
+ prop,
+ -1,
+ softmin,
+ softmax,
+ 0,
+ 0,
+ "");
+ hsv_but->gradient_type = UI_GRAD_HV + 3;
break;
/* user default */
case USER_CP_CIRCLE_HSV:
default:
uiItemS(row);
- but = uiDefButR_prop(block,
- UI_BTYPE_HSVCUBE,
- 0,
- "",
- WHEEL_SIZE + 6,
- 0,
- 14 * UI_DPI_FAC,
- WHEEL_SIZE,
- ptr,
- prop,
- -1,
- softmin,
- softmax,
- UI_GRAD_V_ALT,
- 0,
- "");
+ hsv_but = (uiButHSVCube *)uiDefButR_prop(block,
+ UI_BTYPE_HSVCUBE,
+ 0,
+ "",
+ WHEEL_SIZE + 6,
+ 0,
+ 14 * UI_DPI_FAC,
+ WHEEL_SIZE,
+ ptr,
+ prop,
+ -1,
+ softmin,
+ softmax,
+ 0,
+ 0,
+ "");
+ hsv_but->gradient_type = UI_GRAD_V_ALT;
break;
}
- but->custom_data = cpicker;
+ hsv_but->but.custom_data = cpicker;
}
}