UI Code Quality: Use derived struct for color ramp buttons
The same changes as rB570044e9f412 and rB0ab21bf06ae0.
This commit is contained in:
parent
0ab21bf06a
commit
cd179b5048
|
@ -767,7 +767,6 @@ static bool ui_but_update_from_old_block(const bContext *C,
|
|||
but->editstr = oldbut->editstr;
|
||||
but->editval = oldbut->editval;
|
||||
but->editvec = oldbut->editvec;
|
||||
but->editcoba = oldbut->editcoba;
|
||||
but->selsta = oldbut->selsta;
|
||||
but->selend = oldbut->selend;
|
||||
but->softmin = oldbut->softmin;
|
||||
|
@ -3796,6 +3795,10 @@ static void ui_but_alloc_info(const eButType type,
|
|||
alloc_size = sizeof(uiButHSVCube);
|
||||
alloc_str = "uiButHSVCube";
|
||||
break;
|
||||
case UI_BTYPE_COLORBAND:
|
||||
alloc_size = sizeof(uiButColorBand);
|
||||
alloc_str = "uiButColorBand";
|
||||
break;
|
||||
case UI_BTYPE_CURVE:
|
||||
alloc_size = sizeof(uiButCurveMapping);
|
||||
alloc_str = "uiButCurveMapping";
|
||||
|
|
|
@ -1639,7 +1639,9 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
|
|||
struct ColorManagedDisplay *display = ui_block_cm_display_get(but->block);
|
||||
uint pos_id, col_id;
|
||||
|
||||
ColorBand *coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin);
|
||||
uiButColorBand *but_coba = (uiButColorBand *)but;
|
||||
ColorBand *coba = (but_coba->edit_coba == NULL) ? (ColorBand *)but->poin : but_coba->edit_coba;
|
||||
|
||||
if (coba == NULL) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2086,8 +2086,11 @@ static void ui_apply_but(
|
|||
editstr = but->editstr;
|
||||
editval = but->editval;
|
||||
editvec = but->editvec;
|
||||
editcoba = but->editcoba;
|
||||
if (but->type == UI_BTYPE_CURVE) {
|
||||
if (but->type == UI_BTYPE_COLORBAND) {
|
||||
uiButColorBand *but_coba = (uiButColorBand *)but;
|
||||
editcoba = but_coba->edit_coba;
|
||||
}
|
||||
else if (but->type == UI_BTYPE_CURVE) {
|
||||
uiButCurveMapping *but_cumap = (uiButCurveMapping *)but;
|
||||
editcumap = but_cumap->edit_cumap;
|
||||
}
|
||||
|
@ -2098,8 +2101,11 @@ static void ui_apply_but(
|
|||
but->editstr = NULL;
|
||||
but->editval = NULL;
|
||||
but->editvec = NULL;
|
||||
but->editcoba = NULL;
|
||||
if (but->type == UI_BTYPE_CURVE) {
|
||||
if (but->type == UI_BTYPE_COLORBAND) {
|
||||
uiButColorBand *but_coba = (uiButColorBand *)but;
|
||||
but_coba->edit_coba = NULL;
|
||||
}
|
||||
else if (but->type == UI_BTYPE_CURVE) {
|
||||
uiButCurveMapping *but_cumap = (uiButCurveMapping *)but;
|
||||
but_cumap->edit_cumap = NULL;
|
||||
}
|
||||
|
@ -2215,8 +2221,11 @@ static void ui_apply_but(
|
|||
but->editstr = editstr;
|
||||
but->editval = editval;
|
||||
but->editvec = editvec;
|
||||
but->editcoba = editcoba;
|
||||
if (but->type == UI_BTYPE_CURVE) {
|
||||
if (but->type == UI_BTYPE_COLORBAND) {
|
||||
uiButColorBand *but_coba = (uiButColorBand *)but;
|
||||
but_coba->edit_coba = editcoba;
|
||||
}
|
||||
else if (but->type == UI_BTYPE_CURVE) {
|
||||
uiButCurveMapping *but_cumap = (uiButCurveMapping *)but;
|
||||
but_cumap->edit_cumap = editcumap;
|
||||
}
|
||||
|
@ -3874,8 +3883,9 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
|
|||
but_profile->edit_profile = (CurveProfile *)but->poin;
|
||||
}
|
||||
else if (but->type == UI_BTYPE_COLORBAND) {
|
||||
uiButColorBand *but_coba = (uiButColorBand *)but;
|
||||
data->coba = (ColorBand *)but->poin;
|
||||
but->editcoba = data->coba;
|
||||
but_coba->edit_coba = data->coba;
|
||||
}
|
||||
else if (ELEM(but->type,
|
||||
UI_BTYPE_UNITVEC,
|
||||
|
@ -3961,8 +3971,11 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data)
|
|||
{
|
||||
but->editval = NULL;
|
||||
but->editvec = NULL;
|
||||
but->editcoba = NULL;
|
||||
if (but->type == UI_BTYPE_CURVE) {
|
||||
if (but->type == UI_BTYPE_COLORBAND) {
|
||||
uiButColorBand *but_coba = (uiButColorBand *)but;
|
||||
but_coba->edit_coba = NULL;
|
||||
}
|
||||
else if (but->type == UI_BTYPE_CURVE) {
|
||||
uiButCurveMapping *but_cumap = (uiButCurveMapping *)but;
|
||||
but_cumap->edit_cumap = NULL;
|
||||
}
|
||||
|
|
|
@ -268,7 +268,6 @@ struct uiBut {
|
|||
char *editstr;
|
||||
double *editval;
|
||||
float *editvec;
|
||||
void *editcoba;
|
||||
|
||||
uiButPushedStateFunc pushed_state_func;
|
||||
void *pushed_state_arg;
|
||||
|
@ -335,6 +334,13 @@ typedef struct uiButHSVCube {
|
|||
eButGradientType gradient_type;
|
||||
} uiButHSVCube;
|
||||
|
||||
/** Derived struct for #UI_BTYPE_CURVEPROFILE. */
|
||||
typedef struct uiButColorBand {
|
||||
uiBut but;
|
||||
|
||||
struct ColorBand *edit_coba;
|
||||
} uiButColorBand;
|
||||
|
||||
/** Derived struct for #UI_BTYPE_CURVEPROFILE. */
|
||||
typedef struct uiButCurveProfile {
|
||||
uiBut but;
|
||||
|
|
Loading…
Reference in New Issue