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.
This commit is contained in:
2020-09-04 19:26:12 +02:00
parent 120f4507f6
commit 47881791be
4 changed files with 9 additions and 7 deletions

View File

@@ -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);