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-09-04 20:26:12 +0300
committerJulian Eisel <julian@blender.org>2020-09-04 22:26:30 +0300
commit47881791be0538f9558b2ef091e1761187df250d (patch)
tree11590c150195ee160e255722bb7ffe00825b9ca4
parent120f4507f640cf8b356476a9e82e6301981cfcfd (diff)
UI Code Quality: Store curve-button gradient type in derived struct
We want to move away from using `uiBut.a1`/`a2`, which is a hard to reason about design. Part of T74432. Also correct comment.
-rw-r--r--source/blender/editors/interface/interface_draw.c6
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_query.c2
-rw-r--r--source/blender/editors/interface/interface_templates.c5
4 files changed, 9 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 13dd4ce3001..4d53018cd32 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1922,7 +1922,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
BLI_rcti_size_y(&scissor_new));
/* Do this first to not mess imm context */
- if (but->a1 == UI_GRAD_H) {
+ if (but_cumap->gradient_type == UI_GRAD_H) {
/* magic trigger for curve backgrounds */
const float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */
@@ -1945,7 +1945,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
/* backdrop */
float color_backdrop[4] = {0, 0, 0, 1};
- if (but->a1 == UI_GRAD_H) {
+ if (but_cumap->gradient_type == UI_GRAD_H) {
/* grid, hsv uses different grid */
GPU_blend(GPU_BLEND_ALPHA);
ARRAY_SET_ITEMS(color_backdrop, 0, 0, 0, 48.0 / 255.0);
@@ -2002,7 +2002,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
if (cumap->flag & CUMA_DRAW_SAMPLE) {
immBegin(GPU_PRIM_LINES, 2); /* will draw one of the following 3 lines */
- if (but->a1 == UI_GRAD_H) {
+ if (but_cumap->gradient_type == UI_GRAD_H) {
float tsample[3];
float hsv[3];
linearrgb_to_srgb_v3_v3(tsample, cumap->sample);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 2b9d684ad96..e53309d43b7 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -334,7 +334,7 @@ typedef struct uiButHSVCube {
eButGradientType gradient_type;
} uiButHSVCube;
-/** Derived struct for #UI_BTYPE_CURVEPROFILE. */
+/** Derived struct for #UI_BTYPE_COLORBAND. */
typedef struct uiButColorBand {
uiBut but;
@@ -353,6 +353,7 @@ typedef struct uiButCurveMapping {
uiBut but;
struct CurveMapping *edit_cumap;
+ eButGradientType gradient_type;
} uiButCurveMapping;
/**
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index 9dcfe8c872b..4ad5d85e959 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -427,9 +427,9 @@ bool ui_but_is_cursor_warp(const uiBut *but)
if (ELEM(but->type,
UI_BTYPE_NUM,
UI_BTYPE_NUM_SLIDER,
- UI_BTYPE_HSVCIRCLE,
UI_BTYPE_TRACK_PREVIEW,
UI_BTYPE_HSVCUBE,
+ UI_BTYPE_HSVCIRCLE,
UI_BTYPE_CURVE,
UI_BTYPE_CURVEPROFILE)) {
return true;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 0440a1531c8..e5b485def65 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -4439,8 +4439,9 @@ static void curvemap_buttons_layout(uiLayout *layout,
/* curve itself */
size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
row = uiLayoutRow(layout, false);
- uiDefBut(
- block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, bg, 0, "");
+ 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, "");
+ curve_but->gradient_type = bg;
/* sliders for selected point */
for (i = 0; i < cm->totpoint; i++) {